From: "Peng Fan (OSS)" <peng.fan@oss.nxp.com>
To: Trond Myklebust <trondmy@kernel.org>, Anna Schumaker <anna@kernel.org>
Cc: linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org,
Peng Fan <peng.fan@nxp.com>
Subject: [PATCH 1/3] NFS: flexfilelayout: return ERR_PTR from nfs4_ff_alloc_deviceid_node() and fix caller
Date: Fri, 27 Feb 2026 16:18:20 +0800 [thread overview]
Message-ID: <20260227-nfs-v1-1-2a6ea2ca8528@nxp.com> (raw)
In-Reply-To: <20260227-nfs-v1-0-2a6ea2ca8528@nxp.com>
From: Peng Fan <peng.fan@nxp.com>
nfs4_ff_alloc_deviceid_node() initialized 'ret' but never returned it,
triggering W=1:
fs/nfs/flexfilelayout/flexfilelayoutdev.c:56:9: error: variable 'ret'
set but not used [-Werror=unused-but-set-variable]
The function also returned NULL on error, dropping the specific errno
stored in 'ret'. Convert it to return ERR_PTR(ret) instead, and update
ff_layout_alloc_deviceid_node() to detect errors using IS_ERR().
This preserves the error code for callers and aligns the helper with
common ERR_PTR-returning allocation patterns. It also resolves the build
warning.
No functional change for success paths; improves error reporting.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
fs/nfs/flexfilelayout/flexfilelayout.c | 2 +-
fs/nfs/flexfilelayout/flexfilelayoutdev.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/nfs/flexfilelayout/flexfilelayout.c b/fs/nfs/flexfilelayout/flexfilelayout.c
index f67773d52830d2ab4d12dd04caccc2077d4105e0..cd175204807600ff4e33ff769e03ef7ac700a6dc 100644
--- a/fs/nfs/flexfilelayout/flexfilelayout.c
+++ b/fs/nfs/flexfilelayout/flexfilelayout.c
@@ -2566,7 +2566,7 @@ ff_layout_alloc_deviceid_node(struct nfs_server *server,
struct nfs4_ff_layout_ds *dsaddr;
dsaddr = nfs4_ff_alloc_deviceid_node(server, pdev, gfp_flags);
- if (!dsaddr)
+ if (IS_ERR(dsaddr))
return NULL;
return &dsaddr->id_node;
}
diff --git a/fs/nfs/flexfilelayout/flexfilelayoutdev.c b/fs/nfs/flexfilelayout/flexfilelayoutdev.c
index c40395ae081429f315ccee6b73eafc742b4f01a4..9e36350b10fa84d5e2a2e6f25fce36ed504285ce 100644
--- a/fs/nfs/flexfilelayout/flexfilelayoutdev.c
+++ b/fs/nfs/flexfilelayout/flexfilelayoutdev.c
@@ -181,7 +181,7 @@ nfs4_ff_alloc_deviceid_node(struct nfs_server *server, struct pnfs_device *pdev,
kfree(new_ds);
dprintk("%s ERROR: returning %d\n", __func__, ret);
- return NULL;
+ return ERR_PTR(ret);
}
static void extend_ds_error(struct nfs4_ff_layout_ds_err *err,
--
2.37.1
next prev parent reply other threads:[~2026-02-27 8:16 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-27 8:18 [PATCH 0/3] NFS: Address build error when built with W=1 Peng Fan (OSS)
2026-02-27 8:18 ` Peng Fan (OSS) [this message]
2026-02-27 8:18 ` [PATCH 2/3] NFS: flexfilelayout: Mark err as __maybe_unused in ff_layout_io_track_ds_error Peng Fan (OSS)
2026-02-27 8:18 ` [PATCH 3/3] NFS: nfs4proc: Mark ptr as __maybe_unused in nfs4_proc_create_session Peng Fan (OSS)
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=20260227-nfs-v1-1-2a6ea2ca8528@nxp.com \
--to=peng.fan@oss.nxp.com \
--cc=anna@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=peng.fan@nxp.com \
--cc=trondmy@kernel.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