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.


Reply via email to