Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp1342350rwp; Thu, 13 Jul 2023 09:24:22 -0700 (PDT) X-Google-Smtp-Source: APBJJlGEh92wF/921i4Si4w9Q4oIAqx64kgDwP6sAYz/NW3oe7EHYQqvta5ybVEA6cdBgw3Pp0dp X-Received: by 2002:a17:906:68c9:b0:992:b1b2:9bf4 with SMTP id y9-20020a17090668c900b00992b1b29bf4mr1723063ejr.35.1689265462159; Thu, 13 Jul 2023 09:24:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689265462; cv=none; d=google.com; s=arc-20160816; b=NFIsepewGpd6y5BNtpeCVe3fMJCRRDcE2JcYKd+SL5xJG+8au2M3OltyRqGKnzNAob r91dUtSxWhCtS8VmfKmlRq/2a/mx+9NldB53v2biSaABdbEgHCrK7KZqzfxWGTuuY7Qj 1tqL6K5drCqyntx+qda0X5/aqKI2j9Lsl9txhV0p9YDcAvNHyjlrZH8MVy5h/O4SEGzr 2/VHbGp5KAAxUKwoZhLR7JgZVPFuliGqCl8+Av8URri91sQY32xyN28vzoa4qAykPpX1 NSlRYO/xYKpcLo97cVFQxwaCf3KswdkKBGCxV9QsLM20G4vvLOxZHFYAuA087CSxGIx5 y+8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=XK5WqEujrhaGMw67K2OskvAJZ6H/HjQPFACMk3I55Rg=; fh=mYQKVr72GuI742dmy/eXxzH68Lk7GImudbP+V23OUhg=; b=T6DVa98fvEs1X5Ob+vk7iNuS3ZMnjtAdsszgM7UXeDlYX6o145cXwJ/9EAUyzwKXPV c0rRoLbta6UeKot/QiS6j/gE2vbVVwvRSYRSEqXXS1chlb6UlwSsbig5KH1caZLI2ocF OFVDXr4JzV53lDpAtlaSa/U4qP2H5h4SbVEMkIAWbdssO4+luNBAvs5+dfTWlioc9xj9 K4e0NaLTSvzpMFZFowNHiRBoDqfsJprtf7tAQZsO4NBm5Q9b9bD62TYe+HeilT9tTjIZ 97Z1O9MrRWWjM0ZE/PGEEb7AQWG1mw6Y2fimuOBCoqyEO5ETItGibLXi6IUkaBMgE2cW opqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IHk2BQIP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r17-20020a1709067fd100b0098859d239dfsi8129959ejs.796.2023.07.13.09.23.56; Thu, 13 Jul 2023 09:24:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=IHk2BQIP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231530AbjGMQCp (ORCPT + 99 others); Thu, 13 Jul 2023 12:02:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229906AbjGMQCl (ORCPT ); Thu, 13 Jul 2023 12:02:41 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8E5192708 for ; Thu, 13 Jul 2023 09:02:36 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 1DE6C619DD for ; Thu, 13 Jul 2023 16:02:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 40ADEC433C7; Thu, 13 Jul 2023 16:02:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689264155; bh=cM/w8DteIuiCvz+ZdOohIJG9HbMzhPuzehxZjaExPPE=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=IHk2BQIPyuKXc0oD1dqRMspUjGJMk/7mHCtXHU+bXtN4XIqwPOFmHnb6/vIcA6N06 c2FsW26g3Qo7Cte81e/mf5NBDtGJ0FTRLR1SdhmkeCZLlTMT+1BDAoMJkfsNYqa//4 R5ZltZMOYzASVflX4s2vSTbRSTE2TVYiXDyAhAU4zmlTJms01Djb/5eJBhrapfGJO+ 8WHgrXBSQ2GRbXL4hd/vUpR4PxpsDEzWQHVjPnoqFOtK3e+yjUJAihwbz2bnQ0KQkF bxrvs8SRpC8kpjYwV8GGUWz6wlhLcdkhSoZig1xJDrZgmDS/Fy6JLtZxtZpR+eGBir fpuuOakfcAeMg== Date: Thu, 13 Jul 2023 09:02:34 -0700 From: Jakub Kicinski To: Arkadiusz Kubalewski Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, davem@davemloft.net, pabeni@redhat.com, edumazet@google.com, chuck.lever@oracle.com Subject: Re: [PATCH net-next 1/2 v2] tools: ynl-gen: fix enum index in _decode_enum(..) Message-ID: <20230713090234.28b04145@kernel.org> In-Reply-To: <20230713090550.132858-2-arkadiusz.kubalewski@intel.com> References: <20230713090550.132858-1-arkadiusz.kubalewski@intel.com> <20230713090550.132858-2-arkadiusz.kubalewski@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 13 Jul 2023 11:05:49 +0200 Arkadiusz Kubalewski wrote: > - 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 This doesn't make sense, as I suggested you need to keep i for this loop. Move it to the inside of the if 'enum-as-fla... and init to 0. i is tracking which bit number we are at as we consume / shift out bits from raw. Have you ever used ChatGPT? No shame, just curious. -- pw-bot: cr