Skip to content

Commit 4c8c24e

Browse files
committed
tools: ynl-gen: support empty attribute lists
Differentiate between empty list and None for member lists. New families may want to create request responses with no attribute. If we treat those the same as None we end up rendering a full parsing policy in user space, instead of an empty one. Reviewed-by: Donald Hunter <donald.hunter@gmail.com> Link: https://lore.kernel.org/r/20230824003056.1436637-5-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent dc2ef94 commit 4c8c24e

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ def __init__(self, family, space_name, type_list=None, inherited=None):
615615

616616
self.attr_list = []
617617
self.attrs = dict()
618-
if type_list:
618+
if type_list is not None:
619619
for t in type_list:
620620
self.attr_list.append((t, self.attr_set[t]),)
621621
else:
@@ -1543,7 +1543,14 @@ def parse_rsp_msg(ri, deref=False):
15431543

15441544
ri.cw.write_func_prot('int', f'{op_prefix(ri, "reply", deref=deref)}_parse', func_args)
15451545

1546-
_multi_parse(ri, ri.struct["reply"], init_lines, local_vars)
1546+
if ri.struct["reply"].member_list():
1547+
_multi_parse(ri, ri.struct["reply"], init_lines, local_vars)
1548+
else:
1549+
# Empty reply
1550+
ri.cw.block_start()
1551+
ri.cw.p('return MNL_CB_OK;')
1552+
ri.cw.block_end()
1553+
ri.cw.nl()
15471554

15481555

15491556
def print_req(ri):

0 commit comments

Comments
 (0)