[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <2fae1834-749a-45e1-8594-5e5979cf7103@lucifer.local>
Date: Wed, 25 Sep 2024 08:51:35 +0100
From: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>
To: Al Viro <viro@...iv.linux.org.uk>
Cc: Andrew Morton <akpm@...ux-foundation.org>, linux-mm@...ck.org,
linux-kernel@...r.kernel.org, Arnd Bergmann <arnd@...db.de>
Subject: Re: [PATCH] mm: refactor mm_access() to not return NULL
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@...cle.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@...cle.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
Powered by blists - more mailing lists