Re: [PATCH] jfs: avoid -Wtautological-constant-out-of-range-compare warning

From: Arnd Bergmann

Date: Mon Feb 02 2026 - 15:44:34 EST


On Mon, Feb 2, 2026, at 18:34, Dave Kleikamp wrote:
> On 2/2/26 3:49AM, Arnd Bergmann wrote:
>> From: Arnd Bergmann <arnd@xxxxxxxx>
>>
>> A recent change for the range check started triggering a clang warning:
>>
>> fs/jfs/jfs_dtree.c:2906:31: error: result of comparison of constant 128 with expression of type 's8' (aka 'signed char') is always false [-Werror,-Wtautological-constant-out-of-range-compare]
>> 2906 | if (stbl[i] < 0 || stbl[i] >= DTPAGEMAXSLOT) {
>> | ~~~~~~~ ^ ~~~~~~~~~~~~~
>> fs/jfs/jfs_dtree.c:3111:30: error: result of comparison of constant 128 with expression of type 's8' (aka 'signed char') is always false [-Werror,-Wtautological-constant-out-of-range-compare]
>> 3111 | if (stbl[0] < 0 || stbl[0] >= DTPAGEMAXSLOT) {
>> | ~~~~~~~ ^ ~~~~~~~~~~~~~
>>
>> Both the old and the new check were useless, but the previous version
>> apparently did not lead to the warning.
>>
>> Rephrase this again by adding a cast. The check is still always false,
>> but the compiler shuts up about it.
>
> I think it would be better to just drop the useless part of these tests.

Fair enough, sent v2 now.

Arnd