mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/3] NFS: Address build error when built with W=1
@ 2026-02-27  8:18 Peng Fan (OSS)
  2026-02-27  8:18 ` [PATCH 1/3] NFS: flexfilelayout: return ERR_PTR from nfs4_ff_alloc_deviceid_node() and fix caller Peng Fan (OSS)
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Peng Fan (OSS) @ 2026-02-27  8:18 UTC (permalink / raw)
  To: Trond Myklebust, Anna Schumaker; +Cc: linux-nfs, linux-kernel, Peng Fan

I built x86_64_defconfig with COMPILE_TEST=y and W=1, then saw
three build errors from fs/nfs: "error: variable set but not used"

Detailed info could be found in each patch commit log.

With the patchset, kernel build pass.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
Peng Fan (3):
      NFS: flexfilelayout: return ERR_PTR from nfs4_ff_alloc_deviceid_node() and fix caller
      NFS: flexfilelayout: Mark err as __maybe_unused in ff_layout_io_track_ds_error
      NFS: nfs4proc: Mark ptr as __maybe_unused in nfs4_proc_create_session

 fs/nfs/flexfilelayout/flexfilelayout.c    | 4 ++--
 fs/nfs/flexfilelayout/flexfilelayoutdev.c | 2 +-
 fs/nfs/nfs4proc.c                         | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)
---
base-commit: 7d6661873f6b54c75195780a40d66bad3d482d8f
change-id: 20260227-nfs-ff0f0f96fea3

Best regards,
-- 
Peng Fan <peng.fan@nxp.com>


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

* [PATCH 1/3] NFS: flexfilelayout: return ERR_PTR from nfs4_ff_alloc_deviceid_node() and fix caller
  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)
  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)
  2 siblings, 0 replies; 4+ messages in thread
From: Peng Fan (OSS) @ 2026-02-27  8:18 UTC (permalink / raw)
  To: Trond Myklebust, Anna Schumaker; +Cc: linux-nfs, linux-kernel, Peng Fan

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


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

* [PATCH 2/3] NFS: flexfilelayout: Mark err as __maybe_unused in ff_layout_io_track_ds_error
  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 ` [PATCH 1/3] NFS: flexfilelayout: return ERR_PTR from nfs4_ff_alloc_deviceid_node() and fix caller Peng Fan (OSS)
@ 2026-02-27  8:18 ` 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)
  2 siblings, 0 replies; 4+ messages in thread
From: Peng Fan (OSS) @ 2026-02-27  8:18 UTC (permalink / raw)
  To: Trond Myklebust, Anna Schumaker; +Cc: linux-nfs, linux-kernel, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Fix the following compiler warning when building with W=1:

  flexfilelayout.c: In function 'ff_layout_io_track_ds_error':
  flexfilelayout.c:1503:6:
  error: variable 'err' set but not used [-Werror=unused-but-set-variable]
   1503 |  int err;
        |      ^~~

Variable 'err' is assigned the return value of ff_layout_track_ds_error()
but is only used in the dprintk() debug statement at the end of the
function. When debug output is disabled, the variable appears unused to
the compiler.

Mark it as __maybe_unused to indicate this is intentional.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 fs/nfs/flexfilelayout/flexfilelayout.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/nfs/flexfilelayout/flexfilelayout.c b/fs/nfs/flexfilelayout/flexfilelayout.c
index cd175204807600ff4e33ff769e03ef7ac700a6dc..1d8099337652a1cdbcaf58d394a6e981e8e7e413 100644
--- a/fs/nfs/flexfilelayout/flexfilelayout.c
+++ b/fs/nfs/flexfilelayout/flexfilelayout.c
@@ -1500,7 +1500,7 @@ static void ff_layout_io_track_ds_error(struct pnfs_layout_segment *lseg,
 {
 	struct nfs4_ff_layout_mirror *mirror;
 	u32 status = *op_status;
-	int err;
+	int err __maybe_unused;
 
 	if (status == 0) {
 		switch (error) {

-- 
2.37.1


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

* [PATCH 3/3] NFS: nfs4proc: Mark ptr as __maybe_unused in nfs4_proc_create_session
  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 ` [PATCH 1/3] NFS: flexfilelayout: return ERR_PTR from nfs4_ff_alloc_deviceid_node() and fix caller Peng Fan (OSS)
  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 ` Peng Fan (OSS)
  2 siblings, 0 replies; 4+ messages in thread
From: Peng Fan (OSS) @ 2026-02-27  8:18 UTC (permalink / raw)
  To: Trond Myklebust, Anna Schumaker; +Cc: linux-nfs, linux-kernel, Peng Fan

From: Peng Fan <peng.fan@nxp.com>

Fix the following compiler warning when building with W=1:

  nfs4proc.c: In function 'nfs4_proc_create_session':
  nfs4proc.c:9244:16: error: variable 'ptr' set but
  not used [-Werror=unused-but-set-variable]
   9244 |  unsigned *ptr;
        |            ^~~

The variable 'ptr' is assigned but only used in dprintk() debug statements.
When debug output is disabled, the variable appears unused to the compiler.

Mark it as __maybe_unused to indicate this is intentional.

Signed-off-by: Peng Fan <peng.fan@nxp.com>
---
 fs/nfs/nfs4proc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 91bcf67bd743f72a008a9dcde29207bf7a36c407..64e0221c39423dae58a30018a28d874198de57aa 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -9241,7 +9241,7 @@ static int _nfs4_proc_create_session(struct nfs_client *clp,
 int nfs4_proc_create_session(struct nfs_client *clp, const struct cred *cred)
 {
 	int status;
-	unsigned *ptr;
+	unsigned *ptr __maybe_unused;
 	struct nfs4_session *session = clp->cl_session;
 	struct nfs4_add_xprt_data xprtdata = {
 		.clp = clp,

-- 
2.37.1


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

end of thread, other threads:[~2026-02-27  8:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [PATCH 1/3] NFS: flexfilelayout: return ERR_PTR from nfs4_ff_alloc_deviceid_node() and fix caller Peng Fan (OSS)
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)

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

all inboxes | Powered by JetHome®