Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tools build: Fix a number of Wconversion warnings

There's some expressed interest in having the compiler flag
-Wconversion detect at build time certain kinds of potential problems:
https://lore.kernel.org/lkml/20250103182532.GB781381@e132581.arm.com/

As feature detection passes -Wconversion from CFLAGS when set, the
feature detection compile tests need to not fail because of
-Wconversion as the failure will be interpretted as a missing
feature. Switch various types to avoid the -Wconversion issue, the
exact meaning of the code is unimportant as it is typically looking
for header file definitions.

Signed-off-by: Ian Rogers <irogers@google.com>
Reviewed-by: James Clark <james.clark@linaro.org>
Link: https://lore.kernel.org/r/20250106215443.198633-1-irogers@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>

authored by

Ian Rogers and committed by
Namhyung Kim
7c1e94f5 dc6d2bc2

+8 -8
+1 -1
tools/build/feature/test-backtrace.c
··· 5 5 int main(void) 6 6 { 7 7 void *backtrace_fns[10]; 8 - size_t entries; 8 + int entries; 9 9 10 10 entries = backtrace(backtrace_fns, 10); 11 11 backtrace_symbols_fd(backtrace_fns, entries, 1);
+1 -1
tools/build/feature/test-bpf.c
··· 44 44 * Test existence of __NR_bpf and BPF_PROG_LOAD. 45 45 * This call should fail if we run the testcase. 46 46 */ 47 - return syscall(__NR_bpf, BPF_PROG_LOAD, &attr, sizeof(attr)); 47 + return syscall(__NR_bpf, BPF_PROG_LOAD, &attr, sizeof(attr)) == 0; 48 48 }
+1 -1
tools/build/feature/test-glibc.c
··· 16 16 const char *version = XSTR(__GLIBC__) "." XSTR(__GLIBC_MINOR__); 17 17 #endif 18 18 19 - return (long)version; 19 + return version == NULL; 20 20 }
+1 -1
tools/build/feature/test-libdebuginfod.c
··· 4 4 int main(void) 5 5 { 6 6 debuginfod_client* c = debuginfod_begin(); 7 - return (long)c; 7 + return !!c; 8 8 }
+1 -1
tools/build/feature/test-libdw.c
··· 9 9 { 10 10 Dwarf *dbg = dwarf_begin(0, DWARF_C_READ); 11 11 12 - return (long)dbg; 12 + return dbg == NULL; 13 13 } 14 14 15 15 int test_libdw_unwind(void)
+1 -1
tools/build/feature/test-libelf-gelf_getnote.c
··· 4 4 5 5 int main(void) 6 6 { 7 - return gelf_getnote(NULL, 0, NULL, NULL, NULL); 7 + return gelf_getnote(NULL, 0, NULL, NULL, NULL) == 0; 8 8 }
+1 -1
tools/build/feature/test-libelf.c
··· 5 5 { 6 6 Elf *elf = elf_begin(0, ELF_C_READ, 0); 7 7 8 - return (long)elf; 8 + return !!elf; 9 9 }
+1 -1
tools/build/feature/test-lzma.c
··· 4 4 int main(void) 5 5 { 6 6 lzma_stream strm = LZMA_STREAM_INIT; 7 - int ret; 7 + lzma_ret ret; 8 8 9 9 ret = lzma_stream_decoder(&strm, UINT64_MAX, LZMA_CONCATENATED); 10 10 return ret ? -1 : 0;