Re: Self assigning variable, ie x = x

From: Theron <theron.tarigo_at_gmail.com>
Date: Thu, 29 May 2025 05:16:45 UTC
On 5/29/25 00:39, Farhan Khan wrote:
> In my experience, compilers do not complain about an unused variable passed to a function, but they complain if you initialized the variable in the function and then didn't use it.
At least in clang there are separate warning flags for each case: 
-Wunused-variable, -Wunused-parameter, -Wunused-but-set-variable, 
-Wunused-but-set-parameter.
Of these, only those for variables are included in -Wall.
Note that under -Wall, the assignments you have found are themselves a 
warning -Wself-assign.

> That example was from contrib, but there are other instances that are not upstream, such as in the `pms` driver.
sys/dev/pms/RefTisa/... get away with it because despite the many 
warning flags, they are also compiled with -w.

Clearly these self-assignments were done to please a different compiler 
than the one we have now.