Skip to content

Commit f7cf644

Browse files
committed
tools: ynl-gen: fix single attribute structs with attr 0 only
Chuck run into an issue with a single-element attr-set which only has an attr with value of 0. The search for max attr in a struct records attrs with value larger than 0 only (max_val is set to 0 at the start). Adjust the comparison, alternatively max_val could be init'ed to -1. Somehow picking the last attr of a value seems like a good idea in general. Reported-by: Chuck Lever III <[email protected]> Fixes: be5bea1 ("net: add basic C code generators for Netlink") Signed-off-by: Jakub Kicinski <[email protected]>
1 parent ac3ad19 commit f7cf644

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ def __init__(self, family, space_name, type_list=None, inherited=None):
546546
max_val = 0
547547
self.attr_max_val = None
548548
for name, attr in self.attr_list:
549-
if attr.value > max_val:
549+
if attr.value >= max_val:
550550
max_val = attr.value
551551
self.attr_max_val = attr
552552
self.attrs[name] = attr

0 commit comments

Comments
 (0)