Blob Blame History Raw
From: Andrii Nakryiko <andriin@fb.com>
Date: Wed, 26 Aug 2020 21:11:09 -0700
Subject: libbpf: Fix compilation warnings for 64-bit printf args
Patch-mainline: v5.10-rc1
Git-commit: 2e80be60c465a4f8559327340eaf40845dd7797a
References: bsc#1177028

Fix compilation warnings due to __u64 defined differently as `unsigned long`
or `unsigned long long` on different architectures (e.g., ppc64le differs from
x86-64). Also cast one argument to size_t to fix printf warning of similar
nature.

Fixes: eacaaed784e2 ("libbpf: Implement enum value-based CO-RE relocations")
Fixes: 50e09460d9f8 ("libbpf: Skip well-known ELF sections when iterating ELF")
Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20200827041109.3613090-1-andriin@fb.com
Acked-by: Gary Lin <glin@suse.com>
---
 tools/lib/bpf/libbpf.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -2827,7 +2827,8 @@ static int bpf_object__elf_collect(struc
 			obj->efile.bss = data;
 			obj->efile.bss_shndx = idx;
 		} else {
-			pr_info("elf: skipping section(%d) %s (size %zu)\n", idx, name, sh.sh_size);
+			pr_info("elf: skipping section(%d) %s (size %zu)\n", idx, name,
+				(size_t)sh.sh_size);
 		}
 	}
 
@@ -5223,7 +5224,8 @@ static int bpf_core_patch_insn(struct bp
 		if (res->validate && imm != orig_val) {
 			pr_warning("prog '%s': relo #%d: unexpected insn #%d (LDIMM64) value: got %llu, exp %u -> %u\n",
 				   bpf_program__title(prog, false), relo_idx,
-				   insn_idx, imm, orig_val, new_val);
+				   insn_idx, (unsigned long long)imm,
+				   orig_val, new_val);
 			return -EINVAL;
 		}
 
@@ -5231,7 +5233,7 @@ static int bpf_core_patch_insn(struct bp
 		insn[1].imm = 0; /* currently only 32-bit values are supported */
 		pr_debug("prog '%s': relo #%d: patched insn #%d (LDIMM64) imm64 %llu -> %u\n",
 			 bpf_program__title(prog, false), relo_idx, insn_idx,
-			 imm, new_val);
+			 (unsigned long long)imm, new_val);
 		break;
 	}
 	default: