From: Chuck Lever Date: Thu, 3 Oct 2024 18:54:34 +0000 (-0400) Subject: xdrgen: XDR widths for enum types X-Git-Tag: v6.13-rc1~76^2~58 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3f890755c8f5958ef537a6d8f14de5ec4bfdc3fe;p=thirdparty%2Fkernel%2Flinux.git xdrgen: XDR widths for enum types RFC 4506 says that an XDR enum is represented as a signed integer on the wire; thus its width is 1 XDR_UNIT. Signed-off-by: Chuck Lever --- diff --git a/tools/net/sunrpc/xdrgen/xdr_ast.py b/tools/net/sunrpc/xdrgen/xdr_ast.py index f1d93a1d0ed8a..fbee954c7f706 100644 --- a/tools/net/sunrpc/xdrgen/xdr_ast.py +++ b/tools/net/sunrpc/xdrgen/xdr_ast.py @@ -227,6 +227,18 @@ class _XdrEnum(_XdrAst): maximum: int enumerators: List[_XdrEnumerator] + def max_width(self) -> int: + """Return width of type in XDR_UNITS""" + return 1 + + def symbolic_width(self) -> List: + """Return list containing XDR width of type's components""" + return ["XDR_int"] + + def __post_init__(self): + max_widths[self.name] = self.max_width() + symbolic_widths[self.name] = self.symbolic_width() + @dataclass class _XdrStruct(_XdrAst):