[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 1/2] cdefs: merge from glibc
From: |
Paul Eggert |
Subject: |
[PATCH 1/2] cdefs: merge from glibc |
Date: |
Thu, 5 May 2022 15:16:44 -0700 |
* lib/cdefs.h (__glibc_safe_or_unknown_len):
Use glibc’s newer version.
---
ChangeLog | 6 ++++++
lib/cdefs.h | 12 ++++++------
2 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 02be5e2317..f1a154027a 100644
--- 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
diff --git a/lib/cdefs.h b/lib/cdefs.h
index cb2514504f..7b8ed5b344 100644
--- a/lib/cdefs.h
+++ b/lib/cdefs.h
@@ -164,13 +164,13 @@
|| (__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
--
2.35.1
- [PATCH 1/2] cdefs: merge from glibc,
Paul Eggert <=