-
-
Notifications
You must be signed in to change notification settings - Fork 100
Open
Description
Bug description
A format string mismatch in src/osdp_diag.c causes a compiler warning: the %d format specifier is used for an argument of type size_t, which leads to undefined behavior on 64-bit platforms where int and size_t differ in size (e.g., macOS, Linux x86_64).
Expected behavior
The build should complete without warnings when compiled with strict warning flags (e.g., -Wformat). The log message should correctly print the packet count using the appropriate format specifier for size_t.
Observed behavior
The compiler emits a warning:
warning: format specifies type 'int' but the argument has type 'size_t' (aka 'unsigned long') [-Wformat]
LOG_INF("Captured %d packets", num_packets);
~~ ^~~~~~~~~~~
%zu
at line 55 in src/osdp_diag.c.
Additional context
- Compiler: Apple Clang 15.0+ (and other modern compilers with
-Wformat) - Platform: macOS (64-bit), but also affects Linux/Unix 64-bit builds
- Build system: CMake with debug configuration (
cmake --build ...) - The variable
num_packetsis declared assize_t, but the format string incorrectly uses%d.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels