[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZEmwwJ9c3ube00Ug@mit.edu>
Date: Wed, 26 Apr 2023 19:16:16 -0400
From: "Theodore Ts'o" <tytso@....edu>
To: Nick Desaulniers <ndesaulniers@...gle.com>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>,
Nathan Chancellor <nathan@...nel.org>,
linux-ext4@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-mm@...ck.org
Subject: Re: [GIT PULL] ext4 changes for the 6.4 merge window
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
Powered by blists - more mailing lists