From patchwork Wed Aug 5 08:56:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ophir Munk X-Patchwork-Id: 75206 X-Patchwork-Delegate: rasland@nvidia.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id CA4CAA053A; Wed, 5 Aug 2020 10:56:48 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 385B21BFFA; Wed, 5 Aug 2020 10:56:48 +0200 (CEST) Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-eopbgr10077.outbound.protection.outlook.com [40.107.1.77]) by dpdk.org (Postfix) with ESMTP id 5544B1BFF7 for ; Wed, 5 Aug 2020 10:56:47 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N+Dj9ZG0BI+dAMYKPo4gyymSxmdLpT2tRGkDOuvlzFJYANPlelbpaCtOYL/PzPdOYka9BkWoq9Q+RRCEZyFK2IOMOBVIM1brkktB+BuAuG1IPvil8fqCB6vvrodysYbB5sYFZWLViUqJBENFKa5VSTlXxFPSxsFXWc9E1AaVH1AnnsY1Az60Qcjgz8r+lTKL/BVkUgdPmWFjXCzmBfHoW0Y3CemhvLPiPAu/j4H59/oXoFVSeo+x9LnekhW+rJFQPYPmwa7gzofeNb3og9edoV5aGzMbOqFovYkkYSvcIzTGnG6T5rNJ0resObMps0C60m3VZ/RT2ekiRvX+SVNk4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=a+XhHfx1StvttQzGXIS0hBRIQx65PK6D37FuTrPrcok=; b=QUGg47ugbEuf9UAb9dIXVzmgHAh9hWEz8lEpHJ/C43EY1nxg+d7euQTlUQhuWpsqrvfgf4aAKxezEroKlUWG/6K4JjAiy++FGQid0kmJKH+ynt645yNgRBMWhg3zRy1+x7R3xqpxIge/26iEpU8B+NHxxNdwzq7FwInIiAxuJTc2BDDtCUaolb4qgJ11UhiOQFwA/nwBgcf3hZfR97VzrfA+xnjA6PoFiLjw/6euyzfw6gIoS3cwt9mB1JGrKkrliv28UGI6K6btZ61T78mimSBzm/L3lQo2ZFKijVAyo3Us1fPkEDjYRbQ3LoiFfi1D+8+sAqIaHsGMBqsnq2lYkA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=mellanox.com; dmarc=pass action=none header.from=mellanox.com; dkim=pass header.d=mellanox.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=a+XhHfx1StvttQzGXIS0hBRIQx65PK6D37FuTrPrcok=; b=ahpWhEZ4pxRZ0YhlSU8X/uw4fTBEY4+jfzbwXosJGLIQU1WeWbiZNjbEIrJh6THqmH1mvpuwARvSmjYooA/8kvoWxWkoN+aSKltXpoIrgSvpQ8Aa5tpV8DTNa4j06eOR+FBAsQOas9/kaVslbJqbMPmxHx15PK55FTE9812vmG0= Authentication-Results: dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=none action=none header.from=mellanox.com; Received: from AM0PR05MB4209.eurprd05.prod.outlook.com (2603:10a6:208:61::22) by AM0PR05MB6228.eurprd05.prod.outlook.com (2603:10a6:208:119::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3261.16; Wed, 5 Aug 2020 08:56:45 +0000 Received: from AM0PR05MB4209.eurprd05.prod.outlook.com ([fe80::3949:70c3:126:3972]) by AM0PR05MB4209.eurprd05.prod.outlook.com ([fe80::3949:70c3:126:3972%7]) with mapi id 15.20.3261.017; Wed, 5 Aug 2020 08:56:45 +0000 From: Ophir Munk To: dev@dpdk.org, Raslan Darawsheh Cc: Ophir Munk Date: Wed, 5 Aug 2020 08:56:35 +0000 Message-Id: <20200805085635.18057-1-ophirmu@mellanox.com> X-Mailer: git-send-email 2.8.4 X-ClientProxiedBy: GV0P278CA0040.CHEP278.PROD.OUTLOOK.COM (2603:10a6:710:29::9) To AM0PR05MB4209.eurprd05.prod.outlook.com (2603:10a6:208:61::22) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from mellanox.com (37.142.13.130) by GV0P278CA0040.CHEP278.PROD.OUTLOOK.COM (2603:10a6:710:29::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3239.17 via Frontend Transport; Wed, 5 Aug 2020 08:56:44 +0000 X-Mailer: git-send-email 2.8.4 X-Originating-IP: [37.142.13.130] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 30d181f5-1f1b-4839-7a68-08d8391d7ad6 X-MS-TrafficTypeDiagnostic: AM0PR05MB6228: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtFwd X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5516; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lYT3348BRm0ArbqtujJR8foE+wdK0xTlgvX+ol+z0dEJhjfvQBculCwiHwXYQ1MTPV1YTwKX/iyEe6SQJ+m3ye91oq0vwOvyRmq2JA3oPP28m/oMqcgpcv5bU8hi/0lpcVETw8l2bV6wofynSlRZxT4BqyX0xaT+I6G2d2YxWvRuKNAx+9wmLuhHIiJFS7+oSOz3Q086AwMENaKNmGZ8sG/06et21LOPBJOH8UxeVT8EsLzI1RN1dkyZb/AKbZP4oywh/61ycleuDM/wsEORY+R9razfkeHC3INTticq+XZcz3xJwyMwU6YSmA4cKE8IJKL1+G4hw9nzZa2YqabJcg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR05MB4209.eurprd05.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(366004)(376002)(396003)(346002)(136003)(39860400002)(6862004)(83380400001)(8676002)(6666004)(1076003)(4326008)(37006003)(186003)(36756003)(26005)(55016002)(16526019)(8936002)(316002)(478600001)(86362001)(2616005)(2906002)(956004)(107886003)(5660300002)(6636002)(8886007)(66476007)(7696005)(52116002)(66556008)(66946007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: cqU765fUxO6F2X15Ua5JjqrfxB9ygJKgti6E8Esq1gFVhJXgOgit75ECPDVa/GTbAtXDakiUSBTsFmYapiWrBQwBZoh51SgNWAbZ5W/r5HpbyulpORLZ2xTwqCnXh5Kl2J4GYgFmwWMEyMGObuh0v4XEegiu7G4NjM+uCLEzK+0So2anvhsUCbekFB4HsRMed+3T6P9Pld7W16NmhB4S7bVZc6XNz3BNE4JscllXRt7Q2aJ9cZqrZHH4P443PezW4p8ddi6d8X8zM8VLeHCFoxwomve8u/fbdmhQiTxB0cH7bcP0IV4RM7Zasm7W+b8J1kHHGkae164FKwqLBQFgHotktgz+RirhRIQPMoQQIpJZQzb8iOAkRPfgEl7xr1s/Z/++T+CjBamyvaerMpoTuROx3xdi6b/j3VXJ0S/86xh2BxF2KjQzV8pMgygni8bhG51+8L4pebVJKHPO/BzdwjjGzPAKh55/YVl7Ml66RWRWbeiJHURuFH0UJD8iwYHoKna1z2HNvVAzs4R7mLiELs6FaRVBV4NKcX9RTN+twJbX2RrN62ASB801BUmEs8r2SNCAk0jX9Mp5GiPCYr+Ba0HQUApsoETG5DC7usf6btVk0dOiRAFn3oz5wkaPoHzPCF1+snaMBkq6nuyYO5ZyGA== X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 30d181f5-1f1b-4839-7a68-08d8391d7ad6 X-MS-Exchange-CrossTenant-AuthSource: AM0PR05MB4209.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Aug 2020 08:56:45.2985 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: vDen7gkpfl5DK+p9GoAgoZlqyb7YYrmyPi7WX+WZ3wAzGU9DilRRaN+NwX3oClIQ+ihLUU+hpxvOfPL8ZIIxqQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR05MB6228 Subject: [dpdk-dev] [PATCH v1] 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" 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)