[v1] examples/ntb: fix build issue with GCC 13

Message ID 20230502135045.3541570-2-jerinj@marvell.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series [v1] examples/ntb: fix build issue with GCC 13 |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/github-robot: build success github build: passed
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-abi-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-unit-testing success Testing PASS
ci/intel-Testing success Testing PASS
ci/iol-testing warning Testing issues
ci/iol-x86_64-unit-testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/iol-broadcom-Functional fail Functional Testing issues

Commit Message

Jerin Jacob Kollanukkaran May 2, 2023, 1:50 p.m. UTC
  From: Jerin Jacob <jerinj@marvell.com>

Fix the following build issue by not allowing nb_ids to be zero.
nb_ids can be zero based on rte_rawdev_xstats_get() API
documentation but it is not valid for the case when second
argument is NULL.

examples/ntb/ntb_fwd.c: In function 'ntb_stats_display':
examples/ntb/ntb_fwd.c:945:23: error: 'rte_rawdev_xstats_get'
accessing 8 bytes in a region of size 0 [-Werror=stringop-overflow=]
  945 | if (nb_ids != rte_rawdev_xstats_get(dev_id, ids, values, nb_ids)) {
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

examples/ntb/ntb_fwd.c:945:23: note: referencing argument 3
of type 'uint64_t[0]' {aka 'long unsigned int[]'}
In file included from ../examples/ntb/ntb_fwd.c:17:
lib/rawdev/rte_rawdev.h:504:1: note: in a call to function
'rte_rawdev_xstats_get'
  504 | rte_rawdev_xstats_get(uint16_t dev_id,

Fixes: 5194299d6ef5 ("examples/ntb: support more functions")
Cc: stable@dpdk.org
Signed-off-by: Jerin Jacob <jerinj@marvell.com>
---
 examples/ntb/ntb_fwd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Ali Alnubani May 3, 2023, 8:37 a.m. UTC | #1
> -----Original Message-----
> From: jerinj@marvell.com <jerinj@marvell.com>
> Sent: Tuesday, May 2, 2023 4:51 PM
> To: dev@dpdk.org; Jingjing Wu <jingjing.wu@intel.com>; Junfeng Guo
> <junfeng.guo@intel.com>; Xiaoyun Li <xiaoyun.li@intel.com>
> Cc: NBU-Contact-Thomas Monjalon (EXTERNAL) <thomas@monjalon.net>;
> david.marchand@redhat.com; ferruh.yigit@xilinx.com;
> stephen@networkplumber.org; Jerin Jacob <jerinj@marvell.com>;
> stable@dpdk.org
> Subject: [dpdk-dev] [PATCH v1] examples/ntb: fix build issue with GCC 13
> 
> From: Jerin Jacob <jerinj@marvell.com>
> 
> Fix the following build issue by not allowing nb_ids to be zero.
> nb_ids can be zero based on rte_rawdev_xstats_get() API
> documentation but it is not valid for the case when second
> argument is NULL.
> 
> examples/ntb/ntb_fwd.c: In function 'ntb_stats_display':
> examples/ntb/ntb_fwd.c:945:23: error: 'rte_rawdev_xstats_get'
> accessing 8 bytes in a region of size 0 [-Werror=stringop-overflow=]
>   945 | if (nb_ids != rte_rawdev_xstats_get(dev_id, ids, values, nb_ids)) {
>       |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> examples/ntb/ntb_fwd.c:945:23: note: referencing argument 3
> of type 'uint64_t[0]' {aka 'long unsigned int[]'}
> In file included from ../examples/ntb/ntb_fwd.c:17:
> lib/rawdev/rte_rawdev.h:504:1: note: in a call to function
> 'rte_rawdev_xstats_get'
>   504 | rte_rawdev_xstats_get(uint16_t dev_id,
> 
> Fixes: 5194299d6ef5 ("examples/ntb: support more functions")
> Cc: stable@dpdk.org
> Signed-off-by: Jerin Jacob <jerinj@marvell.com>
> ---

Resolves the build failure for me on Fedora 38 with gcc 13.1.1.

Tested-by: Ali Alnubani <alialnu@nvidia.com>
  
Junfeng Guo May 4, 2023, 8:36 a.m. UTC | #2
> -----Original Message-----
> From: jerinj@marvell.com <jerinj@marvell.com>
> Sent: Tuesday, May 2, 2023 21:51
> To: dev@dpdk.org; Wu, Jingjing <jingjing.wu@intel.com>; Guo, Junfeng
> <junfeng.guo@intel.com>; Li, Xiaoyun <xiaoyun.li@intel.com>
> Cc: thomas@monjalon.net; david.marchand@redhat.com;
> ferruh.yigit@xilinx.com; stephen@networkplumber.org; Jerin Jacob
> <jerinj@marvell.com>; stable@dpdk.org
> Subject: [dpdk-dev] [PATCH v1] examples/ntb: fix build issue with GCC 13
> 
> From: Jerin Jacob <jerinj@marvell.com>
> 
> Fix the following build issue by not allowing nb_ids to be zero.
> nb_ids can be zero based on rte_rawdev_xstats_get() API
> documentation but it is not valid for the case when second
> argument is NULL.

Is this the new standard for GCC 13?

> 
> examples/ntb/ntb_fwd.c: In function 'ntb_stats_display':
> examples/ntb/ntb_fwd.c:945:23: error: 'rte_rawdev_xstats_get'
> accessing 8 bytes in a region of size 0 [-Werror=stringop-overflow=]
>   945 | if (nb_ids != rte_rawdev_xstats_get(dev_id, ids, values, nb_ids)) {
>       |
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> examples/ntb/ntb_fwd.c:945:23: note: referencing argument 3
> of type 'uint64_t[0]' {aka 'long unsigned int[]'}
> In file included from ../examples/ntb/ntb_fwd.c:17:
> lib/rawdev/rte_rawdev.h:504:1: note: in a call to function
> 'rte_rawdev_xstats_get'
>   504 | rte_rawdev_xstats_get(uint16_t dev_id,
> 
> Fixes: 5194299d6ef5 ("examples/ntb: support more functions")
> Cc: stable@dpdk.org
> Signed-off-by: Jerin Jacob <jerinj@marvell.com>
> ---
>  examples/ntb/ntb_fwd.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/examples/ntb/ntb_fwd.c b/examples/ntb/ntb_fwd.c
> index f9abed28e4..5489c3b3cd 100644
> --- a/examples/ntb/ntb_fwd.c
> +++ b/examples/ntb/ntb_fwd.c
> @@ -923,7 +923,7 @@ ntb_stats_display(void)
> 
>  	/* Get NTB dev stats and stats names */
>  	nb_ids = rte_rawdev_xstats_names_get(dev_id, NULL, 0);
> -	if (nb_ids  < 0) {
> +	if (nb_ids <= 0) {

Should the one in func ntb_stats_clear also be updated non-zero?

>  		printf("Error: Cannot get count of xstats\n");
>  		return;
>  	}
> --
> 2.40.1
  
Jerin Jacob May 4, 2023, 8:46 a.m. UTC | #3
On Thu, May 4, 2023 at 2:06 PM Guo, Junfeng <junfeng.guo@intel.com> wrote:
>
>
>
> > -----Original Message-----
> > From: jerinj@marvell.com <jerinj@marvell.com>
> > Sent: Tuesday, May 2, 2023 21:51
> > To: dev@dpdk.org; Wu, Jingjing <jingjing.wu@intel.com>; Guo, Junfeng
> > <junfeng.guo@intel.com>; Li, Xiaoyun <xiaoyun.li@intel.com>
> > Cc: thomas@monjalon.net; david.marchand@redhat.com;
> > ferruh.yigit@xilinx.com; stephen@networkplumber.org; Jerin Jacob
> > <jerinj@marvell.com>; stable@dpdk.org
> > Subject: [dpdk-dev] [PATCH v1] examples/ntb: fix build issue with GCC 13
> >
> > From: Jerin Jacob <jerinj@marvell.com>
> >
> > Fix the following build issue by not allowing nb_ids to be zero.
> > nb_ids can be zero based on rte_rawdev_xstats_get() API
> > documentation but it is not valid for the case when second
> > argument is NULL.
>
> Is this the new standard for GCC 13?

No. Looks like optimization from compiler. It is able to detect their
case for zero memory allocation.

>
> >
> > examples/ntb/ntb_fwd.c: In function 'ntb_stats_display':
> > examples/ntb/ntb_fwd.c:945:23: error: 'rte_rawdev_xstats_get'
> > accessing 8 bytes in a region of size 0 [-Werror=stringop-overflow=]
> >   945 | if (nb_ids != rte_rawdev_xstats_get(dev_id, ids, values, nb_ids)) {
> >       |
> > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> >
> > examples/ntb/ntb_fwd.c:945:23: note: referencing argument 3
> > of type 'uint64_t[0]' {aka 'long unsigned int[]'}
> > In file included from ../examples/ntb/ntb_fwd.c:17:
> > lib/rawdev/rte_rawdev.h:504:1: note: in a call to function
> > 'rte_rawdev_xstats_get'
> >   504 | rte_rawdev_xstats_get(uint16_t dev_id,
> >
> > Fixes: 5194299d6ef5 ("examples/ntb: support more functions")
> > Cc: stable@dpdk.org
> > Signed-off-by: Jerin Jacob <jerinj@marvell.com>
> > ---
> >  examples/ntb/ntb_fwd.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/examples/ntb/ntb_fwd.c b/examples/ntb/ntb_fwd.c
> > index f9abed28e4..5489c3b3cd 100644
> > --- a/examples/ntb/ntb_fwd.c
> > +++ b/examples/ntb/ntb_fwd.c
> > @@ -923,7 +923,7 @@ ntb_stats_display(void)
> >
> >       /* Get NTB dev stats and stats names */
> >       nb_ids = rte_rawdev_xstats_names_get(dev_id, NULL, 0);
> > -     if (nb_ids  < 0) {
> > +     if (nb_ids <= 0) {
>
> Should the one in func ntb_stats_clear also be updated non-zero?

Some reason compiler is not detecting it. I will fix in next version.


>
> >               printf("Error: Cannot get count of xstats\n");
> >               return;
> >       }
> > --
> > 2.40.1
>
  

Patch

diff --git a/examples/ntb/ntb_fwd.c b/examples/ntb/ntb_fwd.c
index f9abed28e4..5489c3b3cd 100644
--- a/examples/ntb/ntb_fwd.c
+++ b/examples/ntb/ntb_fwd.c
@@ -923,7 +923,7 @@  ntb_stats_display(void)
 
 	/* Get NTB dev stats and stats names */
 	nb_ids = rte_rawdev_xstats_names_get(dev_id, NULL, 0);
-	if (nb_ids  < 0) {
+	if (nb_ids <= 0) {
 		printf("Error: Cannot get count of xstats\n");
 		return;
 	}