[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <3ec56c4b-6dbc-474d-8e31-5a019dc8a044@linaro.org>
Date: Tue, 7 Jan 2025 17:06:37 +0000
From: James Clark <james.clark@...aro.org>
To: Ian Rogers <irogers@...gle.com>
Cc: Leo Yan <leo.yan@....com>, Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...hat.com>, Arnaldo Carvalho de Melo <acme@...nel.org>,
Namhyung Kim <namhyung@...nel.org>, Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Jiri Olsa <jolsa@...nel.org>, Adrian Hunter <adrian.hunter@...el.com>,
Kan Liang <kan.liang@...ux.intel.com>, linux-perf-users@...r.kernel.org,
bpf@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v1] tools build: Fix a number of Wconversion warnings
On 07/01/2025 4:11 pm, Ian Rogers wrote:
> On Tue, Jan 7, 2025 at 2:33 AM James Clark <james.clark@...aro.org> wrote:
>>
>> On 06/01/2025 9:54 pm, Ian Rogers wrote:
>>> 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@...gle.com>
>>
>> What's the plan for errors in #includes that we can't modify? I noticed
>> the Perl feature test fails with -Wconversion but can be fixed by
>> disabling the warning:
>>
>> #pragma GCC diagnostic push
>> #pragma GCC diagnostic ignored "-Wsign-conversion"
>> #pragma GCC diagnostic ignored "-Wconversion"
>> #include <EXTERN.h>
>> #include <perl.h>
>> #pragma GCC diagnostic pop
>>
>> Not sure why it needs both those things to be disabled when I only
>> enabled -Wconversion, but it does.
>
> This change lgtm, I'm not sure how others feel. I don't have a plan, I
> was just following up on Leo's Wconversion comment to see what state
> things were in. The feature tests without these changes pretty much
> break the build (I can live without perl support :-) ) so I thought I
> could move things forward there and then see the state of Wconversion
> with the patch I was working on.
>
> I'm not sure how others feel about fixing Wconversion in perf, the
> errors are quite noisy imo. The biggest issue imo will be with headers
> shared by tools and the kernel, where kernel people may be vocal on
> the merits of Wconversion.
>
More warnings are better IMO, but I can't say I have any experience with
that particular one, whether it's too painful to be useful or not.
And if it's going to require those pragmas all over the place to fully
enable it maybe it's better to leave it off. Just your change without
the pragmas makes sense for sporadic manual testing though, and we can
leave libperl disabled.
>>> ---
>>> tools/build/feature/test-backtrace.c | 2 +-
>>> tools/build/feature/test-bpf.c | 2 +-
>>> tools/build/feature/test-glibc.c | 2 +-
>>> tools/build/feature/test-libdebuginfod.c | 2 +-
>>> tools/build/feature/test-libdw.c | 2 +-
>>> tools/build/feature/test-libelf-gelf_getnote.c | 2 +-
>>> tools/build/feature/test-libelf.c | 2 +-
>>> tools/build/feature/test-lzma.c | 2 +-
>>> 8 files changed, 8 insertions(+), 8 deletions(-)
>>>
>>> diff --git a/tools/build/feature/test-backtrace.c b/tools/build/feature/test-backtrace.c
>>> index e9ddd27c69c3..7962fbad6401 100644
>>> --- a/tools/build/feature/test-backtrace.c
>>> +++ b/tools/build/feature/test-backtrace.c
>>> @@ -5,7 +5,7 @@
>>> int main(void)
>>> {
>>> void *backtrace_fns[10];
>>> - size_t entries;
>>> + int entries;
>>>
>>> entries = backtrace(backtrace_fns, 10);
>>> backtrace_symbols_fd(backtrace_fns, entries, 1);
>>> diff --git a/tools/build/feature/test-bpf.c b/tools/build/feature/test-bpf.c
>>> index 727d22e34a6e..e7a405f83af6 100644
>>> --- a/tools/build/feature/test-bpf.c
>>> +++ b/tools/build/feature/test-bpf.c
>>> @@ -44,5 +44,5 @@ int main(void)
>>> * 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;
>>
>> Seems a bit weird to invert some of the return values rather than doing
>> != 0, but as you say, the actual values seem to be unimportant.
>>
>> Reviewed-by: James Clark <james.clark@...aro.org>
>
> Yeah it was arbitrary and I didn't want to add a stdlib.h dependency
> in a bunch of places for the sake of a definition of NULL. I'm happy
> for things to be done differently if people like.
>
> Thanks,
> Ian
Powered by blists - more mailing lists