You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#define dbg(_fmt, _args...) \
do { \
if (dbg_lvl > 0) \
printf("librtas %s(): " _fmt, __func__, ##_args); \
} while (0)
This seems to defeat the format string type-checking that the compiler can do. cppcheck detects many problems (see below)
printf with the assumption that the output will go somewhere useful or safe is poor practice in a library. syslog may be better?
cppcheck report:
cppcheck --enable=warning .
Checking librtas_src/ofdt.c ...
1/18 files checked 2% done
Checking librtas_src/syscall_calls.c ...
librtas_src/syscall_calls.c:106:2: warning: %ld in format string (no. 3) requires 'long' but the argument type is 'unsigned long'. [invalidPrintfArgType_sint]
dbg("Return status %d, delaying for %ld ms\n", status, ms);
^
librtas_src/syscall_calls.c:704:2: warning: %d in format string (no. 2) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]
dbg("(%d, %d, %p) = %d\n", parameter, length, data, rc ? rc : status);
^
librtas_src/syscall_calls.c:704:2: warning: %d in format string (no. 3) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]
dbg("(%d, %d, %p) = %d\n", parameter, length, data, rc ? rc : status);
^
librtas_src/syscall_calls.c:744:2: warning: %d in format string (no. 3) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]
dbg("() = %d, %d, %d, %d, %d, %d, %d, %d\n", rc ? rc : status, *year,
^
librtas_src/syscall_calls.c:744:2: warning: %d in format string (no. 4) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]
dbg("() = %d, %d, %d, %d, %d, %d, %d, %d\n", rc ? rc : status, *year,
^
librtas_src/syscall_calls.c:744:2: warning: %d in format string (no. 5) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]
dbg("() = %d, %d, %d, %d, %d, %d, %d, %d\n", rc ? rc : status, *year,
^
librtas_src/syscall_calls.c:744:2: warning: %d in format string (no. 6) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]
dbg("() = %d, %d, %d, %d, %d, %d, %d, %d\n", rc ? rc : status, *year,
^
librtas_src/syscall_calls.c:744:2: warning: %d in format string (no. 7) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]
dbg("() = %d, %d, %d, %d, %d, %d, %d, %d\n", rc ? rc : status, *year,
^
librtas_src/syscall_calls.c:744:2: warning: %d in format string (no. 8) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]
dbg("() = %d, %d, %d, %d, %d, %d, %d, %d\n", rc ? rc : status, *year,
^
librtas_src/syscall_calls.c:744:2: warning: %d in format string (no. 9) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]
dbg("() = %d, %d, %d, %d, %d, %d, %d, %d\n", rc ? rc : status, *year,
^
librtas_src/syscall_calls.c:811:2: warning: %d in format string (no. 5) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]
dbg("(%s, 0x%p, %zd, %d) = %d, %d, %d", loc_code ? loc_code : "NULL",
^
librtas_src/syscall_calls.c:811:2: warning: %d in format string (no. 7) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]
dbg("(%s, 0x%p, %zd, %d) = %d, %d, %d", loc_code ? loc_code : "NULL",
^
librtas_src/syscall_calls.c:811:2: warning: %d in format string (no. 8) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]
dbg("(%s, 0x%p, %zd, %d) = %d, %d, %d", loc_code ? loc_code : "NULL",
^
librtas_src/syscall_calls.c:865:2: warning: %d in format string (no. 4) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]
dbg("(%d, %p, %d, %d, %p) = %d, %d\n", subfunc, workarea,
^
librtas_src/syscall_calls.c:865:2: warning: %d in format string (no. 5) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]
dbg("(%d, %p, %d, %d, %p) = %d, %d\n", subfunc, workarea,
^
librtas_src/syscall_calls.c:865:2: warning: %d in format string (no. 8) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]
dbg("(%d, %p, %d, %d, %p) = %d, %d\n", subfunc, workarea,
^
librtas_src/syscall_calls.c:1167:2: warning: %d in format string (no. 2) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]
dbg("(%d, %d, %d, %d, %d, %d, %d) = %d\n", year, month, day, hour,
^
librtas_src/syscall_calls.c:1167:2: warning: %d in format string (no. 3) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]
dbg("(%d, %d, %d, %d, %d, %d, %d) = %d\n", year, month, day, hour,
^
librtas_src/syscall_calls.c:1167:2: warning: %d in format string (no. 4) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]
dbg("(%d, %d, %d, %d, %d, %d, %d) = %d\n", year, month, day, hour,
^
librtas_src/syscall_calls.c:1167:2: warning: %d in format string (no. 5) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]
dbg("(%d, %d, %d, %d, %d, %d, %d) = %d\n", year, month, day, hour,
^
librtas_src/syscall_calls.c:1167:2: warning: %d in format string (no. 6) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]
dbg("(%d, %d, %d, %d, %d, %d, %d) = %d\n", year, month, day, hour,
^
librtas_src/syscall_calls.c:1167:2: warning: %d in format string (no. 7) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]
dbg("(%d, %d, %d, %d, %d, %d, %d) = %d\n", year, month, day, hour,
^
librtas_src/syscall_calls.c:1167:2: warning: %d in format string (no. 8) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]
dbg("(%d, %d, %d, %d, %d, %d, %d) = %d\n", year, month, day, hour,
^
librtas_src/syscall_calls.c:1203:2: warning: %d in format string (no. 2) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]
dbg("(%d, %p) = %d\n", parameter, data, rc ? rc : status);
^
librtas_src/syscall_calls.c:1233:2: warning: %d in format string (no. 2) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]
dbg("(%d, %d, %d, %d, %d, %d, %d) = %d\n", year, month, day, hour,
^
librtas_src/syscall_calls.c:1233:2: warning: %d in format string (no. 3) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]
dbg("(%d, %d, %d, %d, %d, %d, %d) = %d\n", year, month, day, hour,
^
librtas_src/syscall_calls.c:1233:2: warning: %d in format string (no. 4) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]
dbg("(%d, %d, %d, %d, %d, %d, %d) = %d\n", year, month, day, hour,
^
librtas_src/syscall_calls.c:1233:2: warning: %d in format string (no. 5) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]
dbg("(%d, %d, %d, %d, %d, %d, %d) = %d\n", year, month, day, hour,
^
librtas_src/syscall_calls.c:1233:2: warning: %d in format string (no. 6) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]
dbg("(%d, %d, %d, %d, %d, %d, %d) = %d\n", year, month, day, hour,
^
librtas_src/syscall_calls.c:1233:2: warning: %d in format string (no. 7) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]
dbg("(%d, %d, %d, %d, %d, %d, %d) = %d\n", year, month, day, hour,
^
librtas_src/syscall_calls.c:1233:2: warning: %d in format string (no. 8) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]
dbg("(%d, %d, %d, %d, %d, %d, %d) = %d\n", year, month, day, hour,
^
librtas_src/syscall_calls.c:1290:2: warning: %d in format string (no. 3) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]
dbg("(%p) %d = %d\n", workarea, scope, rc ? rc : status);
^
librtas_src/syscall_calls.c:1329:2: warning: %d in format string (no. 3) requires 'int' but the argument type is 'unsigned int'. [invalidPrintfArgType_sint]
dbg("(%p) %d = %d\n", workarea, scope, rc ? rc : status);
^
The text was updated successfully, but these errors were encountered:
Couple problems I see with
dbg()
in syscall.h:cppcheck report:
The text was updated successfully, but these errors were encountered: