From: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
To: Al Viro <viro@zeniv.linux.org.uk>
Cc: Andrew Morton <akpm@linux-foundation.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Arnd Bergmann <arnd@arndb.de>
Subject: Re: [PATCH] mm: refactor mm_access() to not return NULL
Date: Wed, 25 Sep 2024 08:51:35 +0100 [thread overview]
Message-ID: <2fae1834-749a-45e1-8594-5e5979cf7103@lucifer.local> (raw)
In-Reply-To: <20240924201352.GF3550746@ZenIV>
On Tue, Sep 24, 2024 at 09:13:52PM GMT, Al Viro wrote:
> On Tue, Sep 24, 2024 at 09:10:23PM +0100, Lorenzo Stoakes wrote:
> > + if (IS_ERR(mm))
> > + return PTR_ERR(mm) == -ESRCH ? NULL : mm;
>
> Pet peeve: what's wrong with mm == ERR_PTR(-ESRCH)?
Ha, yeah I'm easy either way, though your version is less ugly than mine
(and places the macro/constants together which is clearer) so let's go with
that...
Andrew - fix-patch attached, please apply. Thanks!
----8<----
From cb132b841e8cee09da5428ea625b50df9222a74e Mon Sep 17 00:00:00 2001
From: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Date: Wed, 25 Sep 2024 08:48:27 +0100
Subject: [PATCH] procfs: prefer neater pointer error comparison
We can compare a pointer to a known error code via PTR_ERR(ptr) == -EINVAL
or via ptr == ERR_PTR(-EINVAL) - the latter is neater and collects the
macro and constant in one, so refactor to use this form in proc_mem_open().
Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
---
fs/proc/base.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/proc/base.c b/fs/proc/base.c
index fe31decc12b5..94112df5f2a2 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -841,7 +841,7 @@ struct mm_struct *proc_mem_open(struct inode *inode, unsigned int mode)
put_task_struct(task);
if (IS_ERR(mm))
- return PTR_ERR(mm) == -ESRCH ? NULL : mm;
+ return mm == ERR_PTR(-ESRCH) ? NULL : mm;
/* ensure this mm_struct can't be freed */
mmgrab(mm);
--
2.46.0
prev parent reply other threads:[~2024-09-25 7:51 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-24 20:10 Lorenzo Stoakes
2024-09-24 20:13 ` Al Viro
2024-09-25 7:51 ` Lorenzo Stoakes [this message]
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=2fae1834-749a-45e1-8594-5e5979cf7103@lucifer.local \
--to=lorenzo.stoakes@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=viro@zeniv.linux.org.uk \
/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