From 31f4c8cb19bf3f7a1629e259af77d8a63f3816fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Thu, 20 May 2021 22:51:06 +0200 Subject: [PATCH] linux/libzutil: zfs_path_order: remove strtok MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Brian Behlendorf Reviewed-by: John Kennedy Signed-off-by: Ahelenia ZiemiaƄska Closes #12094 --- lib/libzutil/os/linux/zutil_import_os.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/libzutil/os/linux/zutil_import_os.c b/lib/libzutil/os/linux/zutil_import_os.c index 61c42cf2e..84c3cb44f 100644 --- a/lib/libzutil/os/linux/zutil_import_os.c +++ b/lib/libzutil/os/linux/zutil_import_os.c @@ -283,21 +283,20 @@ zpool_default_search_paths(size_t *count) static int zfs_path_order(char *name, int *order) { - int i = 0, error = ENOENT; - char *dir, *env, *envdup; + int i, error = ENOENT; + char *dir, *env, *envdup, *tmp = NULL; env = getenv("ZPOOL_IMPORT_PATH"); if (env) { envdup = strdup(env); - dir = strtok(envdup, ":"); - while (dir) { + for (dir = strtok_r(envdup, ":", &tmp), i = 0; + dir != NULL; + dir = strtok_r(NULL, ":", &tmp), i++) { if (strncmp(name, dir, strlen(dir)) == 0) { *order = i; error = 0; break; } - dir = strtok(NULL, ":"); - i++; } free(envdup); } else {