From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 ; Thu, 25 Dec 2014 16:33:52 +0100 (CET) Received: by mail-pd0-f171.google.com with SMTP id y13so11789047pdi.30 for ; 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 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Dec 2014 15:33:52 -0000 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 --- 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