From: Theodore Ts'o Date: Thu, 5 Dec 2024 01:25:32 +0000 (-0500) Subject: fix portability problem with uselocale(), et. al. X-Git-Tag: v1.47.2-wc1~131 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=44b850bc81092aa489f0224d804c294994031031;p=tools%2Fe2fsprogs.git fix portability problem with uselocale(), et. al. misc/create_inode_libarchive.c uses uselocale(), newlocale(), et. al. These functions are defined in POSIX.1-2017, which isn't available everywhere --- including MacOS and Windows. We don't actually need to use these functions, since mke2fs already calls setlocale() to initialize to use the default locale. So there was no reason to set and restore the locale to use exactly the default locale. Fixes: ecfd4dd1217a ("Decouple --without-libarchive and HAVE_ARCHIVE_H") Fixes: 7e3a4f0a33e9 ("mke2fs: the -d option can now handle tarball input") Signed-off-by: Theodore Ts'o --- diff --git a/debugfs/debugfs.c b/debugfs/debugfs.c index 909c1df..8acb56a 100644 --- a/debugfs/debugfs.c +++ b/debugfs/debugfs.c @@ -16,6 +16,7 @@ #include #include #include +#include #ifdef HAVE_GETOPT_H #include #else @@ -2571,6 +2572,8 @@ int main(int argc, char **argv) char *jbd_debug; #endif + setlocale(LC_CTYPE, ""); + if (debug_prog_name == 0) #ifdef READ_ONLY debug_prog_name = "rdebugfs"; diff --git a/misc/create_inode_libarchive.c b/misc/create_inode_libarchive.c index d14efe8..d094d13 100644 --- a/misc/create_inode_libarchive.c +++ b/misc/create_inode_libarchive.c @@ -58,7 +58,6 @@ typedef ssize_t la_ssize_t; #endif /* HAVE_ARCHIVE_H */ #include -#include static const char *(*dl_archive_entry_hardlink)(struct archive_entry *); static const char *(*dl_archive_entry_pathname)(struct archive_entry *); @@ -583,8 +582,6 @@ errcode_t __populate_fs_from_tar(ext2_filsys fs, ext2_ino_t root_ino, struct archive *a; struct archive_entry *entry; errcode_t retval = 0; - locale_t archive_locale; - locale_t old_locale; ext2_ino_t dirinode, tmpino; const struct stat *st; @@ -594,8 +591,6 @@ errcode_t __populate_fs_from_tar(ext2_filsys fs, ext2_ino_t root_ino, return 1; } - archive_locale = newlocale(LC_CTYPE_MASK, "", (locale_t)0); - old_locale = uselocale(archive_locale); a = dl_archive_read_new(); if (a == NULL) { retval = 1; @@ -720,8 +715,6 @@ errcode_t __populate_fs_from_tar(ext2_filsys fs, ext2_ino_t root_ino, out: dl_archive_read_close(a); dl_archive_read_free(a); - uselocale(old_locale); - freelocale(archive_locale); return retval; }