From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 77A71A0C4B;
	Tue, 13 Jul 2021 22:12:32 +0200 (CEST)
Received: from [217.70.189.124] (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id F0083410EC;
	Tue, 13 Jul 2021 22:12:31 +0200 (CEST)
Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com
 [209.85.210.182])
 by mails.dpdk.org (Postfix) with ESMTP id 5519C4069C
 for <dev@dpdk.org>; Tue, 13 Jul 2021 22:12:31 +0200 (CEST)
Received: by mail-pf1-f182.google.com with SMTP id q10so20595642pfj.12
 for <dev@dpdk.org>; Tue, 13 Jul 2021 13:12:31 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=networkplumber-org.20150623.gappssmtp.com; s=20150623;
 h=from:to:cc:subject:date:message-id:mime-version
 :content-transfer-encoding;
 bh=ocvxKsi51Wyo8NwewVQjAgXiu5JDM4SK7hNMjH8gKSs=;
 b=urudAaRonNj3xU47ki4V6C1ucEGisJ+tC27NgZVH+7Khha3lowHWcZ5iPxlVEvIewC
 OpvPO+eo44lxqwHFqVdW6CaQBOK5LwKcj1HneTEj/UstVp0mMwpC3FeTuloQ0NhFdzSz
 1Z+1mUEpn18Gwy0AubGgjbYZvzen/vTFF57Wfi7MrcldxzbLSVmwD3qplpSxmWHhLFdM
 6ERLH3CmnzTWjra5M136bQOQqmMJlPk8j8hZzHqi7XxuJ6Zkcb1ZvT3j369B2hOI5uQR
 aRV+3Kp+jHng9yzuF6XxuywknB1LMXAQjV7KmaGmqyCJ+TGJEPM49UjfTTiX6p8Tyx5v
 lHUQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version
 :content-transfer-encoding;
 bh=ocvxKsi51Wyo8NwewVQjAgXiu5JDM4SK7hNMjH8gKSs=;
 b=Iim0vdMJzFZIARdkwc/WyRwoe/fanpMURvWqdRIVGfK6RfBi3AGlHnuH+oeWNpaPyt
 aah0aa1i1vU81EN5R0PSTL8s0G+znljc0aMa2MDRr1cbeSJDTauZeLO8XTHgCpS6qDfY
 i8IFQ2kDj9E51fILnMw7X+wCy/Z7SM1GbvjfnFo4x9ZgdCVteZSvQ1USWzZ2guPVBX2C
 vlVDezG6LjsvAiNm++CrtnuPpHntMaHyXQv+o/71+ZtNhRGna/MgH5+NB/Q3aATw7o6v
 T3Q83MztTRK+B2laFq+F6K7Do3c0szGCAZwrvUCo/eRfS7mJdUKBOwauvREA9WFsWWbv
 Z2gA==
X-Gm-Message-State: AOAM532ArimfC9HRTdBcH+BdDr+11x2RcFY8RcQMJh1GelsmoP27kzf6
 qhKtSi+DoDlET9Z+wBydFOby1zEC7REKUw==
X-Google-Smtp-Source: ABdhPJyQSueBDiE3cPBwqpzPqBbVen4n8KIA/NqxzRnMyupEIfzxP3Z598omMwlnaky+G+FOvrmWlQ==
X-Received: by 2002:a05:6a00:10cd:b029:30a:ea3a:4acf with SMTP id
 d13-20020a056a0010cdb029030aea3a4acfmr6521421pfu.51.1626207149861; 
 Tue, 13 Jul 2021 13:12:29 -0700 (PDT)
Received: from hermes.local (204-195-33-123.wavecable.com. [204.195.33.123])
 by smtp.gmail.com with ESMTPSA id v10sm7734pfg.160.2021.07.13.13.12.23
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Tue, 13 Jul 2021 13:12:25 -0700 (PDT)
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>, anatoly.burakov@intel.com
Date: Tue, 13 Jul 2021 13:12:21 -0700
Message-Id: <20210713201221.301248-1-stephen@networkplumber.org>
X-Mailer: git-send-email 2.30.2
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Subject: [dpdk-dev] [PATCH] eal: fix argument to rte_bsf32_safe
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org
Sender: "dev" <dev-bounces@dpdk.org>

The first argument to rte_bsf32_safe was incorrectly declared as
a 64 bit value. This function only correctly handles on 32 bit values
and the underlying function rte_bsf32 only accepts 32 bit values.
This was introduced when the safe version was added and probably cause
by copy/paste from the 64 bit version.

The bug passed silently under the radar until some other code was
built with -Wall and -Wextra in C++ and C++ complains about the
missing cast.

Yes, this is a API signature change, but the original code was wrong.
It is an inline so not an ABI change.

Fixes: 4e261f551986 ("eal: add 64-bit bsf and 32-bit safe bsf functions")
Cc: anatoly.burakov@intel.com
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/eal/include/rte_common.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/eal/include/rte_common.h b/lib/eal/include/rte_common.h
index d5a32c66a5fe..99eb5f1820ae 100644
--- a/lib/eal/include/rte_common.h
+++ b/lib/eal/include/rte_common.h
@@ -623,7 +623,7 @@ rte_bsf32(uint32_t v)
  *     Returns 0 if ``v`` was 0, otherwise returns 1.
  */
 static inline int
-rte_bsf32_safe(uint64_t v, uint32_t *pos)
+rte_bsf32_safe(uint32_t v, uint32_t *pos)
 {
 	if (v == 0)
 		return 0;
-- 
2.30.2