client: check PrintAndLogEx format strings at compile time

Add a printf format attribute to PrintAndLogEx so gcc/clang flag
argument/specifier mismatches (previous commit fixed the 34 existing ones).
On mingw use __MINGW_PRINTF_FORMAT, matching the GNU printf selected by
_ISOC99_SOURCE rather than ms_printf.

PrintAndLogEx(x, "") is the established way to print an empty line, so
-Wno-format-zero-length is added to every build that compiles callers:
client Makefile, client CMake, experimental_lib, and cliparser (Makefile
and cmake).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
iceman1001andClaude Opus 5.5 committed 2026-11-09 18:35:57 +07:00
1 parent 3deae3d904
commit cc50ed6b72
6 files changed
+14 -5

No files matched your search

+1 -1
View File
@@ -885,7 +885,7 @@ if ((NOT SKIPQT EQUAL 1) AND Qt6_FOUND)
target_include_directories(proxmark3 PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
endif()
target_compile_options(proxmark3 PUBLIC -Wall -Werror -Wno-missing-braces -O3)
target_compile_options(proxmark3 PUBLIC -Wall -Werror -Wno-missing-braces -Wno-format-zero-length -O3)
if (EMBED_READLINE)
if (NOT SKIPREADLINE EQUAL 1)
add_dependencies(proxmark3 ncurses readline)
+2
View File
@@ -485,6 +485,8 @@ CFLAGS += $(MYDEFS) $(MYCFLAGS) $(MYINCLUDES)
# We cannot just use CFLAGS+=... because it has impact on sub-makes if CFLAGS is defined in env:
PM3CFLAGS = $(CFLAGS)
PM3CFLAGS += -I./src -I./include -I../include -I../common -I../common_fpga $(PM3INCLUDES) $(INCLUDES)
# PrintAndLogEx(x, "") prints an empty line on purpose
PM3CFLAGS += -Wno-format-zero-length
# WIP Testing
#PM3CFLAGS += -std=c11 -pedantic
+1 -1
View File
@@ -9,5 +9,5 @@ target_include_directories(pm3rrg_rdv4_cliparser PRIVATE
../../include
../src)
target_include_directories(pm3rrg_rdv4_cliparser INTERFACE cliparser)
target_compile_options(pm3rrg_rdv4_cliparser PRIVATE -Wall -Werror -O3)
target_compile_options(pm3rrg_rdv4_cliparser PRIVATE -Wall -Werror -Wno-format-zero-length -O3)
set_property(TARGET pm3rrg_rdv4_cliparser PROPERTY POSITION_INDEPENDENT_CODE ON)
+1 -1
View File
@@ -1,6 +1,6 @@
MYSRCPATHS =
MYINCLUDES = -I../../../common -I../../../include -I../../src
MYCFLAGS = -Wno-cast-align
MYCFLAGS = -Wno-cast-align -Wno-format-zero-length
MYDEFS =
MYSRCS = \
argtable3.c \
+1 -1
View File
@@ -720,7 +720,7 @@ add_library(pm3rrg_rdv4_static STATIC
set(PM3_LIBRARY_TARGETS pm3rrg_rdv4 pm3rrg_rdv4_static)
foreach (target IN LISTS PM3_LIBRARY_TARGETS)
target_compile_definitions(${target} PRIVATE LIBPM3)
target_compile_options(${target} PUBLIC -Wall -Werror -O3)
target_compile_options(${target} PUBLIC -Wall -Werror -Wno-format-zero-length -O3)
target_include_directories(${target} PRIVATE
${PM3_ROOT}/common
${PM3_ROOT}/common_fpga
+8 -1
View File
@@ -30,6 +30,13 @@ extern "C" {
#define _USE_MATH_DEFINES
// mingw: match GNU printf enabled via _ISOC99_SOURCE, not ms_printf
#ifdef __MINGW_PRINTF_FORMAT
#define PM3_PRINTF_FORMAT __MINGW_PRINTF_FORMAT
#else
#define PM3_PRINTF_FORMAT printf
#endif
typedef enum {STYLE_BAR, STYLE_MIXED, STYLE_VALUE} barMode_t;
typedef enum logLevel {NORMAL, SUCCESS, INFO, FAILED, WARNING, ERR, DEBUG, INPLACE, HINT} logLevel_t;
typedef enum emojiMode {EMO_ALIAS, EMO_EMOJI, EMO_ALTTEXT, EMO_NONE} emojiMode_t;
@@ -78,7 +85,7 @@ extern session_arg_t g_session;
#define PROMPT_CLEARLINE PrintAndLogEx(INPLACE, " \r")
void PrintAndLogOptions(const char *str[][2], size_t size, size_t space);
void PrintAndLogEx(logLevel_t level, const char *fmt, ...);
void PrintAndLogEx(logLevel_t level, const char *fmt, ...) __attribute__((format(PM3_PRINTF_FORMAT, 2, 3)));
void PrintAndLogInfoHeaderWithWidth(const char *title, size_t width);
void PrintAndLogInfoHeader(const char *title);
void SetFlushAfterWrite(bool value);