From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.droids-corp.org (zoll.droids-corp.org [94.23.50.67]) by dpdk.org (Postfix) with ESMTP id 8296868AC for ; Mon, 1 Dec 2014 10:09:58 +0100 (CET) Received: from was59-1-82-226-113-214.fbx.proxad.net ([82.226.113.214] helo=[192.168.0.10]) by mail.droids-corp.org with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.80) (envelope-from ) id 1XvN2Q-0006UL-Gc; Mon, 01 Dec 2014 10:13:01 +0100 Message-ID: <547C3052.4080106@6wind.com> Date: Mon, 01 Dec 2014 10:09:38 +0100 From: Olivier MATZ User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Icedove/24.5.0 MIME-Version: 1.0 To: Neil Horman , Bruce Richardson References: <1417188660-14587-1-git-send-email-bruce.richardson@intel.com> <20141130010514.GA19479@localhost.localdomain> In-Reply-To: <20141130010514.GA19479@localhost.localdomain> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: dev@dpdk.org Subject: Re: [dpdk-dev] [PATCH] ixgbe: fix clang compile - remove truncation errors 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: Mon, 01 Dec 2014 09:09:58 -0000 Hi Bruce, Hi Neil, On 11/30/2014 02:05 AM, Neil Horman wrote: > On Fri, Nov 28, 2014 at 03:31:00PM +0000, Bruce Richardson wrote: >> When compiling with clang, errors were being emitted due to truncation >> of values when assigning to the tx_offload_mask bit fields. >> >> dpdk.org/lib/librte_pmd_ixgbe/ixgbe_rxtx.c:404:27: fatal error: implicit truncation from 'int' to bitfield changes value from -1 to 127 [-Wbitfield-constant-conversion] >> tx_offload_mask.l2_len = ~0; >> >> The fix proposed here is to define a static const value of the same type >> with all fields set to 1s, and use that instead of constants for assigning to. >> >> Other options would be to explicitily define the suitable constants that >> would not truncate for each individual field e.g. 0x7f for l2_len, 0x1FF >> for l3_len, etc., but this solution here has the advantage that it works >> without any changes to values if the field sizes are ever modified. >> >> Signed-off-by: Bruce Richardson >> --- >> lib/librte_pmd_ixgbe/ixgbe_rxtx.c | 29 +++++++++++++++-------------- >> 1 file changed, 15 insertions(+), 14 deletions(-) >> >> diff --git a/lib/librte_pmd_ixgbe/ixgbe_rxtx.c b/lib/librte_pmd_ixgbe/ixgbe_rxtx.c >> index 8559ef6..4f71194 100644 >> --- a/lib/librte_pmd_ixgbe/ixgbe_rxtx.c >> +++ b/lib/librte_pmd_ixgbe/ixgbe_rxtx.c >> @@ -367,6 +367,7 @@ ixgbe_set_xmit_ctx(struct igb_tx_queue* txq, >> volatile struct ixgbe_adv_tx_context_desc *ctx_txd, >> uint64_t ol_flags, union ixgbe_tx_offload tx_offload) >> { >> + static const union ixgbe_tx_offload offload_allones = { .data = ~0 }; > Do you want to make this a static data structure? If you make it a macro like > this: > #define ALLONES {.data = ~0} > Then you save the extra data space in the .data area (not that its that much), > and you can define it in a header file and use it in multiple c files (if you > need to) I found that the following code works: tx_offload_mask.l2_len |= ~0; (note the '|=' instead of '=') I would avoid to create a macro. What do you think? Regards, Olivier