From: Chuck Lever <cel@kernel.org>
To: NeilBrown <neil@brown.name>, Jeff Layton <jlayton@kernel.org>,
Olga Kornievskaia <okorniev@redhat.com>,
Dai Ngo <dai.ngo@oracle.com>, Tom Talpey <tom@talpey.com>
Cc: <linux-nfs@vger.kernel.org>
Subject: [PATCH v1 1/4] xdrgen: Handle a union whose arms are all void
Date: Sat, 24 Oct 2026 21:46:13 -0400 [thread overview]
Message-ID: <20261025014616.22236-2-cel@kernel.org> (raw)
In-Reply-To: <20261025014616.22236-1-cel@kernel.org>
_XdrUnion.symbolic_width() assigns its result variable only when
an arm's width exceeds the running maximum, and the maximum starts
at zero. A union whose arms are all void has no such arm, so the
return statement reads a variable that was never bound. The
definitions command then reports "cannot access local variable
'width'" and exits without generating the header. The sibling
max_width() method starts from zero and handles the same union.
Start the symbolic width from an empty list, so an all-void union
reports just the width of its discriminant.
Fixes: ce5a75d9939f ("xdrgen: XDR width for union types")
Signed-off-by: Chuck Lever <cel@kernel.org>
---
tools/net/sunrpc/xdrgen/xdr_ast.py | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/net/sunrpc/xdrgen/xdr_ast.py b/tools/net/sunrpc/xdrgen/xdr_ast.py
index 5b2a78ca745c..537f056a0c27 100644
--- a/tools/net/sunrpc/xdrgen/xdr_ast.py
+++ b/tools/net/sunrpc/xdrgen/xdr_ast.py
@@ -546,6 +546,7 @@ class _XdrUnion(_XdrAst):
def symbolic_width(self) -> List:
"""Return list containing XDR width of type's components"""
max_width = 0
+ width = []
for case in self.cases:
if case.arm.max_width() > max_width:
max_width = case.arm.max_width()
--
2.56.0
next prev parent reply other threads:[~2026-10-25 16:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-25 1:46 [PATCH v1 0/4] xdrgen fixes Chuck Lever
2026-10-25 1:46 ` Chuck Lever [this message]
2026-10-25 1:46 ` [PATCH v1 2/4] xdrgen: Key the width tables by type name only Chuck Lever
2026-10-25 1:46 ` [PATCH v1 3/4] xdrgen: Register optional-data names only for typedefs Chuck Lever
2026-10-25 1:46 ` [PATCH v1 4/4] xdrgen: Take a union's numeric discriminant width from the declaration Chuck Lever
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=20261025014616.22236-2-cel@kernel.org \
--to=cel@kernel.org \
--cc=dai.ngo@oracle.com \
--cc=jlayton@kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=neil@brown.name \
--cc=okorniev@redhat.com \
--cc=tom@talpey.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.