From 48a3b80996d0dce7e472318c2090e5f4df901567 Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Sat, 13 Sep 2025 18:40:03 +0300 Subject: fix: Correct printf format specifiers for unsigned integers This commit addresses cppcheck warnings about mismatched printf format specifiers (invalidPrintfArgType_sint). The format specifiers %i and %d expect signed integers (int) but the variables being passed are unsigned integers (uint32_t, unsigned). This mismatch can lead to undefined behavior and incorrect output formatting. Changes made: - utils/kmstouch.cpp: Changed %i to %u for event code formatting - utils/kmstouch.cpp: Changed %d to %u for event type and property type formatting - utils/kmsview.cpp: Changed %d to %u for frame number formatting These fixes ensure proper type safety in printf formatting and prevent potential undefined behavior when printing unsigned integer values. --- utils/kmstouch.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'utils/kmstouch.cpp') diff --git a/utils/kmstouch.cpp b/utils/kmstouch.cpp index 8afcee5..f4d4c2a 100644 --- a/utils/kmstouch.cpp +++ b/utils/kmstouch.cpp @@ -64,7 +64,7 @@ static void print_code_bits(struct libevdev* dev, unsigned int type, unsigned in if (!libevdev_has_event_code(dev, type, i)) continue; - printf(" Event code %i (%s)\n", i, libevdev_event_code_get_name(type, i)); + printf(" Event code %u (%s)\n", i, libevdev_event_code_get_name(type, i)); if (type == EV_ABS) print_abs_bits(dev, i); } @@ -78,7 +78,7 @@ static void print_bits(struct libevdev* dev) if (!libevdev_has_event_type(dev, i)) continue; - printf(" Event type %d (%s)\n", i, libevdev_event_type_get_name(i)); + printf(" Event type %u (%s)\n", i, libevdev_event_type_get_name(i)); switch (i) { case EV_KEY: @@ -120,7 +120,7 @@ static void print_props(struct libevdev* dev) if (!libevdev_has_property(dev, i)) continue; - printf(" Property type %d (%s)\n", i, libevdev_property_get_name(i)); + printf(" Property type %u (%s)\n", i, libevdev_property_get_name(i)); } } -- cgit v1.2.3