Re: [PATCH v3] RAS/AMD/ATL: Fix unintended sign extension issue from coverity

From: Yazen Ghannam
Date: Wed Dec 11 2024 - 11:02:09 EST


On Wed, Nov 27, 2024 at 06:23:48PM +0000, Karan Sanghavi wrote:
> This error is reported by coverity scan stating as
>
> CID 1593397: (#1 of 1): Unintended sign extension (SIGN_EXTENSION)
> sign_extension: Suspicious implicit sign extension: pc
> with type u16 (16 bits, unsigned) is promoted in
> pc << bit_shifts.pc to type int (32 bits, signed),
> then sign-extended to type unsigned long (64 bits, unsigned).
> If pc << bit_shifts.pc is greater than 0x7FFFFFFF,
> the upper bits of the result will all be 1.
>
> Use u32 for bitwise operations to prevent unintentional
> sign extension by assigning the u16 value to a u32
> variable before performing the bitwise operation to
> avoid unintended sign extension and maintain
> consistency with the existing code style.
>
> Reviewed-by: Yazen Ghannam <yazen.ghannam@xxxxxxx>
> Signed-off-by: Karan Sanghavi <karansanghvi98@xxxxxxxxx>

Thanks Karan.

One minor nit: the Reviewed-by tag should go after the Signed-off-by.
This is noted in the "tip tree handbook":
https://www.kernel.org/doc/html/latest/process/maintainer-tip.html#ordering-of-commit-tags

The EDAC and RAS subsystems generally follow the "TIP" group guidelines,
in my understanding.

I see you're using "b4", so you may want to adjust the "trailer-order"
config option. I've been trying out b4 myself, so this is fresh in my
mind.
https://b4.docs.kernel.org/en/latest/config.html

Boris, can you please take this patch if no objections?

Thanks,
Yazen