This set of patches fixes a number of warnings that I'm seeing when building
a POSIX testdir on MSVC/clang.


2020-08-16  Bruno Haible  <br...@clisp.org>

        Fix "warning: 'WSASocketA' is deprecated: Use WSASocketW() instead".
        * lib/socket.c: Use WSASocketW, not WSASocketA.

        Fix "warning: format specifies type 'unsigned long'".
        * tests/test-nonblocking-writer.h (main_writer_loop): Cast dbgfprintf
        argument to match the format directive.

        Fix "warning: no case matching constant switch condition '0'".
        * tests/test-fcntl.c (check_flags): Add a 'default' case.

        Fix "warning: integer overflow in expression".
        * tests/test-strtol.c (main): Use an 'unsigned long' expression to
        remove a 'long' overflow.

        Fix "warning: "getpagesize" redefined".
        * tests/test-getcwd.c (getpagesize): Don't redefine if defined as a
        macro.

        Fix "warning: implicitly declaring library function 'strncasecmp'".
        * lib/strptime.c: Include <strings.h>.

        Fix "warning: 'snprintf' macro redefined".
        * lib/strerror_r.c (snprintf): Undefine before redefining.

        Fix "warning: address of array 'locale' will always evaluate to 'true'".
        * lib/nl_langinfo.c (ctype_codeset): Remove redundant NULL test.

        Fix "warning: '__stat64' macro redefined".
        * lib/glob.c (__stat64): Undefine also on MSVC/clang.

        Fix "warning: 'format' attribute argument not supported: rpl_printf".
        * lib/stdio.in.h (printf): Treat clang like GCC.

        Fix "warning: attribute declaration must precede definition" with clang.
        * lib/math.in.h (acosl, asinl, atanl, ceill, cosl, expl, fabsf, fabsl,
        floorl, fmodl, frexpf, frexpl, hypotf, hypotl, ldexpf, ldexpl, logl,
        log10l, modfl, sinl, sqrtl, tanl): Disable _GL_CXXALIASWARN invocation
        on non-glibc systems.
        * lib/netdb.in.h (gai_strerror): Likewise.
        * lib/stdio.in.h (snprintf, vfscanf, vscanf, vsnprintf): Likewise.
        * lib/sys_stat.in.h (fstat): Likewise.
        * lib/utime.in.h (utime): Likewise.

        Fix undesired warnings.
        * lib/sys_select.in.h: Disable all _GL_WARN_ON_USE invocations with
        clang.

>From e7307acb2016474fe0d5b12f1e659a661680ea99 Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Sun, 16 Aug 2020 13:00:05 +0200
Subject: [PATCH 01/13] Fix undesired warnings.

* lib/sys_select.in.h: Disable all _GL_WARN_ON_USE invocations with
clang.
---
 ChangeLog           | 6 ++++++
 lib/sys_select.in.h | 4 ++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index af6b5d1..7761d3d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2020-08-16  Bruno Haible  <br...@clisp.org>
 
+	Fix undesired warnings.
+	* lib/sys_select.in.h: Disable all _GL_WARN_ON_USE invocations with
+	clang.
+
+2020-08-16  Bruno Haible  <br...@clisp.org>
+
 	C++ tests: Fix link errors on MSVC (regression from 2020-05-31).
 	* modules/stdio-c++-tests (Makefile.am): Link test-stdio-c++ with
 	$(LIB_GETRANDOM), needed for the rpl_tmpfile symbol.
diff --git a/lib/sys_select.in.h b/lib/sys_select.in.h
index 90bd540..d625d73 100644
--- a/lib/sys_select.in.h
+++ b/lib/sys_select.in.h
@@ -184,7 +184,7 @@ rpl_fd_isset (SOCKET fd, fd_set * set)
 #  if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 #   undef gethostname
 #   define gethostname gethostname_used_without_including_unistd_h
-#  else
+#  elif !defined __clang__
     _GL_WARN_ON_USE (gethostname,
                      "gethostname() used without including <unistd.h>");
 #  endif
@@ -219,7 +219,7 @@ rpl_fd_isset (SOCKET fd, fd_set * set)
 #   define setsockopt          setsockopt_used_without_including_sys_socket_h
 #   undef shutdown
 #   define shutdown            shutdown_used_without_including_sys_socket_h
-#  else
+#  elif !defined __clang__
     _GL_WARN_ON_USE (socket,
                      "socket() used without including <sys/socket.h>");
     _GL_WARN_ON_USE (connect,
-- 
2.7.4

>From 9b2819782e058887d292a827952025c65d235a0b Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Sun, 16 Aug 2020 13:00:17 +0200
Subject: [PATCH 02/13] Fix "warning: attribute declaration must precede
 definition" with clang.

* lib/math.in.h (acosl, asinl, atanl, ceill, cosl, expl, fabsf, fabsl,
floorl, fmodl, frexpf, frexpl, hypotf, hypotl, ldexpf, ldexpl, logl,
log10l, modfl, sinl, sqrtl, tanl): Disable _GL_CXXALIASWARN invocation
on non-glibc systems.
* lib/netdb.in.h (gai_strerror): Likewise.
* lib/stdio.in.h (snprintf, vfscanf, vscanf, vsnprintf): Likewise.
* lib/sys_stat.in.h (fstat): Likewise.
* lib/utime.in.h (utime): Likewise.
---
 ChangeLog         | 10 ++++++++++
 lib/math.in.h     | 44 ++++++++++++++++++++++++++++++++++++++++++++
 lib/netdb.in.h    |  2 ++
 lib/stdio.in.h    |  8 ++++++++
 lib/sys_stat.in.h |  2 ++
 lib/utime.in.h    |  2 ++
 6 files changed, 68 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 7761d3d..3a51cec 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2020-08-16  Bruno Haible  <br...@clisp.org>
 
+	Fix "warning: attribute declaration must precede definition" with clang.
+	* lib/math.in.h (acosl, asinl, atanl, ceill, cosl, expl, fabsf, fabsl,
+	floorl, fmodl, frexpf, frexpl, hypotf, hypotl, ldexpf, ldexpl, logl,
+	log10l, modfl, sinl, sqrtl, tanl): Disable _GL_CXXALIASWARN invocation
+	on non-glibc systems.
+	* lib/netdb.in.h (gai_strerror): Likewise.
+	* lib/stdio.in.h (snprintf, vfscanf, vscanf, vsnprintf): Likewise.
+	* lib/sys_stat.in.h (fstat): Likewise.
+	* lib/utime.in.h (utime): Likewise.
+
 	Fix undesired warnings.
 	* lib/sys_select.in.h: Disable all _GL_WARN_ON_USE invocations with
 	clang.
diff --git a/lib/math.in.h b/lib/math.in.h
index 5dd162e..99b7e32 100644
--- a/lib/math.in.h
+++ b/lib/math.in.h
@@ -255,7 +255,9 @@ _GL_WARN_ON_USE (acosf, "acosf is unportable - "
 _GL_FUNCDECL_SYS (acosl, long double, (long double x));
 # endif
 _GL_CXXALIAS_SYS (acosl, long double, (long double x));
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (acosl);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef acosl
 # if HAVE_RAW_DECL_ACOSL
@@ -295,7 +297,9 @@ _GL_WARN_ON_USE (asinf, "asinf is unportable - "
 _GL_FUNCDECL_SYS (asinl, long double, (long double x));
 # endif
 _GL_CXXALIAS_SYS (asinl, long double, (long double x));
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (asinl);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef asinl
 # if HAVE_RAW_DECL_ASINL
@@ -335,7 +339,9 @@ _GL_WARN_ON_USE (atanf, "atanf is unportable - "
 _GL_FUNCDECL_SYS (atanl, long double, (long double x));
 # endif
 _GL_CXXALIAS_SYS (atanl, long double, (long double x));
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (atanl);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef atanl
 # if HAVE_RAW_DECL_ATANL
@@ -488,7 +494,9 @@ _GL_FUNCDECL_SYS (ceill, long double, (long double x));
 #  endif
 _GL_CXXALIAS_SYS (ceill, long double, (long double x));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (ceill);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef ceill
 # if HAVE_RAW_DECL_CEILL
@@ -574,7 +582,9 @@ _GL_WARN_ON_USE (cosf, "cosf is unportable - "
 _GL_FUNCDECL_SYS (cosl, long double, (long double x));
 # endif
 _GL_CXXALIAS_SYS (cosl, long double, (long double x));
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (cosl);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef cosl
 # if HAVE_RAW_DECL_COSL
@@ -648,7 +658,9 @@ _GL_FUNCDECL_SYS (expl, long double, (long double x));
 #  endif
 _GL_CXXALIAS_SYS (expl, long double, (long double x));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (expl);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef expl
 # if HAVE_RAW_DECL_EXPL
@@ -803,7 +815,9 @@ _GL_WARN_ON_USE (expm1l, "expm1l is unportable - "
 _GL_FUNCDECL_SYS (fabsf, float, (float x));
 # endif
 _GL_CXXALIAS_SYS (fabsf, float, (float x));
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (fabsf);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef fabsf
 # if HAVE_RAW_DECL_FABSF
@@ -827,7 +841,9 @@ _GL_FUNCDECL_SYS (fabsl, long double, (long double x));
 #  endif
 _GL_CXXALIAS_SYS (fabsl, long double, (long double x));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (fabsl);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef fabsl
 # if HAVE_RAW_DECL_FABSL
@@ -892,7 +908,9 @@ _GL_FUNCDECL_SYS (floorl, long double, (long double x));
 #  endif
 _GL_CXXALIAS_SYS (floorl, long double, (long double x));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (floorl);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef floorl
 # if HAVE_RAW_DECL_FLOORL
@@ -1044,7 +1062,9 @@ _GL_FUNCDECL_SYS (fmodl, long double, (long double x, long double y));
 #  endif
 _GL_CXXALIAS_SYS (fmodl, long double, (long double x, long double y));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (fmodl);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef fmodl
 # if HAVE_RAW_DECL_FMODL
@@ -1076,7 +1096,9 @@ _GL_FUNCDECL_SYS (frexpf, float, (float x, int *expptr) _GL_ARG_NONNULL ((2)));
 #  endif
 _GL_CXXALIAS_SYS (frexpf, float, (float x, int *expptr));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (frexpf);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef frexpf
 # if HAVE_RAW_DECL_FREXPF
@@ -1138,7 +1160,9 @@ _GL_CXXALIAS_SYS (frexpl, long double, (long double x, int *expptr));
 # endif
 #endif
 #if @GNULIB_FREXPL@ && !(@REPLACE_FREXPL@ && !@HAVE_DECL_FREXPL@)
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (frexpl);
+# endif
 #endif
 #if !@GNULIB_FREXPL@ && defined GNULIB_POSIXCHECK
 # undef frexpl
@@ -1164,7 +1188,9 @@ _GL_FUNCDECL_SYS (hypotf, float, (float x, float y));
 #  endif
 _GL_CXXALIAS_SYS (hypotf, float, (float x, float y));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (hypotf);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef hypotf
 # if HAVE_RAW_DECL_HYPOTF
@@ -1211,7 +1237,9 @@ _GL_FUNCDECL_SYS (hypotl, long double, (long double x, long double y));
 #  endif
 _GL_CXXALIAS_SYS (hypotl, long double, (long double x, long double y));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (hypotl);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef hypotl
 # if HAVE_RAW_DECL_HYPOTL
@@ -1316,7 +1344,9 @@ _GL_WARN_ON_USE (ilogbl, "ilogbl is unportable - "
 _GL_FUNCDECL_SYS (ldexpf, float, (float x, int exp));
 # endif
 _GL_CXXALIAS_SYS (ldexpf, float, (float x, int exp));
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (ldexpf);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef ldexpf
 # if HAVE_RAW_DECL_LDEXPF
@@ -1342,7 +1372,9 @@ _GL_CXXALIAS_SYS (ldexpl, long double, (long double x, int exp));
 # endif
 #endif
 #if @GNULIB_LDEXPL@
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (ldexpl);
+# endif
 #endif
 #if !@GNULIB_LDEXPL@ && defined GNULIB_POSIXCHECK
 # undef ldexpl
@@ -1414,7 +1446,9 @@ _GL_FUNCDECL_SYS (logl, long double, (long double x));
 #  endif
 _GL_CXXALIAS_SYS (logl, long double, (long double x));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (logl);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef logl
 # if HAVE_RAW_DECL_LOGL
@@ -1485,7 +1519,9 @@ _GL_FUNCDECL_SYS (log10l, long double, (long double x));
 #  endif
 _GL_CXXALIAS_SYS (log10l, long double, (long double x));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (log10l);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef log10l
 # if HAVE_RAW_DECL_LOG10L
@@ -1776,7 +1812,9 @@ _GL_FUNCDECL_SYS (modfl, long double, (long double x, long double *iptr)
 #  endif
 _GL_CXXALIAS_SYS (modfl, long double, (long double x, long double *iptr));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (modfl);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef modfl
 # if HAVE_RAW_DECL_MODFL
@@ -2036,7 +2074,9 @@ _GL_WARN_ON_USE (sinf, "sinf is unportable - "
 _GL_FUNCDECL_SYS (sinl, long double, (long double x));
 # endif
 _GL_CXXALIAS_SYS (sinl, long double, (long double x));
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (sinl);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef sinl
 # if HAVE_RAW_DECL_SINL
@@ -2110,7 +2150,9 @@ _GL_FUNCDECL_SYS (sqrtl, long double, (long double x));
 #  endif
 _GL_CXXALIAS_SYS (sqrtl, long double, (long double x));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (sqrtl);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef sqrtl
 # if HAVE_RAW_DECL_SQRTL
@@ -2150,7 +2192,9 @@ _GL_WARN_ON_USE (tanf, "tanf is unportable - "
 _GL_FUNCDECL_SYS (tanl, long double, (long double x));
 # endif
 _GL_CXXALIAS_SYS (tanl, long double, (long double x));
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (tanl);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef tanl
 # if HAVE_RAW_DECL_TANL
diff --git a/lib/netdb.in.h b/lib/netdb.in.h
index 266920a..2e15c00 100644
--- a/lib/netdb.in.h
+++ b/lib/netdb.in.h
@@ -231,7 +231,9 @@ _GL_FUNCDECL_SYS (gai_strerror, const char *, (int ecode));
 #  endif
 _GL_CXXALIAS_SYS (gai_strerror, const char *, (int ecode));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (gai_strerror);
+# endif
 
 # if !@HAVE_DECL_GETNAMEINFO@
 /* Convert socket address to printable node and service names.
diff --git a/lib/stdio.in.h b/lib/stdio.in.h
index 7308f40..92192ce 100644
--- a/lib/stdio.in.h
+++ b/lib/stdio.in.h
@@ -1199,7 +1199,9 @@ _GL_CXXALIAS_SYS (snprintf, int,
                   (char *restrict str, size_t size,
                    const char *restrict format, ...));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (snprintf);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef snprintf
 # if HAVE_RAW_DECL_SNPRINTF
@@ -1416,7 +1418,9 @@ _GL_CXXALIAS_SYS (vfscanf, int,
                   (FILE *restrict stream,
                    const char *restrict format, va_list args));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (vfscanf);
+# endif
 #endif
 
 #if @GNULIB_VPRINTF_POSIX@ || @GNULIB_VPRINTF@
@@ -1470,7 +1474,9 @@ _GL_CXXALIAS_RPL (vscanf, int, (const char *restrict format, va_list args));
 # else
 _GL_CXXALIAS_SYS (vscanf, int, (const char *restrict format, va_list args));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (vscanf);
+# endif
 #endif
 
 #if @GNULIB_VSNPRINTF@
@@ -1498,7 +1504,9 @@ _GL_CXXALIAS_SYS (vsnprintf, int,
                   (char *restrict str, size_t size,
                    const char *restrict format, va_list args));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (vsnprintf);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef vsnprintf
 # if HAVE_RAW_DECL_VSNPRINTF
diff --git a/lib/sys_stat.in.h b/lib/sys_stat.in.h
index 68b9cf4..2d12610 100644
--- a/lib/sys_stat.in.h
+++ b/lib/sys_stat.in.h
@@ -438,7 +438,9 @@ _GL_CXXALIAS_RPL (fstat, int, (int fd, struct stat *buf));
 # else
 _GL_CXXALIAS_SYS (fstat, int, (int fd, struct stat *buf));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (fstat);
+# endif
 #elif @GNULIB_OVERRIDES_STRUCT_STAT@
 # undef fstat
 # define fstat fstat_used_without_requesting_gnulib_module_fstat
diff --git a/lib/utime.in.h b/lib/utime.in.h
index 923826e..3eab701 100644
--- a/lib/utime.in.h
+++ b/lib/utime.in.h
@@ -75,7 +75,9 @@ _GL_FUNCDECL_SYS (utime, int, (const char *filename, const struct utimbuf *ts)
 #  endif
 _GL_CXXALIAS_SYS (utime, int, (const char *filename, const struct utimbuf *ts));
 # endif
+# if __GLIBC__ >= 2
 _GL_CXXALIASWARN (utime);
+# endif
 #elif defined GNULIB_POSIXCHECK
 # undef utime
 # if HAVE_RAW_DECL_UTIME
-- 
2.7.4

>From 937f11ec8082c1a6a89dd7ca1b771c7bde7ea152 Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Sun, 16 Aug 2020 13:00:35 +0200
Subject: [PATCH 03/13] Fix "warning: 'format' attribute argument not
 supported: rpl_printf".

* lib/stdio.in.h (printf): Treat clang like GCC.
---
 ChangeLog      | 3 +++
 lib/stdio.in.h | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 3a51cec..af210cc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2020-08-16  Bruno Haible  <br...@clisp.org>
 
+	Fix "warning: 'format' attribute argument not supported: rpl_printf".
+	* lib/stdio.in.h (printf): Treat clang like GCC.
+
 	Fix "warning: attribute declaration must precede definition" with clang.
 	* lib/math.in.h (acosl, asinl, atanl, ceill, cosl, expl, fabsf, fabsl,
 	floorl, fmodl, frexpf, frexpl, hypotf, hypotl, ldexpf, ldexpl, logl,
diff --git a/lib/stdio.in.h b/lib/stdio.in.h
index 92192ce..d55ef82 100644
--- a/lib/stdio.in.h
+++ b/lib/stdio.in.h
@@ -964,7 +964,7 @@ _GL_WARN_ON_USE (popen, "popen is buggy on some platforms - "
 #if @GNULIB_PRINTF_POSIX@ || @GNULIB_PRINTF@
 # if (@GNULIB_PRINTF_POSIX@ && @REPLACE_PRINTF@) \
      || (@GNULIB_PRINTF@ && @REPLACE_STDIO_WRITE_FUNCS@ && (@GNULIB_STDIO_H_NONBLOCKING@ || @GNULIB_STDIO_H_SIGPIPE@))
-#  if defined __GNUC__
+#  if defined __GNUC__ || defined __clang__
 #   if !(defined __cplusplus && defined GNULIB_NAMESPACE)
 /* Don't break __attribute__((format(printf,M,N))).  */
 #    define printf __printf__
-- 
2.7.4

>From ff3e4348a8309e81637414ac72584196b6438901 Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Sun, 16 Aug 2020 13:00:38 +0200
Subject: [PATCH 04/13] Fix "warning: '__stat64' macro redefined".

* lib/glob.c (__stat64): Undefine also on MSVC/clang.
---
 ChangeLog  | 3 +++
 lib/glob.c | 4 ++--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index af210cc..f08d762 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2020-08-16  Bruno Haible  <br...@clisp.org>
 
+	Fix "warning: '__stat64' macro redefined".
+	* lib/glob.c (__stat64): Undefine also on MSVC/clang.
+
 	Fix "warning: 'format' attribute argument not supported: rpl_printf".
 	* lib/stdio.in.h (printf): Treat clang like GCC.
 
diff --git a/lib/glob.c b/lib/glob.c
index add5d93..32e2e11 100644
--- a/lib/glob.c
+++ b/lib/glob.c
@@ -72,8 +72,8 @@
 # define __glob                 glob
 # define __getlogin_r(buf, len) getlogin_r (buf, len)
 # define __lstat64(fname, buf)  lstat (fname, buf)
-# ifdef __MINGW32__
-   /* Avoid GCC warning.  mingw has an unused __stat64 macro.  */
+# if defined _WIN32 && !defined __CYGWIN__
+   /* Avoid GCC or clang warning.  The original __stat64 macro is unused.  */
 #  undef __stat64
 # endif
 # define __stat64(fname, buf)   stat (fname, buf)
-- 
2.7.4

>From 28b15af95870f363a93a8d53c7a975b014ba7dee Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Sun, 16 Aug 2020 13:00:40 +0200
Subject: [PATCH 05/13] Fix "warning: address of array 'locale' will always
 evaluate to 'true'".

* lib/nl_langinfo.c (ctype_codeset): Remove redundant NULL test.
---
 ChangeLog         | 3 +++
 lib/nl_langinfo.c | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index f08d762..a7a22d8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2020-08-16  Bruno Haible  <br...@clisp.org>
 
+	Fix "warning: address of array 'locale' will always evaluate to 'true'".
+	* lib/nl_langinfo.c (ctype_codeset): Remove redundant NULL test.
+
 	Fix "warning: '__stat64' macro redefined".
 	* lib/glob.c (__stat64): Undefine also on MSVC/clang.
 
diff --git a/lib/nl_langinfo.c b/lib/nl_langinfo.c
index 23299cb..869d831 100644
--- a/lib/nl_langinfo.c
+++ b/lib/nl_langinfo.c
@@ -57,7 +57,7 @@ ctype_codeset (void)
   codeset = buf;
   codeset[0] = '\0';
 
-  if (locale && locale[0])
+  if (locale[0])
     {
       /* If the locale name contains an encoding after the dot, return it.  */
       char *dot = strchr (locale, '.');
-- 
2.7.4

>From 6cc9ad5fd79c9efb43b25a0f5a0a3fccc2121b91 Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Sun, 16 Aug 2020 13:00:43 +0200
Subject: [PATCH 06/13] Fix "warning: 'snprintf' macro redefined".

* lib/strerror_r.c (snprintf): Undefine before redefining.
---
 ChangeLog        | 3 +++
 lib/strerror_r.c | 1 +
 2 files changed, 4 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index a7a22d8..eca93a8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2020-08-16  Bruno Haible  <br...@clisp.org>
 
+	Fix "warning: 'snprintf' macro redefined".
+	* lib/strerror_r.c (snprintf): Undefine before redefining.
+
 	Fix "warning: address of array 'locale' will always evaluate to 'true'".
 	* lib/nl_langinfo.c (ctype_codeset): Remove redundant NULL test.
 
diff --git a/lib/strerror_r.c b/lib/strerror_r.c
index 9ccc6c3..3044599 100644
--- a/lib/strerror_r.c
+++ b/lib/strerror_r.c
@@ -120,6 +120,7 @@ local_snprintf (char *buf, size_t buflen, const char *format, ...)
     buf[buflen - 1] = '\0';
   return result;
 }
+# undef snprintf
 # define snprintf local_snprintf
 #endif
 
-- 
2.7.4

>From 8fb93504017f40ede26f846050548715480532c5 Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Sun, 16 Aug 2020 13:00:46 +0200
Subject: [PATCH 07/13] Fix "warning: implicitly declaring library function
 'strncasecmp'".

* lib/strptime.c: Include <strings.h>.
---
 ChangeLog      | 3 +++
 lib/strptime.c | 1 +
 2 files changed, 4 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index eca93a8..edd4114 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2020-08-16  Bruno Haible  <br...@clisp.org>
 
+	Fix "warning: implicitly declaring library function 'strncasecmp'".
+	* lib/strptime.c: Include <strings.h>.
+
 	Fix "warning: 'snprintf' macro redefined".
 	* lib/strerror_r.c (snprintf): Undefine before redefining.
 
diff --git a/lib/strptime.c b/lib/strptime.c
index 1a856db..b97fa5c 100644
--- a/lib/strptime.c
+++ b/lib/strptime.c
@@ -28,6 +28,7 @@
 #endif
 #include <limits.h>
 #include <string.h>
+#include <strings.h>
 #include <stdbool.h>
 
 #ifdef _LIBC
-- 
2.7.4

>From ce900be9a0674cf219f85b160eae2930dac1e641 Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Sun, 16 Aug 2020 13:00:48 +0200
Subject: [PATCH 08/13] Fix "warning: "getpagesize" redefined".

* tests/test-getcwd.c (getpagesize): Don't redefine if defined as a
macro.
---
 ChangeLog           | 4 ++++
 tests/test-getcwd.c | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index edd4114..56e893b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2020-08-16  Bruno Haible  <br...@clisp.org>
 
+	Fix "warning: "getpagesize" redefined".
+	* tests/test-getcwd.c (getpagesize): Don't redefine if defined as a
+	macro.
+
 	Fix "warning: implicitly declaring library function 'strncasecmp'".
 	* lib/strptime.c: Include <strings.h>.
 
diff --git a/tests/test-getcwd.c b/tests/test-getcwd.c
index e1df1ff..ab1f5f1 100644
--- a/tests/test-getcwd.c
+++ b/tests/test-getcwd.c
@@ -29,7 +29,7 @@
 #include "pathmax.h"
 #include "macros.h"
 
-#if ! HAVE_GETPAGESIZE
+#if !(HAVE_GETPAGESIZE || defined getpagesize)
 # define getpagesize() 0
 #endif
 
-- 
2.7.4

>From 76361a07d79633619849478e7c3b0859e548d85c Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Sun, 16 Aug 2020 13:00:51 +0200
Subject: [PATCH 09/13] Fix "warning: integer overflow in expression".

* tests/test-strtol.c (main): Use an 'unsigned long' expression to
remove a 'long' overflow.
---
 ChangeLog           | 4 ++++
 tests/test-strtol.c | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 56e893b..696aefc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2020-08-16  Bruno Haible  <br...@clisp.org>
 
+	Fix "warning: integer overflow in expression".
+	* tests/test-strtol.c (main): Use an 'unsigned long' expression to
+	remove a 'long' overflow.
+
 	Fix "warning: "getpagesize" redefined".
 	* tests/test-getcwd.c (getpagesize): Don't redefine if defined as a
 	macro.
diff --git a/tests/test-strtol.c b/tests/test-strtol.c
index 8d523c2..d33ac12 100644
--- a/tests/test-strtol.c
+++ b/tests/test-strtol.c
@@ -172,7 +172,7 @@ main (void)
       long result;
       errno = 0;
       result = strtol (input, &ptr, 10);
-      ASSERT (result == 65535L * 65537L);
+      ASSERT (result == (long) 4294967295UL);
       ASSERT (ptr == input + 10);
       ASSERT (errno == 0);
     }
-- 
2.7.4

>From e520e148f1690754290ca455004e2c20ee8e51a2 Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Sun, 16 Aug 2020 13:00:54 +0200
Subject: [PATCH 10/13] Fix "warning: no case matching constant switch
 condition '0'".

* tests/test-fcntl.c (check_flags): Add a 'default' case.
---
 ChangeLog          | 3 +++
 tests/test-fcntl.c | 1 +
 2 files changed, 4 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 696aefc..d2b2277 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2020-08-16  Bruno Haible  <br...@clisp.org>
 
+	Fix "warning: no case matching constant switch condition '0'".
+	* tests/test-fcntl.c (check_flags): Add a 'default' case.
+
 	Fix "warning: integer overflow in expression".
 	* tests/test-strtol.c (main): Use an 'unsigned long' expression to
 	remove a 'long' overflow.
diff --git a/tests/test-fcntl.c b/tests/test-fcntl.c
index 1f5565a..9ef354c 100644
--- a/tests/test-fcntl.c
+++ b/tests/test-fcntl.c
@@ -206,6 +206,7 @@ check_flags (void)
 # endif
 #endif
 
+    default:
       ;
     }
 }
-- 
2.7.4

>From 3726823d042c8010390797d6a46e002dac783086 Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Sun, 16 Aug 2020 13:00:57 +0200
Subject: [PATCH 11/13] Fix "warning: format specifies type 'unsigned long'".

* tests/test-nonblocking-writer.h (main_writer_loop): Cast dbgfprintf
argument to match the format directive.
---
 ChangeLog                       | 4 ++++
 tests/test-nonblocking-writer.h | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index d2b2277..c939272 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2020-08-16  Bruno Haible  <br...@clisp.org>
 
+	Fix "warning: format specifies type 'unsigned long'".
+	* tests/test-nonblocking-writer.h (main_writer_loop): Cast dbgfprintf
+	argument to match the format directive.
+
 	Fix "warning: no case matching constant switch condition '0'".
 	* tests/test-fcntl.c (check_flags): Add a 'default' case.
 
diff --git a/tests/test-nonblocking-writer.h b/tests/test-nonblocking-writer.h
index d579980..0cb4911 100644
--- a/tests/test-nonblocking-writer.h
+++ b/tests/test-nonblocking-writer.h
@@ -79,7 +79,7 @@ main_writer_loop (int test, size_t data_block_size, int fd,
         usleep (1000000);
 
         dbgfprintf (stderr, "%s:1: >> write (%lu)\n", PROG_ROLE,
-                    (unsigned long) 2 * data_block_size);
+                    (unsigned long) (2 * data_block_size));
         START_TIMING
         ret = write (fd, data, 2 * data_block_size);
         saved_errno = errno;
-- 
2.7.4

>From 0fc41d2b9777053f57199426a1e14e6fa425d3c5 Mon Sep 17 00:00:00 2001
From: Bruno Haible <br...@clisp.org>
Date: Sun, 16 Aug 2020 13:00:59 +0200
Subject: [PATCH 12/13] Fix "warning: 'WSASocketA' is deprecated: Use
 WSASocketW() instead".

* lib/socket.c: Use WSASocketW, not WSASocketA.
---
 ChangeLog    | 3 +++
 lib/socket.c | 4 ++--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index c939272..7ac37a6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2020-08-16  Bruno Haible  <br...@clisp.org>
 
+	Fix "warning: 'WSASocketA' is deprecated: Use WSASocketW() instead".
+	* lib/socket.c: Use WSASocketW, not WSASocketA.
+
 	Fix "warning: format specifies type 'unsigned long'".
 	* tests/test-nonblocking-writer.h (main_writer_loop): Cast dbgfprintf
 	argument to match the format directive.
diff --git a/lib/socket.c b/lib/socket.c
index ebf777f..34e59ca 100644
--- a/lib/socket.c
+++ b/lib/socket.c
@@ -28,9 +28,9 @@
 
 #include "sockets.h"
 
-/* Don't assume that UNICODE is not defined.  */
+/* Don't assume that UNICODE is defined.  */
 #undef WSASocket
-#define WSASocket WSASocketA
+#define WSASocket WSASocketW
 
 int
 rpl_socket (int domain, int type, int protocol)
-- 
2.7.4

Reply via email to