Message ID | 1426510564-19164-1-git-send-email-john.mcnamara@intel.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 1F7D858EF; Mon, 16 Mar 2015 13:56:10 +0100 (CET) Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 7BDE458D8 for <dev@dpdk.org>; Mon, 16 Mar 2015 13:56:08 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga103.jf.intel.com with ESMTP; 16 Mar 2015 05:52:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.11,409,1422950400"; d="scan'208";a="699322847" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga002.jf.intel.com with ESMTP; 16 Mar 2015 05:56:06 -0700 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 t2GCu5HR000733; Mon, 16 Mar 2015 12:56:05 GMT Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1]) by sivswdev02.ir.intel.com with ESMTP id t2GCu5sL019204; Mon, 16 Mar 2015 12:56:05 GMT Received: (from jmcnam2x@localhost) by sivswdev02.ir.intel.com with id t2GCu59w019200; Mon, 16 Mar 2015 12:56:05 GMT From: John McNamara <john.mcnamara@intel.com> To: dev@dpdk.org Date: Mon, 16 Mar 2015 12:56:04 +0000 Message-Id: <1426510564-19164-1-git-send-email-john.mcnamara@intel.com> X-Mailer: git-send-email 1.7.4.1 Subject: [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> Errors-To: dev-bounces@dpdk.org Sender: "dev" <dev-bounces@dpdk.org> |
Commit Message
John McNamara
March 16, 2015, 12:56 p.m. UTC
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(-)
Comments
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
> -----Original Message----- > From: Neil Horman [mailto:nhorman@tuxdriver.com] > Sent: Monday, March 16, 2015 1:19 PM > To: Mcnamara, John > Cc: dev@dpdk.org > Subject: Re: [dpdk-dev] [PATCH] eal: fix Wbad-function-cast warning > > > 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? Hi Neil, Seems like a good idea. I'll submit a v2. Does rte_align_floor_int() need to be deprecated in some way or is it okay to just remove it? John
On Mon, Mar 16, 2015 at 03:04:45PM +0000, Mcnamara, John wrote: > > -----Original Message----- > > From: Neil Horman [mailto:nhorman@tuxdriver.com] > > Sent: Monday, March 16, 2015 1:19 PM > > To: Mcnamara, John > > Cc: dev@dpdk.org > > Subject: Re: [dpdk-dev] [PATCH] eal: fix Wbad-function-cast warning > > > > > > 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? > > Hi Neil, > > Seems like a good idea. I'll submit a v2. > > Does rte_align_floor_int() need to be deprecated in some way or is it okay to just remove it? > > John > After the 2.0 release you should put a note in the api document, yes, but right now its not required. Though if you wanted to, I wouldn't stop you :) Neil
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