From 0deb74c871ea10c7e1589a196a5ce1f0c409e715 Mon Sep 17 00:00:00 2001 From: tsteven4 <13596209+tsteven4@users.noreply.github.com> Date: Fri, 23 Jun 2023 16:15:35 -0600 Subject: [PATCH] fix clang 15 warnings on windows (#1132) * fix some format specifier issues that came to light trying to get clang to work under visual studio. * fix another windows only warning * fix some more wordsize issues. --- exif.cc | 10 +++++----- garmin_fit.cc | 2 +- garmin_gpi.cc | 2 +- inifile.cc | 2 ++ jeeps/gpsusbwin.cc | 2 +- wbt-200.cc | 6 +++--- 6 files changed, 13 insertions(+), 11 deletions(-) diff --git a/exif.cc b/exif.cc index da634db51..25bcd7b06 100644 --- a/exif.cc +++ b/exif.cc @@ -59,7 +59,7 @@ #include // for fabs, modf, copysign, round, fmax #include // for uint32_t, int32_t, uint16_t, int16_t, uint8_t, INT32_MAX #include // for printf, SEEK_SET, snprintf, SEEK_CUR -#include // for labs +#include // for abs #include // for memcmp, strlen #include // for add_const<>::type @@ -1159,7 +1159,7 @@ ExifFormat::exif_find_wpt_by_time(const Waypoint* wpt) if (exif_wpt_ref == nullptr) { exif_wpt_ref = wpt; - } else if (labs(exif_time_ref.msecsTo(wpt->creation_time)) < labs(exif_time_ref.msecsTo(exif_wpt_ref->creation_time))) { + } else if (std::abs(exif_time_ref.msecsTo(wpt->creation_time)) < std::abs(exif_time_ref.msecsTo(exif_wpt_ref->creation_time))) { exif_wpt_ref = wpt; } } @@ -1535,13 +1535,13 @@ ExifFormat::write() if (exif_wpt_ref == nullptr) { warning(MYNAME ": No point with a valid timestamp found.\n"); - } else if (labs(exif_time_ref.secsTo(exif_wpt_ref->creation_time)) > frame) { + } else if (std::abs(exif_time_ref.secsTo(exif_wpt_ref->creation_time)) > frame) { QString time_str = exif_time_str(exif_time_ref); warning(MYNAME ": No matching point found for image date %s!\n", qPrintable(time_str)); if (exif_wpt_ref != nullptr) { QString str = exif_time_str(exif_wpt_ref->creation_time); - warning(MYNAME ": Best is from %s, %ld second(s) away.\n", - qPrintable(str), labs(exif_time_ref.secsTo(exif_wpt_ref->creation_time))); + warning(MYNAME ": Best is from %s, %lld second(s) away.\n", + qPrintable(str), std::abs(exif_time_ref.secsTo(exif_wpt_ref->creation_time))); } exif_wpt_ref = nullptr; } diff --git a/garmin_fit.cc b/garmin_fit.cc index 0cc111d03..3982216f8 100644 --- a/garmin_fit.cc +++ b/garmin_fit.cc @@ -865,7 +865,7 @@ GarminFitFormat::read() } catch (ReaderException& e) { if (opt_recoverymode) { warning(MYNAME ": %s\n",e.what()); - warning(MYNAME ": Aborting read and continuning processing.\n"); + warning(MYNAME ": Aborting read and continuing processing.\n"); } else { fatal(MYNAME ": %s Use recoverymode option at your risk.\n",e.what()); } diff --git a/garmin_gpi.cc b/garmin_gpi.cc index 4ec4661ca..473871bb2 100644 --- a/garmin_gpi.cc +++ b/garmin_gpi.cc @@ -176,7 +176,7 @@ GarminGPIFormat::read_header() rdata->crdate = gbfgetint32(fin); if (GPI_DBG) { time_t crdate = GPS_Math_Gtime_To_Utime(rdata->crdate); - warning("crdate = %lu (%s)\n", rdata->crdate, + warning("crdate = %lld (%s)\n", (long long) rdata->crdate, CSTR(QDateTime::fromSecsSinceEpoch(crdate, Qt::UTC).toString(Qt::ISODate))); } diff --git a/inifile.cc b/inifile.cc index 3daa49c8d..be1e28a70 100644 --- a/inifile.cc +++ b/inifile.cc @@ -52,7 +52,9 @@ class InifileSection /* internal procedures */ static constexpr char GPSBABEL_INIFILE[] = "gpsbabel.ini"; +#ifndef __WIN32__ static constexpr char GPSBABEL_SUBDIR[] = ".gpsbabel"; +#endif static QString diff --git a/jeeps/gpsusbwin.cc b/jeeps/gpsusbwin.cc index 5cec69609..6ed6e6854 100644 --- a/jeeps/gpsusbwin.cc +++ b/jeeps/gpsusbwin.cc @@ -117,7 +117,7 @@ gusb_win_send(const garmin_usb_packet* opkt, size_t sz) WriteFile(usb_handle, obuf, sz, &rsz, NULL); if (rsz != sz) { - fatal("Error sending %d bytes. Successfully sent %ld\n", sz, rsz); + fatal("Error sending %zu bytes. Successfully sent %ld\n", sz, rsz); } return rsz; diff --git a/wbt-200.cc b/wbt-200.cc index 75f16aff1..f88b54286 100644 --- a/wbt-200.cc +++ b/wbt-200.cc @@ -614,7 +614,7 @@ static bool is_valid(struct buf_head* h, int fmt) buf_rewind(h); - db(2, "Checking %lu bytes of data against format %d\n", h->used, fmt); + db(2, "Checking %zu bytes of data against format %d\n", h->used, fmt); for (;;) { size_t got = buf_read(h, buf, reclen); @@ -650,7 +650,7 @@ static void wbt200_process_data(struct read_state* pst, int fmt) buf_rewind(&pst->data); - db(2, "Processing %lu bytes of data using format %d\n", pst->data.used, fmt); + db(2, "Processing %zu bytes of data using format %d\n", pst->data.used, fmt); for (;;) { size_t got = buf_read(&pst->data, buf, reclen); @@ -843,7 +843,7 @@ static void wbt201_process_chunk(struct read_state* st) { char buf[RECLEN_WBT201]; - db(2, "Processing %lu bytes of data\n", st->data.used); + db(2, "Processing %zu bytes of data\n", st->data.used); while (buf_read(&st->data, buf, sizeof(buf)) == sizeof(buf) && wbt201_data_chunk(st, buf)) {