From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pd0-f178.google.com (mail-pd0-f178.google.com [209.85.192.178]) by dpdk.org (Postfix) with ESMTP id 789F03005 for ; Sat, 27 Dec 2014 16:30:55 +0100 (CET) Received: by mail-pd0-f178.google.com with SMTP id r10so14429007pdi.37 for ; Sat, 27 Dec 2014 07:30:54 -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=LvjVSEJW6V2Z4TqvnmpNpW2s7gvDagp2FnXBMIvdPaQw4kkdY/veGVScIx5VpSsHWe gpsnPAS0tEMVwHU+Fv/2scU3COkfT441CqcDCfQ9EW5viED0REKOgkIWpan9d5uuq9jM F6w+q7JUiG/OvfiXSaxcSXEr36UtXhHzDChrB1XC2dstfHqufX+QoUGtN1hyQuzxRRNc r5vQp6Iq2nDB25TdvQ0gG/Z9OQCPzJt/971klbfR56IK1dkCFSZedgVKpqsA4D6jXlz8 6uHNxosC689ZxT48wFxVSHLKKiSjhpeu2DFBcv32hgGJascJTCADzn4oQg49Q+gcdhN+ JvFA== X-Received: by 10.67.5.229 with SMTP id cp5mr35240908pad.8.1419694254738; Sat, 27 Dec 2014 07:30:54 -0800 (PST) Received: from iaas-l305162.englab.brocade.com ([144.49.130.148]) by mx.google.com with ESMTPSA id mw3sm6694409pdb.70.2014.12.27.07.30.53 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 27 Dec 2014 07:30:54 -0800 (PST) From: Ravi Kerur To: dev@dpdk.org Date: Sat, 27 Dec 2014 10:30:44 -0500 Message-Id: <1419694244-2018-1-git-send-email-rkerur@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1419694115-1892-1-git-send-email-rkerur@gmail.com> References: <1419694115-1892-1-git-send-email-rkerur@gmail.com> Subject: [dpdk-dev] [PATCH v2] 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: Sat, 27 Dec 2014 15:30:55 -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