Browse Source

leansdr: Fix unsigned printf format specifiers

Replace signed %ld format specifiers with unsigned %lu conversions when
printing values stored as unsigned long.

The previous format strings passed unsigned values to signed printf
conversions, which could result in undefined behavior due to variadic
argument type mismatches. These issues were identified by cppcheck
invalidPrintfArgType_sint warnings.

Use format specifiers matching the actual argument types to ensure
correct and portable printf usage.

Signed-off-by: Robin Getz <rgetz503@gmail.com>
chirpmodem-v8.0.0
Robin Getz 4 months ago
parent
commit
655841008e
No known key found for this signature in database
GPG Key ID: 51C7231FFED0E060
  1. 10
      plugins/channelrx/demoddatv/leansdr/framework.h

10
plugins/channelrx/demoddatv/leansdr/framework.h

@ -193,7 +193,7 @@ struct scheduler
pipes[i]->dump(&total_bufs); pipes[i]->dump(&total_bufs);
} }
fprintf(stderr, "Total buffer memory: %ld KiB\n", fprintf(stderr, "Total buffer memory: %lu KiB\n",
(unsigned long)total_bufs / 1024); (unsigned long)total_bufs / 1024);
} }
}; };
@ -287,23 +287,23 @@ struct pipebuf : pipebuf_common
{ {
if (total_written < 10000) if (total_written < 10000)
{ {
fprintf(stderr, ".%-16s : %4ld/%4ld", name, total_read, fprintf(stderr, ".%-16s : %4lu/%4lu", name, total_read,
total_written); total_written);
} }
else if (total_written < 1000000) else if (total_written < 1000000)
{ {
fprintf(stderr, ".%-16s : %3ldk/%3ldk", name, total_read / 1000, fprintf(stderr, ".%-16s : %3luk/%3luk", name, total_read / 1000,
total_written / 1000); total_written / 1000);
} }
else else
{ {
fprintf(stderr, ".%-16s : %3ldM/%3ldM", name, total_read / 1000000, fprintf(stderr, ".%-16s : %3luM/%3luM", name, total_read / 1000000,
total_written / 1000000); total_written / 1000000);
} }
*total_bufs += (end - buf) * sizeof(T); *total_bufs += (end - buf) * sizeof(T);
unsigned long nw = end - wr; unsigned long nw = end - wr;
fprintf(stderr, " %6ld writable %c,", nw, (nw < min_write) ? '!' : ' '); fprintf(stderr, " %6lu writable %c,", nw, (nw < min_write) ? '!' : ' ');
T *rd = wr; T *rd = wr;
for (int j = 0; j < nrd; ++j) for (int j = 0; j < nrd; ++j)

Loading…
Cancel
Save