From patchwork Thu Jul 20 09:18:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vadim Fedorenko X-Patchwork-Id: 13320186 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 87B8BEB64DC for ; Thu, 20 Jul 2023 09:20:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=DkwtyPIGOBBTDl8G/VJIgSHbddiVJhn8NMpWrlHP6gQ=; b=XvzjPi61PzCUVd 2O1N+Zl3r894vcbbyDTcXB9QMJs5tkp5L1JcN8qLxv8zA2ulyD+qjlXS3s63nNpam9ZVYJl0BrWfZ ekE0gakS8IV66G03D10oRdIrdcidSz9vxzJGNV+Oa5D++IwyKx9kl8YYKIobrWWdyXRqFesPTHM6C TqkqKZGkOEJJfJTEeeC5D43yp0klDQXI0NdFklr/IVMSdQcOObb61pRiNm23CCCuXZix1LLJcLvBA 7Ff0daU1/lbpNemsuiv/NrPToPVPXtwsENMOp5NmzFJ9Dv1CXkh0noYEmkeS4YzXiZGmYMOrpd4/Q UAp70oxKTrncuxKVTpQg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qMPpO-00AVMI-07; Thu, 20 Jul 2023 09:20:06 +0000 Received: from out-3.mta0.migadu.com ([2001:41d0:1004:224b::3]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qMPpF-00AVHu-2r for linux-arm-kernel@lists.infradead.org; Thu, 20 Jul 2023 09:19:59 +0000 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1689844790; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=aY5ZIHVzqKStKyl3k69PdYOrRbB8zSK0DaCbVQ7/OGA=; b=fgIJIFH/Cnyi8aVF1Q+r8C7Thp478NsKaKk1wRZboWWj6Yxu5jcjjRloE1Vf+YkMk9TYRF Vjry3TSPqhOlqODz00DJuvPXPlTSrN4jWkmXqNriwp8wp8wRDFoSIzG2qlx4ADDe1pA4fW 0vs7WMo0+27zCZxIXo9ZCp6oCIt/rnI= From: Vadim Fedorenko To: Jakub Kicinski , Jiri Pirko , Arkadiusz Kubalewski , Jonathan Lemon , Paolo Abeni Cc: Milena Olech , Michal Michalik , Vadim Fedorenko , linux-arm-kernel@lists.infradead.org, poros@redhat.com, mschmidt@redhat.com, netdev@vger.kernel.org, linux-clk@vger.kernel.org, Bart Van Assche Subject: [PATCH net-next 01/11] tools: ynl-gen: fix enum index in _decode_enum(..) Date: Thu, 20 Jul 2023 10:18:53 +0100 Message-Id: <20230720091903.297066-2-vadim.fedorenko@linux.dev> In-Reply-To: <20230720091903.297066-1-vadim.fedorenko@linux.dev> References: <20230720091903.297066-1-vadim.fedorenko@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230720_021958_103435_6623CE2B X-CRM114-Status: UNSURE ( 8.42 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Arkadiusz Kubalewski 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 Signed-off-by: Vadim Fedorenko Reviewed-by: Jiri Pirko --- 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):