Skip to content

Commit bb13793

Browse files
Asbjørn Sloth Tønnesengregkh
authored andcommitted
tools: ynl-gen: fix nested array counting
[ Upstream commit b4ada06 ] The blamed commit introduced the concept of split attribute counting, and later allocating an array to hold them, however TypeArrayNest wasn't updated to use the new counting variable. Abbreviated example from tools/net/ynl/generated/nl80211-user.c: nl80211_if_combination_attributes_parse(...): unsigned int n_limits = 0; [...] ynl_attr_for_each(attr, nlh, yarg->ys->family->hdr_len) if (type == NL80211_IFACE_COMB_LIMITS) ynl_attr_for_each_nested(attr2, attr) dst->_count.limits++; if (n_limits) { dst->_count.limits = n_limits; /* allocate and parse attributes */ } In the above example n_limits is guaranteed to always be 0, hence the conditional is unsatisfiable and is optimized out. This patch changes the attribute counting to use n_limits++ in the attribute counting loop in the above example. Fixes: 58da455 ("tools: ynl-gen: improve unwind on parsing errors") Signed-off-by: Asbjørn Sloth Tønnesen <ast@fiberby.net> Link: https://patch.msgid.link/20250902160001.760953-1-ast@fiberby.net Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 5cb7cab commit bb13793

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tools/net/ynl/pyynl/ynl_gen_c.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,7 @@ def _attr_get(self, ri, var):
830830
'ynl_attr_for_each_nested(attr2, attr) {',
831831
'\tif (ynl_attr_validate(yarg, attr2))',
832832
'\t\treturn YNL_PARSE_CB_ERROR;',
833-
f'\t{var}->_count.{self.c_name}++;',
833+
f'\tn_{self.c_name}++;',
834834
'}']
835835
return get_lines, None, local_vars
836836

0 commit comments

Comments
 (0)