Message ID | 1419521597-31978-2-git-send-email-rkerur@gmail.com (mailing list archive) |
---|---|
State | Superseded, archived |
Headers |
Return-Path: <dev-bounces@dpdk.org> X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id EEE6A95EB; Thu, 25 Dec 2014 16:33:53 +0100 (CET) Received: from mail-pd0-f171.google.com (mail-pd0-f171.google.com [209.85.192.171]) by dpdk.org (Postfix) with ESMTP id 7E8AF689B for <dev@dpdk.org>; Thu, 25 Dec 2014 16:33:52 +0100 (CET) Received: by mail-pd0-f171.google.com with SMTP id y13so11789047pdi.30 for <dev@dpdk.org>; Thu, 25 Dec 2014 07:33:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=UFI+QDaVRW5W/U+/hOzv3TwoVInOCzQCN285Ce6cMlI=; b=CXJmJvhCqJ83xvO7Pa3a/ctmocqYJ0J81SWlQt3F5DqDQt5txt327dZzhn5mbe6f8w dRr//LgoGvB95zqFocTTa1Yvcbmo5q8K4B1BmRmvR8GtmSx5sXpafNig2qIj846gISGD 8HCf6bUZ6ApWTgN4yUU2Q+25QqvPnhGxgw5E//3FI9uOm4qD60qlOATR9+7OA2Kp11ob RrwRPKi30ule7PwbmmyXnbisfvIgcyUYKWWdphqefRKr070wXvV38HPvPxnYc4PstWLS SvIO3zacBFeaamIVx33T+D1s1fwJXicJdrdnmX8DKBGdfD3kxDNPuQpnuZyP1qbxM2yE Pynw== X-Received: by 10.70.38.71 with SMTP id e7mr62321790pdk.130.1419521631901; Thu, 25 Dec 2014 07:33:51 -0800 (PST) Received: from iaas-l305162.englab.brocade.com ([144.49.130.148]) by mx.google.com with ESMTPSA id pe8sm25719713pdb.60.2014.12.25.07.33.51 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 25 Dec 2014 07:33:51 -0800 (PST) From: Ravi Kerur <rkerur@gmail.com> To: dev@dpdk.org Date: Thu, 25 Dec 2014 10:33:11 -0500 Message-Id: <1419521597-31978-2-git-send-email-rkerur@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1419521597-31978-1-git-send-email-rkerur@gmail.com> References: <1419521597-31978-1-git-send-email-rkerur@gmail.com> Subject: [dpdk-dev] [PATCH 1/7] Fix rte_is_power_of_2 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK <dev.dpdk.org> List-Unsubscribe: <http://dpdk.org/ml/options/dev>, <mailto:dev-request@dpdk.org?subject=unsubscribe> List-Archive: <http://dpdk.org/ml/archives/dev/> List-Post: <mailto:dev@dpdk.org> List-Help: <mailto:dev-request@dpdk.org?subject=help> List-Subscribe: <http://dpdk.org/ml/listinfo/dev>, <mailto:dev-request@dpdk.org?subject=subscribe> Errors-To: dev-bounces@dpdk.org Sender: "dev" <dev-bounces@dpdk.org> |
Commit Message
Ravi Kerur
Dec. 25, 2014, 3:33 p.m. UTC
rte_is_power_of_2 returns true for 0 and 0 is not power_of_2. Fix
by checking for n.
Signed-off-by: Ravi Kerur <rkerur@gmail.com>
---
lib/librte_eal/common/include/rte_common.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Thu, Dec 25, 2014 at 10:33:11AM -0500, Ravi Kerur wrote: > rte_is_power_of_2 returns true for 0 and 0 is not power_of_2. Fix > by checking for n. > > Signed-off-by: Ravi Kerur <rkerur@gmail.com> > --- > lib/librte_eal/common/include/rte_common.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/lib/librte_eal/common/include/rte_common.h b/lib/librte_eal/common/include/rte_common.h > index 921b91f..8ac940c 100644 > --- a/lib/librte_eal/common/include/rte_common.h > +++ b/lib/librte_eal/common/include/rte_common.h > @@ -203,7 +203,7 @@ extern int RTE_BUILD_BUG_ON_detected_error; > static inline int > rte_is_power_of_2(uint32_t n) > { > - return ((n-1) & n) == 0; > + return n && !(n & (n - 1)); > } > > /** > -- > 1.9.1 > > This is the third time you've tried to slip this change in with some larger changeset. I'm in favor of it, but please, stop trying to bury stuff in other, larger changesets. Its a legitimate bug, you can just post this on its own. Neil
Sure, will post it separately. Thanks. On Thu, Dec 25, 2014 at 9:21 AM, Neil Horman <nhorman@tuxdriver.com> wrote: > On Thu, Dec 25, 2014 at 10:33:11AM -0500, Ravi Kerur wrote: > > rte_is_power_of_2 returns true for 0 and 0 is not power_of_2. Fix > > by checking for n. > > > > Signed-off-by: Ravi Kerur <rkerur@gmail.com> > > --- > > lib/librte_eal/common/include/rte_common.h | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/lib/librte_eal/common/include/rte_common.h > b/lib/librte_eal/common/include/rte_common.h > > index 921b91f..8ac940c 100644 > > --- a/lib/librte_eal/common/include/rte_common.h > > +++ b/lib/librte_eal/common/include/rte_common.h > > @@ -203,7 +203,7 @@ extern int RTE_BUILD_BUG_ON_detected_error; > > static inline int > > rte_is_power_of_2(uint32_t n) > > { > > - return ((n-1) & n) == 0; > > + return n && !(n & (n - 1)); > > } > > > > /** > > -- > > 1.9.1 > > > > > > This is the third time you've tried to slip this change in with some larger > changeset. I'm in favor of it, but please, stop trying to bury stuff in > other, > larger changesets. Its a legitimate bug, you can just post this on its > own. > > Neil > >
diff --git a/lib/librte_eal/common/include/rte_common.h b/lib/librte_eal/common/include/rte_common.h index 921b91f..8ac940c 100644 --- a/lib/librte_eal/common/include/rte_common.h +++ b/lib/librte_eal/common/include/rte_common.h @@ -203,7 +203,7 @@ extern int RTE_BUILD_BUG_ON_detected_error; static inline int rte_is_power_of_2(uint32_t n) { - return ((n-1) & n) == 0; + return n && !(n & (n - 1)); } /**