Skip to content

Commit ff466b5

Browse files
rdnaAlexei Starovoitov
authored andcommitted
libbpf: Ignore -Wformat-nonliteral warning
vsprintf() in __base_pr() uses nonliteral format string and it breaks compilation for those who provide corresponding extra CFLAGS, e.g.: libbpf/libbpf#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>
1 parent 347807d commit ff466b5

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

‎tools/lib/bpf/libbpf.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@
5252
#define BPF_FS_MAGIC 0xcafe4a11
5353
#endif
5454

55+
/* vsprintf() in __base_pr() uses nonliteral format string. It may break
56+
* compilation if user enables corresponding warning. Disable it explicitly.
57+
*/
58+
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
59+
5560
#define __printf(a, b) __attribute__((format(printf, a, b)))
5661

5762
static int __base_pr(enum libbpf_print_level level, const char *format,

0 commit comments

Comments
 (0)