]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
xdrgen: XDR widths for enum types
authorChuck Lever <chuck.lever@oracle.com>
Thu, 3 Oct 2024 18:54:34 +0000 (14:54 -0400)
committerChuck Lever <chuck.lever@oracle.com>
Mon, 11 Nov 2024 18:42:02 +0000 (13:42 -0500)
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 <chuck.lever@oracle.com>
tools/net/sunrpc/xdrgen/xdr_ast.py

index f1d93a1d0ed8a8d6729c7bbadcfbf6a94bf6c549..fbee954c7f706a2013ebc602a61a1eac11bb70ea 100644 (file)
@@ -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):