RE: [PATCH v2 08/10] x86/mce: Remove the redundant zeroing assignments
From: H. Peter Anvin
Date: Sat Oct 19 2024 - 20:25:48 EST
On October 19, 2024 1:30:04 AM PDT, "Zhuo, Qiuxu" <qiuxu.zhuo@xxxxxxxxx> wrote:
>> From: H. Peter Anvin <hpa@xxxxxxxxx>
>> [...]
>>
>> Keep in mind that usually the compiler will remove redundant assignments,
>> and if they are too obscure for the compiler to discover, they are probably too
>> subtle for programmers to not introduce bugs in the future ...
>
>Thanks, H.Peter.
>
>This is a good tip to quickly check whether a cleanup of removing unnecessary
>assignments changes the function. If there is no difference in the text before and
>after the cleanup, then it's OK. Otherwise, the cleanup probably changes the
>function in an unintended way.
>
>-Qiuxu
>
Yes and no. Deleting things like redundant reinitialization should only be done if it makes the code clearer. You can think of the redundant statements as comments/asserts.