Re: [GIT PULL] ext4 changes for the 6.4 merge window
From: Theodore Ts'o
Date: Wed Apr 26 2023 - 19:16:37 EST
On Wed, Apr 26, 2023 at 03:07:48PM -0700, Nick Desaulniers wrote:
> Is this what you had in mind?
> ```
> $ cat linus.c
> #define NULL ((void*)0)
>
> void * _Nonnull foo (void) {
> return &foo;
> }
>
> void bar (void) {
> if (foo() == NULL) // maybe should warn that foo() returns _Nonnull?
> bar();
> }
>
> $ clang linus.c -fsyntax-only
> linus.c:8:15: warning: comparison of _Nonnull function call 'foo'
> equal to a null pointer is always false
Ideally, the warning should also fire in this case:
if (!foo()) {
bar();
}
And of course, what if the code does this:
p = foo();
if (p) {
quux();
}
Would these also be considered implicit comparisons to a NULL pointer?
- Ted