From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <nhorman@tuxdriver.com>
Received: from smtp.tuxdriver.com (charlotte.tuxdriver.com [70.61.120.58])
 by dpdk.org (Postfix) with ESMTP id C87AC58EF
 for <dev@dpdk.org>; Mon, 16 Mar 2015 14:19:24 +0100 (CET)
Received: from hmsreliant.think-freely.org
 ([2001:470:8:a08:7aac:c0ff:fec2:933b] helo=localhost)
 by smtp.tuxdriver.com with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.63)
 (envelope-from <nhorman@tuxdriver.com>)
 id 1YXUvN-0005Ye-6i; Mon, 16 Mar 2015 09:19:23 -0400
Date: Mon, 16 Mar 2015 09:19:16 -0400
From: Neil Horman <nhorman@tuxdriver.com>
To: John McNamara <john.mcnamara@intel.com>
Message-ID: <20150316131916.GC16238@hmsreliant.think-freely.org>
References: <1426510564-19164-1-git-send-email-john.mcnamara@intel.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <1426510564-19164-1-git-send-email-john.mcnamara@intel.com>
User-Agent: Mutt/1.5.23 (2014-03-12)
X-Spam-Score: -2.9 (--)
X-Spam-Status: No
Cc: dev@dpdk.org
Subject: Re: [dpdk-dev] [PATCH] eal: fix Wbad-function-cast warning
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>
X-List-Received-Date: Mon, 16 Mar 2015 13:19:25 -0000

On Mon, Mar 16, 2015 at 12:56:04PM +0000, John McNamara wrote:
> Fix a warning when the rte_common.h header is included in a compilation
> using  -Wbad-function-cast, such as in Open vSwitch where the
> following warning is emitted repeatedly:
> 
>     ../rte_common.h: In function 'rte_is_aligned':
>     ../rte_common.h:184:9: warning: cast from function call of
>     type 'uintptr_t' to non-matching type 'void *' [-Wbad-function-cast]
> 
> This change fixes the issue in rte_common.h by using the RTE_ALIGN_FLOOR
> macro to get the aligned floor value with generic type casting.
> 
> Signed-off-by: John McNamara <john.mcnamara@intel.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 4971049..86b7e9b 100644
> --- a/lib/librte_eal/common/include/rte_common.h
> +++ b/lib/librte_eal/common/include/rte_common.h
> @@ -120,7 +120,7 @@ rte_align_floor_int(uintptr_t ptr, uintptr_t align)
>   * must be a power-of-two value.
>   */
>  #define RTE_PTR_ALIGN_FLOOR(ptr, align) \
> -	(typeof(ptr))rte_align_floor_int((uintptr_t)ptr, align)
> +	(typeof(ptr))RTE_ALIGN_FLOOR((uintptr_t)ptr, align)
>  
>  /**
>   * Macro to align a value to a given power-of-two. The resultant value
> -- 
> 1.8.1.4
> 
> 

This looks reasonable, but it rather begs the question as to why we need
rte_align_floor_int in the first place.  Theres only one other call site, and it
looks like it could use RTE_PTR_ALIGN_FLOOR just as easily.  What about fixing
up the second call site and removing the function to save some space?

Best
Neil