DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Ananyev, Konstantin" <konstantin.ananyev@intel.com>
To: Michael Qiu <qdy220091330@gmail.com>, "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH v2] test-pmd: Fix pointer aliasing error
Date: Thu, 4 Dec 2014 12:54:47 +0000
Message-ID: <2601191342CEEE43887BDE71AB977258213BC8B1@IRSMSX105.ger.corp.intel.com> (raw)
In-Reply-To: <1417663711-19576-1-git-send-email-michael.qiu@intel.com>



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Michael Qiu
> Sent: Thursday, December 04, 2014 3:29 AM
> To: dev@dpdk.org
> Subject: [dpdk-dev] [PATCH v2] test-pmd: Fix pointer aliasing error
> 
> 
> app/test-pmd/csumonly.c: In function ‘get_psd_sum’:
> build/include/rte_ip.h:161: error: dereferencing pointer ‘u16’
>         does break strict-aliasing rules
> build/include/rte_ip.h:157: note: initialized from here
>         ...
> 
> The root cause is that, compile enable strict aliasing by default,
> while in function rte_raw_cksum() try to convert 'const char *'
> to 'const uint16_t *'.
> 
> This patch is one workaround fix.
> 
> Signed-off-by: Michael Qiu <michael.qiu@intel.com>
> ---
>  lib/librte_net/rte_ip.h | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/librte_net/rte_ip.h b/lib/librte_net/rte_ip.h
> index 61e4457..f1c7087 100644
> --- a/lib/librte_net/rte_ip.h
> +++ b/lib/librte_net/rte_ip.h
> @@ -154,7 +154,8 @@ struct ipv4_hdr {
>  static inline uint16_t
>  rte_raw_cksum(const char *buf, size_t len)
>  {
> -	const uint16_t *u16 = (const uint16_t *)buf;
> +	unsigned long ptr = (unsigned long)buf;

I think better use uintptr_t here.
It is specially designed to be long enough to hold pointer value.

> +	const uint16_t *u16 = (const uint16_t *)ptr;
>  	uint32_t sum = 0;
> 
>  	while (len >= (sizeof(*u16) * 4)) {
> --
> 1.9.3


  parent reply	other threads:[~2014-12-04 12:54 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1417606044-3432-1-git-send-email-michael.qiu@intel.com>
     [not found] ` <1417606099-3489-1-git-send-email-michael.qiu@intel.com>
2014-12-03 11:42   ` [dpdk-dev] [PATCH] " Bruce Richardson
2014-12-03 13:59     ` Qiu, Michael
2014-12-03 14:51       ` Bruce Richardson
2014-12-03 15:19         ` Qiu, Michael
2014-12-03 15:36           ` Bruce Richardson
2014-12-04  2:38             ` Qiu, Michael
2014-12-04  3:28               ` [dpdk-dev] [PATCH v2] " Michael Qiu
2014-12-04  4:16                 ` [dpdk-dev] [PATCH v3] " Michael Qiu
2014-12-05  5:34                   ` Qiu, Michael
2014-12-05  9:24                     ` Thomas Monjalon
2014-12-08  1:28                       ` Qiu, Michael
2014-12-08  1:30                   ` Qiu, Michael
2014-12-10  3:44                     ` Qiu, Michael
2014-12-11  0:54                     ` Thomas Monjalon
2014-12-11 17:51                       ` r k
2014-12-12  6:49                         ` Qiu, Michael
2014-12-04 12:54                 ` Ananyev, Konstantin [this message]
2014-12-03 15:24     ` [dpdk-dev] [PATCH] " Olivier MATZ
2014-12-03 16:03       ` Dayu Qiu
2014-12-03 15:57     ` Dayu Qiu
2014-12-03 16:26 ` [dpdk-dev] [PATCH] test-pmd: Fix "__BYTE_ORDER__" not defined error Qiu, Michael
2014-12-03 19:59   ` Thomas Monjalon
2014-12-03 20:47     ` [dpdk-dev] [PATCH 0/2] fix endianness in EAL Thomas Monjalon
2014-12-03 20:47       ` [dpdk-dev] [PATCH 1/2] eal: detect endianness Thomas Monjalon
2014-12-04  2:28         ` Qiu, Michael
2014-12-04  9:00           ` Thomas Monjalon
2014-12-04 10:28             ` Qiu, Michael
2014-12-04 12:19               ` Thomas Monjalon
2014-12-04 12:50                 ` Qiu, Michael
2014-12-03 20:47       ` [dpdk-dev] [PATCH 2/2] app/testpmd: fix endianness detection Thomas Monjalon
2014-12-04  9:28       ` [dpdk-dev] [PATCH 0/2] fix endianness in EAL Chao Zhu
2014-12-05 16:01         ` Thomas Monjalon

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=2601191342CEEE43887BDE71AB977258213BC8B1@IRSMSX105.ger.corp.intel.com \
    --to=konstantin.ananyev@intel.com \
    --cc=dev@dpdk.org \
    --cc=qdy220091330@gmail.com \
    /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

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git