[PATCH] KVM: arm64: nVHE: gen-hyprel: Silent build warnings
From: Tianjia Zhang
Date: Wed Oct 09 2024 - 04:59:03 EST
This patch silent the some mismatch format build warnings
with clang, like:
arch/arm64/kvm/hyp/nvhe/gen-hyprel.c:233:2: warning: format specifies
type 'unsigned long' but the argument has type 'Elf64_Off'
(aka 'unsigned long long') [-Wformat]
233 | assert_ne(off, 0UL, "%lu");
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
| %llu
arch/arm64/kvm/hyp/nvhe/gen-hyprel.c:193:34: note: expanded from macro 'assert_ne'
193 | #define assert_ne(lhs, rhs, fmt) assert_op(lhs, rhs, fmt, !=)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/arm64/kvm/hyp/nvhe/gen-hyprel.c:188:19: note: expanded from macro 'assert_op'
187 | " failed (lhs=" fmt ", rhs=" fmt \
| ~~~
188 | ", line=%d)", _lhs, _rhs, __LINE__); \
| ^~~~
arch/arm64/kvm/hyp/nvhe/gen-hyprel.c:167:17: note: expanded from macro 'fatal_error'
166 | fprintf(stderr, "error: %s: " fmt "\n", \
| ~~~
167 | elf.path, ## __VA_ARGS__); \
| ^~~~~~~~~~~
Signed-off-by: Tianjia Zhang <tianjia.zhang@xxxxxxxxxxxxxxxxx>
---
arch/arm64/kvm/hyp/nvhe/gen-hyprel.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/arch/arm64/kvm/hyp/nvhe/gen-hyprel.c b/arch/arm64/kvm/hyp/nvhe/gen-hyprel.c
index b63f4e1c1033..0d916d91b13c 100644
--- a/arch/arm64/kvm/hyp/nvhe/gen-hyprel.c
+++ b/arch/arm64/kvm/hyp/nvhe/gen-hyprel.c
@@ -230,7 +230,7 @@ static inline const char *section_begin(Elf64_Shdr *shdr)
/* Find a section by its offset from the beginning of the file. */
static inline Elf64_Shdr *section_by_off(Elf64_Off off)
{
- assert_ne(off, 0UL, "%lu");
+ assert_ne(off, 0ULL, "%llu");
return elf_ptr(Elf64_Shdr, off);
}
@@ -276,7 +276,7 @@ static void init_elf(const char *path)
close(fd);
/* Get pointer to the ELF header. */
- assert_ge(stat.st_size, sizeof(*elf.ehdr), "%lu");
+ assert_ge(stat.st_size, (off_t)sizeof(*elf.ehdr), "%llu");
elf.ehdr = elf_ptr(Elf64_Ehdr, 0);
/* Check the ELF magic. */
@@ -340,7 +340,7 @@ static void emit_rela_abs64(Elf64_Rela *rela, const char *sh_orig_name)
* a symbol at the beginning of the relocated section, and <offset>
* is `rela->r_offset`.
*/
- printf(".reloc %lu, R_AARCH64_PREL32, %s%s + 0x%lx\n",
+ printf(".reloc %lu, R_AARCH64_PREL32, %s%s + 0x%llx\n",
reloc_offset, HYP_SECTION_SYMBOL_PREFIX, sh_orig_name,
elf64toh(rela->r_offset));
@@ -376,7 +376,7 @@ static void emit_rela_section(Elf64_Shdr *sh_rela)
uint32_t type = (uint32_t)elf64toh(rela->r_info);
/* Check that rela points inside the relocated section. */
- assert_lt(elf64toh(rela->r_offset), elf64toh(sh_orig->sh_size), "0x%lx");
+ assert_lt(elf64toh(rela->r_offset), elf64toh(sh_orig->sh_size), "0x%llx");
switch (type) {
/*
--
2.47.0