Dear gnulib developers, We recently updated gnulib in GNU Octave to a newer revision (d4ec02b3cc70cddaaa5183cc5a45814e0afb2292). (Kudos on the impressive speedup to the bootstrap process.)
Since then, we are seeing warnings like the following when building for MinGW: ../../libgnu/tzset.c: In function 'rpl_tzset': ../../libgnu/tzset.c:68:24: warning: initialization of 'char *' from incompatible pointer type 'char **' [-Wincompatible-pointer-types] 68 | for (char *s = env; *s != NULL; s++) | ^~~ ../../libgnu/tzset.c:68:32: warning: comparison between pointer and integer 68 | for (char *s = env; *s != NULL; s++) | ^~ ../../libgnu/tzset.c:72:28: warning: initialization of 'wchar_t *' {aka 'short unsigned int *'} from incompatible pointer type 'wchar_t **' {aka 'short unsigned int **'} [-Wincompatible-pointer-types] 72 | for (wchar_t *ws = wenv; *ws != NULL; ws++) | ^~~~ ../../libgnu/tzset.c:72:38: warning: comparison between pointer and integer 72 | for (wchar_t *ws = wenv; *ws != NULL; ws++) ^~ IIUC, these warnings might be legitimate. The attached patch avoids those warnings. I'm hoping this is the correct format to propose changes to gnulib. Best, Markus Mützel
From 87b83c757f7d249f983410e85d13ba450d57b417 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=BCtzel?= <markus.muet...@gmx.de> Date: Sat, 27 Apr 2024 13:44:29 +0200 Subject: [PATCH] ctime, localtime, tzset, wcsftime: Check content of environment. * lib/ctime.c (rpl_ctime): Index into content of each environment variable. * lib/localtime.c (rpl_localtime): Likewise. * lib/tzset.c (rpl_tzset): Likewise. * lib/wcsftime.c (rpl_wcsftime): Likewise. --- lib/ctime.c | 12 ++++++------ lib/localtime.c | 12 ++++++------ lib/tzset.c | 12 ++++++------ lib/wcsftime.c | 12 ++++++------ 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/lib/ctime.c b/lib/ctime.c index 8c54ef463c..e30b7997c8 100644 --- a/lib/ctime.c +++ b/lib/ctime.c @@ -63,13 +63,13 @@ rpl_ctime (const time_t *tp) char **env = _environ; wchar_t **wenv = _wenviron; if (env != NULL) - for (char *s = env; *s != NULL; s++) - if (s[0] == 'T' && s[1] == 'Z' && s[2] == '=') - s[0] = '$'; + for (char **s = env; *s != NULL; s++) + if (*s[0] == 'T' && *s[1] == 'Z' && *s[2] == '=') + *s[0] = '$'; if (wenv != NULL) - for (wchar_t *ws = wenv; *ws != NULL; ws++) - if (ws[0] == L'T' && ws[1] == L'Z' && ws[2] == L'=') - ws[0] = L'$'; + for (wchar_t **ws = wenv; *ws != NULL; ws++) + if (*ws[0] == L'T' && *ws[1] == L'Z' && *ws[2] == L'=') + *ws[0] = L'$'; } #endif diff --git a/lib/localtime.c b/lib/localtime.c index f0e91ac647..1c6bb9856e 100644 --- a/lib/localtime.c +++ b/lib/localtime.c @@ -63,13 +63,13 @@ rpl_localtime (const time_t *tp) char **env = _environ; wchar_t **wenv = _wenviron; if (env != NULL) - for (char *s = env; *s != NULL; s++) - if (s[0] == 'T' && s[1] == 'Z' && s[2] == '=') - s[0] = '$'; + for (char **s = env; *s != NULL; s++) + if (*s[0] == 'T' && *s[1] == 'Z' && *s[2] == '=') + *s[0] = '$'; if (wenv != NULL) - for (wchar_t *ws = wenv; *ws != NULL; ws++) - if (ws[0] == L'T' && ws[1] == L'Z' && ws[2] == L'=') - ws[0] = L'$'; + for (wchar_t **ws = wenv; *ws != NULL; ws++) + if (*ws[0] == L'T' && *ws[1] == L'Z' && *ws[2] == L'=') + *ws[0] = L'$'; } #endif diff --git a/lib/tzset.c b/lib/tzset.c index f307f0c3d1..c8d48e1afb 100644 --- a/lib/tzset.c +++ b/lib/tzset.c @@ -65,13 +65,13 @@ rpl_tzset (void) char **env = _environ; wchar_t **wenv = _wenviron; if (env != NULL) - for (char *s = env; *s != NULL; s++) - if (s[0] == 'T' && s[1] == 'Z' && s[2] == '=') - s[0] = '$'; + for (char **s = env; *s != NULL; s++) + if (*s[0] == 'T' && *s[1] == 'Z' && *s[2] == '=') + *s[0] = '$'; if (wenv != NULL) - for (wchar_t *ws = wenv; *ws != NULL; ws++) - if (ws[0] == L'T' && ws[1] == L'Z' && ws[2] == L'=') - ws[0] = L'$'; + for (wchar_t **ws = wenv; *ws != NULL; ws++) + if (*ws[0] == L'T' && *ws[1] == L'Z' && *ws[2] == L'=') + *ws[0] = L'$'; } /* On native Windows, tzset() is deprecated. Use _tzset() instead. See diff --git a/lib/wcsftime.c b/lib/wcsftime.c index d8b471ab57..81d1762a92 100644 --- a/lib/wcsftime.c +++ b/lib/wcsftime.c @@ -61,13 +61,13 @@ rpl_wcsftime (wchar_t *buf, size_t bufsize, const wchar_t *format, const struct char **env = _environ; wchar_t **wenv = _wenviron; if (env != NULL) - for (char *s = env; *s != NULL; s++) - if (s[0] == 'T' && s[1] == 'Z' && s[2] == '=') - s[0] = '$'; + for (char **s = env; *s != NULL; s++) + if (*s[0] == 'T' && *s[1] == 'Z' && *s[2] == '=') + *s[0] = '$'; if (wenv != NULL) - for (wchar_t *ws = wenv; *ws != NULL; ws++) - if (ws[0] == L'T' && ws[1] == L'Z' && ws[2] == L'=') - ws[0] = L'$'; + for (wchar_t **ws = wenv; *ws != NULL; ws++) + if (*ws[0] == L'T' && *ws[1] == L'Z' && *ws[2] == L'=') + *ws[0] = L'$'; } #endif -- 2.44.0.windows.1