Message ID | 5a64b69a-40a6-4add-b758-ec3a9d93eb11@moroto.mountain (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | mm: use ERR_CAST() as a cleanup | expand |
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.
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
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); }
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(-)