DPDK patches and discussions
 help / color / mirror / Atom feed
From: <jerinj@marvell.com>
To: <dev@dpdk.org>, Jingjing Wu <jingjing.wu@intel.com>,
	Junfeng Guo <junfeng.guo@intel.com>,
	Xiaoyun Li <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
Date: Thu, 4 May 2023 14:23:37 +0530	[thread overview]
Message-ID: <20230504085337.3446264-1-jerinj@marvell.com> (raw)
In-Reply-To: <20230502135045.3541570-2-jerinj@marvell.com>

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)
 
 	/* 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;
 	}
-- 
2.40.1


  parent reply	other threads:[~2023-05-04  8:53 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-02 13:50 [dpdk-dev] [PATCH v1] examples/ip_pipeline: " jerinj
2023-05-02 13:50 ` [dpdk-dev] [PATCH v1] examples/ntb: " jerinj
2023-05-03  8:37   ` Ali Alnubani
2023-05-04  8:36   ` Guo, Junfeng
2023-05-04  8:46     ` Jerin Jacob
2023-05-04  8:53   ` jerinj [this message]
2023-05-04  9:07     ` [dpdk-dev] [PATCH v2] " Guo, Junfeng
2023-05-11  6:54     ` Gao, DaxueX
2023-05-11  7:02     ` David Marchand
2023-05-02 14:54 ` [dpdk-dev] [PATCH v1] examples/ip_pipeline: " Dumitrescu, Cristian
2023-05-11  6:51 ` Gao, DaxueX
2023-05-11  7:01 ` David Marchand

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=20230504085337.3446264-1-jerinj@marvell.com \
    --to=jerinj@marvell.com \
    --cc=alialnu@nvidia.com \
    --cc=david.marchand@redhat.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@amd.com \
    --cc=jingjing.wu@intel.com \
    --cc=junfeng.guo@intel.com \
    --cc=stable@dpdk.org \
    --cc=thomas@monjalon.net \
    --cc=xiaoyun.li@intel.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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).