This is useful for Emacs when compiled with -Wunused-paramet3er.
* lib/malloc/dynarray-skeleton.c (DYNARRAY_NAME (free__elements__)):
* lib/malloc/dynarray_at_failure.c (__libc_dynarray_at_failure):
* lib/regcomp.c (regerror, calc_next, build_range_exp)
(build_collating_symbol, parse_bracket_element, build_equiv_class)
(free_tree):
* lib/regex_internal.h (re_string_elem_size_at):
Use __attribute_maybe_unused__ for arguments that are unused,
perhaps only when compiled under Gnulib.  Since glibc does not
have anything like _GL_UNNAMED, don’t use that here.
* lib/set-permissions.c (set_acls):
* lib/strftime.c (get_tm_zone): Use _GL_UNSUED for arguments that
might not be used, depending on compile-time options.
---
 ChangeLog                        | 17 ++++++++++++++
 lib/malloc/dynarray-skeleton.c   |  4 +++-
 lib/malloc/dynarray_at_failure.c |  3 ++-
 lib/regcomp.c                    | 40 +++++++++++++++++++++-----------
 lib/regex_internal.h             |  3 ++-
 lib/set-permissions.c            |  2 +-
 lib/strftime.c                   |  3 ++-
 7 files changed, 53 insertions(+), 19 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d5322ac92d..99724e3e54 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2026-10-16  Paul Eggert  <[email protected]>
+
+       regex, ac-permissions, nstrftime: use maybe_unused
+       This is useful for Emacs when compiled with -Wunused-paramet3er.
+       * lib/malloc/dynarray-skeleton.c (DYNARRAY_NAME (free__elements__)):
+       * lib/malloc/dynarray_at_failure.c (__libc_dynarray_at_failure):
+       * lib/regcomp.c (regerror, calc_next, build_range_exp)
+       (build_collating_symbol, parse_bracket_element, build_equiv_class)
+       (free_tree):
+       * lib/regex_internal.h (re_string_elem_size_at):
+       Use __attribute_maybe_unused__ for arguments that are unused,
+       perhaps only when compiled under Gnulib.  Since glibc does not
+       have anything like _GL_UNNAMED, don’t use that here.
+       * lib/set-permissions.c (set_acls):
+       * lib/strftime.c (get_tm_zone): Use _GL_UNSUED for arguments that
+       might not be used, depending on compile-time options.
+
 2026-10-16  Bruno Haible  <[email protected]>
 
        tests: Fix build with 32-bit MSVC in 64-bit Cygwin/MSYS2 environment.
diff --git a/lib/malloc/dynarray-skeleton.c b/lib/malloc/dynarray-skeleton.c
index 9d83658eeb..38fbc69071 100644
--- a/lib/malloc/dynarray-skeleton.c
+++ b/lib/malloc/dynarray-skeleton.c
@@ -167,7 +167,9 @@ struct DYNARRAY_STRUCT
    elements.  Name mangling needed due to the DYNARRAY_ELEMENT_FREE
    macro expansion.  */
 static inline void
-DYNARRAY_NAME (free__elements__) (DYNARRAY_ELEMENT *__dynarray_array,
+DYNARRAY_NAME (free__elements__) (__attribute_maybe_unused__
+                                  DYNARRAY_ELEMENT *__dynarray_array,
+                                  __attribute_maybe_unused__
                                   size_t __dynarray_used)
 {
 #ifdef DYNARRAY_ELEMENT_FREE
diff --git a/lib/malloc/dynarray_at_failure.c b/lib/malloc/dynarray_at_failure.c
index c05807f00e..f7f2050ce9 100644
--- a/lib/malloc/dynarray_at_failure.c
+++ b/lib/malloc/dynarray_at_failure.c
@@ -25,7 +25,8 @@
 #include <stdio.h>
 
 void
-__libc_dynarray_at_failure (size_t size, size_t index)
+__libc_dynarray_at_failure (__attribute_maybe_unused__ size_t size,
+                            __attribute_maybe_unused__ size_t index)
 {
 #ifdef _LIBC
   char buf[200];
diff --git a/lib/regcomp.c b/lib/regcomp.c
index 5cd18a7639..e3af96f4c8 100644
--- a/lib/regcomp.c
+++ b/lib/regcomp.c
@@ -522,7 +522,9 @@ weak_alias (__regcomp, regcomp)
    from either regcomp or regexec.   We don't use PREG here.  */
 
 size_t
-regerror (int errcode, const regex_t *__restrict preg, char *__restrict errbuf,
+regerror (int errcode,
+         __attribute_maybe_unused__ const regex_t *__restrict preg,
+         char *__restrict errbuf,
          size_t errbuf_size)
 {
   const char *msg;
@@ -1391,7 +1393,7 @@ calc_first (void *extra, bin_tree_t *node)
 
 /* Pass 2: compute NEXT on the tree.  Preorder visit.  */
 static reg_errcode_t
-calc_next (void *extra, bin_tree_t *node)
+calc_next (__attribute_maybe_unused__ void *extra, bin_tree_t *node)
 {
   switch (node->token.type)
     {
@@ -2680,10 +2682,13 @@ parse_byte (unsigned char b, re_dfa_t const *dfa)
 static reg_errcode_t
 build_range_exp (bitset_t sbcset, re_charset_t *mbcset, Idx *range_alloc,
                 bracket_elem_t *start_elem, bracket_elem_t *end_elem,
-                re_dfa_t *dfa, reg_syntax_t syntax, uint_fast32_t nrules,
-                const unsigned char *collseqmb, const char *collseqwc,
-                int_fast32_t table_size, const void *symb_table,
-                const unsigned char *extra)
+                re_dfa_t *dfa, reg_syntax_t syntax,
+                __attribute_maybe_unused__ uint_fast32_t nrules,
+                __attribute_maybe_unused__ const unsigned char *collseqmb,
+                __attribute_maybe_unused__ const char *collseqwc,
+                __attribute_maybe_unused__ int_fast32_t table_size,
+                __attribute_maybe_unused__ const void *symb_table,
+                __attribute_maybe_unused__ const unsigned char *extra)
 {
   /* Equivalence Classes and Character Classes can't be a range start/end.  */
   if (__glibc_unlikely (start_elem->type == EQUIV_CLASS
@@ -2778,10 +2783,14 @@ build_range_exp (bitset_t sbcset, re_charset_t *mbcset, 
Idx *range_alloc,
    pointer argument since we may update it.  */
 
 static reg_errcode_t
-build_collating_symbol (bitset_t sbcset, re_charset_t *mbcset,
-                       Idx *coll_sym_alloc, const unsigned char *name,
-                       uint_fast32_t nrules, int_fast32_t table_size,
-                       const void *symb_table, const unsigned char *extra)
+build_collating_symbol (bitset_t sbcset,
+                       __attribute_maybe_unused__ re_charset_t *mbcset,
+                       __attribute_maybe_unused__ Idx *coll_sym_alloc,
+                       const unsigned char *name,
+                       __attribute_maybe_unused__ uint_fast32_t nrules,
+                       __attribute_maybe_unused__ int_fast32_t table_size,
+                       __attribute_maybe_unused__ const void *symb_table,
+                       __attribute_maybe_unused__ const unsigned char *extra)
 {
   size_t name_len = strlen ((const char *) name);
   if (__glibc_unlikely (name_len != 1))
@@ -3331,7 +3340,8 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, 
re_token_t *token,
 
 static reg_errcode_t
 parse_bracket_element (bracket_elem_t *elem, re_string_t *regexp,
-                      re_token_t *token, int token_len, re_dfa_t *dfa,
+                      re_token_t *token, int token_len,
+                      __attribute_maybe_unused__ re_dfa_t *dfa,
                       reg_syntax_t syntax, bool accept_hyphen)
 {
   int cur_char_size;
@@ -3415,8 +3425,10 @@ parse_bracket_symbol (bracket_elem_t *elem, re_string_t 
*regexp,
      is a pointer argument since we may update it.  */
 
 static reg_errcode_t
-build_equiv_class (bitset_t sbcset, re_charset_t *mbcset,
-                  Idx *equiv_class_alloc, const unsigned char *name)
+build_equiv_class (bitset_t sbcset,
+                  __attribute_maybe_unused__ re_charset_t *mbcset,
+                  __attribute_maybe_unused__ Idx *equiv_class_alloc,
+                  const unsigned char *name)
 {
 #ifdef _LIBC
   uint32_t nrules = _NL_CURRENT_WORD (LC_COLLATE, _NL_COLLATE_NRULES);
@@ -3770,7 +3782,7 @@ free_token (re_token_t *node)
    and its children. */
 
 static reg_errcode_t
-free_tree (void *extra, bin_tree_t *node)
+free_tree (__attribute_maybe_unused__ void *extra, bin_tree_t *node)
 {
   free_token (&node->token);
   return REG_NOERROR;
diff --git a/lib/regex_internal.h b/lib/regex_internal.h
index bf6c9ba3b8..cc421e6320 100644
--- a/lib/regex_internal.h
+++ b/lib/regex_internal.h
@@ -814,7 +814,8 @@ re_string_wchar_at (const re_string_t *pstr, Idx idx)
 
 static int
 __attribute__ ((pure, unused))
-re_string_elem_size_at (const re_string_t *pstr, Idx idx)
+re_string_elem_size_at (__attribute_maybe_unused__ const re_string_t *pstr,
+                       __attribute_maybe_unused__ Idx idx)
 {
 #ifdef _LIBC
   const unsigned char *p, *extra;
diff --git a/lib/set-permissions.c b/lib/set-permissions.c
index f6a1315e0d..e17a1e376d 100644
--- a/lib/set-permissions.c
+++ b/lib/set-permissions.c
@@ -473,7 +473,7 @@ context_acl_from_mode (struct permission_context *ctx)
 
 static int
 set_acls (struct permission_context *ctx, const char *name, int desc,
-          int from_mode, bool *must_chmod, bool *acls_set)
+          int from_mode, _GL_UNUSED bool *must_chmod, bool *acls_set)
 {
   int ret = 0;
 
diff --git a/lib/strftime.c b/lib/strftime.c
index fbde375bfe..6b24ce40ad 100644
--- a/lib/strftime.c
+++ b/lib/strftime.c
@@ -1082,7 +1082,8 @@ underlying_strftime (timezone_t tz, char *ubuf, size_t 
ubufsize,
    use plain "%Z".  Format an abbreviation appropriate for
    TP and EXTRA_ARGS_SPEC.  Return the empty string on failure.  */
 static char const *
-get_tm_zone (timezone_t tz, char *ubuf, int ubufsize, int modifier,
+get_tm_zone (MAYBE_UNUSED timezone_t tz, MAYBE_UNUSED char *ubuf,
+            MAYBE_UNUSED int ubufsize, MAYBE_UNUSED int modifier,
              struct tm const *tp)
 {
 #if HAVE_STRUCT_TM_TM_ZONE
-- 
2.56.0


Reply via email to