Skip to content

Commit

Permalink
fix clang 15 warnings on windows (#1132)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
tsteven4 authored Jun 23, 2023
1 parent 043fe4f commit 0deb74c
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 11 deletions.
10 changes: 5 additions & 5 deletions exif.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
#include <cmath> // for fabs, modf, copysign, round, fmax
#include <cstdint> // for uint32_t, int32_t, uint16_t, int16_t, uint8_t, INT32_MAX
#include <cstdio> // for printf, SEEK_SET, snprintf, SEEK_CUR
#include <cstdlib> // for labs
#include <cstdlib> // for abs
#include <cstring> // for memcmp, strlen
#include <type_traits> // for add_const<>::type

Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion garmin_fit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
2 changes: 1 addition & 1 deletion garmin_gpi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
}

Expand Down
2 changes: 2 additions & 0 deletions inifile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion jeeps/gpsusbwin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions wbt-200.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)) {
Expand Down

0 comments on commit 0deb74c

Please sign in to comment.