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>
int main(void)
{
void *backtrace_fns[10];
- size_t entries;
+ int entries;
entries = backtrace(backtrace_fns, 10);
backtrace_symbols_fd(backtrace_fns, entries, 1);
* Test existence of __NR_bpf and BPF_PROG_LOAD.
* This call should fail if we run the testcase.
*/
- return syscall(__NR_bpf, BPF_PROG_LOAD, &attr, sizeof(attr));
+ return syscall(__NR_bpf, BPF_PROG_LOAD, &attr, sizeof(attr)) == 0;
}
const char *version = XSTR(__GLIBC__) "." XSTR(__GLIBC_MINOR__);
#endif
- return (long)version;
+ return version == NULL;
}
int main(void)
{
debuginfod_client* c = debuginfod_begin();
- return (long)c;
+ return !!c;
}
{
Dwarf *dbg = dwarf_begin(0, DWARF_C_READ);
- return (long)dbg;
+ return dbg == NULL;
}
int test_libdw_unwind(void)
int main(void)
{
- return gelf_getnote(NULL, 0, NULL, NULL, NULL);
+ return gelf_getnote(NULL, 0, NULL, NULL, NULL) == 0;
}
{
Elf *elf = elf_begin(0, ELF_C_READ, 0);
- return (long)elf;
+ return !!elf;
}
int main(void)
{
lzma_stream strm = LZMA_STREAM_INIT;
- int ret;
+ lzma_ret ret;
ret = lzma_stream_decoder(&strm, UINT64_MAX, LZMA_CONCATENATED);
return ret ? -1 : 0;