[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <02817c9a-e512-427f-bd64-b1420132adf6@zytor.com>
Date: Tue, 20 Jan 2026 16:17:52 -0800
From: "H. Peter Anvin" <hpa@...or.com>
To: David Desobry <david.desobry@...malgen.com>,
David Laight <david.laight.linux@...il.com>
Cc: tglx@...nel.org, mingo@...hat.com, bp@...en8.de,
dave.hansen@...ux.intel.com, x86@...nel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] x86/lib: Optimize num_digits() and fix INT_MIN
overflow
On 2026-01-20 16:04, David Desobry wrote:
>
> Actually, the V3 change:
> if (val < 0) {
> - d++;
> - val = -val;
> + d = 1;
> + v = -val;
> + } else {
> + d = 0;
> + v = val;
> }
> reintroduced the undefined behavior for val == INT_MIN.
> So this V3 version is incorrect.
> I'm not familiar enough with the rest of the codebase to know if changing the
> function signature to unsigned int is correct here.
It is only ever called with a cpu number, a node number, or a CPU count. Never
negative.
-hpa
Powered by blists - more mailing lists