summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2024-10-03 20:54:36 +0200
committerChuck Lever <chuck.lever@oracle.com>2024-11-11 19:42:02 +0100
commitb0b85ef754740102cd659aea10aa516fe27f6b36 (patch)
tree50d4d8d9b33090e71cb6eae258303f6580668d9f /tools
parentxdrgen: XDR width for fixed-length opaque (diff)
downloadlinux-b0b85ef754740102cd659aea10aa516fe27f6b36.tar.xz
linux-b0b85ef754740102cd659aea10aa516fe27f6b36.zip
xdrgen: XDR width for variable-length opaque
The byte size of a variable-length opaque is conveyed in an unsigned integer. If there is a specified maximum size, that is included in the type's widths list. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/net/sunrpc/xdrgen/xdr_ast.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/tools/net/sunrpc/xdrgen/xdr_ast.py b/tools/net/sunrpc/xdrgen/xdr_ast.py
index 9fe7fa688caa..94cdcfb36e77 100644
--- a/tools/net/sunrpc/xdrgen/xdr_ast.py
+++ b/tools/net/sunrpc/xdrgen/xdr_ast.py
@@ -148,6 +148,21 @@ class _XdrVariableLengthOpaque(_XdrDeclaration):
maxsize: str
template: str = "variable_length_opaque"
+ def max_width(self) -> int:
+ """Return width of type in XDR_UNITS"""
+ return 1 + xdr_quadlen(self.maxsize)
+
+ def symbolic_width(self) -> List:
+ """Return list containing XDR width of type's components"""
+ widths = ["XDR_unsigned_int"]
+ if self.maxsize != "0":
+ widths.append("XDR_QUADLEN(" + self.maxsize + ")")
+ return widths
+
+ def __post_init__(self):
+ max_widths[self.name] = self.max_width()
+ symbolic_widths[self.name] = self.symbolic_width()
+
@dataclass
class _XdrString(_XdrDeclaration):