From: Karel Zak Date: Thu, 20 Mar 2025 11:57:06 +0100 Subject: misc: never include wchar.h We have a portable "widechar.h" that follows --disable-widechar and provides portability. It is a bug to directly include libc's wchar.h or wctype.h. Fixes: https://github.com/util-linux/util-linux/issues/3470 Signed-off-by: Karel Zak (cherry picked from commit 5c0888dde3cc296d06b8243dcc78248ff90526e5) --- disk-utils/cfdisk.c | 6 +----- include/carefulputc.h | 5 +---- include/fgetwc_or_err.h | 6 +----- lib/idcache.c | 2 +- sys-utils/irqtop.c | 7 ++----- sys-utils/lsns.c | 2 +- tests/helpers/test_sysinfo.c | 2 +- 7 files changed, 8 insertions(+), 22 deletions(-) diff --git a/disk-utils/cfdisk.c b/disk-utils/cfdisk.c index 4018f4d..d4057ee 100644 --- a/disk-utils/cfdisk.c +++ b/disk-utils/cfdisk.c @@ -52,14 +52,10 @@ # include #endif -#ifdef HAVE_WIDECHAR -# include -# include -#endif - #include "c.h" #include "closestream.h" #include "nls.h" +#include "widechar.h" #include "strutils.h" #include "xalloc.h" #include "mbsalign.h" diff --git a/include/carefulputc.h b/include/carefulputc.h index 3cc6f7f..c6b778b 100644 --- a/include/carefulputc.h +++ b/include/carefulputc.h @@ -4,12 +4,9 @@ #include #include #include -#ifdef HAVE_WIDECHAR -#include -#include -#endif #include +#include "widechar.h" #include "cctype.h" /* diff --git a/include/fgetwc_or_err.h b/include/fgetwc_or_err.h index 3cf9262..f6ba71c 100644 --- a/include/fgetwc_or_err.h +++ b/include/fgetwc_or_err.h @@ -1,13 +1,9 @@ #ifndef UTIL_LINUX_FGETWC_OR_ERR_H #define UTIL_LINUX_FGETWC_OR_ERR_H -#include -#include -#include - -#include "widechar.h" #include "c.h" #include "nls.h" +#include "widechar.h" static inline wint_t fgetwc_or_err(FILE *stream) { wint_t ret; diff --git a/lib/idcache.c b/lib/idcache.c index fa77e7b..7bae768 100644 --- a/lib/idcache.c +++ b/lib/idcache.c @@ -4,12 +4,12 @@ * * Written by Karel Zak */ -#include #include #include #include #include "c.h" +#include "widechar.h" #include "idcache.h" struct identry *get_id(struct idcache *ic, unsigned long int id) diff --git a/sys-utils/irqtop.c b/sys-utils/irqtop.c index ce6a2ca..f05bf6b 100644 --- a/sys-utils/irqtop.c +++ b/sys-utils/irqtop.c @@ -43,13 +43,10 @@ # include #endif -#ifdef HAVE_WIDECHAR -# include -# include -#endif - #include +#include "c.h" +#include "widechar.h" #include "closestream.h" #include "cpuset.h" #include "monotonic.h" diff --git a/sys-utils/lsns.c b/sys-utils/lsns.c index 6b2dcba..2b613cf 100644 --- a/sys-utils/lsns.c +++ b/sys-utils/lsns.c @@ -19,7 +19,6 @@ #include #include #include -#include #include #include # include @@ -43,6 +42,7 @@ #include "nls.h" #include "xalloc.h" #include "c.h" +#include "widechar.h" #include "list.h" #include "closestream.h" #include "optutils.h" diff --git a/tests/helpers/test_sysinfo.c b/tests/helpers/test_sysinfo.c index 1559d47..95f50f3 100644 --- a/tests/helpers/test_sysinfo.c +++ b/tests/helpers/test_sysinfo.c @@ -23,12 +23,12 @@ #include #include #include -#include #include #include #include #include "c.h" +#include "widechar.h" #ifdef __linux__ # include