From: Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>
To: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
kuba@kernel.org, davem@davemloft.net, pabeni@redhat.com,
edumazet@google.com, chuck.lever@oracle.com
Cc: Arkadiusz Kubalewski <arkadiusz.kubalewski@intel.com>
Subject: [PATCH net-next 1/2 v2] tools: ynl-gen: fix enum index in _decode_enum(..)
Date: Thu, 13 Jul 2023 11:05:49 +0200 [thread overview]
Message-ID: <20230713090550.132858-2-arkadiusz.kubalewski@intel.com> (raw)
In-Reply-To: <20230713090550.132858-1-arkadiusz.kubalewski@intel.com>
Remove wrong index adjustment, which is a 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@intel.com>
---
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.37.3
next prev parent reply other threads:[~2023-07-13 9:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-13 9:05 [PATCH net-next 0/2] tools: ynl-gen: fix parse multi-attr enum attribute Arkadiusz Kubalewski
2023-07-13 9:05 ` Arkadiusz Kubalewski [this message]
2023-07-13 16:02 ` [PATCH net-next 1/2 v2] tools: ynl-gen: fix enum index in _decode_enum(..) Jakub Kicinski
2023-07-18 16:30 ` Kubalewski, Arkadiusz
2023-07-13 9:05 ` [PATCH net-next 2/2 v2] tools: ynl-gen: fix parse multi-attr enum attribute Arkadiusz Kubalewski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230713090550.132858-2-arkadiusz.kubalewski@intel.com \
--to=arkadiusz.kubalewski@intel.com \
--cc=chuck.lever@oracle.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®