bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: Arnd Bergmann <arnd@kernel.org>
Cc: "Alexei Starovoitov" <ast@kernel.org>,
	"Daniel Borkmann" <daniel@iogearbox.net>,
	"Arnd Bergmann" <arnd@arndb.de>,
	"Martin KaFai Lau" <kafai@fb.com>,
	"Song Liu" <songliubraving@fb.com>, "Yonghong Song" <yhs@fb.com>,
	"Andrii Nakryiko" <andrii@kernel.org>,
	"John Fastabend" <john.fastabend@gmail.com>,
	"KP Singh" <kpsingh@chromium.org>,
	"David Miller" <davem@davemloft.net>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"Jakub Sitnicki" <jakub@cloudflare.com>,
	"Björn Töpel" <bjorn.topel@intel.com>,
	"Toke Høiland-Jørgensen" <toke@redhat.com>,
	"Jiri Olsa" <jolsa@kernel.org>,
	"Pankaj Bharadiya" <pankaj.laxminarayan.bharadiya@intel.com>,
	Networking <netdev@vger.kernel.org>, bpf <bpf@vger.kernel.org>,
	"open list" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] bpf: suppress -Wcast-function-type warning
Date: Mon, 26 Oct 2020 15:26:11 -0700	[thread overview]
Message-ID: <CAEf4BzaKSzEbPStm8EXk4RH417jHieSF3LCazQPXZ6qGskqB6Q@mail.gmail.com> (raw)
In-Reply-To: <20201026210332.3885166-1-arnd@kernel.org>

On Mon, Oct 26, 2020 at 2:03 PM Arnd Bergmann <arnd@kernel.org> wrote:
>
> From: Arnd Bergmann <arnd@arndb.de>
>
> Building with -Wextra shows lots of warnings in the bpf
> code such as
>
> kernel/bpf/verifier.c: In function ‘jit_subprogs’:
> include/linux/filter.h:345:4: warning: cast between incompatible function types from ‘unsigned int (*)(const void *, const struct bpf_insn *)’ to ‘u64 (*)(u64,  u64,  u64,  u64,  u64)’ {aka ‘long long unsigned int (*)(long long unsigned int,  long long unsigned int,  long long unsigned int,  long long unsigned int,  long long unsigned int)’} [-Wcast-function-type]
>   345 |   ((u64 (*)(u64, u64, u64, u64, u64))(x))
>       |    ^
> kernel/bpf/verifier.c:10706:16: note: in expansion of macro ‘BPF_CAST_CALL’
> 10706 |    insn->imm = BPF_CAST_CALL(func[subprog]->bpf_func) -
>       |                ^~~~~~~~~~~~~
>
> This appears to be intentional, so change the cast in a way that
> suppresses the warning.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---

LGTM.

Acked-by: Andrii Nakryiko <andrii@kernel.org>

>  include/linux/filter.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/linux/filter.h b/include/linux/filter.h
> index 1b62397bd124..20ba04583eaa 100644
> --- a/include/linux/filter.h
> +++ b/include/linux/filter.h
> @@ -342,7 +342,7 @@ static inline bool insn_is_zext(const struct bpf_insn *insn)
>  /* Function call */
>
>  #define BPF_CAST_CALL(x)                                       \
> -               ((u64 (*)(u64, u64, u64, u64, u64))(x))
> +               ((u64 (*)(u64, u64, u64, u64, u64))(uintptr_t)(x))
>
>  #define BPF_EMIT_CALL(FUNC)                                    \
>         ((struct bpf_insn) {                                    \
> --
> 2.27.0
>

      parent reply	other threads:[~2020-10-26 22:26 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-26 21:03 [PATCH] bpf: suppress -Wcast-function-type warning Arnd Bergmann
2020-10-26 22:20 ` David Laight
2020-10-26 22:26 ` Andrii Nakryiko [this message]

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=CAEf4BzaKSzEbPStm8EXk4RH417jHieSF3LCazQPXZ6qGskqB6Q@mail.gmail.com \
    --to=andrii.nakryiko@gmail.com \
    --cc=andrii@kernel.org \
    --cc=arnd@arndb.de \
    --cc=arnd@kernel.org \
    --cc=ast@kernel.org \
    --cc=bjorn.topel@intel.com \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=jakub@cloudflare.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kafai@fb.com \
    --cc=kpsingh@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pankaj.laxminarayan.bharadiya@intel.com \
    --cc=songliubraving@fb.com \
    --cc=tglx@linutronix.de \
    --cc=toke@redhat.com \
    --cc=yhs@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;
as well as URLs for NNTP newsgroup(s).