Message ID | 20250413040828.2529-1-huhai@kylinos.cn (mailing list archive) |
---|---|
State | Handled Elsewhere |
Headers | show |
Series | nfs: Use IS_ERR_OR_NULL() helper function | expand |
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>
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));