Commit 8f76a4f8 authored by Lorenzo Bianconi's avatar Lorenzo Bianconi Committed by Jakub Kicinski

tools: ynl: fix render-max for flags definition

Properly manage render-max property for flags definition type
introducing mask value and setting it to (last_element << 1) - 1
instead of adding max value set to last_element + 1

Fixes: be5bea1c ("net: add basic C code generators for Netlink")
Signed-off-by: default avatarLorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 7e4f8a0c
......@@ -1931,6 +1931,11 @@ def render_uapi(family, cw):
if const.get('render-max', False):
cw.nl()
if const['type'] == 'flags':
max_name = c_upper(name_pfx + 'mask')
max_val = f' = {enum.get_mask()},'
cw.p(max_name + max_val)
else:
max_name = c_upper(name_pfx + 'max')
cw.p('__' + max_name + ',')
cw.p(max_name + ' = (__' + max_name + ' - 1)')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment