]> Savannah Git Hosting - gnulib.git/commitdiff
cdefs: merge from glibc
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 5 May 2022 21:34:23 +0000 (14:34 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 5 May 2022 22:15:50 +0000 (15:15 -0700)
* lib/cdefs.h (__glibc_safe_or_unknown_len):
Use glibc’s newer version.

ChangeLog
lib/cdefs.h

index 02be5e231747d250eff8b4c38e92b33adffc68ed..f1a154027a0639657bd414149b24e364ba204587 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2022-05-05  Paul Eggert  <eggert@cs.ucla.edu>
+
+       cdefs: merge from glibc
+       * lib/cdefs.h (__glibc_safe_or_unknown_len):
+       Use glibc’s newer version.
+
 2022-05-02  Paul Eggert  <eggert@cs.ucla.edu>
 
        gettime-res: help the compiler
index cb2514504f19008a270dd76b4082c2d2388ced92..7b8ed5b344b89d6acff337c7d88c79347f2ba3ad 100644 (file)
    || (__builtin_constant_p (__l) && (__l) > 0))
 
 /* Length is known to be safe at compile time if the __L * __S <= __OBJSZ
-   condition can be folded to a constant and if it is true.  The -1 check is
-   redundant because since it implies that __glibc_safe_len_cond is true.  */
+   condition can be folded to a constant and if it is true, or unknown (-1) */
 #define __glibc_safe_or_unknown_len(__l, __s, __osz) \
-  (__glibc_unsigned_or_positive (__l)                                        \
-   && __builtin_constant_p (__glibc_safe_len_cond ((__SIZE_TYPE__) (__l),     \
-                                                  __s, __osz))               \
-   && __glibc_safe_len_cond ((__SIZE_TYPE__) (__l), __s, __osz))
+  ((__osz) == (__SIZE_TYPE__) -1                                             \
+   || (__glibc_unsigned_or_positive (__l)                                    \
+       && __builtin_constant_p (__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), \
+                                                      (__s), (__osz)))       \
+       && __glibc_safe_len_cond ((__SIZE_TYPE__) (__l), (__s), (__osz))))
 
 /* Conversely, we know at compile time that the length is unsafe if the
    __L * __S <= __OBJSZ condition can be folded to a constant and if it is