[v2] examples/ntb: fix build issue with GCC 13
Checks
Commit Message
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>
Tested-by: Ali Alnubani <alialnu@nvidia.com>
---
v2:
- Apply the same fix for ntb_stats_clear()(Junfeng)
examples/ntb/ntb_fwd.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Comments
> -----Original Message-----
> From: jerinj@marvell.com <jerinj@marvell.com>
> Sent: Thursday, May 4, 2023 16:54
> 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@amd.com; Jerin Jacob <jerinj@marvell.com>;
> stable@dpdk.org; Ali Alnubani <alialnu@nvidia.com>
> Subject: [dpdk-dev] [PATCH v2] 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>
> Tested-by: Ali Alnubani <alialnu@nvidia.com>
> ---
> v2:
> - Apply the same fix for ntb_stats_clear()(Junfeng)
>
> examples/ntb/ntb_fwd.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/examples/ntb/ntb_fwd.c b/examples/ntb/ntb_fwd.c
> index f9abed28e4..585aad9d70 100644
> --- a/examples/ntb/ntb_fwd.c
> +++ b/examples/ntb/ntb_fwd.c
> @@ -865,7 +865,7 @@ ntb_stats_clear(void)
> --
> 2.40.1
LGTM, it makes sense to avoid zero memory allocation. Thanks!
Acked-by: Junfeng Guo <junfeng.guo@intel.com>
Regards,
Junfeng Guo
> -----Original Message-----
> From: jerinj@marvell.com <jerinj@marvell.com>
> Sent: 2023年5月4日 16:54
> 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@amd.com; Jerin Jacob <jerinj@marvell.com>; stable@dpdk.org; Ali
> Alnubani <alialnu@nvidia.com>
> Subject: [dpdk-dev] [PATCH v2] 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>
> Tested-by: Ali Alnubani <alialnu@nvidia.com>
Tested-by: Daxue Gao <daxuex.gao@intel.com>
On Thu, May 4, 2023 at 10:54 AM <jerinj@marvell.com> wrote:
>
> 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>
> Tested-by: Ali Alnubani <alialnu@nvidia.com>
Acked-by: Junfeng Guo <junfeng.guo@intel.com>
Tested-by: Daxue Gao <daxuex.gao@intel.com>
Applied, thanks.
@@ -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;
}
@@ -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;
}