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

Andrew Morton
2025-05-07T18:07:06Z

On Wed, 7 May 2025 12:06:11 +0800 WangYuli <wangyuli@uniontech.com> wrote:

> 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.

Sure.

> 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.

`int' is a curse. Yes, we do this very frequently - we unthinkingly
use a signed type for a naturally unsigned concept. Ths signed type
spreads and spreads and the incorrect signage causes (small) problems
in various places. By then it's a big mess trying to switch to an
unsigned type.

Oh well, we just battle on. We should at least be more vigilant about
this when adding new things.

hp2:/usr/src/25> grep "int nid" mm/*.c | wc -l
316

argh.