Netdev List
 help / color / mirror / Atom feed
From: Yonghong Song <yhs@fb.com>
To: Andrey Ignatov <rdna@fb.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Cc: "ast@kernel.org" <ast@kernel.org>,
	"daniel@iogearbox.net" <daniel@iogearbox.net>,
	Kernel Team <Kernel-team@fb.com>
Subject: Re: [PATCH bpf-next] libbpf: Ignore -Wformat-nonliteral warning
Date: Sun, 7 Apr 2019 06:11:25 +0000	[thread overview]
Message-ID: <74b38291-f82d-b97c-bcb7-39762e86f0ae@fb.com> (raw)
In-Reply-To: <20190407053734.781995-1-rdna@fb.com>



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,
> 

  reply	other threads:[~2019-04-07  6:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-07  5:37 [PATCH bpf-next] libbpf: Ignore -Wformat-nonliteral warning Andrey Ignatov
2019-04-07  6:11 ` Yonghong Song [this message]
2019-04-07  6:15 ` Alexei Starovoitov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=74b38291-f82d-b97c-bcb7-39762e86f0ae@fb.com \
    --to=yhs@fb.com \
    --cc=Kernel-team@fb.com \
    --cc=ast@kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=netdev@vger.kernel.org \
    --cc=rdna@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox