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 AB27C45CC3 for ; Thu, 14 Nov 2024 20:26:40 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 54E3842F59; Thu, 14 Nov 2024 20:26:34 +0100 (CET) Received: from mail-oa1-f51.google.com (mail-oa1-f51.google.com [209.85.160.51]) by mails.dpdk.org (Postfix) with ESMTP id 9A97142F2D for ; Thu, 14 Nov 2024 20:26:26 +0100 (CET) Received: by mail-oa1-f51.google.com with SMTP id 586e51a60fabf-28854674160so429419fac.2 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=kjVeuCBF5fkrRMa114aLzvDLuGY87rmSa1dvijxo1YXsGYFHisA+dUhayGDY3xnAfb lw16hta2qn9mv+18kFoItFyHfJwoM0CY3Ste4OayZbsHDeZbSDS+PNU6pGdqknE7lOcu T9/hyeFeU17JJUIJcOJlU98c67g3nv93FWkCQl0CgilaId02OIQnWEgepFRc17JP3UNB eqLwZgQmkOK5JVWXUffMS/HoMuLl58CwvIFrRrrykVm/qkoi3ySwQNp+txdMXqUKLccQ QudWGBle56bxAHUpjqeDN0Xva310rqCEh/uMbmy/cZKMwZaWH6hRXkVoYp9d8d7DlNcp ZY8w== X-Forwarded-Encrypted: i=1; AJvYcCUcQ89I7b7SvTQTXXmNK8HGk9DfPBRWcpdMp7M0pLtCHS6ALBKYFgBBFE3WpLXZOx+jj00OryE=@dpdk.org X-Gm-Message-State: AOJu0YyAG6Kh2nz51SR1mEtYOjXeKvOeNt2U1ZQ9w8zzMi6N2bUnNDd3 PAiqziHWvxwQ++Tp5cG+3YrknXtgNqPlpc7xJRq5SkJpbJ0NxeA2uKFLCu/+49s= 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: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-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