summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorQuentin Monnet <quentin.monnet@netronome.com>2018-12-14 08:56:01 -0500
committerDaniel Borkmann <daniel@iogearbox.net>2018-12-14 19:31:49 -0500
commitc101189bc9680675a2686bafe908015a07a0da51 (patch)
tree65178d436002e69009993778078eb7c2e1a8940e /tools
parent8c03ecf712f5bbbb9d353ed69715aef3cc2b4029 (diff)
tools: bpftool: fix -Wmissing declaration warnings
Help compiler check arguments for several utility functions used to print items to the console by adding the "printf" attribute when declaring those functions. Also, declare as "static" two functions that are only used in prog.c. All of them discovered by compiling bpftool with -Wmissing-format-attribute -Wmissing-declarations. Signed-off-by: Quentin Monnet <quentin.monnet@netronome.com> Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'tools')
-rw-r--r--tools/bpf/bpftool/common.c4
-rw-r--r--tools/bpf/bpftool/json_writer.c6
-rw-r--r--tools/bpf/bpftool/prog.c4
-rw-r--r--tools/bpf/bpftool/xlated_dumper.c7
4 files changed, 12 insertions, 9 deletions
diff --git a/tools/bpf/bpftool/common.c b/tools/bpf/bpftool/common.c
index 99e4027dde75..24582e8a96fb 100644
--- a/tools/bpf/bpftool/common.c
+++ b/tools/bpf/bpftool/common.c
@@ -28,7 +28,7 @@
28#define BPF_FS_MAGIC 0xcafe4a11 28#define BPF_FS_MAGIC 0xcafe4a11
29#endif 29#endif
30 30
31void p_err(const char *fmt, ...) 31void __printf(1, 2) p_err(const char *fmt, ...)
32{ 32{
33 va_list ap; 33 va_list ap;
34 34
@@ -46,7 +46,7 @@ void p_err(const char *fmt, ...)
46 va_end(ap); 46 va_end(ap);
47} 47}
48 48
49void p_info(const char *fmt, ...) 49void __printf(1, 2) p_info(const char *fmt, ...)
50{ 50{
51 va_list ap; 51 va_list ap;
52 52
diff --git a/tools/bpf/bpftool/json_writer.c b/tools/bpf/bpftool/json_writer.c
index a07d17918725..bff7ee026680 100644
--- a/tools/bpf/bpftool/json_writer.c
+++ b/tools/bpf/bpftool/json_writer.c
@@ -20,6 +20,7 @@
20#include <malloc.h> 20#include <malloc.h>
21#include <inttypes.h> 21#include <inttypes.h>
22#include <stdint.h> 22#include <stdint.h>
23#include <linux/compiler.h>
23 24
24#include "json_writer.h" 25#include "json_writer.h"
25 26
@@ -157,7 +158,8 @@ void jsonw_name(json_writer_t *self, const char *name)
157 putc(' ', self->out); 158 putc(' ', self->out);
158} 159}
159 160
160void jsonw_vprintf_enquote(json_writer_t *self, const char *fmt, va_list ap) 161void __printf(2, 0)
162jsonw_vprintf_enquote(json_writer_t *self, const char *fmt, va_list ap)
161{ 163{
162 jsonw_eor(self); 164 jsonw_eor(self);
163 putc('"', self->out); 165 putc('"', self->out);
@@ -165,7 +167,7 @@ void jsonw_vprintf_enquote(json_writer_t *self, const char *fmt, va_list ap)
165 putc('"', self->out); 167 putc('"', self->out);
166} 168}
167 169
168void jsonw_printf(json_writer_t *self, const char *fmt, ...) 170void __printf(2, 3) jsonw_printf(json_writer_t *self, const char *fmt, ...)
169{ 171{
170 va_list ap; 172 va_list ap;
171 173
diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c
index ee51279be9c7..2d1bb7d6ff51 100644
--- a/tools/bpf/bpftool/prog.c
+++ b/tools/bpf/bpftool/prog.c
@@ -32,7 +32,7 @@ static const char * const attach_type_strings[] = {
32 [__MAX_BPF_ATTACH_TYPE] = NULL, 32 [__MAX_BPF_ATTACH_TYPE] = NULL,
33}; 33};
34 34
35enum bpf_attach_type parse_attach_type(const char *str) 35static enum bpf_attach_type parse_attach_type(const char *str)
36{ 36{
37 enum bpf_attach_type type; 37 enum bpf_attach_type type;
38 38
@@ -798,7 +798,7 @@ struct map_replace {
798 char *name; 798 char *name;
799}; 799};
800 800
801int map_replace_compar(const void *p1, const void *p2) 801static int map_replace_compar(const void *p1, const void *p2)
802{ 802{
803 const struct map_replace *a = p1, *b = p2; 803 const struct map_replace *a = p1, *b = p2;
804 804
diff --git a/tools/bpf/bpftool/xlated_dumper.c b/tools/bpf/bpftool/xlated_dumper.c
index 640ffe86a655..7073dbe1ff27 100644
--- a/tools/bpf/bpftool/xlated_dumper.c
+++ b/tools/bpf/bpftool/xlated_dumper.c
@@ -81,7 +81,7 @@ struct kernel_sym *kernel_syms_search(struct dump_data *dd,
81 sizeof(*dd->sym_mapping), kernel_syms_cmp) : NULL; 81 sizeof(*dd->sym_mapping), kernel_syms_cmp) : NULL;
82} 82}
83 83
84static void print_insn(void *private_data, const char *fmt, ...) 84static void __printf(2, 3) print_insn(void *private_data, const char *fmt, ...)
85{ 85{
86 va_list args; 86 va_list args;
87 87
@@ -90,7 +90,7 @@ static void print_insn(void *private_data, const char *fmt, ...)
90 va_end(args); 90 va_end(args);
91} 91}
92 92
93static void 93static void __printf(2, 3)
94print_insn_for_graph(void *private_data, const char *fmt, ...) 94print_insn_for_graph(void *private_data, const char *fmt, ...)
95{ 95{
96 char buf[64], *p; 96 char buf[64], *p;
@@ -121,7 +121,8 @@ print_insn_for_graph(void *private_data, const char *fmt, ...)
121 printf("%s", buf); 121 printf("%s", buf);
122} 122}
123 123
124static void print_insn_json(void *private_data, const char *fmt, ...) 124static void __printf(2, 3)
125print_insn_json(void *private_data, const char *fmt, ...)
125{ 126{
126 unsigned int l = strlen(fmt); 127 unsigned int l = strlen(fmt);
127 char chomped_fmt[l]; 128 char chomped_fmt[l];