Re: [PATCH v1] mount: handle OOM on mnt_warn_timestamp_expiry
From: Al Viro
Date: Tue Jul 30 2024 - 16:45:49 EST
On Tue, Jul 30, 2024 at 09:58:27PM +0200, Olaf Hering wrote:
> Tue, 30 Jul 2024 16:49:24 +0100 Al Viro <viro@xxxxxxxxxxxxxxxxxx>:
>
> > d_path() is *NOT* going to return NULL.
>
> The existing documentation does not state that fact.
Needs to be fixed, but as a general rule - mixing NULL and ERR_PTR()
for error reporting is a Very Bad Idea(tm). There are cases when
there's a legitimate reason for a function to return both, but they
are rare and NULL should not be an error case. Example: d_splice_alias();
ERR_PTR(-E...) => error; NULL => success, passed candidate had been
accepted and attached to inode; pointer to struct dentry instance
=> success, preexisting alias returned and should be used instead
of the candidate.
Using IS_ERR_OR_NULL for "future-proofing" is obfuscating the things
for no good reason - it confuses the readers, and it tends to spread
when people are copying the code around.
Please, don't do it.