libzutil: zfs_strcmp_shortname: remove strtok

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
This commit is contained in:
наб 2021-05-20 22:47:43 +02:00 committed by Brian Behlendorf
parent 2fdd61a30b
commit 91d6780671
1 changed files with 6 additions and 7 deletions

View 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 {