[PATCH net-next 01/11] tools: ynl-gen: fix enum index in _decode_enum(..)
Vadim Fedorenko
vadim.fedorenko at linux.dev
Thu Jul 20 02:18:53 PDT 2023
From: Arkadiusz Kubalewski <arkadiusz.kubalewski at intel.com>
Remove wrong index adjustement, 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: c311aaa74ca1 ("tools: ynl: fix enum-as-flags in the generic CLI")
Signed-off-by: Arkadiusz Kubalewski <arkadiusz.kubalewski at intel.com>
Signed-off-by: Vadim Fedorenko <vadim.fedorenko at linux.dev>
---
tools/net/ynl/lib/ynl.py | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/tools/net/ynl/lib/ynl.py b/tools/net/ynl/lib/ynl.py
index 1b3a36fbb1c3..3908438d3716 100644
--- a/tools/net/ynl/lib/ynl.py
+++ b/tools/net/ynl/lib/ynl.py
@@ -420,16 +420,14 @@ 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']:
value = set()
while raw:
if raw & 1:
- value.add(enum.entries_by_val[i].name)
+ value.add(enum.entries_by_val[raw & 1].name)
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):
--
2.27.0
More information about the linux-arm-kernel
mailing list