diff options
author | Quentin Monnet <quentin.monnet@netronome.com> | 2019-08-15 16:32:20 +0200 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2019-08-16 07:06:46 +0200 |
commit | 8918dc42dc85ba6981028f65a989c478eb80bc02 (patch) | |
tree | fb4d3e3897a5731d4d7bf7a856eb8dc197157c62 /tools/bpf/bpftool/json_writer.c | |
parent | tools: bpftool: fix format string for p_err() in detect_common_prefix() (diff) | |
download | linux-8918dc42dc85ba6981028f65a989c478eb80bc02.tar.xz linux-8918dc42dc85ba6981028f65a989c478eb80bc02.zip |
tools: bpftool: move "__printf()" attributes to header file
Some functions in bpftool have a "__printf()" format attributes to tell
the compiler they should expect printf()-like arguments. But because
these attributes are not used for the function prototypes in the header
files, the compiler does not run the checks everywhere the functions are
used, and some mistakes on format string and corresponding arguments
slipped in over time.
Let's move the __printf() attributes to the correct places.
Note: We add guards around the definition of GCC_VERSION in
tools/include/linux/compiler-gcc.h to prevent a conflict in jit_disasm.c
on GCC_VERSION from headers pulled via libbfd.
Fixes: c101189bc968 ("tools: bpftool: fix -Wmissing declaration warnings")
Reported-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: Quentin Monnet <quentin.monnet@netronome.com>
Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'tools/bpf/bpftool/json_writer.c')
-rw-r--r-- | tools/bpf/bpftool/json_writer.c | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/tools/bpf/bpftool/json_writer.c b/tools/bpf/bpftool/json_writer.c index 6046dcab51cc..86501cd3c763 100644 --- a/tools/bpf/bpftool/json_writer.c +++ b/tools/bpf/bpftool/json_writer.c @@ -15,7 +15,6 @@ #include <malloc.h> #include <inttypes.h> #include <stdint.h> -#include <linux/compiler.h> #include "json_writer.h" @@ -153,8 +152,7 @@ void jsonw_name(json_writer_t *self, const char *name) putc(' ', self->out); } -void __printf(2, 0) -jsonw_vprintf_enquote(json_writer_t *self, const char *fmt, va_list ap) +void jsonw_vprintf_enquote(json_writer_t *self, const char *fmt, va_list ap) { jsonw_eor(self); putc('"', self->out); @@ -162,7 +160,7 @@ jsonw_vprintf_enquote(json_writer_t *self, const char *fmt, va_list ap) putc('"', self->out); } -void __printf(2, 3) jsonw_printf(json_writer_t *self, const char *fmt, ...) +void jsonw_printf(json_writer_t *self, const char *fmt, ...) { va_list ap; |