Linux NFS development
 help / color / mirror / Atom feed
* [PATCH] nfs: Use IS_ERR_OR_NULL() helper function
@ 2025-04-13  4:08 hhtracer
  2025-04-18 17:27 ` Jeff Layton
  0 siblings, 1 reply; 2+ messages in thread
From: hhtracer @ 2025-04-13  4:08 UTC (permalink / raw)
  To: trondmy, anna; +Cc: linux-nfs, huhai

From: huhai <huhai@kylinos.cn>

Use the IS_ERR_OR_NULL() helper instead of open-coding a
NULL and an error pointer checks to simplify the code and
improve readability.

No functional changes are intended.

Signed-off-by: huhai <huhai@kylinos.cn>
---
 fs/nfs/write.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/fs/nfs/write.c b/fs/nfs/write.c
index 23df8b214474..bf44ab0f5de3 100644
--- a/fs/nfs/write.c
+++ b/fs/nfs/write.c
@@ -637,14 +637,13 @@ static int nfs_page_async_flush(struct folio *folio,
 				struct nfs_pageio_descriptor *pgio)
 {
 	struct nfs_page *req;
-	int ret = 0;
+	int ret;
 
 	req = nfs_lock_and_join_requests(folio);
-	if (!req)
-		goto out;
-	ret = PTR_ERR(req);
-	if (IS_ERR(req))
+	if (IS_ERR_OR_NULL(req)) {
+		ret = PTR_ERR_OR_ZERO(req);
 		goto out;
+	}
 
 	nfs_folio_set_writeback(folio);
 	WARN_ON_ONCE(test_bit(PG_CLEAN, &req->wb_flags));
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] nfs: Use IS_ERR_OR_NULL() helper function
  2025-04-13  4:08 [PATCH] nfs: Use IS_ERR_OR_NULL() helper function hhtracer
@ 2025-04-18 17:27 ` Jeff Layton
  0 siblings, 0 replies; 2+ messages in thread
From: Jeff Layton @ 2025-04-18 17:27 UTC (permalink / raw)
  To: hhtracer, trondmy, anna; +Cc: linux-nfs, huhai

On Sun, 2025-04-13 at 12:08 +0800, hhtracer@gmail.com wrote:
> From: huhai <huhai@kylinos.cn>
> 
> Use the IS_ERR_OR_NULL() helper instead of open-coding a
> NULL and an error pointer checks to simplify the code and
> improve readability.
> 
> No functional changes are intended.
> 
> Signed-off-by: huhai <huhai@kylinos.cn>
> ---
>  fs/nfs/write.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/fs/nfs/write.c b/fs/nfs/write.c
> index 23df8b214474..bf44ab0f5de3 100644
> --- a/fs/nfs/write.c
> +++ b/fs/nfs/write.c
> @@ -637,14 +637,13 @@ static int nfs_page_async_flush(struct folio *folio,
>  				struct nfs_pageio_descriptor *pgio)
>  {
>  	struct nfs_page *req;
> -	int ret = 0;
> +	int ret;
>  
>  	req = nfs_lock_and_join_requests(folio);
> -	if (!req)
> -		goto out;
> -	ret = PTR_ERR(req);
> -	if (IS_ERR(req))
> +	if (IS_ERR_OR_NULL(req)) {
> +		ret = PTR_ERR_OR_ZERO(req);
>  		goto out;
> +	}
>  
>  	nfs_folio_set_writeback(folio);
>  	WARN_ON_ONCE(test_bit(PG_CLEAN, &req->wb_flags));

Looks right to me.

Reviewed-by: Jeff Layton <jlayton@kernel.org>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-04-18 17:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-13  4:08 [PATCH] nfs: Use IS_ERR_OR_NULL() helper function hhtracer
2025-04-18 17:27 ` Jeff Layton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox