* [PATCH bpf-next] libbpf: Ignore -Wformat-nonliteral warning
@ 2019-04-07 5:37 Andrey Ignatov
2019-04-07 6:11 ` Yonghong Song
2019-04-07 6:15 ` Alexei Starovoitov
0 siblings, 2 replies; 3+ messages in thread
From: Andrey Ignatov @ 2019-04-07 5:37 UTC (permalink / raw)
To: netdev; +Cc: Andrey Ignatov, ast, daniel, kernel-team
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>
---
tools/lib/bpf/libbpf.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index e1e4d35cf08e..1ebfe7943d53 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -52,6 +52,11 @@
#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,
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH bpf-next] libbpf: Ignore -Wformat-nonliteral warning
2019-04-07 5:37 [PATCH bpf-next] libbpf: Ignore -Wformat-nonliteral warning Andrey Ignatov
@ 2019-04-07 6:11 ` Yonghong Song
2019-04-07 6:15 ` Alexei Starovoitov
1 sibling, 0 replies; 3+ messages in thread
From: Yonghong Song @ 2019-04-07 6:11 UTC (permalink / raw)
To: Andrey Ignatov, netdev@vger.kernel.org
Cc: ast@kernel.org, daniel@iogearbox.net, Kernel Team
On 4/6/19 10:37 PM, Andrey Ignatov wrote:
> 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>
Tested with clang compiler as well. It also resolved the same issue
when using clang to build libbpf in libbpf repo.
Acked-by: Yonghong Song <yhs@fb.com>
> ---
> tools/lib/bpf/libbpf.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> index e1e4d35cf08e..1ebfe7943d53 100644
> --- a/tools/lib/bpf/libbpf.c
> +++ b/tools/lib/bpf/libbpf.c
> @@ -52,6 +52,11 @@
> #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,
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH bpf-next] libbpf: Ignore -Wformat-nonliteral warning
2019-04-07 5:37 [PATCH bpf-next] libbpf: Ignore -Wformat-nonliteral warning Andrey Ignatov
2019-04-07 6:11 ` Yonghong Song
@ 2019-04-07 6:15 ` Alexei Starovoitov
1 sibling, 0 replies; 3+ messages in thread
From: Alexei Starovoitov @ 2019-04-07 6:15 UTC (permalink / raw)
To: Andrey Ignatov; +Cc: netdev, ast, daniel, kernel-team
On Sat, Apr 06, 2019 at 10:37:34PM -0700, Andrey Ignatov wrote:
> 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>
Applied, Thanks
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-04-07 6:15 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-04-07 5:37 [PATCH bpf-next] libbpf: Ignore -Wformat-nonliteral warning Andrey Ignatov
2019-04-07 6:11 ` Yonghong Song
2019-04-07 6:15 ` Alexei Starovoitov
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.