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 5A5C3A034F; Sun, 21 Feb 2021 02:29:21 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EE82522A28B; Sun, 21 Feb 2021 02:28:49 +0100 (CET) Received: from mail-lj1-f172.google.com (mail-lj1-f172.google.com [209.85.208.172]) by mails.dpdk.org (Postfix) with ESMTP id 3822C22A276 for ; Sun, 21 Feb 2021 02:28:46 +0100 (CET) Received: by mail-lj1-f172.google.com with SMTP id a22so44492745ljp.10 for ; Sat, 20 Feb 2021 17:28:46 -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=ZKumYdrvmtxvWa2XorOv4diluGJ/8ibNHac13F3wVVU=; b=U56gcXPaNcfSdGeDW4G24plCuU3TowKB2BwDnbImMswa06orJCiCRMoRDWHD/X+ov1 kHRTKtrT5mHQ0cbIYvtIqzDp/0VSgh4AExMbGk/4udgGADrddn5chbr3PrYSChjivoQJ RoeSkBr7AvpFGdpfwc/ftU0vPCRcA+bmhatOymjNebAolLN6JjB1tDwL1GlS1Y1mxMHm gY6HmHzSb9u2/DcD2LRCzTzlh6dRUJ6XVkCLXEWYq1DSSFtj4HxkWzgj270BzJEGJ5Np c+zmWE8fAkFc97xfxxp0IWszs/BNEZSEUx+Et5W7gfJMHJMT0Dy+3x/euFUD+QHpPA1b lAFQ== 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=ZKumYdrvmtxvWa2XorOv4diluGJ/8ibNHac13F3wVVU=; b=l9BenO0mrQQ1u5wJp4+JzCLSvIYPglNnm6jwLApMNuqStcm2KDvOg3RpqpqQ9SGIxx L7qVYs6NZylUO/0XZL8TCZTU6WKjSxyqt0xHKwri8Rp1lbLNbGeJPtwdKPrZbKwVhjzR 1WgBECxCIgEdAi9+BqaDsFpJrWO4RLnhfXgAM5dYhdguGTDYu/r6I71ttTgrTEYKvKTq YzefoNdusA3lL0qww1JdeCt0A5bO13CE25D3sPO8bHXMYXdtxOu6ZoEyKkZlFSxZtw5q iQTtsFuwNEVCZAKedoRj1cnPFM85uwGQeq2i7Ak6rlsAB0gN+3H2zINPwgPu9RkkW+AI KJsw== X-Gm-Message-State: AOAM533821jCy5/qIE6o6yWBjbH5jeB8zqDj+pIr6HLBerVgfXeH0ooA ew8U9qDgjwlBS2iaH35vWk3zawjjEwiAic2N X-Google-Smtp-Source: ABdhPJyKdSU5H6RBNji43o97o45E1+Vr72uClgliULzub0xg+fSbVhkT8OFX9HLuJx+yJ5E4MFSCyQ== X-Received: by 2002:a05:651c:103c:: with SMTP id w28mr10118078ljm.101.1613870925583; Sat, 20 Feb 2021 17:28:45 -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.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Feb 2021 17:28:45 -0800 (PST) From: Dmitry Kozlyuk To: dev@dpdk.org Cc: Tyler Retzlaff , Nick Connolly , Dmitry Kozlyuk , Matan Azrad , Shahaf Shuler , Viacheslav Ovsiienko , Beilei Xing , Jeff Guo Date: Sun, 21 Feb 2021 04:28:30 +0300 Message-Id: <20210221012831.14643-7-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 6/7] drivers: 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 strncasecmp() with EAL rte_strncasecmp(). Replace POSIX strtok_r() with EAL rte_strtok(). Replace POSIX strdup() with EAL rte_strdup(). Signed-off-by: Dmitry Kozlyuk --- i40e: checkpatches.sh complains about long lines (it's ~85). I doubt that mechanical fix would keep the code readable. It's on 5th level of indentation, so I'd extract a function, but would like to hear from maintainers first. drivers/bus/pci/private.h | 2 +- drivers/bus/vdev/vdev.c | 4 +- drivers/bus/vdev/vdev_params.c | 3 +- drivers/common/mlx5/mlx5_common_pci.c | 4 +- drivers/common/mlx5/mlx5_common_pci.h | 1 + drivers/net/i40e/i40e_ethdev.c | 56 +++++++++++++-------------- 6 files changed, 36 insertions(+), 34 deletions(-) diff --git a/drivers/bus/pci/private.h b/drivers/bus/pci/private.h index f566943f5..5648916d1 100644 --- a/drivers/bus/pci/private.h +++ b/drivers/bus/pci/private.h @@ -92,7 +92,7 @@ struct mapped_pci_resource { TAILQ_ENTRY(mapped_pci_resource) next; struct rte_pci_addr pci_addr; - char path[PATH_MAX]; + char path[RTE_PATH_MAX]; int nb_maps; struct pci_map maps[PCI_MAX_RESOURCE]; struct pci_msix_table msix_table; diff --git a/drivers/bus/vdev/vdev.c b/drivers/bus/vdev/vdev.c index 9a673347a..a490d26a2 100644 --- a/drivers/bus/vdev/vdev.c +++ b/drivers/bus/vdev/vdev.c @@ -245,9 +245,9 @@ alloc_devargs(const char *name, const char *args) devargs->bus = &rte_vdev_bus; if (args) - devargs->args = strdup(args); + devargs->args = rte_strdup(args); else - devargs->args = strdup(""); + devargs->args = rte_strdup(""); ret = strlcpy(devargs->name, name, sizeof(devargs->name)); if (ret < 0 || ret >= (int)sizeof(devargs->name)) { diff --git a/drivers/bus/vdev/vdev_params.c b/drivers/bus/vdev/vdev_params.c index 6f74704d1..64848f4c2 100644 --- a/drivers/bus/vdev/vdev_params.c +++ b/drivers/bus/vdev/vdev_params.c @@ -8,6 +8,7 @@ #include #include #include +#include #include "vdev_logs.h" #include "vdev_private.h" @@ -31,7 +32,7 @@ vdev_dev_match(const struct rte_device *dev, char *name; /* cannot pass const dev->name to rte_kvargs_process() */ - name = strdup(dev->name); + name = rte_strdup(dev->name); if (name == NULL) return -1; ret = rte_kvargs_process(kvlist, diff --git a/drivers/common/mlx5/mlx5_common_pci.c b/drivers/common/mlx5/mlx5_common_pci.c index 2b657686d..37f4182e2 100644 --- a/drivers/common/mlx5/mlx5_common_pci.c +++ b/drivers/common/mlx5/mlx5_common_pci.c @@ -88,7 +88,7 @@ bus_cmdline_options_handler(__rte_unused const char *key, return *ret; } nstr_org = nstr; - found = strtok_r(nstr, ":", &refstr); + found = rte_strtok(nstr, ":", &refstr); if (!found) goto err; do { @@ -102,7 +102,7 @@ bus_cmdline_options_handler(__rte_unused const char *key, goto err; } *ret |= class_val; - found = strtok_r(NULL, ":", &refstr); + found = rte_strtok(NULL, ":", &refstr); } while (found); err: free(nstr_org); diff --git a/drivers/common/mlx5/mlx5_common_pci.h b/drivers/common/mlx5/mlx5_common_pci.h index de89bb98b..729d0f4cc 100644 --- a/drivers/common/mlx5/mlx5_common_pci.h +++ b/drivers/common/mlx5/mlx5_common_pci.h @@ -45,6 +45,7 @@ extern "C" { #include #include +#include #include diff --git a/drivers/net/i40e/i40e_ethdev.c b/drivers/net/i40e/i40e_ethdev.c index d7cd04989..5b806d201 100644 --- a/drivers/net/i40e/i40e_ethdev.c +++ b/drivers/net/i40e/i40e_ethdev.c @@ -12036,110 +12036,110 @@ i40e_update_customized_ptype(struct rte_eth_dev *dev, uint8_t *pkg, memset(name, 0, sizeof(name)); strcpy(name, proto[n].name); PMD_DRV_LOG(INFO, "name = %s\n", name); - if (!strncasecmp(name, "PPPOE", 5)) + if (!rte_strncasecmp(name, "PPPOE", 5)) ptype_mapping[i].sw_ptype |= RTE_PTYPE_L2_ETHER_PPPOE; - else if (!strncasecmp(name, "IPV4FRAG", 8) && + else if (!rte_strncasecmp(name, "IPV4FRAG", 8) && !in_tunnel) { ptype_mapping[i].sw_ptype |= RTE_PTYPE_L3_IPV4_EXT_UNKNOWN; ptype_mapping[i].sw_ptype |= RTE_PTYPE_L4_FRAG; - } else if (!strncasecmp(name, "IPV4FRAG", 8) && + } else if (!rte_strncasecmp(name, "IPV4FRAG", 8) && in_tunnel) { ptype_mapping[i].sw_ptype |= RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN; ptype_mapping[i].sw_ptype |= RTE_PTYPE_INNER_L4_FRAG; - } else if (!strncasecmp(name, "OIPV4", 5)) { + } else if (!rte_strncasecmp(name, "OIPV4", 5)) { ptype_mapping[i].sw_ptype |= RTE_PTYPE_L3_IPV4_EXT_UNKNOWN; in_tunnel = true; - } else if (!strncasecmp(name, "IPV4", 4) && + } else if (!rte_strncasecmp(name, "IPV4", 4) && !in_tunnel) ptype_mapping[i].sw_ptype |= RTE_PTYPE_L3_IPV4_EXT_UNKNOWN; - else if (!strncasecmp(name, "IPV4", 4) && + else if (!rte_strncasecmp(name, "IPV4", 4) && in_tunnel) ptype_mapping[i].sw_ptype |= RTE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN; - else if (!strncasecmp(name, "IPV6FRAG", 8) && + else if (!rte_strncasecmp(name, "IPV6FRAG", 8) && !in_tunnel) { ptype_mapping[i].sw_ptype |= RTE_PTYPE_L3_IPV6_EXT_UNKNOWN; ptype_mapping[i].sw_ptype |= RTE_PTYPE_L4_FRAG; - } else if (!strncasecmp(name, "IPV6FRAG", 8) && + } else if (!rte_strncasecmp(name, "IPV6FRAG", 8) && in_tunnel) { ptype_mapping[i].sw_ptype |= RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN; ptype_mapping[i].sw_ptype |= RTE_PTYPE_INNER_L4_FRAG; - } else if (!strncasecmp(name, "OIPV6", 5)) { + } else if (!rte_strncasecmp(name, "OIPV6", 5)) { ptype_mapping[i].sw_ptype |= RTE_PTYPE_L3_IPV6_EXT_UNKNOWN; in_tunnel = true; - } else if (!strncasecmp(name, "IPV6", 4) && + } else if (!rte_strncasecmp(name, "IPV6", 4) && !in_tunnel) ptype_mapping[i].sw_ptype |= RTE_PTYPE_L3_IPV6_EXT_UNKNOWN; - else if (!strncasecmp(name, "IPV6", 4) && + else if (!rte_strncasecmp(name, "IPV6", 4) && in_tunnel) ptype_mapping[i].sw_ptype |= RTE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN; - else if (!strncasecmp(name, "UDP", 3) && + else if (!rte_strncasecmp(name, "UDP", 3) && !in_tunnel) ptype_mapping[i].sw_ptype |= RTE_PTYPE_L4_UDP; - else if (!strncasecmp(name, "UDP", 3) && + else if (!rte_strncasecmp(name, "UDP", 3) && in_tunnel) ptype_mapping[i].sw_ptype |= RTE_PTYPE_INNER_L4_UDP; - else if (!strncasecmp(name, "TCP", 3) && + else if (!rte_strncasecmp(name, "TCP", 3) && !in_tunnel) ptype_mapping[i].sw_ptype |= RTE_PTYPE_L4_TCP; - else if (!strncasecmp(name, "TCP", 3) && + else if (!rte_strncasecmp(name, "TCP", 3) && in_tunnel) ptype_mapping[i].sw_ptype |= RTE_PTYPE_INNER_L4_TCP; - else if (!strncasecmp(name, "SCTP", 4) && + else if (!rte_strncasecmp(name, "SCTP", 4) && !in_tunnel) ptype_mapping[i].sw_ptype |= RTE_PTYPE_L4_SCTP; - else if (!strncasecmp(name, "SCTP", 4) && + else if (!rte_strncasecmp(name, "SCTP", 4) && in_tunnel) ptype_mapping[i].sw_ptype |= RTE_PTYPE_INNER_L4_SCTP; - else if ((!strncasecmp(name, "ICMP", 4) || - !strncasecmp(name, "ICMPV6", 6)) && + else if ((!rte_strncasecmp(name, "ICMP", 4) || + !rte_strncasecmp(name, "ICMPV6", 6)) && !in_tunnel) ptype_mapping[i].sw_ptype |= RTE_PTYPE_L4_ICMP; - else if ((!strncasecmp(name, "ICMP", 4) || - !strncasecmp(name, "ICMPV6", 6)) && + else if ((!rte_strncasecmp(name, "ICMP", 4) || + !rte_strncasecmp(name, "ICMPV6", 6)) && in_tunnel) ptype_mapping[i].sw_ptype |= RTE_PTYPE_INNER_L4_ICMP; - else if (!strncasecmp(name, "GTPC", 4)) { + else if (!rte_strncasecmp(name, "GTPC", 4)) { ptype_mapping[i].sw_ptype |= RTE_PTYPE_TUNNEL_GTPC; in_tunnel = true; - } else if (!strncasecmp(name, "GTPU", 4)) { + } else if (!rte_strncasecmp(name, "GTPU", 4)) { ptype_mapping[i].sw_ptype |= RTE_PTYPE_TUNNEL_GTPU; in_tunnel = true; - } else if (!strncasecmp(name, "ESP", 3)) { + } else if (!rte_strncasecmp(name, "ESP", 3)) { ptype_mapping[i].sw_ptype |= RTE_PTYPE_TUNNEL_ESP; in_tunnel = true; - } else if (!strncasecmp(name, "GRENAT", 6)) { + } else if (!rte_strncasecmp(name, "GRENAT", 6)) { ptype_mapping[i].sw_ptype |= RTE_PTYPE_TUNNEL_GRENAT; in_tunnel = true; - } else if (!strncasecmp(name, "L2TPV2CTL", 9) || - !strncasecmp(name, "L2TPV2", 6) || - !strncasecmp(name, "L2TPV3", 6)) { + } else if (!rte_strncasecmp(name, "L2TPV2CTL", 9) || + !rte_strncasecmp(name, "L2TPV2", 6) || + !rte_strncasecmp(name, "L2TPV3", 6)) { ptype_mapping[i].sw_ptype |= RTE_PTYPE_TUNNEL_L2TP; in_tunnel = true; -- 2.29.2