]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
tools: bpftool: fix -Wmissing declaration warnings
authorQuentin Monnet <quentin.monnet@netronome.com>
Fri, 14 Dec 2018 13:56:01 +0000 (13:56 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 12 Feb 2019 19:02:19 +0000 (20:02 +0100)
[ Upstream commit c101189bc9680675a2686bafe908015a07a0da51 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/bpf/bpftool/common.c
tools/bpf/bpftool/json_writer.c
tools/bpf/bpftool/prog.c
tools/bpf/bpftool/xlated_dumper.c

index 70fd48d79f611fd98666a0ecf156c00285007fd9..05d715e6b12850e12cb3ad4d273abc9b6eb5f640 100644 (file)
@@ -58,7 +58,7 @@
 #define BPF_FS_MAGIC           0xcafe4a11
 #endif
 
-void p_err(const char *fmt, ...)
+void __printf(1, 2) p_err(const char *fmt, ...)
 {
        va_list ap;
 
@@ -76,7 +76,7 @@ void p_err(const char *fmt, ...)
        va_end(ap);
 }
 
-void p_info(const char *fmt, ...)
+void __printf(1, 2) p_info(const char *fmt, ...)
 {
        va_list ap;
 
index c6eef76322ae915ff5b88295b6f153dafb0ddd7d..4e4149421d07bd46b90f6e92575240fe617f43ce 100644 (file)
@@ -19,6 +19,7 @@
 #include <malloc.h>
 #include <inttypes.h>
 #include <stdint.h>
+#include <linux/compiler.h>
 
 #include "json_writer.h"
 
@@ -156,7 +157,8 @@ void jsonw_name(json_writer_t *self, const char *name)
                putc(' ', self->out);
 }
 
-void jsonw_vprintf_enquote(json_writer_t *self, const char *fmt, va_list ap)
+void __printf(2, 0)
+jsonw_vprintf_enquote(json_writer_t *self, const char *fmt, va_list ap)
 {
        jsonw_eor(self);
        putc('"', self->out);
@@ -164,7 +166,7 @@ void jsonw_vprintf_enquote(json_writer_t *self, const char *fmt, va_list ap)
        putc('"', self->out);
 }
 
-void jsonw_printf(json_writer_t *self, const char *fmt, ...)
+void __printf(2, 3) jsonw_printf(json_writer_t *self, const char *fmt, ...)
 {
        va_list ap;
 
index ccee180dfb761248f078ffa4b2154793d0308420..69b01a6158bdd8d722b55b82d07bb2d75ce45f61 100644 (file)
@@ -84,7 +84,7 @@ static const char * const attach_type_strings[] = {
        [__MAX_BPF_ATTACH_TYPE] = NULL,
 };
 
-enum bpf_attach_type parse_attach_type(const char *str)
+static enum bpf_attach_type parse_attach_type(const char *str)
 {
        enum bpf_attach_type type;
 
@@ -713,7 +713,7 @@ struct map_replace {
        char *name;
 };
 
-int map_replace_compar(const void *p1, const void *p2)
+static int map_replace_compar(const void *p1, const void *p2)
 {
        const struct map_replace *a = p1, *b = p2;
 
index 3284759df98ad4f325b25f719db0cfef7ac9f61c..98083e4dc0f9dec8c4fe544b70addbd1ed8312ce 100644 (file)
@@ -114,7 +114,7 @@ struct kernel_sym *kernel_syms_search(struct dump_data *dd,
                       sizeof(*dd->sym_mapping), kernel_syms_cmp) : NULL;
 }
 
-static void print_insn(void *private_data, const char *fmt, ...)
+static void __printf(2, 3) print_insn(void *private_data, const char *fmt, ...)
 {
        va_list args;
 
@@ -123,7 +123,7 @@ static void print_insn(void *private_data, const char *fmt, ...)
        va_end(args);
 }
 
-static void
+static void __printf(2, 3)
 print_insn_for_graph(void *private_data, const char *fmt, ...)
 {
        char buf[64], *p;
@@ -154,7 +154,8 @@ print_insn_for_graph(void *private_data, const char *fmt, ...)
        printf("%s", buf);
 }
 
-static void print_insn_json(void *private_data, const char *fmt, ...)
+static void __printf(2, 3)
+print_insn_json(void *private_data, const char *fmt, ...)
 {
        unsigned int l = strlen(fmt);
        char chomped_fmt[l];