Re: [PATCH] jiffies: Cast to unsigned long for secs_to_jiffies() conversion

From: Easwar Hariharan
Date: Mon Feb 03 2025 - 15:44:07 EST


On 1/31/2025 9:55 AM, Easwar Hariharan wrote:
> On 1/31/2025 12:10 AM, Geert Uytterhoeven wrote:

<snip>

>>
>> More importantly, I doubt this change is guaranteed to fix the
>> reported issue. The code[*] in retry_timeout_seconds_store() does:
>>
>> int val;
>> ...
>> if (val < -1 || val > 86400)
>> return -EINVAL;
>> ...
>> if (val != -1)
>> ASSERT(secs_to_jiffies(val) < LONG_MAX);
>>
>> As HZ is a known (rather small) constant, and val is range-checked
>> before, the compiler can still devise that the condition is always true.
>> So I think that assertion should just be removed.
>>

Following the lkp instructions to repro the issue, with this patch, the
compiler does not continue reporting that the condition is always true.
This patch is sufficient IMHO, without needing to remove the assert.

- Easwar (he/him)