[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250730064937.GM222315@ZenIV>
Date: Wed, 30 Jul 2025 07:49:37 +0100
From: Al Viro <viro@...iv.linux.org.uk>
To: Xichao Zhao <zhao.xichao@...o.com>
Cc: tytso@....edu, adilger.kernel@...ger.ca, linux-ext4@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] ext4: Use IS_ERR_OR_NULL() helper function
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...
Powered by blists - more mailing lists