diff options
author | Chuck Lever <chuck.lever@oracle.com> | 2024-10-03 20:54:39 +0200 |
---|---|---|
committer | Chuck Lever <chuck.lever@oracle.com> | 2024-11-11 19:42:03 +0100 |
commit | 2db8940e6ceda6aeb566429e8d58c34ab093d3c7 (patch) | |
tree | d85abf65a90e2369453f6f4ba486c72cd2ddf48c /tools/net/sunrpc | |
parent | xdrgen: XDR width for fixed-length array (diff) | |
download | linux-2db8940e6ceda6aeb566429e8d58c34ab093d3c7.tar.xz linux-2db8940e6ceda6aeb566429e8d58c34ab093d3c7.zip |
xdrgen: XDR width for variable-length array
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Diffstat (limited to 'tools/net/sunrpc')
-rw-r--r-- | tools/net/sunrpc/xdrgen/xdr_ast.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tools/net/sunrpc/xdrgen/xdr_ast.py b/tools/net/sunrpc/xdrgen/xdr_ast.py index e9bc81e83b48..cb89d5d9987c 100644 --- a/tools/net/sunrpc/xdrgen/xdr_ast.py +++ b/tools/net/sunrpc/xdrgen/xdr_ast.py @@ -220,6 +220,22 @@ class _XdrVariableLengthArray(_XdrDeclaration): maxsize: str template: str = "variable_length_array" + def max_width(self) -> int: + """Return width of type in XDR_UNITS""" + return 1 + (xdr_quadlen(self.maxsize) * max_widths[self.spec.type_name]) + + def symbolic_width(self) -> List: + """Return list containing XDR width of type's components""" + widths = ["XDR_unsigned_int"] + if self.maxsize != "0": + item_width = " + ".join(symbolic_widths[self.spec.type_name]) + widths.append("(" + self.maxsize + " * (" + item_width + "))") + return widths + + def __post_init__(self): + max_widths[self.name] = self.max_width() + symbolic_widths[self.name] = self.symbolic_width() + @dataclass class _XdrOptionalData(_XdrDeclaration): |