From: Neil Horman <nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
To: Bruce Richardson
<bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Cc: dev-VfR2kkLFssw@public.gmane.org
Subject: Re: [PATCH] ixgbe: fix clang compile - remove truncation errors
Date: Sat, 29 Nov 2014 20:05:14 -0500 [thread overview]
Message-ID: <20141130010514.GA19479@localhost.localdomain> (raw)
In-Reply-To: <1417188660-14587-1-git-send-email-bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
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 <bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> ---
> 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)
Neil
next prev parent reply other threads:[~2014-11-30 1:05 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-28 15:31 [PATCH] ixgbe: fix clang compile - remove truncation errors Bruce Richardson
[not found] ` <1417188660-14587-1-git-send-email-bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2014-11-30 1:05 ` Neil Horman [this message]
[not found] ` <20141130010514.GA19479-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2014-12-01 9:09 ` Olivier MATZ
[not found] ` <547C3052.4080106-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
2014-12-01 9:48 ` Bruce Richardson
2014-12-01 9:59 ` Olivier MATZ
2014-12-01 11:18 ` Neil Horman
[not found] ` <20141201111817.GA15135-B26myB8xz7F8NnZeBjwnZQMhkBWG/bsMQH7oEaQurus@public.gmane.org>
2014-12-01 11:24 ` Bruce Richardson
2014-12-01 14:25 ` Neil Horman
[not found] ` <20141201142544.GB15135-B26myB8xz7F8NnZeBjwnZQMhkBWG/bsMQH7oEaQurus@public.gmane.org>
2014-12-01 14:36 ` Bruce Richardson
2014-12-01 15:18 ` Neil Horman
[not found] ` <20141201151806.GC15135-B26myB8xz7F8NnZeBjwnZQMhkBWG/bsMQH7oEaQurus@public.gmane.org>
2014-12-01 15:24 ` Bruce Richardson
2014-12-01 16:35 ` Neil Horman
[not found] ` <20141201163528.GD15135-B26myB8xz7F8NnZeBjwnZQMhkBWG/bsMQH7oEaQurus@public.gmane.org>
2014-12-01 16:44 ` Bruce Richardson
2014-12-01 17:16 ` Neil Horman
[not found] ` <20141201171623.GE15135-B26myB8xz7F8NnZeBjwnZQMhkBWG/bsMQH7oEaQurus@public.gmane.org>
2014-12-01 21:55 ` Olivier MATZ
[not found] ` <547CE3D1.50104-pdR9zngts4EAvxtiuMwx3w@public.gmane.org>
2014-12-02 11:32 ` Neil Horman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20141130010514.GA19479@localhost.localdomain \
--to=nhorman-2xusbdqka4r54taoqtywwq@public.gmane.org \
--cc=bruce.richardson-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=dev-VfR2kkLFssw@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.