tools: ynl-gen: fix enum index in _decode_enum(..)

[ Upstream commit d7ddf5f426 ]

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: c311aaa74c ("tools: ynl: fix enum-as-flags in the generic CLI")
Signed-off-by: Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>
Reviewed-by: Donald Hunter <donald.hunter@gmail.com>
Link: https://lore.kernel.org/r/20230725101642.267248-2-arkadiusz.kubalewski@intel.com
Reviewed-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Arkadiusz Kubalewski 2023-07-25 12:16:41 +02:00 committed by Greg Kroah-Hartman
parent 33e9ae3dac
commit fcbfd96a1e
1 changed files with 2 additions and 2 deletions

View File

@ -405,8 +405,8 @@ class YnlFamily(SpecFamily):
def _decode_enum(self, rsp, attr_spec):
raw = rsp[attr_spec['name']]
enum = self.consts[attr_spec['enum']]
i = attr_spec.get('value-start', 0)
if 'enum-as-flags' in attr_spec and attr_spec['enum-as-flags']:
i = 0
value = set()
while raw:
if raw & 1:
@ -414,7 +414,7 @@ class YnlFamily(SpecFamily):
raw >>= 1
i += 1
else:
value = enum.entries_by_val[raw - i].name
value = enum.entries_by_val[raw].name
rsp[attr_spec['name']] = value
def _decode_binary(self, attr, attr_spec):