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 EF48AA034F; Sun, 21 Feb 2021 15:29:07 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DF2B922A2C5; Sun, 21 Feb 2021 15:28:35 +0100 (CET) Received: from mail-lj1-f176.google.com (mail-lj1-f176.google.com [209.85.208.176]) by mails.dpdk.org (Postfix) with ESMTP id 9BA4E22A2BD for ; Sun, 21 Feb 2021 15:28:32 +0100 (CET) Received: by mail-lj1-f176.google.com with SMTP id r11so4640819ljk.9 for ; Sun, 21 Feb 2021 06:28:32 -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=qs3na/7wlYcSpCJAsIlrAdr1fmtVxoeUi48JXCd0+7OWy+BeJDnRdGv+X1zdr+uDja 8S2ZOZ0TbhYmLYn5SMygzOcAufh+nMshi8NueZF4mu3A/5OvvOHyro8NznzeQSnlWzpw iMXpn2svlYPTtHoeKSPEkBnMHhNGMGk+01pbAVZDRql+/qAwmHIEuTM1Gx0THiS3F1i6 y+UoOsvfUPd3aXSWmLn+4pBS18BmMVUc9bM6LqhwG3GVXqEGilrz8EbjABIW4gjADDeA a91cdg4O8urpg3oGDtKmp2GTyNm/YqCPSgiCaed1URNu8UVMFsX7iIAU0fDoX7DV8Z5c Ccnw== 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=n05XTb3helmEYIbGZcZdqNJ91fZydLNc1Pv7ZVuz2hJhPbcLJyBPNChjEe3vv0SYIK A2W6G2RK/DxpVA4HW3DcCAHtsZ0kxhbjVp+4NZjNcF1veV6VAcj1Yl448LPtPGgC9Ls9 tnu8UAS3Na1AfX28rP+cropEAJCcbyNMW6FsZw9oZCYazRtnTeBAWF2u71tqiVNFIlpK tNqhZIKblsiIBMcm/pbxAoaNdd2KCORLLP8fSFI6UEux8UBgqj8jgP5un6o+PvHOm31s QN1lvdUYM0zZByn7ATZ1Ob0Bd3tukxHjoHg1Irvw5TpTDBd6yrUX3cyFfbQmp3otrhw+ wu4g== X-Gm-Message-State: AOAM530tkIjl786vAREw4InGTWYjRzhD9cxBO1FnS/AIZFrFpMfBqSx1 PGCRoHSdGrviveXXuzSFszXaPf4vowO9Ce1N X-Google-Smtp-Source: ABdhPJwFKZd9GKLwHs1lm+EyMF82g9Ziw/hk2v8SgTrKCLsQgvpC43okO32OZdN2/KSqTP+cJigDMQ== X-Received: by 2002:a2e:8ed4:: with SMTP id e20mr6436150ljl.55.1613917712042; Sun, 21 Feb 2021 06:28:32 -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 a30sm1569885lfo.56.2021.02.21.06.28.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Feb 2021 06:28:31 -0800 (PST) From: Dmitry Kozlyuk To: dev@dpdk.org Cc: Tal Shnaiderman , Dmitry Kozlyuk , Olivier Matz , Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko Date: Sun, 21 Feb 2021 17:28:17 +0300 Message-Id: <20210221142819.6769-6-dmitry.kozliuk@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210221142819.6769-1-dmitry.kozliuk@gmail.com> References: <20210221012831.14643-1-dmitry.kozliuk@gmail.com> <20210221142819.6769-1-dmitry.kozliuk@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v3 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