Re: [PATCH] mm: vmscan: Avoid signedness error for GCC 5.4

WangYuli
2025-05-07T04:07:16Z

[-- Attachment #1.1.1: Type: text/plain, Size: 1123 bytes --]

Hi Andrew Morton,

On 2025/5/7 07:24, Andrew Morton wrote:
> On Wed, 7 May 2025 00:02:38 +0800 WangYuli <wangyuli@uniontech.com> wrote:
>
> Make `tier' unsigned? After all, negative tier numbers are nonsensical.

That point is well taken.

However, I've noticed that variables named "tier" seem to be commonly
defined as int rather than unsigned int throughout the mm subsystem, and
perhaps even the wider kernel code.

I was wondering if changing just this one instance might feel a little
inconsistent?

Perhaps a possible approach for now could be to change this line to for
(i = tier % MAX_NR_TIERS; i <= min_t(int, tier, MAX_NR_TIERS - 1); i++)
{, which would allow us to keep the signed int type for the tier
variable itself.

Regarding the potential for a more comprehensive change in the future to
redefine all these "tier" variables and related ones as unsigned int, I
would be very grateful for your guidance on whether that's a direction
we should consider.

But actually, whether it's signed or not likely won't affect its normal
operation...

Thanks,

--
WangYuli

[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 645 bytes --]

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]