]> sourceware.org Git - lvm2.git/commitdiff
dev-cache: change locales just once
authorZdenek Kabelac <zkabelac@redhat.com>
Sat, 23 Mar 2024 23:05:57 +0000 (00:05 +0100)
committerZdenek Kabelac <zkabelac@redhat.com>
Mon, 25 Mar 2024 10:05:05 +0000 (11:05 +0100)
lib/device/dev-cache.c

index 3e87ddc3a59ddc9914657ef89267eeb64f80e74b..789d8487f849350301fc14b7f7efec0501365fea 100644 (file)
@@ -870,7 +870,6 @@ static int _insert_dir(const char *dir)
        if (len && path[len - 1] != '/')
                path[len++] = '/';
 
-       setlocale(LC_COLLATE, "C"); /* Avoid sorting by locales */
        dirent_count = scandir(dir, &dirent, NULL, alphasort);
        if (dirent_count > 0) {
                for (n = 0; n < dirent_count; n++) {
@@ -890,7 +889,6 @@ static int _insert_dir(const char *dir)
                        free(dirent[n]);
                free(dirent);
        }
-       setlocale(LC_COLLATE, "");
 
        return r;
 }
@@ -1198,7 +1196,9 @@ void dev_cache_scan(struct cmd_context *cmd)
 
        _cache.has_scanned = 1;
 
+       setlocale(LC_COLLATE, "C"); /* Avoid sorting by locales */
        _insert_dirs(&_cache.dirs);
+       setlocale(LC_COLLATE, "");
 
        if (cmd->check_devs_used)
                (void) dev_cache_index_devs();
This page took 0.036317 seconds and 5 git commands to generate.