[PATCH 3/3] NFS: nfs4proc: Mark ptr as __maybe_unused in nfs4_proc_create_session

Peng Fan (OSS) posted 3 patches 1 month, 1 week ago
[PATCH 3/3] NFS: nfs4proc: Mark ptr as __maybe_unused in nfs4_proc_create_session
Posted by Peng Fan (OSS) 1 month, 1 week ago
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