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 DE200A0524; Sun, 21 Feb 2021 00:30:01 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5ECB522A271; Sun, 21 Feb 2021 00:29:29 +0100 (CET) Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com [209.85.208.180]) by mails.dpdk.org (Postfix) with ESMTP id CAA9522A266 for ; Sun, 21 Feb 2021 00:29:24 +0100 (CET) Received: by mail-lj1-f180.google.com with SMTP id k22so44109584ljg.3 for ; Sat, 20 Feb 2021 15:29:24 -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=SJsXGjv6vFj7rCJC2wTkCfJ4Dt82EHLOPNnfE9uWfZo=; b=ZgGClD3wmxOtIP597mSIbIUjv6OKIcVvSP1I3iWJ8KXT2BUsmiiGm2c7vp0HzxCT/J eLxJXKV1oc+fsRv5Mtsm2kmuh7Cgx8iFJm6SkjdHV+tW0U5BE1ePJbHBIUoI+LzQbzd2 Y3OZjcotIJh1FTyP24RsZ+WTULrSNf0/9+0lgerd+C88Q+vlAGjk04Pr9pOH2YYUH+6X t2lbYHJKJvaVTfGAJD9OEcRcHs6IdFcDXzVYUhJYjQKrB835njgjGVfZrUlyj3aoIfGE jw7mO+cByU+b0IMmoXqwDmV3IZxQM+SZLjwe9J9pNAtSYQBhJnWDgIUAvzhZ5yxgnlxn h21Q== 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=SJsXGjv6vFj7rCJC2wTkCfJ4Dt82EHLOPNnfE9uWfZo=; b=hjXbVGnKjGqQ0qSGOGk6DfzxZ2S+gBEYiovVv5PoW3LCpCy1NzrOo6IePshFyxACpa VvBtXYlbhz90J7eHLHkXC3HcHY41Kna0jCZl5LcYMOvOp7c4trqDW4R3zjcZOSeydPGf V8eZ/3gaxh0joOFDIinEro/FMN6wDB2Q5+m6H0cUwrmszKzr/9eeKjzzubEXu6e4vMnB SNq1jMS8Q8N1xVZjjkjTX5/QoxuxIgM9Qn+2vqhWctuz4GhxQoXhoEe4PRLSRwCVpnfM H6DJGddeaDbjhP5s6LFCKaTIeNvEvcLIu7ahkIxuRkViZIfW8PWzxOANpqlq4pLs0w8C MVVA== X-Gm-Message-State: AOAM5318zGHcs3+VveamBJgHJwDv6U+UBE+pwVluk2PjKiiUZDylsAPP N7Pooh6PBqxMohU2gUmvZvOKPw+fWkuoHhmF X-Google-Smtp-Source: ABdhPJxRytcOZIIN8iZfcVo823Mn4I2RtXxoLH+G2K/by1kMzrNixDDtBi4nef6xIWR/rKnHAMkgjQ== X-Received: by 2002:a2e:7007:: with SMTP id l7mr9493683ljc.176.1613863764159; Sat, 20 Feb 2021 15:29:24 -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.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 20 Feb 2021 15:29:23 -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 02:29:09 +0300 Message-Id: <20210220232910.772-7-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 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/net/i40e/i40e_ethdev.c | 56 +++++++++++++-------------- 5 files changed, 35 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/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