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

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