On Fri, Jun 27, 2025 at 04:15:09PM +0530, Anshuman Khandual wrote:
On 25/06/25 3:54 PM, Mark Brown wrote:
- int status;
- int status = 0;
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.
Yes, it's a fairly common false positive pattern (in this case it'll be that the compiler can't understand the constraints with pulling things out of the exit status).
But the compiler still throws these build warnings. Seems to be false positives and this fix just works around that.
Right, the problem is that it works around it with a big hammer that just shuts the warning up completely meaning that if we do cause issues in the future then the compiler won't be able to tell us about them. It would be better to suppess it by changing the control flow such that the compiler can follow it.