* [PATCH] mm: use ERR_CAST() as a cleanup
@ 2024-02-21 6:22 Dan Carpenter
2024-02-21 6:23 ` Matthew Wilcox
0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2024-02-21 6:22 UTC (permalink / raw)
To: Matthew Wilcox (Oracle)
Cc: Andrew Morton, linux-fsdevel, linux-mm, kernel-janitors
The ->page is the first and only member of the folio struct so this code
works fine. However, if we use ERR_CAST() then it's clearer that
this is an error pointer.
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
This was introduced in 2020 in 539a3322f208 ("filemap: Add
read_cache_folio and read_mapping_folio").
mm/filemap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/filemap.c b/mm/filemap.c
index 5603ced05fb7..54e9ebaf4e84 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -3768,7 +3768,7 @@ static struct page *do_read_cache_page(struct address_space *mapping,
folio = do_read_cache_folio(mapping, index, filler, file, gfp);
if (IS_ERR(folio))
- return &folio->page;
+ return ERR_CAST(folio);
return folio_file_page(folio, index);
}
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] mm: use ERR_CAST() as a cleanup
2024-02-21 6:22 [PATCH] mm: use ERR_CAST() as a cleanup Dan Carpenter
@ 2024-02-21 6:23 ` Matthew Wilcox
2024-02-21 6:28 ` Dan Carpenter
0 siblings, 1 reply; 3+ messages in thread
From: Matthew Wilcox @ 2024-02-21 6:23 UTC (permalink / raw)
To: Dan Carpenter; +Cc: Andrew Morton, linux-fsdevel, linux-mm, kernel-janitors
On Wed, Feb 21, 2024 at 09:22:13AM +0300, Dan Carpenter wrote:
> The ->page is the first and only member of the folio struct so this code
> works fine. However, if we use ERR_CAST() then it's clearer that
> this is an error pointer.
NAK. &folio->page is an indicator that this code is in need of cleanup.
I use it in my scripts.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] mm: use ERR_CAST() as a cleanup
2024-02-21 6:23 ` Matthew Wilcox
@ 2024-02-21 6:28 ` Dan Carpenter
0 siblings, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2024-02-21 6:28 UTC (permalink / raw)
To: Matthew Wilcox; +Cc: Andrew Morton, linux-fsdevel, linux-mm, kernel-janitors
On Wed, Feb 21, 2024 at 06:23:06AM +0000, Matthew Wilcox wrote:
> On Wed, Feb 21, 2024 at 09:22:13AM +0300, Dan Carpenter wrote:
> > The ->page is the first and only member of the folio struct so this code
> > works fine. However, if we use ERR_CAST() then it's clearer that
> > this is an error pointer.
>
> NAK. &folio->page is an indicator that this code is in need of cleanup.
> I use it in my scripts.
Ah. Fair enough.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-02-21 6:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-21 6:22 [PATCH] mm: use ERR_CAST() as a cleanup Dan Carpenter
2024-02-21 6:23 ` Matthew Wilcox
2024-02-21 6:28 ` Dan Carpenter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).