DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] examples: compilation fix for GCC-12
@ 2022-09-01  8:23 Amit Prakash Shukla
  2022-09-01 15:24 ` Stephen Hemminger
  2022-09-02  7:43 ` [PATCH v2] " Amit Prakash Shukla
  0 siblings, 2 replies; 7+ messages in thread
From: Amit Prakash Shukla @ 2022-09-01  8:23 UTC (permalink / raw)
  To: Ruifeng Wang; +Cc: dev, jerinj, stable, gakhil, Amit Prakash Shukla

GCC-12 warns when a pointer of type union points to an array of same
defined size, as union internally gets paded with pad bytes.

../examples/common/neon/port_group.h:42:21: error: array subscript
	'union <anonymous>[0]' is partly outside array bounds of
	'uint16_t[5]' {aka 'short unsigned int[5]'}
	[-Werror=array-bounds]
   42 |                 pnum->u64 = gptbl[v].pnum;
      |                     ^~
../examples/common/neon/port_group.h:21:23: note: object 'pn' of
	size [0, 10]
   21 | port_groupx4(uint16_t pn[FWDSTEP + 1], uint16_t *lp, uint16x8_t dp1
      |              ~~~~~~~~~^~~~~~~~~~~~~~~
../examples/common/neon/port_group.h:43:21: error: array subscript
	'union <anonymous>[0]' is partly outside array bounds of
	'uint16_t[5]' {aka 'short unsigned int[5]'} [-Werror=array-bounds]
   43 |                 pnum->u16[FWDSTEP] = 1;
      |                     ^~

Fixes: bdfc3816fbfc ("examples: common packet group functionality")
Cc: stable@dpdk.org

Signed-off-by: Amit Prakash Shukla <amitprakashs@marvell.com>
---
 examples/common/neon/port_group.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/examples/common/neon/port_group.h b/examples/common/neon/port_group.h
index 82c6ed6d73..97da604583 100644
--- a/examples/common/neon/port_group.h
+++ b/examples/common/neon/port_group.h
@@ -24,7 +24,7 @@ port_groupx4(uint16_t pn[FWDSTEP + 1], uint16_t *lp, uint16x8_t dp1,
 	union {
 		uint16_t u16[FWDSTEP + 1];
 		uint64_t u64;
-	} *pnum = (void *)pn;
+	} __attribute__((__packed__)) *pnum = (void *)pn;
 
 	uint16x8_t mask = {1, 2, 4, 8, 0, 0, 0, 0};
 	int32_t v;
-- 
2.25.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] examples: compilation fix for GCC-12
  2022-09-01  8:23 [PATCH] examples: compilation fix for GCC-12 Amit Prakash Shukla
@ 2022-09-01 15:24 ` Stephen Hemminger
  2022-09-02  7:19   ` [EXT] " Amit Prakash Shukla
  2022-09-02  7:43 ` [PATCH v2] " Amit Prakash Shukla
  1 sibling, 1 reply; 7+ messages in thread
From: Stephen Hemminger @ 2022-09-01 15:24 UTC (permalink / raw)
  To: Amit Prakash Shukla; +Cc: Ruifeng Wang, dev, jerinj, stable, gakhil

On Thu, 1 Sep 2022 13:53:43 +0530
Amit Prakash Shukla <amitprakashs@marvell.com> wrote:

> diff --git a/examples/common/neon/port_group.h b/examples/common/neon/port_group.h
> index 82c6ed6d73..97da604583 100644
> --- a/examples/common/neon/port_group.h
> +++ b/examples/common/neon/port_group.h
> @@ -24,7 +24,7 @@ port_groupx4(uint16_t pn[FWDSTEP + 1], uint16_t *lp, uint16x8_t dp1,
>  	union {
>  		uint16_t u16[FWDSTEP + 1];
>  		uint64_t u64;
> -	} *pnum = (void *)pn;
> +	} __attribute__((__packed__)) *pnum = (void *)pn;

Use __rte_packed instead of direct attribute

^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [EXT] Re: [PATCH] examples: compilation fix for GCC-12
  2022-09-01 15:24 ` Stephen Hemminger
@ 2022-09-02  7:19   ` Amit Prakash Shukla
  0 siblings, 0 replies; 7+ messages in thread
From: Amit Prakash Shukla @ 2022-09-02  7:19 UTC (permalink / raw)
  To: Stephen Hemminger
  Cc: Ruifeng Wang, dev, Jerin Jacob Kollanukkaran, stable, Akhil Goyal

Thanks Stephen for feedback. I will make the change in v2.

> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Thursday, September 1, 2022 8:54 PM
> To: Amit Prakash Shukla <amitprakashs@marvell.com>
> Cc: Ruifeng Wang <ruifeng.wang@arm.com>; dev@dpdk.org; Jerin Jacob
> Kollanukkaran <jerinj@marvell.com>; stable@dpdk.org; Akhil Goyal
> <gakhil@marvell.com>
> Subject: [EXT] Re: [PATCH] examples: compilation fix for GCC-12
> 
> External Email
> 
> ----------------------------------------------------------------------
> On Thu, 1 Sep 2022 13:53:43 +0530
> Amit Prakash Shukla <amitprakashs@marvell.com> wrote:
> 
> > diff --git a/examples/common/neon/port_group.h
> b/examples/common/neon/port_group.h
> > index 82c6ed6d73..97da604583 100644
> > --- a/examples/common/neon/port_group.h
> > +++ b/examples/common/neon/port_group.h
> > @@ -24,7 +24,7 @@ port_groupx4(uint16_t pn[FWDSTEP + 1], uint16_t *lp,
> uint16x8_t dp1,
> >  	union {
> >  		uint16_t u16[FWDSTEP + 1];
> >  		uint64_t u64;
> > -	} *pnum = (void *)pn;
> > +	} __attribute__((__packed__)) *pnum = (void *)pn;
> 
> Use __rte_packed instead of direct attribute

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2] examples: compilation fix for GCC-12
  2022-09-01  8:23 [PATCH] examples: compilation fix for GCC-12 Amit Prakash Shukla
  2022-09-01 15:24 ` Stephen Hemminger
@ 2022-09-02  7:43 ` Amit Prakash Shukla
  2022-10-06  6:31   ` Amit Prakash Shukla
  2022-10-06  9:27   ` Thomas Monjalon
  1 sibling, 2 replies; 7+ messages in thread
From: Amit Prakash Shukla @ 2022-09-02  7:43 UTC (permalink / raw)
  To: Ruifeng Wang; +Cc: dev, jerinj, stable, gakhil, stephen, Amit Prakash Shukla

GCC-12 warns when a pointer of type union points to an array of same
defined size, as union internally gets paded with pad bytes.

../examples/common/neon/port_group.h:42:21: error: array subscript
	'union <anonymous>[0]' is partly outside array bounds of
	'uint16_t[5]' {aka 'short unsigned int[5]'}
	[-Werror=array-bounds]
   42 |                 pnum->u64 = gptbl[v].pnum;
      |                     ^~
../examples/common/neon/port_group.h:21:23: note: object 'pn' of
	size [0, 10]
   21 | port_groupx4(uint16_t pn[FWDSTEP + 1], uint16_t *lp, uint16x8_t dp1
      |              ~~~~~~~~~^~~~~~~~~~~~~~~
../examples/common/neon/port_group.h:43:21: error: array subscript
	'union <anonymous>[0]' is partly outside array bounds of
	'uint16_t[5]' {aka 'short unsigned int[5]'} [-Werror=array-bounds]
   43 |                 pnum->u16[FWDSTEP] = 1;
      |                     ^~

Fixes: bdfc3816fbfc ("examples: common packet group functionality")
Cc: stable@dpdk.org

Signed-off-by: Amit Prakash Shukla <amitprakashs@marvell.com>
---
v2:
- Changed to __rte_packed instead of direct attribute

 examples/common/neon/port_group.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/examples/common/neon/port_group.h b/examples/common/neon/port_group.h
index 82c6ed6d73..04e5699f70 100644
--- a/examples/common/neon/port_group.h
+++ b/examples/common/neon/port_group.h
@@ -24,7 +24,7 @@ port_groupx4(uint16_t pn[FWDSTEP + 1], uint16_t *lp, uint16x8_t dp1,
 	union {
 		uint16_t u16[FWDSTEP + 1];
 		uint64_t u64;
-	} *pnum = (void *)pn;
+	} __rte_packed *pnum = (void *)pn;
 
 	uint16x8_t mask = {1, 2, 4, 8, 0, 0, 0, 0};
 	int32_t v;
-- 
2.25.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* RE: [PATCH v2] examples: compilation fix for GCC-12
  2022-09-02  7:43 ` [PATCH v2] " Amit Prakash Shukla
@ 2022-10-06  6:31   ` Amit Prakash Shukla
  2022-10-06  9:21     ` Thomas Monjalon
  2022-10-06  9:27   ` Thomas Monjalon
  1 sibling, 1 reply; 7+ messages in thread
From: Amit Prakash Shukla @ 2022-10-06  6:31 UTC (permalink / raw)
  To: Amit Prakash Shukla, Ruifeng Wang
  Cc: dev, Jerin Jacob Kollanukkaran, stable, Akhil Goyal, stephen

checkpatch complains about coding style error. It looks like a false positive ? 

Please suggest.

Thanks,
Amit Shukla

> -----Original Message-----
> From: Amit Prakash Shukla <amitprakashs@marvell.com>
> Sent: Friday, September 2, 2022 1:14 PM
> To: Ruifeng Wang <ruifeng.wang@arm.com>
> Cc: dev@dpdk.org; Jerin Jacob Kollanukkaran <jerinj@marvell.com>;
> stable@dpdk.org; Akhil Goyal <gakhil@marvell.com>;
> stephen@networkplumber.org; Amit Prakash Shukla
> <amitprakashs@marvell.com>
> Subject: [PATCH v2] examples: compilation fix for GCC-12
> 
> GCC-12 warns when a pointer of type union points to an array of same
> defined size, as union internally gets paded with pad bytes.
> 
> ../examples/common/neon/port_group.h:42:21: error: array subscript
> 	'union <anonymous>[0]' is partly outside array bounds of
> 	'uint16_t[5]' {aka 'short unsigned int[5]'}
> 	[-Werror=array-bounds]
>    42 |                 pnum->u64 = gptbl[v].pnum;
>       |                     ^~
> ../examples/common/neon/port_group.h:21:23: note: object 'pn' of
> 	size [0, 10]
>    21 | port_groupx4(uint16_t pn[FWDSTEP + 1], uint16_t *lp, uint16x8_t dp1
>       |              ~~~~~~~~~^~~~~~~~~~~~~~~
> ../examples/common/neon/port_group.h:43:21: error: array subscript
> 	'union <anonymous>[0]' is partly outside array bounds of
> 	'uint16_t[5]' {aka 'short unsigned int[5]'} [-Werror=array-bounds]
>    43 |                 pnum->u16[FWDSTEP] = 1;
>       |                     ^~
> 
> Fixes: bdfc3816fbfc ("examples: common packet group functionality")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Amit Prakash Shukla <amitprakashs@marvell.com>
> ---
> v2:
> - Changed to __rte_packed instead of direct attribute
> 
>  examples/common/neon/port_group.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/examples/common/neon/port_group.h
> b/examples/common/neon/port_group.h
> index 82c6ed6d73..04e5699f70 100644
> --- a/examples/common/neon/port_group.h
> +++ b/examples/common/neon/port_group.h
> @@ -24,7 +24,7 @@ port_groupx4(uint16_t pn[FWDSTEP + 1], uint16_t *lp,
> uint16x8_t dp1,
>  	union {
>  		uint16_t u16[FWDSTEP + 1];
>  		uint64_t u64;
> -	} *pnum = (void *)pn;
> +	} __rte_packed *pnum = (void *)pn;
> 
>  	uint16x8_t mask = {1, 2, 4, 8, 0, 0, 0, 0};
>  	int32_t v;
> --
> 2.25.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] examples: compilation fix for GCC-12
  2022-10-06  6:31   ` Amit Prakash Shukla
@ 2022-10-06  9:21     ` Thomas Monjalon
  0 siblings, 0 replies; 7+ messages in thread
From: Thomas Monjalon @ 2022-10-06  9:21 UTC (permalink / raw)
  To: Amit Prakash Shukla, Ruifeng Wang, stable
  Cc: dev, Jerin Jacob Kollanukkaran, stable, Akhil Goyal, stephen,
	Amit Prakash Shukla

06/10/2022 08:31, Amit Prakash Shukla:
> checkpatch complains about coding style error. It looks like a false positive ?

Yes we can ignore this checkpatch warning.



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] examples: compilation fix for GCC-12
  2022-09-02  7:43 ` [PATCH v2] " Amit Prakash Shukla
  2022-10-06  6:31   ` Amit Prakash Shukla
@ 2022-10-06  9:27   ` Thomas Monjalon
  1 sibling, 0 replies; 7+ messages in thread
From: Thomas Monjalon @ 2022-10-06  9:27 UTC (permalink / raw)
  To: Amit Prakash Shukla
  Cc: Ruifeng Wang, dev, jerinj, stable, gakhil, stephen, Rahul Bhansali

02/09/2022 09:43, Amit Prakash Shukla:
> GCC-12 warns when a pointer of type union points to an array of same
> defined size, as union internally gets paded with pad bytes.
> 
> ../examples/common/neon/port_group.h:42:21: error: array subscript
> 	'union <anonymous>[0]' is partly outside array bounds of
> 	'uint16_t[5]' {aka 'short unsigned int[5]'}
> 	[-Werror=array-bounds]
>    42 |                 pnum->u64 = gptbl[v].pnum;
>       |                     ^~
> ../examples/common/neon/port_group.h:21:23: note: object 'pn' of
> 	size [0, 10]
>    21 | port_groupx4(uint16_t pn[FWDSTEP + 1], uint16_t *lp, uint16x8_t dp1
>       |              ~~~~~~~~~^~~~~~~~~~~~~~~
> ../examples/common/neon/port_group.h:43:21: error: array subscript
> 	'union <anonymous>[0]' is partly outside array bounds of
> 	'uint16_t[5]' {aka 'short unsigned int[5]'} [-Werror=array-bounds]
>    43 |                 pnum->u16[FWDSTEP] = 1;
>       |                     ^~
> 
> Fixes: bdfc3816fbfc ("examples: common packet group functionality")

Should be:
Fixes: 732115ce38c6 ("examples/l3fwd: move packet group function in common")

> Cc: stable@dpdk.org
> 
> Signed-off-by: Amit Prakash Shukla <amitprakashs@marvell.com>

Applied, thanks.




^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-10-06  9:27 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-01  8:23 [PATCH] examples: compilation fix for GCC-12 Amit Prakash Shukla
2022-09-01 15:24 ` Stephen Hemminger
2022-09-02  7:19   ` [EXT] " Amit Prakash Shukla
2022-09-02  7:43 ` [PATCH v2] " Amit Prakash Shukla
2022-10-06  6:31   ` Amit Prakash Shukla
2022-10-06  9:21     ` Thomas Monjalon
2022-10-06  9:27   ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).