From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id C8879A04B1; Tue, 25 Aug 2020 11:31:56 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3D2AD1C1C2; Tue, 25 Aug 2020 11:31:35 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 94D18255 for ; Tue, 25 Aug 2020 11:31:29 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from ophirmu@nvidia.com) with SMTP; 25 Aug 2020 12:31:25 +0300 Received: from nvidia.com (pegasus05.mtr.labs.mlnx [10.210.16.100]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 07P9VPMp030009; Tue, 25 Aug 2020 12:31:25 +0300 From: Ophir Munk To: dev@dpdk.org Cc: Ophir Munk Date: Tue, 25 Aug 2020 09:31:04 +0000 Message-Id: <20200825093116.26538-2-ophirmu@nvidia.com> X-Mailer: git-send-email 2.8.4 In-Reply-To: <20200825093116.26538-1-ophirmu@nvidia.com> References: <20200820145028.4090-1-ophirmu@nvidia.com> <20200825093116.26538-1-ophirmu@nvidia.com> Subject: [dpdk-dev] [PATCH v2 01/13] common/mlx5: replace strsep with strtok_r X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Ophir Munk strsep() is a non-standardized API (by C or POSIX) and thus it is non-portable between different operating systems. Replace it with strtok_r() which is standardized by the C standard, and hence also by POSIX. The replacement occurs in the code that extracts individual PCI class names (e.g. class=net:vdpa:foo:bar). Signed-off-by: Ophir Munk Acked-by: Matan Azrad --- drivers/common/mlx5/mlx5_common_pci.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/drivers/common/mlx5/mlx5_common_pci.c b/drivers/common/mlx5/mlx5_common_pci.c index d4ff039..02417c6 100644 --- a/drivers/common/mlx5/mlx5_common_pci.c +++ b/drivers/common/mlx5/mlx5_common_pci.c @@ -72,6 +72,7 @@ bus_cmdline_options_handler(__rte_unused const char *key, int class_val; char *found; char *nstr; + char *refstr = NULL; *ret = 0; nstr = strdup(class_names); @@ -80,21 +81,22 @@ bus_cmdline_options_handler(__rte_unused const char *key, return *ret; } nstr_org = nstr; - while (nstr) { + found = strtok_r(nstr, ":", &refstr); + if (!found) + goto err; + do { /* Extract each individual class name. Multiple * class key,value is supplied as class=net:vdpa:foo:bar. */ - found = strsep(&nstr, ":"); - if (!found) - continue; - /* Check if its a valid class. */ class_val = class_name_to_value(found); + /* Check if its a valid class. */ if (class_val < 0) { *ret = -EINVAL; goto err; } *ret |= class_val; - } + found = strtok_r(NULL, ":", &refstr); + } while (found); err: free(nstr_org); if (*ret < 0) -- 2.8.4