summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChuck Lever <chuck.lever@oracle.com>2024-10-03 20:54:43 +0200
committerChuck Lever <chuck.lever@oracle.com>2024-11-11 19:42:05 +0100
commit447dc1efebac1484d5903ba34655289e7725df6d (patch)
tree0634ef2c22185d8a24dac568c60f84629dc52137
parentxdrgen: XDR width for struct types (diff)
downloadlinux-447dc1efebac1484d5903ba34655289e7725df6d.tar.xz
linux-447dc1efebac1484d5903ba34655289e7725df6d.zip
xdrgen: XDR width for pointer types
The XDR width of a pointer type is the sum of the widths of each of the struct's fields, except for the last field. The width of the implicit boolean "value follows" field is added as well. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
-rw-r--r--tools/net/sunrpc/xdrgen/xdr_ast.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/tools/net/sunrpc/xdrgen/xdr_ast.py b/tools/net/sunrpc/xdrgen/xdr_ast.py
index f34b147c8dfd..8d53c889eee8 100644
--- a/tools/net/sunrpc/xdrgen/xdr_ast.py
+++ b/tools/net/sunrpc/xdrgen/xdr_ast.py
@@ -378,9 +378,26 @@ class _XdrPointer(_XdrAst):
name: str
fields: List[_XdrDeclaration]
+ def max_width(self) -> int:
+ """Return width of type in XDR_UNITS"""
+ width = 1
+ for field in self.fields[0:-1]:
+ width += field.max_width()
+ return width
+
+ def symbolic_width(self) -> List:
+ """Return list containing XDR width of type's components"""
+ widths = []
+ widths += ["XDR_bool"]
+ for field in self.fields[0:-1]:
+ widths += field.symbolic_width()
+ return widths
+
def __post_init__(self):
structs.add(self.name)
pass_by_reference.add(self.name)
+ max_widths[self.name] = self.max_width()
+ symbolic_widths[self.name] = self.symbolic_width()
@dataclass