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 4A1F045D0D; Fri, 15 Nov 2024 08:19:24 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D12BC402B5; Fri, 15 Nov 2024 08:19:23 +0100 (CET) Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by mails.dpdk.org (Postfix) with ESMTP id 322A8402B5 for ; Fri, 15 Nov 2024 08:19:21 +0100 (CET) Received: from mail.maildlp.com (unknown [172.19.88.105]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4XqSyZ1YN2zpZcC; Fri, 15 Nov 2024 15:17:26 +0800 (CST) Received: from kwepemk500009.china.huawei.com (unknown [7.202.194.94]) by mail.maildlp.com (Postfix) with ESMTPS id 8275B1400D4; Fri, 15 Nov 2024 15:19:18 +0800 (CST) Received: from [10.67.121.161] (10.67.121.161) by kwepemk500009.china.huawei.com (7.202.194.94) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.11; Fri, 15 Nov 2024 15:19:17 +0800 Message-ID: <71f3e4eb-2049-445c-a57a-838a15797d50@huawei.com> Date: Fri, 15 Nov 2024 15:19:17 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC 09/10] app/test-dma-perf: fix parsing of dma address To: Stephen Hemminger , CC: , Cheng Jiang , Jiayu Hu , =?UTF-8?Q?Morten_Br=C3=B8rup?= , Anoob Joseph , Chenbo Xia References: <20241114001403.147609-1-stephen@networkplumber.org> <20241114001403.147609-10-stephen@networkplumber.org> Content-Language: en-US From: fengchengwen In-Reply-To: <20241114001403.147609-10-stephen@networkplumber.org> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.121.161] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemk500009.china.huawei.com (7.202.194.94) 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 2024/11/14 8:12, 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. Incomplete modification for strtok, I suggest the strtok adopt HaiJie's patchset [1], This commit just modify non-strtok logic. [1] https://inbox.dpdk.org/dev/20241108110404.18317-6-haijie1@huawei.com/ > > Link: https://pvs-studio.com/en/blog/posts/cpp/1179/ > > Fixes: 623dc9364dc6 ("app/dma-perf: introduce DMA performance test") > Cc: cheng1.jiang@intel.com > > Signed-off-by: Stephen Hemminger > --- > app/test-dma-perf/main.c | 9 ++++----- > 1 file changed, 4 insertions(+), 5 deletions(-) > > diff --git a/app/test-dma-perf/main.c b/app/test-dma-perf/main.c > index 18219918cc..dabf4e02e6 100644 > --- a/app/test-dma-perf/main.c > +++ b/app/test-dma-perf/main.c > @@ -217,19 +217,18 @@ 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') > + while (*addrs == '\0' && isspace(*addrs)) > addrs++; > if (*addrs == '\0') { > fprintf(stderr, "No input DMA addresses\n"); > @@ -237,7 +236,7 @@ parse_lcore_dma(struct test_configure *test_case, const char *value) > goto out; > } > > - substr = strtok(addrs, ","); > + substr = strtok_r(addrs, ",", &saveptr); > if (substr == NULL) { > fprintf(stderr, "No input DMA address\n"); > ret = -1;