@@ -56,7 +56,8 @@ prefix ?= /usr/local
bash_compdir ?= /usr/share/bash-completion/completions
CFLAGS += -O2
-CFLAGS += -W -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers
+CFLAGS += -W -Wall -Wextra -Werror
+CFLAGS += -Wno-unused-parameter -Wno-missing-field-initializers
CFLAGS += $(filter-out -Wswitch-enum -Wnested-externs,$(EXTRA_WARNINGS))
CFLAGS += -DPACKAGE='"bpftool"' -D__EXPORTED_HEADERS__ \
-I$(if $(OUTPUT),$(OUTPUT),.) \
@@ -118,7 +118,10 @@ void disasm_print_insn(unsigned char *image, ssize_t len, int opcodes,
info.arch = bfd_get_arch(bfdf);
info.mach = bfd_get_mach(bfdf);
if (disassembler_options)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdiscarded-qualifiers"
info.disassembler_options = disassembler_options;
+#pragma GCC diagnostic push
info.buffer = image;
info.buffer_length = len;
Make bpftool compilation stricter and treat all compilation warnigs as errors. Depending on libbfd version on the system, jit_disasm.c might trigger the following compilation warning-turned-error: jit_disasm.c: In function ‘disasm_print_insn’: jit_disasm.c:121:29: error: assignment discards ‘const’ qualifier from pointer target type [-Werror=discarded-qualifiers] info.disassembler_options = disassembler_options; ^ This was fixed in libbfd, but older versions of the library are still widely used. So disable -Wdiscarded-qualifiers for that particular line of code. Signed-off-by: Andrii Nakryiko <andrii@kernel.org> --- tools/bpf/bpftool/Makefile | 3 ++- tools/bpf/bpftool/jit_disasm.c | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-)