linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@linaro.org>
To: "Matthew Wilcox (Oracle)" <willy@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	linux-fsdevel@vger.kernel.org, linux-mm@kvack.org,
	kernel-janitors@vger.kernel.org
Subject: [PATCH] mm: use ERR_CAST() as a cleanup
Date: Wed, 21 Feb 2024 09:22:13 +0300	[thread overview]
Message-ID: <5a64b69a-40a6-4add-b758-ec3a9d93eb11@moroto.mountain> (raw)

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



             reply	other threads:[~2024-02-21  6:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-21  6:22 Dan Carpenter [this message]
2024-02-21  6:23 ` Matthew Wilcox
2024-02-21  6:28   ` Dan Carpenter

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=5a64b69a-40a6-4add-b758-ec3a9d93eb11@moroto.mountain \
    --to=dan.carpenter@linaro.org \
    --cc=akpm@linux-foundation.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=willy@infradead.org \
    /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