Skip to contentSkip to conversation

nfsd: Mark variable __maybe_unused to avoid W=1 build break

PATCH In review Andy Shevchenko 3 participants 8 messages Nov 13, 2025 – Nov 27, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nfsd: Mark variable __maybe_unused to avoid W=1 build break

Clang is not happy about set but (in some cases) unused variable:

fs/nfsd/export.c:1027:17: error: variable 'inode' set but not used [-Werror,-Wunused-but-set-variable]

since it's used as a parameter to dprintk() which might be configured a no-op. To avoid uglifying code with the specific ifdeffery just mark the variable __maybe_unused.

The commit [1], which introduced this behaviour, is quite old and hence the Fixes tag points to the first of Git era.

---
 fs/nfsd/export.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfsd/export.c +1 -1
index 9d55512d0cc9..2a1499f2ad19 100644
@@ -1024,7 +1024,7 @@ exp_rootfh(struct net *net, struct auth_domain *clp, char *name,
 {
 	struct svc_export	*exp;
 	struct path		path;
-	struct inode		*inode;
+	struct inode		*inode __maybe_unused;
 	struct svc_fh		fh;
 	int			err;
 	struct nfsd_net		*nn = net_generic(net, nfsd_net_id);
Signature · 1 line
2.50.1
#1 lore raw
Quoted 23 lines · Andy Shevchenko

Clang is not happy about set but (in some cases) unused variable:

fs/nfsd/export.c:1027:17: error: variable 'inode' set but not used [-Werror,-Wunused-but-set-variable]

since it's used as a parameter to dprintk() which might be configured a no-op. To avoid uglifying code with the specific ifdeffery just mark the variable __maybe_unused.

The commit [1], which introduced this behaviour, is quite old and hence the Fixes tag points to the first of Git era.

---
 fs/nfsd/export.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/nfsd/export.c +0 -0
index 9d55512d0cc9..2a1499f2ad19 100644

fs/nfsd/export.c exp_rootfh(struct net *net, struct auth_domain *clp, char *name, · line 1027

Quoted 5 lines
fs/nfsd/export.c +1 -1
@@ -1024,7 +1024,7 @@ exp_rootfh(struct net *net, struct auth_domain *clp, char *name,
 {
 	struct svc_export	*exp;
 	struct path		path;
-	struct inode		*inode;
+	struct inode		*inode __maybe_unused;

We typically use "#ifdef CONFIG_SUNRPC_DEBUG" instead for this purpose. I don't think that would be terribly out of place.

Quoted 3 lines
fs/nfsd/export.c +0 -0
 	struct svc_fh		fh;
 	int			err;
 	struct nfsd_net		*nn = net_generic(net, nfsd_net_id);
Signature · 1 line
Chuck Lever
maintainer
#2 lore raw
In reply to Andy Shevchenko

From: Chuck Lever <[email protected]>

Quoted 9 lines · Andy Shevchenko

Clang is not happy about set but (in some cases) unused variable:

fs/nfsd/export.c:1027:17: error: variable 'inode' set but not used [-Werror,-Wunused-but-set-variable]

since it's used as a parameter to dprintk() which might be configured a no-op. To avoid uglifying code with the specific ifdeffery just mark the variable __maybe_unused.

[...]

Applied to nfsd-testing, thanks!

[1/1] nfsd: Mark variable __maybe_unused to avoid W=1 build break

      commit: 56e9f88b25abf08de6f2b1bfbbb2ddc4e6622d1e

--
Chuck Lever

#3 lore raw
Quoted 8 lines · Chuck Lever
Quoted 7 lines · Andy Shevchenko

Clang is not happy about set but (in some cases) unused variable:

fs/nfsd/export.c:1027:17: error: variable 'inode' set but not used [-Werror,-Wunused-but-set-variable]

since it's used as a parameter to dprintk() which might be configured a no-op. To avoid uglifying code with the specific ifdeffery just mark the variable __maybe_unused.

[...]

Quoted 4 lines

Applied to nfsd-testing, thanks!

[1/1] nfsd: Mark variable __maybe_unused to avoid W=1 build break

      commit: 56e9f88b25abf08de6f2b1bfbbb2ddc4e6622d1e

Thanks, but still no appearance in Linux Next and problem seems to be present.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer
#4 lore raw
Quoted 10 lines · Andy Shevchenko
Quoted 8 lines · Chuck Lever
Quoted 7 lines · Andy Shevchenko

Clang is not happy about set but (in some cases) unused variable:

fs/nfsd/export.c:1027:17: error: variable 'inode' set but not used [-Werror,-Wunused-but-set-variable]

since it's used as a parameter to dprintk() which might be configured a no-op. To avoid uglifying code with the specific ifdeffery just mark the variable __maybe_unused.

Quoted 9 lines

[...]

Quoted 4 lines

Applied to nfsd-testing, thanks!

[1/1] nfsd: Mark variable __maybe_unused to avoid W=1 build break

      commit: 56e9f88b25abf08de6f2b1bfbbb2ddc4e6622d1e

Thanks, but still no appearance in Linux Next and problem seems to be present.

The usual practice is to keep patches in nfsd-testing for four weeks to allow NFSD and community CI processes to work, and to enable extended review before it is merged. Both the community CI processes (eg, zero-day bots) and the availability of reviewers are not something I have control over.

It will be available for upstream merge after December 11. You seem to be suggesting there is a sense of urgency so I will direct it towards v6.20-rc as soon as it is merge-ready.

Signature · 1 line
Chuck Lever
#5 lore raw
Quoted 10 lines · Chuck Lever
Quoted 9 lines · Andy Shevchenko
Quoted 8 lines · Chuck Lever
Quoted 7 lines · Andy Shevchenko

Clang is not happy about set but (in some cases) unused variable:

fs/nfsd/export.c:1027:17: error: variable 'inode' set but not used [-Werror,-Wunused-but-set-variable]

since it's used as a parameter to dprintk() which might be configured a no-op. To avoid uglifying code with the specific ifdeffery just mark the variable __maybe_unused.

[...]

Quoted 14 lines
Quoted 7 lines
Quoted 4 lines

Applied to nfsd-testing, thanks!

[1/1] nfsd: Mark variable __maybe_unused to avoid W=1 build break

      commit: 56e9f88b25abf08de6f2b1bfbbb2ddc4e6622d1e

Thanks, but still no appearance in Linux Next and problem seems to be present.

The usual practice is to keep patches in nfsd-testing for four weeks to allow NFSD and community CI processes to work, and to enable extended review before it is merged. Both the community CI processes (eg, zero-day bots) and the availability of reviewers are not something I have control over.

Quoted 3 lines

It will be available for upstream merge after December 11. You seem to be suggesting there is a sense of urgency so I will direct it towards v6.20-rc as soon as it is merge-ready.

Since it's (not so critical TBH, but still) a build breakage I supposed this to go via the respective -fixes path. But okay, your call.

So far I will keep a patch locally to remember to annoy you :-) if it isn't applied

TL;DR: Thanks for the explanation.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
maintainer
#6 lore raw
Quoted 28 lines · Andy Shevchenko
Quoted 10 lines · Chuck Lever
Quoted 9 lines · Andy Shevchenko
Quoted 8 lines · Chuck Lever
Quoted 7 lines · Andy Shevchenko

Clang is not happy about set but (in some cases) unused variable:

fs/nfsd/export.c:1027:17: error: variable 'inode' set but not used [-Werror,-Wunused-but-set-variable]

since it's used as a parameter to dprintk() which might be configured a no-op. To avoid uglifying code with the specific ifdeffery just mark the variable __maybe_unused.

[...]

Quoted 14 lines
Quoted 7 lines
Quoted 4 lines

Applied to nfsd-testing, thanks!

[1/1] nfsd: Mark variable __maybe_unused to avoid W=1 build break

      commit: 56e9f88b25abf08de6f2b1bfbbb2ddc4e6622d1e

Thanks, but still no appearance in Linux Next and problem seems to be present.

The usual practice is to keep patches in nfsd-testing for four weeks to allow NFSD and community CI processes to work, and to enable extended review before it is merged. Both the community CI processes (eg, zero-day bots) and the availability of reviewers are not something I have control over.

Quoted 3 lines
Quoted 3 lines

It will be available for upstream merge after December 11. You seem to be suggesting there is a sense of urgency so I will direct it towards v6.20-rc as soon as it is merge-ready.

Oops:

s/v6.20-rc/v6.19-rc/

Quoted 2 lines

Since it's (not so critical TBH, but still) a build breakage I supposed this to go via the respective -fixes path.

Yes, what I meant above was I will submit it just after the v6.19 merge window closes in a few weeks.

Quoted 1 line

But okay, your call.

It's just a build warning, but I know such issues affect the Fedora and Red Hat kernel build pipelines, as they enable the "warning => error" compile option.

However, those distributions enable SunRPC debugging, which means they won't see it. So I think this problem is not likely to be pervasive.

Signature · 1 line
Chuck Lever
#7 lore raw
Quoted 12 lines · Chuck Lever
Quoted 11 lines · Andy Shevchenko
Quoted 10 lines · Chuck Lever
Quoted 9 lines · Andy Shevchenko
Quoted 8 lines · Chuck Lever
Quoted 7 lines · Andy Shevchenko

Clang is not happy about set but (in some cases) unused variable:

fs/nfsd/export.c:1027:17: error: variable 'inode' set but not used [-Werror,-Wunused-but-set-variable]

since it's used as a parameter to dprintk() which might be configured a no-op. To avoid uglifying code with the specific ifdeffery just mark the variable __maybe_unused.

[...]

Quoted 20 lines
Quoted 14 lines
Quoted 14 lines
Quoted 7 lines
Quoted 4 lines

Applied to nfsd-testing, thanks!

[1/1] nfsd: Mark variable __maybe_unused to avoid W=1 build break

      commit: 56e9f88b25abf08de6f2b1bfbbb2ddc4e6622d1e

Thanks, but still no appearance in Linux Next and problem seems to be present.

The usual practice is to keep patches in nfsd-testing for four weeks to allow NFSD and community CI processes to work, and to enable extended review before it is merged. Both the community CI processes (eg, zero-day bots) and the availability of reviewers are not something I have control over.

Quoted 3 lines
Quoted 3 lines

It will be available for upstream merge after December 11. You seem to be suggesting there is a sense of urgency so I will direct it towards v6.20-rc as soon as it is merge-ready.

Oops:

Quoted 8 lines

s/v6.20-rc/v6.19-rc/

Quoted 2 lines

Since it's (not so critical TBH, but still) a build breakage I supposed this to go via the respective -fixes path.

Yes, what I meant above was I will submit it just after the v6.19 merge window closes in a few weeks.

Ah, that's wonderful, thanks!

Quoted 9 lines
Quoted 1 line

But okay, your call.

It's just a build warning, but I know such issues affect the Fedora and Red Hat kernel build pipelines, as they enable the "warning => error" compile option.

However, those distributions enable SunRPC debugging, which means they won't see it. So I think this problem is not likely to be pervasive.

Signature · 2 lines
With Best Regards,
Andy Shevchenko