linux/tools/net/ynl
Asbjørn Sloth Tønnesen b4ada0618e tools: ynl-gen: fix nested array counting
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: 58da455b31 ("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>
2025-09-03 15:18:34 -07:00
..
generated tools: ynl: enable codegen for TC 2025-05-21 12:38:23 -07:00
lib tools: ynl-gen: support weird sub-message formats 2025-05-21 12:38:23 -07:00
pyynl tools: ynl-gen: fix nested array counting 2025-09-03 15:18:34 -07:00
samples tools: ynl: add a sample for TC 2025-05-21 12:38:23 -07:00
Makefile tools: ynl: add main install target 2025-01-09 12:53:27 -08:00
Makefile.deps tools: ynl: enable codegen for TC 2025-05-21 12:38:23 -07:00
pyproject.toml tools: ynl: add initial pyproject.toml for packaging 2025-01-09 12:53:27 -08:00
requirements.txt tools: ynl: add the Python requirements.txt file 2023-03-24 19:11:02 -07:00
ynl-regen.sh tools: ynl: move python code to separate sub-directory 2025-01-09 12:53:27 -08:00