Skip to content

Commit d7ddf5f

Browse files
kubalewskikuba-moo
authored andcommitted
tools: ynl-gen: fix enum index in _decode_enum(..)
Remove wrong index adjustment, which is leftover from adding support for sparse enums. enum.entries_by_val() function shall not subtract the start-value, as it is indexed with real enum value. Fixes: c311aaa ("tools: ynl: fix enum-as-flags in the generic CLI") Signed-off-by: Arkadiusz Kubalewski <[email protected]> Reviewed-by: Donald Hunter <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Jakub Kicinski <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent d4a7ce6 commit d7ddf5f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tools/net/ynl/lib/ynl.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,16 +420,16 @@ def _add_attr(self, space, name, value):
420420
def _decode_enum(self, rsp, attr_spec):
421421
raw = rsp[attr_spec['name']]
422422
enum = self.consts[attr_spec['enum']]
423-
i = attr_spec.get('value-start', 0)
424423
if 'enum-as-flags' in attr_spec and attr_spec['enum-as-flags']:
424+
i = 0
425425
value = set()
426426
while raw:
427427
if raw & 1:
428428
value.add(enum.entries_by_val[i].name)
429429
raw >>= 1
430430
i += 1
431431
else:
432-
value = enum.entries_by_val[raw - i].name
432+
value = enum.entries_by_val[raw].name
433433
rsp[attr_spec['name']] = value
434434

435435
def _decode_binary(self, attr, attr_spec):

0 commit comments

Comments
 (0)