Skip to content

Commit

Permalink
tools: ynl-gen: add error checking for nested structs
Browse files Browse the repository at this point in the history
Parsing nested types may return an error, propagate it.
Not marking as a fix, because nothing uses YNL upstream.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Jakub Kicinski committed Jun 3, 2023
1 parent 5605f10 commit eef9b79
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tools/net/ynl/ynl-gen-c.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,8 @@ def attr_put(self, ri, var):
f"{self.enum_name}, &{var}->{self.c_name})")

def _attr_get(self, ri, var):
get_lines = [f"{self.nested_render_name}_parse(&parg, attr);"]
get_lines = [f"if ({self.nested_render_name}_parse(&parg, attr))",
"return MNL_CB_ERROR;"]
init_lines = [f"parg.rsp_policy = &{self.nested_render_name}_nest;",
f"parg.data = &{var}->{self.c_name};"]
return get_lines, init_lines, None
Expand Down

0 comments on commit eef9b79

Please sign in to comment.