Skip to content

Commit

Permalink
examples/ntb: fix build with GCC 13
Browse files Browse the repository at this point in the history
[ upstream commit dbff181d62c997f128b75db2bbac9f42e8dd0f8f ]

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: 5194299 ("examples/ntb: support more functions")

Signed-off-by: Jerin Jacob <jerinj@marvell.com>
Tested-by: Ali Alnubani <alialnu@nvidia.com>
Acked-by: Junfeng Guo <junfeng.guo@intel.com>
Tested-by: Daxue Gao <daxuex.gao@intel.com>
  • Loading branch information
jerinjacobk authored and kevintraynor committed Jul 11, 2023
1 parent 43a3d77 commit 27f385c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions examples/ntb/ntb_fwd.c
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ ntb_stats_clear(void)

/* Clear NTB dev stats */
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;
}
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 27f385c

Please sign in to comment.