LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: Jeremy Cline <jcline@redhat.com>
Cc: Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Martin KaFai Lau <kafai@fb.com>, Song Liu <songliubraving@fb.com>,
	Yonghong Song <yhs@fb.com>, Andrii Nakryiko <andriin@fb.com>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@chromium.org>,
	"David S . Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	Jesper Dangaard Brouer <hawk@kernel.org>,
	Networking <netdev@vger.kernel.org>, bpf <bpf@vger.kernel.org>,
	open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] libbpf: Initialize *nl_pid so gcc 10 is happy
Date: Sun, 5 Apr 2020 19:46:38 -0700	[thread overview]
Message-ID: <CAEf4BzZmki+vzzC0j_uXWfPFs6BGqwxbJn2fYK83L5fpUm+UHg@mail.gmail.com> (raw)
In-Reply-To: <20200404051430.698058-1-jcline@redhat.com>

On Fri, Apr 3, 2020 at 10:15 PM Jeremy Cline <jcline@redhat.com> wrote:
>
> Builds of Fedora's kernel-tools package started to fail with "may be
> used uninitialized" warnings for nl_pid in bpf_set_link_xdp_fd() and
> bpf_get_link_xdp_info() on the s390 architecture.
>
> Although libbpf_netlink_open() always returns a negative number when it
> does not set *nl_pid, the compiler does not determine this and thus
> believes the variable might be used uninitialized. Assuage gcc's fears
> by explicitly initializing nl_pid.
>
> Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1807781
> Signed-off-by: Jeremy Cline <jcline@redhat.com>
> ---

Yep, unfortunately compiler is not that smart.

Acked-by: Andrii Nakryiko <andriin@fb.com>

>  tools/lib/bpf/netlink.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/lib/bpf/netlink.c b/tools/lib/bpf/netlink.c
> index 18b5319025e19..9a14694176de0 100644
> --- a/tools/lib/bpf/netlink.c
> +++ b/tools/lib/bpf/netlink.c
> @@ -142,7 +142,7 @@ static int __bpf_set_link_xdp_fd_replace(int ifindex, int fd, int old_fd,
>                 struct ifinfomsg ifinfo;
>                 char             attrbuf[64];
>         } req;
> -       __u32 nl_pid;
> +       __u32 nl_pid = 0;
>
>         sock = libbpf_netlink_open(&nl_pid);
>         if (sock < 0)
> @@ -288,7 +288,7 @@ int bpf_get_link_xdp_info(int ifindex, struct xdp_link_info *info,
>  {
>         struct xdp_id_md xdp_id = {};
>         int sock, ret;
> -       __u32 nl_pid;
> +       __u32 nl_pid = 0;
>         __u32 mask;
>
>         if (flags & ~XDP_FLAGS_MASK || !info_size)
> --
> 2.26.0
>

  reply	other threads:[~2020-04-06  2:46 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-04  5:14 Jeremy Cline
2020-04-06  2:46 ` Andrii Nakryiko [this message]
2020-04-06 20:14 ` Daniel Borkmann

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=CAEf4BzZmki+vzzC0j_uXWfPFs6BGqwxbJn2fYK83L5fpUm+UHg@mail.gmail.com \
    --to=andrii.nakryiko@gmail.com \
    --cc=andriin@fb.com \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=hawk@kernel.org \
    --cc=jcline@redhat.com \
    --cc=john.fastabend@gmail.com \
    --cc=kafai@fb.com \
    --cc=kpsingh@chromium.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=songliubraving@fb.com \
    --cc=yhs@fb.com \
    --subject='Re: [PATCH] libbpf: Initialize *nl_pid so gcc 10 is happy' \
    /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

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).