Thread (11 messages) 11 messages, 2 authors, 2026-02-18

Re: [PATCH v2 1/2] nfs: fix unused variable warnings

From: Andrew Lunn <andrew@lunn.ch>
Date: 2026-02-16 20:06:58
Also in: linux-nfs, lkml

On Tue, Feb 17, 2026 at 01:49:49AM +0800, Sean Chang wrote:
Add __maybe_unused to variables only used in specific configurations
to silence compiler warnings found during RISC-V builds.
Could you give more details.
 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,
Lets look at this function

int nfs4_proc_create_session(struct nfs_client *clp, const struct cred *cred)
{
	int status;
	unsigned *ptr;
	struct nfs4_session *session = clp->cl_session;
	struct nfs4_add_xprt_data xprtdata = {
		.clp = clp,
	};
	struct rpc_add_xprt_test rpcdata = {
		.add_xprt_test = clp->cl_mvops->session_trunk,
		.data = &xprtdata,
	};

	dprintk("--> %s clp=%p session=%p\n", __func__, clp, session);

	status = _nfs4_proc_create_session(clp, cred);
	if (status)
		goto out;

	/* Init or reset the session slot tables */
	status = nfs4_setup_session_slot_tables(session);
	dprintk("slot table setup returned %d\n", status);
	if (status)
		goto out;

	ptr = (unsigned *)&session->sess_id.data[0];
	dprintk("%s client>seqid %d sessionid %u:%u:%u:%u\n", __func__,
		clp->cl_seqid, ptr[0], ptr[1], ptr[2], ptr[3]);
	rpc_clnt_probe_trunked_xprts(clp->cl_rpcclient, &rpcdata);
out:
	return status;
}

There is no #ifdef'ery here. How is ptr not used? Is status always
true, so the goto it always taken? But then rpcdata should also be
unused?

	Andrew
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help