From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 74CFC5A95 for ; Fri, 16 Jan 2015 16:10:40 +0100 (CET) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga101.jf.intel.com with ESMTP; 16 Jan 2015 07:10:39 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,411,1418112000"; d="scan'208";a="638363240" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga001.jf.intel.com with ESMTP; 16 Jan 2015 07:10:38 -0800 Received: from sivswdev02.ir.intel.com (sivswdev02.ir.intel.com [10.237.217.46]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id t0GFAbuF029565; Fri, 16 Jan 2015 15:10:37 GMT Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1]) by sivswdev02.ir.intel.com with ESMTP id t0GFAbw1022842; Fri, 16 Jan 2015 15:10:37 GMT Received: (from dwdohert@localhost) by sivswdev02.ir.intel.com with id t0GFAaTu022838; Fri, 16 Jan 2015 15:10:36 GMT From: Declan Doherty To: dev@dpdk.org Date: Fri, 16 Jan 2015 15:10:30 +0000 Message-Id: <1421421030-22261-1-git-send-email-declan.doherty@intel.com> X-Mailer: git-send-email 1.7.12.2 Subject: [dpdk-dev] [PATCH] eal / malloc : alignment parameter check failing due to changes in 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: Fri, 16 Jan 2015 15:10:40 -0000 In commit 2fc8d6d the behaviour of function rte_is_power_of_2 was changed to not return true for 0. memzone_reserve_aligned_thread_unsafe and rte_malloc_socket both make the assumption that for align = 0 !rte_is_power_of_2(align) will return false. This patch adds a check that align parameter is non-zero before doing the power of 2 check Signed-off-by: Declan Doherty --- lib/librte_eal/common/eal_common_memzone.c | 2 +- lib/librte_malloc/rte_malloc.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/librte_eal/common/eal_common_memzone.c b/lib/librte_eal/common/eal_common_memzone.c index b5a5d72..3f09338 100644 --- a/lib/librte_eal/common/eal_common_memzone.c +++ b/lib/librte_eal/common/eal_common_memzone.c @@ -156,7 +156,7 @@ memzone_reserve_aligned_thread_unsafe(const char *name, size_t len, } /* if alignment is not a power of two */ - if (!rte_is_power_of_2(align)) { + if (align ? !rte_is_power_of_2(align) : 0) { RTE_LOG(ERR, EAL, "%s(): Invalid alignment: %u\n", __func__, align); rte_errno = EINVAL; diff --git a/lib/librte_malloc/rte_malloc.c b/lib/librte_malloc/rte_malloc.c index b966fc7..15c7e20 100644 --- a/lib/librte_malloc/rte_malloc.c +++ b/lib/librte_malloc/rte_malloc.c @@ -75,7 +75,7 @@ rte_malloc_socket(const char *type, size_t size, unsigned align, int socket_arg) void *ret; /* return NULL if size is 0 or alignment is not power-of-2 */ - if (size == 0 || !rte_is_power_of_2(align)) + if (size == 0 || align ? !rte_is_power_of_2(align) : 0) return NULL; if (socket_arg == SOCKET_ID_ANY) -- 1.7.12.2