From: Al Viro <viro@zeniv.linux.org.uk>
To: Xichao Zhao <zhao.xichao@vivo.com>
Cc: tytso@mit.edu, adilger.kernel@dilger.ca,
linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ext4: Use IS_ERR_OR_NULL() helper function
Date: Wed, 30 Jul 2025 07:49:37 +0100 [thread overview]
Message-ID: <20250730064937.GM222315@ZenIV> (raw)
In-Reply-To: <20250730063823.313324-1-zhao.xichao@vivo.com>
On Wed, Jul 30, 2025 at 02:38:23PM +0800, Xichao Zhao wrote:
> Use the IS_ERR_OR_NULL() helper instead of open-coding a NULL and
> an error pointer checks to simplify the code and improve readability.
IS_ERR_OR_NULL() is almost always a bad idea. ext4_bread() *is* one
of the cases where NULL is a legitimate return values that is not an
error - it indicates a hole in a sparse file (BTW, not sure if it
can legitimately occur in a directory); the thing is, among the
functions that can return both NULL and ERR_PTR() the meaning assigned
to NULL varies a lot; so much that "ERR_PTR() or NULL" has no good
semantics.
Most of the uses are either sloppy code from somebody who couldn't be
arsed to find out whether it's pointer-or-NULL or pointer-or-ERR_PTR()
or misguided "defensive" crap. Any caller that is *not* of that sort
is drowning in a pile of garbage. Let's not breed that...
next prev parent reply other threads:[~2025-07-30 6:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-30 6:38 [PATCH] ext4: Use IS_ERR_OR_NULL() helper function Xichao Zhao
2025-07-30 6:49 ` Al Viro [this message]
2025-07-30 9:42 ` Xichao Zhao
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250730064937.GM222315@ZenIV \
--to=viro@zeniv.linux.org.uk \
--cc=adilger.kernel@dilger.ca \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tytso@mit.edu \
--cc=zhao.xichao@vivo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox