From: Zdenek Kabelac Date: Sat, 23 Mar 2024 23:05:57 +0000 (+0100) Subject: dev-cache: change locales just once X-Git-Tag: v2_03_24~343 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=ab3c69007739807b032867f33ac61c6ec2d714ce;p=lvm2.git dev-cache: change locales just once --- diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c index 3e87ddc3a..789d8487f 100644 --- a/lib/device/dev-cache.c +++ b/lib/device/dev-cache.c @@ -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();