]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
libbpf: Ignore -Wformat-nonliteral warning
authorAndrey Ignatov <rdna@fb.com>
Sun, 7 Apr 2019 05:37:34 +0000 (22:37 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Sun, 7 Apr 2019 06:13:54 +0000 (23:13 -0700)
vsprintf() in __base_pr() uses nonliteral format string and it breaks
compilation for those who provide corresponding extra CFLAGS, e.g.:
https://github.com/libbpf/libbpf/issues/27

If libbpf is built with the flags from PR:

  libbpf.c:68:26: error: format string is not a string literal
  [-Werror,-Wformat-nonliteral]
          return vfprintf(stderr, format, args);
                                  ^~~~~~
  1 error generated.

Ignore this warning since the use case in libbpf.c is legit.

Signed-off-by: Andrey Ignatov <rdna@fb.com>
Acked-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/lib/bpf/libbpf.c

index e1e4d35cf08edf5943db3488382765fdd2beadc5..1ebfe7943d53139ecc8b3a8c3ada54e0b5298e98 100644 (file)
 #define BPF_FS_MAGIC           0xcafe4a11
 #endif
 
+/* vsprintf() in __base_pr() uses nonliteral format string. It may break
+ * compilation if user enables corresponding warning. Disable it explicitly.
+ */
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
+
 #define __printf(a, b) __attribute__((format(printf, a, b)))
 
 static int __base_pr(enum libbpf_print_level level, const char *format,