Blame 0001-Initialize-nl_pid-so-gcc-shuts-up.patch

a8209b8
From 6d23065901549562b69fc84f34279d4635e5e9f0 Mon Sep 17 00:00:00 2001
a8209b8
From: Jeremy Cline <jcline@redhat.com>
a8209b8
Date: Fri, 3 Apr 2020 21:25:00 -0400
a8209b8
Subject: [PATCH] libbpf: Initialize *nl_pid so gcc 10 is happy
a8209b8
a8209b8
Builds of Fedora's kernel-tools package started to fail with "may be
a8209b8
used uninitialized" warnings for nl_pid in bpf_set_link_xdp_fd() and
a8209b8
bpf_get_link_xdp_info() on the s390 architecture.
a8209b8
a8209b8
Although libbpf_netlink_open() always returns a negative number when it
a8209b8
does not set *nl_pid, the compiler does not determine this and thus
a8209b8
believes the variable might be used uninitialized. Assuage gcc's fears
a8209b8
by explicitly initializing nl_pid.
a8209b8
a8209b8
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1807781
a8209b8
Signed-off-by: Jeremy Cline <jcline@redhat.com>
a8209b8
---
a8209b8
 tools/lib/bpf/netlink.c | 4 ++--
a8209b8
 1 file changed, 2 insertions(+), 2 deletions(-)
a8209b8
a8209b8
diff --git a/tools/lib/bpf/netlink.c b/tools/lib/bpf/netlink.c
a8209b8
index 18b5319025e19..9a14694176de0 100644
a8209b8
--- a/tools/lib/bpf/netlink.c
a8209b8
+++ b/tools/lib/bpf/netlink.c
a8209b8
@@ -142,7 +142,7 @@ static int __bpf_set_link_xdp_fd_replace(int ifindex, int fd, int old_fd,
a8209b8
 		struct ifinfomsg ifinfo;
a8209b8
 		char             attrbuf[64];
a8209b8
 	} req;
a8209b8
-	__u32 nl_pid;
a8209b8
+	__u32 nl_pid = 0;
a8209b8
 
a8209b8
 	sock = libbpf_netlink_open(&nl_pid);
a8209b8
 	if (sock < 0)
a8209b8
@@ -288,7 +288,7 @@ int bpf_get_link_xdp_info(int ifindex, struct xdp_link_info *info,
a8209b8
 {
a8209b8
 	struct xdp_id_md xdp_id = {};
a8209b8
 	int sock, ret;
a8209b8
-	__u32 nl_pid;
a8209b8
+	__u32 nl_pid = 0;
a8209b8
 	__u32 mask;
a8209b8
 
a8209b8
 	if (flags & ~XDP_FLAGS_MASK || !info_size)
a8209b8
-- 
a8209b8
2.26.0
a8209b8