All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: Bruce Richardson <bruce.richardson@intel.com>
Cc: dev@dpdk.org, cheng1.jiang@intel.com, stable@dpdk.org,
	"Cheng Jiang" <honest.jiang@foxmail.com>,
	"Chengwen Feng" <fengchengwen@huawei.com>,
	"Yuan Wang" <yuanx.wang@intel.com>,
	"Morten Brørup" <mb@smartsharesystems.com>,
	"Jiayu Hu" <hujiayu.hu@foxmail.com>
Subject: Re: [PATCH v2 10/10] app/test-dma-perf: fix parsing of DMA address
Date: Fri, 15 Nov 2024 11:58:47 -0800	[thread overview]
Message-ID: <20241115115847.062e99fa@hermes.local> (raw)
In-Reply-To: <ZzcQqGq2gD60EBuS@bricha3-mobl1.ger.corp.intel.com>

On Fri, 15 Nov 2024 09:13:12 +0000
Bruce Richardson <bruce.richardson@intel.com> wrote:

> On Thu, Nov 14, 2024 at 11:25:08AM -0800, Stephen Hemminger wrote:
> > There was useless loop when looking at the DMA address.
> > It looks like it was meant to skip whitespace before
> > calling strtok.
> > 
> > Good time to replace strtok with strtok_r as well.
> > 
> > Link: https://pvs-studio.com/en/blog/posts/cpp/1179/
> > 
> > Fixes: 623dc9364dc6 ("app/dma-perf: introduce DMA performance test")
> > Cc: cheng1.jiang@intel.com
> > Cc: stable@dpdk.org
> > 
> > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>  
> 
> One comment inline below. With that fixed:
> 
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
> 
> > ---
> >  app/test-dma-perf/main.c | 12 ++++++------
> >  1 file changed, 6 insertions(+), 6 deletions(-)
> > 
> > diff --git a/app/test-dma-perf/main.c b/app/test-dma-perf/main.c
> > index 18219918cc..dccb0a3541 100644
> > --- a/app/test-dma-perf/main.c
> > +++ b/app/test-dma-perf/main.c
> > @@ -217,27 +217,27 @@ parse_lcore_dma(struct test_configure *test_case, const char *value)
> >  	struct lcore_dma_map_t *lcore_dma_map;
> >  	char *input, *addrs;
> >  	char *ptrs[2];
> > -	char *start, *end, *substr;
> > +	char *start, *end, *substr, *saveptr;
> >  	uint16_t lcore_id;
> >  	int ret = 0;
> >  
> >  	if (test_case == NULL || value == NULL)
> >  		return -1;
> >  
> > -	input = strndup(value, strlen(value) + 1);
> > +	input = strdup(value);
> >  	if (input == NULL)
> >  		return -1;
> > -	addrs = input;
> >  
> > -	while (*addrs == '\0')
> > -		addrs++;
> > +	addrs = input;
> > +	while (isspace(*addrs))
> > +		++addrs;
> >  	if (*addrs == '\0') {
> >  		fprintf(stderr, "No input DMA addresses\n");
> >  		ret = -1;
> >  		goto out;
> >  	}
> >  
> > -	substr = strtok(addrs, ",");
> > +	substr = strtok_r(addrs, ",", &saveptr);  
> 
> Don't need to use strtok here at all. Just use strchr, and then no need for
> a new temporary variable.

The issue is that the test is passing each comma seperated section to rte_strsplit
and that needs the first part to be null terminated.
But using strtok_r in only one spot is wrong, will fix.

  reply	other threads:[~2024-11-15 19:58 UTC|newest]

Thread overview: 69+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-14  0:12 [RFC 00/10] unit test bugs Stephen Hemminger
2024-11-14  0:12 ` [RFC 01/10] app/test: do not duplicate loop variable Stephen Hemminger
2024-11-14  0:12 ` [RFC 02/10] app/test: fix typo in mac address compare Stephen Hemminger
2024-11-14  0:12 ` [RFC 03/10] app/test: fix paren typo Stephen Hemminger
2024-11-14  0:12 ` [RFC 04/10] app/test: avoid duplicate initialization Stephen Hemminger
2024-11-14  0:12 ` [RFC 05/10] app/test: fix TLS zero length record Stephen Hemminger
2024-11-14  0:12 ` [RFC 06/10] test/eal: fix core check in c flag test Stephen Hemminger
2024-11-14  0:12 ` [RFC 07/10] app/test-pmd: remove redundant condition Stephen Hemminger
2024-11-14  0:12 ` [RFC 08/10] app/test-pmd: avoid potential outside of array reference Stephen Hemminger
2024-11-14  0:12 ` [RFC 09/10] app/test-dma-perf: fix parsing of dma address Stephen Hemminger
2024-11-14  7:00   ` Morten Brørup
2024-11-14 16:21     ` Stephen Hemminger
2024-11-15  7:19   ` fengchengwen
2024-11-14  0:12 ` [RFC 10/10] app/test: fix operator precedence bug Stephen Hemminger
2024-11-14 19:24 ` [PATCH v2 00/10] Bug fixes for unit tests Stephen Hemminger
2024-11-14 19:24   ` [PATCH v2 01/10] app/test: do not duplicated loop variable Stephen Hemminger
2024-11-15  9:01     ` Bruce Richardson
2024-11-14 19:25   ` [PATCH v2 02/10] app/test: fix typo in address compare Stephen Hemminger
2024-11-14 19:25   ` [PATCH v2 03/10] app/test: fix paren typo Stephen Hemminger
2024-11-15  9:02     ` Bruce Richardson
2024-11-14 19:25   ` [PATCH v2 04/10] app/test: avoid duplicate initialization Stephen Hemminger
2024-11-15  9:03     ` Bruce Richardson
2024-11-14 19:25   ` [PATCH v2 05/10] app/test: fix TLS zero length record Stephen Hemminger
2024-11-14 19:25   ` [PATCH v2 06/10] app/test: fix operator precedence bug Stephen Hemminger
2024-11-15  9:06     ` Bruce Richardson
2024-11-14 19:25   ` [PATCH v2 07/10] test/eal: fix core check in c flag test Stephen Hemminger
2024-11-15  9:07     ` Bruce Richardson
2024-11-15 19:53       ` Stephen Hemminger
2024-11-14 19:25   ` [PATCH v2 08/10] app/test-pmd: remove redundant condition Stephen Hemminger
2024-11-14 19:27     ` Ajit Khaparde
2024-11-15  9:08     ` Bruce Richardson
2024-11-14 19:25   ` [PATCH v2 09/10] app/test-pmd: avoid potential outside of array reference Stephen Hemminger
2024-11-15  9:09     ` Bruce Richardson
2024-11-14 19:25   ` [PATCH v2 10/10] app/test-dma-perf: fix parsing of DMA address Stephen Hemminger
2024-11-15  9:13     ` Bruce Richardson
2024-11-15 19:58       ` Stephen Hemminger [this message]
2024-11-15 20:06 ` [PATCH v3 00/10] bug fixes for unit tests Stephen Hemminger
2024-11-15 20:06   ` [PATCH v3 01/10] app/test: do not duplicate loop variable Stephen Hemminger
2024-11-15 20:06   ` [PATCH v3 02/10] app/test: fix typo in address compare Stephen Hemminger
2024-11-15 20:06   ` [PATCH v3 03/10] app/test: fix paren typo Stephen Hemminger
2024-11-15 20:06   ` [PATCH v3 04/10] app/test: avoid duplicate initialization Stephen Hemminger
2024-11-18  4:49     ` Gujjar, Abhinandan S
2024-11-15 20:06   ` [PATCH v3 05/10] app/test: fix TLS zero length record Stephen Hemminger
2024-11-15 20:06   ` [PATCH v3 06/10] app/test: fix operator precedence bug Stephen Hemminger
2024-11-15 20:06   ` [PATCH v3 07/10] test/eal: fix core check in c flag test Stephen Hemminger
2024-11-15 20:06   ` [PATCH v3 08/10] app/test-pmd: remove redundant condition Stephen Hemminger
2024-11-15 20:52     ` Ajit Khaparde
2024-11-15 20:06   ` [PATCH v3 09/10] app/test-pmd: avoid potential outside of array reference Stephen Hemminger
2024-11-15 20:06   ` [PATCH v3 10/10] app/test-dma-perf: fix parsing of DMA address Stephen Hemminger
2024-11-18  2:44     ` fengchengwen
2024-11-21 18:23 ` [PATCH v4 0/9] Bug fixes for standalone tests Stephen Hemminger
2024-11-21 18:23   ` [PATCH v4 1/9] app/test: do not duplicate loop variable Stephen Hemminger
2024-11-22  0:39     ` fengchengwen
2024-11-21 18:23   ` [PATCH v4 2/9] app/test: fix typo in address compare Stephen Hemminger
2024-11-22  0:37     ` fengchengwen
2024-11-22  8:54     ` Bruce Richardson
2024-11-21 18:23   ` [PATCH v4 3/9] app/test: fix paren typo Stephen Hemminger
2024-11-22  0:34     ` fengchengwen
2024-11-21 18:23   ` [PATCH v4 4/9] app/test: avoid duplicate initialization Stephen Hemminger
2024-11-21 18:23   ` [PATCH v4 5/9] app/test: fix TLS zero length record Stephen Hemminger
2024-11-22  7:22     ` [EXTERNAL] " Anoob Joseph
2024-11-21 18:23   ` [PATCH v4 6/9] app/test: fix operator precedence bug Stephen Hemminger
2024-11-21 18:23   ` [PATCH v4 7/9] test/eal: fix core check in c flag test Stephen Hemminger
2024-11-26 17:13     ` Aaron Conole
2024-11-21 18:23   ` [PATCH v4 8/9] app/test-pmd: remove redundant condition Stephen Hemminger
2024-11-22  0:33     ` fengchengwen
2024-11-21 18:23   ` [PATCH v4 9/9] app/test-pmd: avoid potential outside of array reference Stephen Hemminger
2024-11-22  0:33     ` fengchengwen
2024-11-26 22:33   ` [PATCH v4 0/9] Bug fixes for standalone tests Thomas Monjalon

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=20241115115847.062e99fa@hermes.local \
    --to=stephen@networkplumber.org \
    --cc=bruce.richardson@intel.com \
    --cc=cheng1.jiang@intel.com \
    --cc=dev@dpdk.org \
    --cc=fengchengwen@huawei.com \
    --cc=honest.jiang@foxmail.com \
    --cc=hujiayu.hu@foxmail.com \
    --cc=mb@smartsharesystems.com \
    --cc=stable@dpdk.org \
    --cc=yuanx.wang@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.