Skip to content

Commit

Permalink
tools: ynl-gen: loosen type consistency check for events
Browse files Browse the repository at this point in the history
Both event and notify types are always consistent. Rewrite
the condition checking if we can reuse reply types to be
less picky and let notify thru.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Jakub Kicinski committed Jun 3, 2023
1 parent 67c65ce commit 5605f10
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions tools/net/ynl/ynl-gen-c.py
Original file line number Diff line number Diff line change
Expand Up @@ -897,11 +897,12 @@ def __init__(self, cw, family, ku_space, op, op_name, op_mode, attr_set=None):
self.op_mode = op_mode

# 'do' and 'dump' response parsing is identical
if op_mode != 'do' and 'dump' in op and 'do' in op and 'reply' in op['do'] and \
op["do"]["reply"] == op["dump"]["reply"]:
self.type_consistent = True
else:
self.type_consistent = op_mode == 'event'
self.type_consistent = True
if op_mode != 'do' and 'dump' in op and 'do' in op:
if ('reply' in op['do']) != ('reply' in op["dump"]):
self.type_consistent = False
elif 'reply' in op['do'] and op["do"]["reply"] != op["dump"]["reply"]:
self.type_consistent = False

self.attr_set = attr_set
if not self.attr_set:
Expand Down Expand Up @@ -2245,7 +2246,7 @@ def main():
ri = RenderInfo(cw, parsed, args.mode, op, op_name, 'notify')
has_ntf = True
if not ri.type_consistent:
raise Exception('Only notifications with consistent types supported')
raise Exception(f'Only notifications with consistent types supported ({op.name})')
print_wrapped_type(ri)

if 'event' in op:
Expand Down Expand Up @@ -2304,7 +2305,7 @@ def main():
ri = RenderInfo(cw, parsed, args.mode, op, op_name, 'notify')
has_ntf = True
if not ri.type_consistent:
raise Exception('Only notifications with consistent types supported')
raise Exception(f'Only notifications with consistent types supported ({op.name})')
print_ntf_type_free(ri)

if 'event' in op:
Expand Down

0 comments on commit 5605f10

Please sign in to comment.