Skip to content

Commit 8d86767

Browse files
mrpreanakryiko
authored andcommitted
bpftool: Add -Wformat-signedness flag to detect format errors
This commit adds the -Wformat-signedness compiler flag to detect and prevent printf format errors, where signed or unsigned types are mismatched with format specifiers. This helps to catch potential issues at compile-time, ensuring that our code is more robust and reliable. With this flag, the compiler will now warn about incorrect format strings, such as using %d with unsigned types or %u with signed types. Signed-off-by: Jiayuan Chen <jiayuan.chen@linux.dev> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20250311112809.81901-2-jiayuan.chen@linux.dev
1 parent b02f072 commit 8d86767

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

tools/bpf/bpftool/Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,12 @@ prefix ?= /usr/local
7171
bash_compdir ?= /usr/share/bash-completion/completions
7272

7373
CFLAGS += -O2
74-
CFLAGS += -W -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers
74+
CFLAGS += -W
75+
CFLAGS += -Wall
76+
CFLAGS += -Wextra
77+
CFLAGS += -Wformat-signedness
78+
CFLAGS += -Wno-unused-parameter
79+
CFLAGS += -Wno-missing-field-initializers
7580
CFLAGS += $(filter-out -Wswitch-enum -Wnested-externs,$(EXTRA_WARNINGS))
7681
CFLAGS += -DPACKAGE='"bpftool"' -D__EXPORTED_HEADERS__ \
7782
-I$(or $(OUTPUT),.) \

0 commit comments

Comments
 (0)