In Emacs, I saw the following warning:

In file included from /usr/lib/gcc/x86_64-redhat-linux/14/include/stdint.h:9,
                 from file-has-acl.c:53:
/usr/include/stdint.h:216:11: warning: "SIZE_MAX" redefined
  216 | #  define SIZE_MAX              (18446744073709551615UL)
      |           ^~~~~~~~
acl-internal.h:57:10: note: this is the location of the previous definition
   57 | # define SIZE_MAX ((size_t) -1)
      |          ^~~~~~~~

Upon closer look it is easy to see why this occurs. In acl-internal.h
there was:

    #include <limits.h>
    #ifndef SIZE_MAX
    # define SIZE_MAX ((size_t) -1)
    #endif

Then file-has-acl.c includes stdint.h where SIZE_MAX is properly
defined as required by POSIX.

I was conflicted on whether it was worth adding the stdint-h dependency,
or just including the file and keeping the #ifdef in case it wasn't
defined. But I decided since both modules that use the header use
SIZE_MAX, I think the dependency is fine.

    $ gnulib-tool --find lib/acl-internal.h \
      | xargs gnulib-tool --extract-filelist \
      | grep '^lib/.*\.c$' | xargs grep -l SIZE_MAX \
      | xargs gnulib-tool --find
    acl-permissions
    file-has-acl

Collin

>From c1a7af9bc8ebc9bbe9fb8d62664103810a76ba10 Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.fu...@gmail.com>
Date: Tue, 11 Feb 2025 18:44:33 -0800
Subject: [PATCH] acl-permissions, file-has-acl: Depend on stdint-h for
 SIZE_MAX.

* lib/acl-internal.h: Include stdint.h.
(SIZE_MAX): Remove definition.
* lib/file-has-acl.c: Don't include stdint.h again.
* modules/acl-permissions (Depends-on): Add stdint-h.
* modules/file-has-acl (Depends-on): Likewise.
---
 ChangeLog               | 9 +++++++++
 lib/acl-internal.h      | 5 +----
 lib/file-has-acl.c      | 1 -
 modules/acl-permissions | 1 +
 modules/file-has-acl    | 1 +
 5 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index dabace1a4b..1ad2f6ed5b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2025-02-11  Collin Funk  <collin.fu...@gmail.com>
+
+	acl-permissions, file-has-acl: Depend on stdint-h for SIZE_MAX.
+	* lib/acl-internal.h: Include stdint.h.
+	(SIZE_MAX): Remove definition.
+	* lib/file-has-acl.c: Don't include stdint.h again.
+	* modules/acl-permissions (Depends-on): Add stdint-h.
+	* modules/file-has-acl (Depends-on): Likewise.
+
 2025-02-10  KO Myung-Hun  <kom...@gmail.com>
 
 	popen: Set gl_cv_func_popen_works to "guessing no" on OS/2.
diff --git a/lib/acl-internal.h b/lib/acl-internal.h
index f37b3bcff5..b32a1cdafd 100644
--- a/lib/acl-internal.h
+++ b/lib/acl-internal.h
@@ -52,10 +52,7 @@ extern int aclsort (int, int, struct acl *);
 #include <errno.h>
 
 #include <limits.h>
-
-#ifndef SIZE_MAX
-# define SIZE_MAX ((size_t) -1)
-#endif
+#include <stdint.h>
 
 #ifndef HAVE_FCHMOD
 # define HAVE_FCHMOD false
diff --git a/lib/file-has-acl.c b/lib/file-has-acl.c
index c02cfee842..179e805bd4 100644
--- a/lib/file-has-acl.c
+++ b/lib/file-has-acl.c
@@ -50,7 +50,6 @@ static char const UNKNOWN_SECURITY_CONTEXT[] = "?";
 #  include <selinux/selinux.h>
 # endif
 # include <stdckdint.h>
-# include <stdint.h>
 # include <string.h>
 # include <arpa/inet.h>
 # include <sys/xattr.h>
diff --git a/modules/acl-permissions b/modules/acl-permissions
index 6b9f791978..bcd1fc5e40 100644
--- a/modules/acl-permissions
+++ b/modules/acl-permissions
@@ -18,6 +18,7 @@ minmax
 stat
 bool
 sys_stat-h
+stdint-h
 
 configure.ac:
 gl_FUNC_ACL
diff --git a/modules/file-has-acl b/modules/file-has-acl
index 2105483f6d..aefd786247 100644
--- a/modules/file-has-acl
+++ b/modules/file-has-acl
@@ -17,6 +17,7 @@ extern-inline
 minmax
 free-posix
 limits-h
+stdint-h
 malloc-posix
 ssize_t
 stat
-- 
2.48.1

Reply via email to