diff options
| author | Chuck Lever <chuck.lever@oracle.com> | 2024-10-03 14:54:34 -0400 |
|---|---|---|
| committer | Chuck Lever <chuck.lever@oracle.com> | 2024-11-11 13:42:02 -0500 |
| commit | 3f890755c8f5958ef537a6d8f14de5ec4bfdc3fe (patch) | |
| tree | 4b9268d9480518fd18b047632a1b8ee17cd9536f | |
| parent | xdrgen: Keep track of on-the-wire data type widths (diff) | |
| download | linux-3f890755c8f5958ef537a6d8f14de5ec4bfdc3fe.tar.gz linux-3f890755c8f5958ef537a6d8f14de5ec4bfdc3fe.zip | |
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 <chuck.lever@oracle.com>
| -rw-r--r-- | tools/net/sunrpc/xdrgen/xdr_ast.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/tools/net/sunrpc/xdrgen/xdr_ast.py b/tools/net/sunrpc/xdrgen/xdr_ast.py index f1d93a1d0ed8..fbee954c7f70 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): |
