From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 73B2C45D16; Fri, 15 Nov 2024 20:58:51 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0E08D40615; Fri, 15 Nov 2024 20:58:51 +0100 (CET) Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) by mails.dpdk.org (Postfix) with ESMTP id 7B029402C4 for ; Fri, 15 Nov 2024 20:58:50 +0100 (CET) Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-71e4e481692so24959b3a.1 for ; Fri, 15 Nov 2024 11:58:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1731700729; x=1732305529; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=1DFbwDVy99A/ekMgH4MB8129fIPEq8KRQ8OmICSSx4U=; b=wuuIrzR/FvFsEoXuvPwhgDFLqlZoWik/L9VXShyIlDkJ3OKbeN9IZ3jAUvVoTjq836 fsc3jUTeUh7oJTawW51KbtShJQwoAjYcoaQCZ65JuvN1/41HJHvdA6a4ZUKe6LpgDgbF JVntGttVOQF6Jimj39St2c6QmN87i4mVlkhPhBAL8ocYX3DDJo40zLjcTXCZxwLYiu/p hZGG31hNDGq/lX01OCyXRphxxnWM+EE7I1LPB07LwtPaZH1ty8WqyNvyhzGLkGeo1dWi XFWmxbtBulP7EU7kPsDmRfX0mfi0iz4kUEWD2tKALCS86GFV/xF7hbcfl6pUiNCLenFY 9QhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731700729; x=1732305529; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1DFbwDVy99A/ekMgH4MB8129fIPEq8KRQ8OmICSSx4U=; b=hgYfF8UxHyBU14OGSJDCX2Vi7TZyEZkPoqx9MkmQLHM6AgN5eEzMNMcazeEBUsO0S1 wLZLI8cvwC+fLxwnCR6q9UwupOtt5KuIztSNC55A/AUQSH9Qg/427kuvYImEn7eXPrG8 hpo0QkibOg42PPXIJeP3MmTr4ccM9cVtW7T6+TnjgnC/bmsctmalj67C+OLftt23iM2y TRJRr1BPApqrjWGBvqP+hJBPZekHBQ7piDV1QNe5GFRLgNbpySy0Me6EJycMGq5nX/7F A2kHoi4nACQTEmXmeYW2P7iMMePvxtQAyzmntqE7m645KV/yjqCR/TVhSztIz5Q43a0O pNuw== X-Gm-Message-State: AOJu0YzKpm5ASZp3yi4rCU/3hb6EYVui/CGtuIoVaa1Od+XXCz4vZOp4 SVdFL+dQPmIaJZ0kpSXA3tqUAdDqe+FFAA2ZvIlw8Aab8ZSA6mPGee2TExjiTio= X-Google-Smtp-Source: AGHT+IETC+SIGZcBsNl89B7t7trYq37CkokVkQFG6MHm4ySXx6wvD+FL92rsgC+PcQhBcyNA7HyHwg== X-Received: by 2002:a05:6a00:1902:b0:724:6bac:1003 with SMTP id d2e1a72fcca58-7247709df42mr5622591b3a.24.1731700729454; Fri, 15 Nov 2024 11:58:49 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7f8c1c2c505sm1661259a12.18.2024.11.15.11.58.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Nov 2024 11:58:49 -0800 (PST) Date: Fri, 15 Nov 2024 11:58:47 -0800 From: Stephen Hemminger To: Bruce Richardson Cc: , , , Cheng Jiang , Chengwen Feng , "Yuan Wang" , Morten =?UTF-8?B?QnLDuHJ1cA==?= , Jiayu Hu Subject: Re: [PATCH v2 10/10] app/test-dma-perf: fix parsing of DMA address Message-ID: <20241115115847.062e99fa@hermes.local> In-Reply-To: References: <20241114001403.147609-1-stephen@networkplumber.org> <20241114192603.41145-1-stephen@networkplumber.org> <20241114192603.41145-11-stephen@networkplumber.org> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On Fri, 15 Nov 2024 09:13:12 +0000 Bruce Richardson 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 > > One comment inline below. With that fixed: > > Acked-by: Bruce Richardson > > > --- > > 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.