From: Ophir Munk <ophirmu@mellanox.com>
To: dev@dpdk.org, Raslan Darawsheh <rasland@mellanox.com>
Cc: Ophir Munk <ophirmu@mellanox.com>
Subject: [dpdk-dev] [PATCH v1] common/mlx5: replace strsep with strtok_r
Date: Wed, 5 Aug 2020 08:56:35 +0000 [thread overview]
Message-ID: <20200805085635.18057-1-ophirmu@mellanox.com> (raw)
strsep() is a non-standardized API (by C or POSIX) and thus it is
non-portable between different operating systems. Replace it with
strtok_r() which is standardized by the C standard, and hence also by
POSIX.
The replacement occurs in the code that extracts individual PCI class
names (e.g. class=net:vdpa:foo:bar).
Signed-off-by: Ophir Munk <ophirmu@mellanox.com>
Acked-by: Matan Azrad <matan@mellanox.com>
---
drivers/common/mlx5/mlx5_common_pci.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/drivers/common/mlx5/mlx5_common_pci.c b/drivers/common/mlx5/mlx5_common_pci.c
index d4ff039..02417c6 100644
--- a/drivers/common/mlx5/mlx5_common_pci.c
+++ b/drivers/common/mlx5/mlx5_common_pci.c
@@ -72,6 +72,7 @@ bus_cmdline_options_handler(__rte_unused const char *key,
int class_val;
char *found;
char *nstr;
+ char *refstr = NULL;
*ret = 0;
nstr = strdup(class_names);
@@ -80,21 +81,22 @@ bus_cmdline_options_handler(__rte_unused const char *key,
return *ret;
}
nstr_org = nstr;
- while (nstr) {
+ found = strtok_r(nstr, ":", &refstr);
+ if (!found)
+ goto err;
+ do {
/* Extract each individual class name. Multiple
* class key,value is supplied as class=net:vdpa:foo:bar.
*/
- found = strsep(&nstr, ":");
- if (!found)
- continue;
- /* Check if its a valid class. */
class_val = class_name_to_value(found);
+ /* Check if its a valid class. */
if (class_val < 0) {
*ret = -EINVAL;
goto err;
}
*ret |= class_val;
- }
+ found = strtok_r(NULL, ":", &refstr);
+ } while (found);
err:
free(nstr_org);
if (*ret < 0)
--
2.8.4
reply other threads:[~2020-08-05 8:56 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200805085635.18057-1-ophirmu@mellanox.com \
--to=ophirmu@mellanox.com \
--cc=dev@dpdk.org \
--cc=rasland@mellanox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).