Re: Self assigning variable, ie x = x

From: Farhan Khan <farhan_at_farhan.codes>
Date: Wed, 28 May 2025 22:39:44 UTC
On Wed, May 28, 2025, at 6:04 PM, Dimitry Andric wrote:
>
> Most likely the reason was to avoid "unused variable" or "unused 
> parameter" warnings. These days, there are attributes for this purpose.
>
> On the other hand, if it is contrib software, you might want to take it 
> upstream first. Unless there is no upstream anymore, of course. :)
>
> -Dimitry

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.

That example was from contrib, but there are other instances that are not upstream, such as in the `pms` driver.

I found this by running the following ugly grep command:

$  grep -E '^[[:space:]]*(\w*)[[:space:]]*=[[:space:]]*\1;' -r /usr/src/

-- 
Farhan Khan