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 E6F5BA0524; Sun, 21 Feb 2021 00:29:55 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1A64222A276; Sun, 21 Feb 2021 00:29:28 +0100 (CET) Received: from mail-lj1-f179.google.com (mail-lj1-f179.google.com [209.85.208.179]) by mails.dpdk.org (Postfix) with ESMTP id D099F22A26A for ; Sun, 21 Feb 2021 00:29:23 +0100 (CET) Received: by mail-lj1-f179.google.com with SMTP id u4so44084179ljh.6 for ; Sat, 20 Feb 2021 15:29:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=r8bmfTIjhTMfqOSZTKeB2VL8S+Pg71ymVvNvcArd5ZA=; b=thjK6gDf9Gr+mR+1lDJrkr5wvRJlT7aGtLLyoHnOpBGN9kAtFKAkMiR6GdjzDErltq J+QKf2VyEJln+ssvUlG4LsRERmhtjtg4RfOEhtm9UjsgWk99HvR4F72NHNKAV+6Mw02B sWXPHkOrPUr2VYzap62kMEH+LqO5hmw8a99F6ovdM4hYX2ZJ2+C/NKMYwgEnRTfnedm/ 6yFNHsjzkBwRZns9FF/9lJQNEFhLWyaxbP6YiLK57Hi0wrCnVJb7OlwxVJ+nTTenVI+4 5emf/pLlHITSPoLyxx4FwjWookT5eSz8n4CJvWZaHqmQDv05VCMnmOFLOeavhCSWiacP sSmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=r8bmfTIjhTMfqOSZTKeB2VL8S+Pg71ymVvNvcArd5ZA=; b=J0byp0iuaO6gHTgCTzJ3QyYg5Q6HzHK7mbT8YraY2o56gLFS6xhX1UlzjIcw3rgRo5 YU+kPF1IJ0o8q+yMTdwUIr7Tj36LEboJ+CnDIOg7DQSmbWs0J/x6lVf04LjhW9v5ICvt JjyTt2jTM8QgxHg87Ltb2TFeLCIPouJ5fFH7/0XNnVIx+dHRpxxU5g65RPMOfAjy8s31 OKMT5AEIheNUN0nCw2cQvwXmKL8KAgjGnKtqrb6sqqCcLiGgEy8pTmkckU6gpBdIE+he Fc2IHFes3ZDX60ZANfDuh4ehv2B/jIXAeVH5dWRv1bM8FO24XoL4sjPuMaRWL0wJJB1E OW3A== X-Gm-Message-State: AOAM533qeDEA8FT6lS5C5jqTieLaL+Rmnf5oejWEuiqd2WGeNvErmki0 n2+Gbju3dqfOKRI3Yx6FCe1LTqmRL3Y0O7VQ X-Google-Smtp-Source: ABdhPJzQP0bRm3qij3TqtVmALlMVdVw+OQpGkUmPtEFmnuTrghR9FZTUU2hcxtn6ZPcjwZ/7w9piAQ== X-Received: by 2002:a05:6512:ac4:: with SMTP id n4mr9272107lfu.622.1613863763266; Sat, 20 Feb 2021 15:29:23 -0800 (PST) Received: from localhost.localdomain (broadband-37-110-65-23.ip.moscow.rt.ru. [37.110.65.23]) by smtp.gmail.com with ESMTPSA id f5sm1462931ljc.8.2021.02.20.15.29.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Feb 2021 15:29:22 -0800 (PST) From: Dmitry Kozlyuk To: dev@dpdk.org Cc: Tyler Retzlaff , Nick Connolly , Dmitry Kozlyuk , Olivier Matz , Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko Date: Sun, 21 Feb 2021 02:29:08 +0300 Message-Id: <20210220232910.772-6-dmitry.kozliuk@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210220232910.772-1-dmitry.kozliuk@gmail.com> References: <20210220232910.772-1-dmitry.kozliuk@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH 5/7] lib: remove POSIX dependencies 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 Sender: "dev" Replace POSIX strtok_r() with EAL rte_strtok(). Replace POSIX strdup() with EAL rte_strdup(). Locally rename Windows _close() to standard close(). Signed-off-by: Dmitry Kozlyuk --- lib/librte_cmdline/cmdline.c | 1 + lib/librte_ethdev/rte_class_eth.c | 2 +- lib/librte_ethdev/rte_ethdev.c | 2 +- lib/librte_kvargs/rte_kvargs.c | 17 ++++++++++------- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/lib/librte_cmdline/cmdline.c b/lib/librte_cmdline/cmdline.c index 79ea5f98c..4dfa1178f 100644 --- a/lib/librte_cmdline/cmdline.c +++ b/lib/librte_cmdline/cmdline.c @@ -19,6 +19,7 @@ #include "cmdline_private.h" #ifdef RTE_EXEC_ENV_WINDOWS +#define close _close #define write _write #endif diff --git a/lib/librte_ethdev/rte_class_eth.c b/lib/librte_ethdev/rte_class_eth.c index ca2ce87f7..9b72bdf15 100644 --- a/lib/librte_ethdev/rte_class_eth.c +++ b/lib/librte_ethdev/rte_class_eth.c @@ -73,7 +73,7 @@ eth_representor_cmp(const char *key __rte_unused, return -1; /* not a representor port */ /* Parse devargs representor values. */ - values = strdup(value); + values = rte_strdup(value); if (values == NULL) return -1; memset(&representors, 0, sizeof(representors)); diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index 6f514c388..a09fec2ce 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -5515,7 +5515,7 @@ eth_dev_devargs_tokenise(struct rte_kvargs *arglist, const char *str_in) struct rte_kvargs_pair *pair; char *letter; - arglist->str = strdup(str_in); + arglist->str = rte_strdup(str_in); if (arglist->str == NULL) return -ENOMEM; diff --git a/lib/librte_kvargs/rte_kvargs.c b/lib/librte_kvargs/rte_kvargs.c index 285081c86..fd1103b33 100644 --- a/lib/librte_kvargs/rte_kvargs.c +++ b/lib/librte_kvargs/rte_kvargs.c @@ -26,20 +26,22 @@ rte_kvargs_tokenize(struct rte_kvargs *kvlist, const char *params) /* Copy the const char *params to a modifiable string * to pass to rte_strsplit */ - kvlist->str = strdup(params); + kvlist->str = rte_strdup(params); if (kvlist->str == NULL) return -1; /* browse each key/value pair and add it in kvlist */ str = kvlist->str; - while ((str = strtok_r(str, RTE_KVARGS_PAIRS_DELIM, &ctx1)) != NULL) { + while ((str = rte_strtok(str, RTE_KVARGS_PAIRS_DELIM, &ctx1)) != NULL) { i = kvlist->count; if (i >= RTE_KVARGS_MAX) return -1; - kvlist->pairs[i].key = strtok_r(str, RTE_KVARGS_KV_DELIM, &ctx2); - kvlist->pairs[i].value = strtok_r(NULL, RTE_KVARGS_KV_DELIM, &ctx2); + kvlist->pairs[i].key = rte_strtok( + str, RTE_KVARGS_KV_DELIM, &ctx2); + kvlist->pairs[i].value = rte_strtok( + NULL, RTE_KVARGS_KV_DELIM, &ctx2); if (kvlist->pairs[i].key == NULL || kvlist->pairs[i].value == NULL) return -1; @@ -49,12 +51,13 @@ rte_kvargs_tokenize(struct rte_kvargs *kvlist, const char *params) if (str[0] == '[') { /* Find the end of the list. */ while (str[strlen(str) - 1] != ']') { - /* Restore the comma erased by strtok_r(). */ + /* Restore the comma erased by rte_strtok(). */ if (ctx1 == NULL || ctx1[0] == '\0') return -1; /* no closing bracket */ str[strlen(str)] = ','; /* Parse until next comma. */ - str = strtok_r(NULL, RTE_KVARGS_PAIRS_DELIM, &ctx1); + str = rte_strtok( + NULL, RTE_KVARGS_PAIRS_DELIM, &ctx1); if (str == NULL) return -1; /* no closing bracket */ } @@ -199,7 +202,7 @@ rte_kvargs_parse_delim(const char *args, const char * const valid_keys[], if (valid_ends == NULL) return rte_kvargs_parse(args, valid_keys); - copy = strdup(args); + copy = rte_strdup(args); if (copy == NULL) return NULL; -- 2.29.2