From: Ophir Munk Date: Tue, 25 Aug 2020 09:31:04 +0000 (+0000) Subject: common/mlx5: replace strsep with strtok_r X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=3475aeaca7b0095a24a708650b4b7edb2631b8e0;p=dpdk.git common/mlx5: replace strsep with strtok_r 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 Acked-by: Matan Azrad --- diff --git a/drivers/common/mlx5/mlx5_common_pci.c b/drivers/common/mlx5/mlx5_common_pci.c index d4ff0392ff..02417c6ff1 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)