[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <af5cbd48-6312-481d-8e91-7739612493c1@arm.com>
Date: Fri, 27 Jun 2025 16:15:09 +0530
From: Anshuman Khandual <anshuman.khandual@....com>
To: Mark Brown <broonie@...nel.org>
Cc: linux-arm-kernel@...ts.infradead.org,
Catalin Marinas <catalin.marinas@....com>, Will Deacon <will@...nel.org>,
Shuah Khan <shuah@...nel.org>, linux-kselftest@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] selftests/arm64: Prevent build warnings from
-Wmaybe-uninitialized
On 25/06/25 3:54 PM, Mark Brown wrote:
> On Wed, Jun 25, 2025 at 03:01:38AM +0100, Anshuman Khandual wrote:
>
>> @@ -96,7 +96,7 @@ static int write_sleep_read(void)
>> static int write_fork_read(void)
>> {
>> pid_t newpid, waiting, oldpid;
>> - int status;
>> + int status = 0;
>>
>> set_tpidr2(getpid());
>>
>
> This will shut the warnings up, but it's a bit of a heavy hammer that
> means that the warning can never trigger warnings for that variable
> being unused. Is it possible to fix this by updating the control flow
> such that the compiler can tell that the initialisation follows the use?
The problem might not exist in reality. In the test function test_fork()
in the file tools/testing/selftests/arm64/gcs/basic-gcs.c there does not
seem to be a path where WIFEXITED(status) might get called when 'status'
has not been initialized as there is a preceding waitpid() which would
ensure 'status' gets set. Similar scenarios are present in fork_test_c()
and write_fork_read() as well.
But the compiler still throws these build warnings. Seems to be false
positives and this fix just works around that.
Powered by blists - more mailing lists