aboutsummaryrefslogtreecommitdiffstats
path: root/lib/libzutil/zutil_device_path.c
diff options
context:
space:
mode:
authorнаб <[email protected]>2021-05-20 22:47:43 +0200
committerBrian Behlendorf <[email protected]>2021-05-26 14:50:41 -0700
commit91d67806719c80fbdcf1b4fd47862ae4ac2b7f74 (patch)
tree88631fc8c9fbfc760ee1c22397cb080c7a5adad3 /lib/libzutil/zutil_device_path.c
parent2fdd61a30b517498f766b5a7d9eec6182c32cd72 (diff)
libzutil: zfs_strcmp_shortname: remove strtok
Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: John Kennedy <[email protected]> Signed-off-by: Ahelenia Ziemiańska <[email protected]> Closes #12094
Diffstat (limited to 'lib/libzutil/zutil_device_path.c')
-rw-r--r--lib/libzutil/zutil_device_path.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/lib/libzutil/zutil_device_path.c b/lib/libzutil/zutil_device_path.c
index be8d02673..518f94161 100644
--- a/lib/libzutil/zutil_device_path.c
+++ b/lib/libzutil/zutil_device_path.c
@@ -82,21 +82,20 @@ static int
zfs_strcmp_shortname(const char *name, const char *cmp_name, int wholedisk)
{
int path_len, cmp_len, i = 0, error = ENOENT;
- char *dir, *env, *envdup = NULL;
+ char *dir, *env, *envdup = NULL, *tmp = NULL;
char path_name[MAXPATHLEN];
- const char * const *zpool_default_import_path;
+ const char * const *zpool_default_import_path = NULL;
size_t count;
- zpool_default_import_path = zpool_default_search_paths(&count);
-
cmp_len = strlen(cmp_name);
env = getenv("ZPOOL_IMPORT_PATH");
if (env) {
envdup = strdup(env);
- dir = strtok(envdup, ":");
+ dir = strtok_r(envdup, ":", &tmp);
} else {
- dir = (char *)zpool_default_import_path[i];
+ zpool_default_import_path = zpool_default_search_paths(&count);
+ dir = (char *)zpool_default_import_path[i];
}
while (dir) {
@@ -116,7 +115,7 @@ zfs_strcmp_shortname(const char *name, const char *cmp_name, int wholedisk)
}
if (env) {
- dir = strtok(NULL, ":");
+ dir = strtok_r(NULL, ":", &tmp);
} else if (++i < count) {
dir = (char *)zpool_default_import_path[i];
} else {