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 AB40845CFB; Thu, 14 Nov 2024 01:15:08 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0319C427B9; Thu, 14 Nov 2024 01:14:29 +0100 (CET) Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172]) by mails.dpdk.org (Postfix) with ESMTP id B0B8D42790 for ; Thu, 14 Nov 2024 01:14:25 +0100 (CET) Received: by mail-pg1-f172.google.com with SMTP id 41be03b00d2f7-7f71f2b1370so82130a12.1 for ; Wed, 13 Nov 2024 16:14:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1731543265; x=1732148065; darn=dpdk.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mxSvc4SXeQxe/dCjsahCvAyYTWz2KYw3MydtzQcZeGM=; b=MRXQ/EpGQC6NH3PXo84gVUuxWNXpwJQ6C3pk0AKB4+Oggdm5B1tnCJpCSNDrPdQV9J vgvp47FuFW+vF62M4M4y8V8OIi4fWt9/eKFWqhr4indv5SMbGKvnGcEEIi+Mwf1L3vT/ N6GAFPRKs7RrMuSVD+uEXvyaOUrqYBDRaZeJlLcet33rtkpAPfUcGOgy+5Zck0cDygDb 4JvqrmlBV+JfnfEc0j4AhB4AH5TbB8Oc5ZhVe6l2JQvrPqBwoSr0KoSaXsMWBfzGN2I2 ITdJXeCnd8z0Abw+5/koBzdxJqUj5yKTwtouweOxJsZR5/qk59tiD7KENRZ54AY49vj1 bwiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731543265; x=1732148065; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mxSvc4SXeQxe/dCjsahCvAyYTWz2KYw3MydtzQcZeGM=; b=ZOPzlax2Kjmq5+4GuyuTJlBM8eXPxBF5p0MuDOb6swWTlb5KyD4VDz3IboCO9UkY4t 39752FR+MmkVjVUV4ELMTGjzmpYCoW+PX9QeUsm35HtAC3Re1+zpMK47ZqoCRXr8kHvf h/I+SkkG5CPKYU4wJZ16BWcUWsoVZ9XwEVF/nJJF5Kcyi712mLOM7iKwvDECRkRG3Gig kB/bVPkCGG+LS0CwJF1iPIXlJCoJni5plLIxr5G4XSWAYoip/GWTvj6y09mVS8YFx81r CR5LTfQ0cpJ9s5ILs+JXMH2J4gBP5pL1+X+cuoANMVCDMHFyX2ZUgpwOaZd7LP7TsATu QdCA== X-Gm-Message-State: AOJu0YzZCwHJIHCVzcTzVK2DYoM2Z93WtZPGajeWoptUHEuZNgE5tjpf CU6oO0sLMAi+RHIty27iF3GRYR20DI7IR+JczTyOjAGXLG3bGUzbL2MoKYamNtJ7Um/DXudsbA6 Q X-Google-Smtp-Source: AGHT+IFagRzNlxgBVm6CJLeZd8+8MvkpZ8VzyxTPMwR+6Ml9W2pH533NPdUle+8ECd7DRg1W1kvSsw== X-Received: by 2002:a17:902:d541:b0:20c:cd14:a7f3 with SMTP id d9443c01a7336-211ab9503aamr117948085ad.22.1731543264921; Wed, 13 Nov 2024 16:14:24 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7246a9a81a9sm9280b3a.99.2024.11.13.16.14.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Nov 2024 16:14:24 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , cheng1.jiang@intel.com, Cheng Jiang , Chengwen Feng , Jiayu Hu , =?UTF-8?q?Morten=20Br=C3=B8rup?= , Anoob Joseph , Chenbo Xia Subject: [RFC 09/10] app/test-dma-perf: fix parsing of dma address Date: Wed, 13 Nov 2024 16:12:21 -0800 Message-ID: <20241114001403.147609-10-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241114001403.147609-1-stephen@networkplumber.org> References: <20241114001403.147609-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 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 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; -- 2.45.2