Skip to content

Commit 8cea95b

Browse files
committed
tools: ynl-gen: handle do ops with no input attrs
The code supports dumps with no input attributes currently thru a combination of special-casing and luck. Clean up the handling of ops with no inputs. Create empty Structs, and skip printing of empty types. This makes dos with no inputs work. Tested-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com> Link: https://lore.kernel.org/r/20231006135032.3328523-1-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent a4cd2f3 commit 8cea95b

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

tools/net/ynl/ynl-gen-c.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,9 +1041,11 @@ def __init__(self, cw, family, ku_space, op, op_mode, attr_set=None):
10411041
if op_mode == 'notify':
10421042
op_mode = 'do'
10431043
for op_dir in ['request', 'reply']:
1044-
if op and op_dir in op[op_mode]:
1045-
self.struct[op_dir] = Struct(family, self.attr_set,
1046-
type_list=op[op_mode][op_dir]['attributes'])
1044+
if op:
1045+
type_list = []
1046+
if op_dir in op[op_mode]:
1047+
type_list = op[op_mode][op_dir]['attributes']
1048+
self.struct[op_dir] = Struct(family, self.attr_set, type_list=type_list)
10471049
if op_mode == 'event':
10481050
self.struct['reply'] = Struct(family, self.attr_set, type_list=op['event']['attributes'])
10491051

@@ -1752,6 +1754,8 @@ def print_type_helpers(ri, direction, deref=False):
17521754

17531755

17541756
def print_req_type_helpers(ri):
1757+
if len(ri.struct["request"].attr_list) == 0:
1758+
return
17551759
print_alloc_wrapper(ri, "request")
17561760
print_type_helpers(ri, "request")
17571761

@@ -1773,6 +1777,8 @@ def print_parse_prototype(ri, direction, terminate=True):
17731777

17741778

17751779
def print_req_type(ri):
1780+
if len(ri.struct["request"].attr_list) == 0:
1781+
return
17761782
print_type(ri, "request")
17771783

17781784

@@ -2515,9 +2521,8 @@ def main():
25152521
if 'dump' in op:
25162522
cw.p(f"/* {op.enum_name} - dump */")
25172523
ri = RenderInfo(cw, parsed, args.mode, op, 'dump')
2518-
if 'request' in op['dump']:
2519-
print_req_type(ri)
2520-
print_req_type_helpers(ri)
2524+
print_req_type(ri)
2525+
print_req_type_helpers(ri)
25212526
if not ri.type_consistent:
25222527
print_rsp_type(ri)
25232528
print_wrapped_type(ri)

0 commit comments

Comments
 (0)