On 9/19/26 10:39, Yue Yi wrote:
- test1.txt: built with the same commit plus Paul's patch applied.

Does the first attached patch fix the false positives in Emacs's Gnulib-derived files? If so, it sounds like I should install the second attached patch into Gnulib. This sort of circumlocution avoids the need to worry about which GCC warning options are used.

cc'ing to [email protected].
From b6b41665fbc5e71d1afc5e6d8b59ce40db1bc89c Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email protected]>
Date: Sat, 19 Sep 2026 12:36:46 -0700
Subject: [PATCH] test patch for MS-Windows -Waddress

---
 lib/boot-time-aux.h | 5 ++++-
 lib/getrandom.c     | 5 ++++-
 lib/gettimeofday.c  | 5 ++++-
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/lib/boot-time-aux.h b/lib/boot-time-aux.h
index e09d84b67a2..4abe058fee3 100644
--- a/lib/boot-time-aux.h
+++ b/lib/boot-time-aux.h
@@ -372,9 +372,12 @@ initialize (void)
   initialized = TRUE;
 }
 
+#   define has_GetTickCount64Func (GetTickCount64Func != NULL)
+
 #  else
 
 #   define GetTickCount64Func GetTickCount64
+#   define has_GetTickCount64Func 1
 
 #  endif
 
@@ -390,7 +393,7 @@ get_windows_boot_time_fallback (struct timespec *p_boot_time)
   if (! initialized)
     initialize ();
 #  endif
-  if (GetTickCount64Func != NULL)
+  if (has_GetTickCount64Func)
     {
       ULONGLONG uptime_ms = GetTickCount64Func ();
 
diff --git a/lib/getrandom.c b/lib/getrandom.c
index 7bc5a4b416e..afce8bcaa25 100644
--- a/lib/getrandom.c
+++ b/lib/getrandom.c
@@ -80,9 +80,12 @@ initialize (void)
   initialized = TRUE;
 }
 
+#  define has_BCryptGenRandomFunc (BCryptGenRandomFunc != NULL)
+
 # else
 
 #  define BCryptGenRandomFunc BCryptGenRandom
+#  define has_BCryptGenRandomFunc 1
 
 # endif
 
@@ -124,7 +127,7 @@ getrandom (void *buffer, size_t length, unsigned int flags)
       if (!initialized)
         initialize ();
 # endif
-      if (BCryptGenRandomFunc != NULL
+      if (has_BCryptGenRandomFunc
           && BCryptGenRandomFunc (NULL, buffer, length,
                                   BCRYPT_USE_SYSTEM_PREFERRED_RNG)
              == 0 /*STATUS_SUCCESS*/)
diff --git a/lib/gettimeofday.c b/lib/gettimeofday.c
index f236c427fd1..6b789fb410e 100644
--- a/lib/gettimeofday.c
+++ b/lib/gettimeofday.c
@@ -58,9 +58,12 @@ initialize (void)
   initialized = TRUE;
 }
 
+#  define has_GetSystemTimePreciseAsFileTimeFunc (GetSystemTimePreciseAsFileTime != NULL)
+
 # else
 
 #  define GetSystemTimePreciseAsFileTimeFunc GetSystemTimePreciseAsFileTime
+#  define has_GetSystemTimePreciseAsFileTimeFunc 1
 
 # endif
 
@@ -98,7 +101,7 @@ gettimeofday (struct timeval *restrict tv, void *restrict tz)
 # endif
 
   FILETIME current_time;
-  if (GetSystemTimePreciseAsFileTimeFunc != NULL)
+  if (has_GetSystemTimePreciseAsFileTimeFunc)
     GetSystemTimePreciseAsFileTimeFunc (&current_time);
   else
     GetSystemTimeAsFileTime (&current_time);
-- 
2.55.0

From bbe7c125307f04627710f8d4228d830113398f9f Mon Sep 17 00:00:00 2001
From: Paul Eggert <[email protected]>
Date: Sat, 19 Sep 2026 12:33:28 -0700
Subject: [PATCH] Pacify -Waddress on MS-Windows

Problem reported by Yue Yi <https://bugs.gnu.org/81837#23>.
* lib/boot-time-aux.h (has_GetTickCount64Func): New macro.
(get_windows_boot_time_fallback): Use it.
* lib/getrandom.c (has_BCryptGenRandomFunc): New macro.
(getrandom): Use it.
* lib/gettimeofday.c (has_GetSystemTimePreciseAsFileTimeFunc):
New macro.
(gettimeofday): Use it.
* lib/link.c (has_CreateHardLinkFunc): New macro.
(link): Use it.
* lib/stat-w32.c (has_GetFileInformationByHandleExFunc): New macro.
(_gl_fstat_by_handle): Use it.
---
 ChangeLog           | 16 ++++++++++++++++
 lib/boot-time-aux.h |  5 ++++-
 lib/getrandom.c     |  5 ++++-
 lib/gettimeofday.c  |  5 ++++-
 lib/link.c          |  5 ++++-
 lib/stat-w32.c      |  7 +++++--
 6 files changed, 37 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 1d6cdc6762..db8b553c0e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2026-09-19  Paul Eggert  <[email protected]>
+
+	Pacify -Waddress on MS-Windows
+	Problem reported by Yue Yi <https://bugs.gnu.org/81837#23>.
+	* lib/boot-time-aux.h (has_GetTickCount64Func): New macro.
+	(get_windows_boot_time_fallback): Use it.
+	* lib/getrandom.c (has_BCryptGenRandomFunc): New macro.
+	(getrandom): Use it.
+	* lib/gettimeofday.c (has_GetSystemTimePreciseAsFileTimeFunc):
+	New macro.
+	(gettimeofday): Use it.
+	* lib/link.c (has_CreateHardLinkFunc): New macro.
+	(link): Use it.
+	* lib/stat-w32.c (has_GetFileInformationByHandleExFunc): New macro.
+	(_gl_fstat_by_handle): Use it.
+
 2026-09-19  Pádraig Brady  <[email protected]>
 
 	regex: check for glibc greek locale bug 20381
diff --git a/lib/boot-time-aux.h b/lib/boot-time-aux.h
index e09d84b67a..4abe058fee 100644
--- a/lib/boot-time-aux.h
+++ b/lib/boot-time-aux.h
@@ -372,9 +372,12 @@ initialize (void)
   initialized = TRUE;
 }
 
+#   define has_GetTickCount64Func (GetTickCount64Func != NULL)
+
 #  else
 
 #   define GetTickCount64Func GetTickCount64
+#   define has_GetTickCount64Func 1
 
 #  endif
 
@@ -390,7 +393,7 @@ get_windows_boot_time_fallback (struct timespec *p_boot_time)
   if (! initialized)
     initialize ();
 #  endif
-  if (GetTickCount64Func != NULL)
+  if (has_GetTickCount64Func)
     {
       ULONGLONG uptime_ms = GetTickCount64Func ();
 
diff --git a/lib/getrandom.c b/lib/getrandom.c
index 7bc5a4b416..afce8bcaa2 100644
--- a/lib/getrandom.c
+++ b/lib/getrandom.c
@@ -80,9 +80,12 @@ initialize (void)
   initialized = TRUE;
 }
 
+#  define has_BCryptGenRandomFunc (BCryptGenRandomFunc != NULL)
+
 # else
 
 #  define BCryptGenRandomFunc BCryptGenRandom
+#  define has_BCryptGenRandomFunc 1
 
 # endif
 
@@ -124,7 +127,7 @@ getrandom (void *buffer, size_t length, unsigned int flags)
       if (!initialized)
         initialize ();
 # endif
-      if (BCryptGenRandomFunc != NULL
+      if (has_BCryptGenRandomFunc
           && BCryptGenRandomFunc (NULL, buffer, length,
                                   BCRYPT_USE_SYSTEM_PREFERRED_RNG)
              == 0 /*STATUS_SUCCESS*/)
diff --git a/lib/gettimeofday.c b/lib/gettimeofday.c
index f236c427fd..6b789fb410 100644
--- a/lib/gettimeofday.c
+++ b/lib/gettimeofday.c
@@ -58,9 +58,12 @@ initialize (void)
   initialized = TRUE;
 }
 
+#  define has_GetSystemTimePreciseAsFileTimeFunc (GetSystemTimePreciseAsFileTime != NULL)
+
 # else
 
 #  define GetSystemTimePreciseAsFileTimeFunc GetSystemTimePreciseAsFileTime
+#  define has_GetSystemTimePreciseAsFileTimeFunc 1
 
 # endif
 
@@ -98,7 +101,7 @@ gettimeofday (struct timeval *restrict tv, void *restrict tz)
 # endif
 
   FILETIME current_time;
-  if (GetSystemTimePreciseAsFileTimeFunc != NULL)
+  if (has_GetSystemTimePreciseAsFileTimeFunc)
     GetSystemTimePreciseAsFileTimeFunc (&current_time);
   else
     GetSystemTimeAsFileTime (&current_time);
diff --git a/lib/link.c b/lib/link.c
index 6198929943..cc35f66add 100644
--- a/lib/link.c
+++ b/lib/link.c
@@ -61,9 +61,12 @@ initialize (void)
   initialized = TRUE;
 }
 
+#   define has_CreateHardLinkFunc (CreateHardLinkFunc != NULL)
+
 #  else
 
 #   define CreateHardLinkFunc CreateHardLink
+#   define has_CreateHardLinkFunc 1
 
 #  endif
 
@@ -75,7 +78,7 @@ link (const char *file1, const char *file2)
     initialize ();
 #  endif
 
-  if (CreateHardLinkFunc == NULL)
+  if (!has_CreateHardLinkFunc)
     {
       /* System does not support hard links.  */
       errno = EPERM;
diff --git a/lib/stat-w32.c b/lib/stat-w32.c
index e5a9e28688..74d495e05a 100644
--- a/lib/stat-w32.c
+++ b/lib/stat-w32.c
@@ -80,9 +80,12 @@ initialize (void)
   initialized = TRUE;
 }
 
+# define has_GetFileInformationByHandleExFunc (GetFileInformationByHandleExFunc != NULL)
+
 #else
 
 # define GetFileInformationByHandleExFunc GetFileInformationByHandleEx
+# define has_GetFileInformationByHandleExFunc 1
 
 #endif
 
@@ -200,7 +203,7 @@ _gl_fstat_by_handle (HANDLE h, const char *path, struct stat *buf)
              error ERROR_INVALID_LEVEL, whereas GetFileInformationByHandle
              succeeds.  */
 # if _GL_WINDOWS_STAT_INODES == 2
-      if (GetFileInformationByHandleExFunc != NULL)
+      if (has_GetFileInformationByHandleExFunc)
         {
           FILE_ID_INFO id;
           if (GetFileInformationByHandleExFunc (h, FileIdInfo, &id, sizeof (id)))
@@ -264,7 +267,7 @@ _gl_fstat_by_handle (HANDLE h, const char *path, struct stat *buf)
                   char storage[sizeof (FILE_NAME_INFO)
                                + PATH_MAX * sizeof (WCHAR)];
                 } fni;
-              if (GetFileInformationByHandleExFunc != NULL
+              if (has_GetFileInformationByHandleExFunc
                   && GetFileInformationByHandleExFunc (h, FileNameInfo,
                                                        &fni.info,
                                                        sizeof (fni)))
-- 
2.55.0

Reply via email to