Re: [PATCH] mm: fix the type of a parameter

From: Andrew Morton
Date: Wed Dec 01 2021 - 22:34:20 EST


On Thu, 2 Dec 2021 02:12:36 +0800 Yixuan Cao <caoyixuan2019@xxxxxxxxxxxxxxxx> wrote:

> The type of "last_migrate_reason" in struct page_owner is short.
> However, the type of "reason" in the argument list of following functions
> __set_page_owner_migrate_reason
> set_page_owner_migrate_reason
>
> is int, which is inconsistent.

Well.

I'd say "no", because `int' is a natural type and the packing of that
scalar into a `short' is an expedient little space-saving hack (ie, an
"implementation detail") which should be hidden from callers rather
than propagated back up the call stack.

However, all these `int's should be of type `enum migrate_reason'. And
the lowest-level hack of stuffing that enum into a `short' should
remain an implementation detail, hidden from callers.