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 29B2945CC3; Thu, 14 Nov 2024 20:27:18 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id D77CB42F08; Thu, 14 Nov 2024 20:26:32 +0100 (CET) Received: from mail-oa1-f45.google.com (mail-oa1-f45.google.com [209.85.160.45]) by mails.dpdk.org (Postfix) with ESMTP id 9BB4542F2F for ; Thu, 14 Nov 2024 20:26:26 +0100 (CET) Received: by mail-oa1-f45.google.com with SMTP id 586e51a60fabf-296252514c2so361728fac.3 for ; Thu, 14 Nov 2024 11:26:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1731612386; x=1732217186; 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=z03DVpzi2c0vE+sw2ZtTP7X5ulmiPT+u/9kU1AhllOY=; b=Rqf8IXUODe5h4Wg/csJqQV+oAUrRBUIYCpNjcqXElZtxL3if+lIUe++mKcue/RI9Nz fUcUZVjk91msLTVhK6Ly2KrLih1zgPAnX2aXdQHA9oRU4M8DlmOV3HGcZyngcWk7Deac a8YYS4cP3FrrE/FenxqVkIjOx6Gtdl571WWYqWIe6RbgmpDpBggejT4d7OuK8QJ5igSe FE98F1viscbKAdlrqRniOOtD02Qr3wcMiLcIxG1mlerXTqPrNkNRhwYF2ZxlhsUSYCuB Hkdg3Ph1TYasohzpRPujSMOwQsEyASDH2lojIsuBYftq70TYHll5PgzPJGriRlSXPH5C g9Dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731612386; x=1732217186; 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=z03DVpzi2c0vE+sw2ZtTP7X5ulmiPT+u/9kU1AhllOY=; b=QSX0JS5OgNd+laQVGRLEAfBllOHVMI+1bAmcwKHuhdZOi0N4Xs2RQ5Grm6Ixc4JRko qwcVWFh3BZ6pW7dyToStzZxLPLJP9KQ13hJxuczEOY+XB/ZmYWtatlF/y8KtyW12fRAK CZPVRCck+LLoG7/0Oj2FZi21LbqXI74LecrULOgnf0/888WeQ9ce8++hP+N/PBezCaso 7QfaBE4fJsZhJrj/AVvGFUdALCeA0e9E5PB7fXh41jLTacV9JMs+UrZRk/+wvI4ukcOH 9Jj1o++dizDTPNUq6kZ4WVJE5PZwKBnMSTq3AiBbJtSQcOpgZQwD46YmnwfTPlQyzkQg ftRA== X-Gm-Message-State: AOJu0Yz3wqUrEGF0VqlB5WHEPU1homxewKL6jDnSD6pR5JpZ3lJlzKTi 8MdWy9gkt5NEln1fL3+/tnKgoBpYqSzs0Kn+jXrloXKsBc6rtxcvkBiHypnfrkOYZVQphVwqR+s gtPQ= X-Google-Smtp-Source: AGHT+IEgt4G8fRXHlwVNB+d+HSxi5cGvhPPDDZPUcWnvoZWxaiB99z6RkCTFJT3awHmktsm9a5s36Q== X-Received: by 2002:a05:6871:e00a:b0:278:245d:cde7 with SMTP id 586e51a60fabf-295e903e15fmr8032534fac.36.1731612385946; Thu, 14 Nov 2024 11:26:25 -0800 (PST) Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7f8b37f3466sm1461632a12.35.2024.11.14.11.26.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Nov 2024 11:26:25 -0800 (PST) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , cheng1.jiang@intel.com, stable@dpdk.org, Cheng Jiang , Chengwen Feng , Yuan Wang , =?UTF-8?q?Morten=20Br=C3=B8rup?= , Jiayu Hu Subject: [PATCH v2 10/10] app/test-dma-perf: fix parsing of DMA address Date: Thu, 14 Nov 2024 11:25:08 -0800 Message-ID: <20241114192603.41145-11-stephen@networkplumber.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241114192603.41145-1-stephen@networkplumber.org> References: <20241114001403.147609-1-stephen@networkplumber.org> <20241114192603.41145-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 Cc: stable@dpdk.org Signed-off-by: Stephen Hemminger --- 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); if (substr == NULL) { fprintf(stderr, "No input DMA address\n"); ret = -1; -- 2.45.2