]> git.proxmox.com Git - mirror_zfs.git/commitdiff
libzutil: zfs_strcmp_shortname: remove strtok
authorнаб <nabijaczleweli@nabijaczleweli.xyz>
Thu, 20 May 2021 20:47:43 +0000 (22:47 +0200)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 26 May 2021 21:50:41 +0000 (14:50 -0700)
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Closes #12094

lib/libzutil/zutil_device_path.c

index be8d02673bc4fa5853333081c4c270a878c664c4..518f941615a9f89e0806a389627d246ec5ef6739 100644 (file)
@@ -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 {