]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
xalloc-oversized: pacify gcc -Wuseless-cast
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 26 May 2026 03:09:50 +0000 (20:09 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 26 May 2026 03:10:12 +0000 (20:10 -0700)
* lib/xalloc-oversized.h (xalloc_oversized): 1 → 1u.

ChangeLog
lib/xalloc-oversized.h

index ea72f7062ec003e52cac6c87dcf47b52f32a5455..33a67ff3229d6e68c993cc4ce32f32dff9243f56 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 2026-05-25  Paul Eggert  <eggert@cs.ucla.edu>
 
+       xalloc-oversized: pacify gcc -Wuseless-cast
+       * lib/xalloc-oversized.h (xalloc_oversized): 1 → 1u.
+
        quotearg: be nicer on macOS etc
        Problem reported by Bruno Haible in:
        https://lists.gnu.org/r/bug-gnulib/2026-05/msg00150.html
index cecdaec51ef4e30bee301a8b7f7a98a6efb08753..96c5f16570a1c4edd1e2789e6b8844b7b1e72dd1 100644 (file)
    : malloc (N * (size_t) S)).
 
    This is a macro, not a function, so that it works even if an
-   argument exceeds MAX (PTRDIFF_MAX, SIZE_MAX).  */
+   argument exceeds MAX (PTRDIFF_MAX, SIZE_MAX).  The 1u pacifies
+   -Wuseless-cast, and unlike a compound literal can appear in an
+   integer constant expression.  */
 #if 7 <= __GNUC__ && !defined __clang__ && PTRDIFF_MAX < SIZE_MAX
 # define xalloc_oversized(n, s) \
-   __builtin_mul_overflow_p (n, s, (ptrdiff_t) 1)
+   __builtin_mul_overflow_p (n, s, (ptrdiff_t) 1u)
 #elif 5 <= __GNUC__ && !defined __clang__ && !defined __ICC \
       && PTRDIFF_MAX < SIZE_MAX
 # define xalloc_oversized(n, s) \