On 18/12/2025 at 23:31, Vincent Mailhol wrote:
(...)
> Concerning clang, here are the statistics:
>
> $ make -s LLVM=1 CFLAGS_KERNEL="-Wtype-limits" 2>&1 | grep -o
> '\[-W\S*\]' | sort | uniq -c
> 2 [-Wtautological-type-limit-compare]
> 15 [-Wtautological-unsigned-enum-zero-compare]$ make -s LLVM=1
> CFLAGS_KERNEL="-Wtype-limits"
>
> (done on a linux v6.19-rc1 defconfig with clang v20.1.8)
>
> Not so many warnings, at least, less than what I would have thought!
>
> -Wtautological-unsigned-char-zero-compare and
> -Wtautological-unsigned-zero-compare gave zero findings. So those two
> can be enabled, I guess? I am still surprised that
> -Wtautological-unsigned-zero-compare gives nothing. I would have
> expected some kind of false positives on that one. No sure if I missed
> something here.
I was a bit worried of that -Wtautological-unsigned-zero-compare got
zero findings so I reran a build but this time on an allyesconfig
(minus CONFIG_WERROR):
$ make -j8 -s LLVM=1 CFLAGS_KERNEL="-Wtype-limits" 2>&1 | grep -o
'\[-W\S*\]' | sort | uniq -c
29 [-Wtautological-type-limit-compare]
55 [-Wtautological-unsigned-enum-zero-compare]
76 [-Wtautological-unsigned-zero-compare]
This is closer than expected. And looking at the findings,
-Wtautological-unsigned-zero-compare also warns on some sane code
which is just doing some range checks.
(...)
> In conclusion, I agree that we could enable three of clang's
> -Wtype-limits sub-warning. But this is not the scope of that series. I
> would rather prefer to have this as a separate series.
With this, I want to amend my conclusion. both
-Wtautological-unsigned-enum-zero-compare and
-Wtautological-unsigned-zero-compare should be kept disabled. The only
candidates are -Wtautological-type-limit-compare and
-Wtautological-unsigned-char-zero-compare.
-Wtautological-unsigned-char-zero-compare would need another study. It
seems that this warning is only triggered on platforms where char is
unsigned which explains why I did not see it when building on x86_64.
Well, I think I will stop this clang's -Wtype-limits study for the
moment. If anyone wants to continue the work please go ahead.
Yours sincerely,
Vincent Mailhol