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 91ADFA034F; Sun, 21 Feb 2021 02:29:15 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B342222A282; Sun, 21 Feb 2021 02:28:48 +0100 (CET) Received: from mail-lj1-f171.google.com (mail-lj1-f171.google.com [209.85.208.171]) by mails.dpdk.org (Postfix) with ESMTP id 4C1C722A276 for ; Sun, 21 Feb 2021 02:28:45 +0100 (CET) Received: by mail-lj1-f171.google.com with SMTP id e17so44540318ljl.8 for ; Sat, 20 Feb 2021 17:28:45 -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=Z1t8RlEcRjZ9IyDnHM1Mtqb61bhDQjBuM2BkVR0Y4pFSz8THVE9ijJblxFC8wClt1S GopmPFD3WQnYgJzf8kD8V1jV7B/U7+64rsHjcNsI+wpJXXuqFxTDaIR0PJtmwnNzC3xR M/QWaTSkz5PX+89PX5Ky7Sr9IjMcF/SDrU5D+PwsXwiY3/VLT6w4wJiz9Qjm5oz2P3T/ h3mQLKHpnb8knyJNH0Zv2jSa1gbntkoPdKFdROKjo9SZvnGuwYXEE6Ra4lj6l1ejgwQs A8b9nHB/zKje/D+kSMvraaeLdWCpaswteJI6xyuBXM5Nl5D+dzEHm10uJS1TMO8vcXez udgA== 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=PwVIflXI1PA5jDfyaQcevhETZUMwqfikTT2YN+E4URmn3KHi7CJLz6HiaJvRCHbiK4 JBTCS75ppeMwxilpGwzyE4jxVrNl/XQKSX+kwECWwhp9uPlAMXDSiXbjFSLbZkd21o4y 1aXEXmWJ/ZI/JynJJr6stGJ6IXXVJ8tcf51LwpWyqmOC8dI2GYDhdWxZhGu5Kmm9oNei XP0x2My+VPwSvqihvPFxk4WIvNm0oTKZQxck0Zpe/uedR495GXaqtrN8jUcfbUqsmeWx vOodbrcI+Q/Ca6cvk3lJdwWJvdQkVW05XQSxmf0NIi8V97msMnxsepa0UsM4yzOwbF8m qMFg== X-Gm-Message-State: AOAM530QTpKPDxEooYFI6gJ0+mkM1isPRgHcXWvVuKuHbtMsIUMVjKny 4TfkW4SIy9Fuqbde/i6yG96zZfaGrqnirGsb X-Google-Smtp-Source: ABdhPJyXI42K5+HvpcLwDsvEmlnD4YhO69bbNl/iS+UbpQVghQ0wIauqsYmzcXr7qCUmJwKdJv1r9g== X-Received: by 2002:a2e:8e61:: with SMTP id t1mr1168294ljk.221.1613870924619; Sat, 20 Feb 2021 17:28:44 -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 d5sm1401666lfe.232.2021.02.20.17.28.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Feb 2021 17:28:44 -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 04:28:29 +0300 Message-Id: <20210221012831.14643-6-dmitry.kozliuk@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210221012831.14643-1-dmitry.kozliuk@gmail.com> References: <20210220232910.772-1-dmitry.kozliuk@gmail.com> <20210221012831.14643-1-dmitry.kozliuk@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v2 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