[PATCH] Remove __SIZE_TYPE__ usage (BZ 33969)
Florian Weimer
fweimer@redhat.com
Wed Mar 11 11:58:26 GMT 2026
* Adhemerval Zanella:
> diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
> index 8d27f26da8..8d7807968f 100644
> --- a/misc/sys/cdefs.h
> +++ b/misc/sys/cdefs.h
> @@ -180,20 +180,20 @@
> /* 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, or unknown (-1) */
> #define __glibc_safe_or_unknown_len(__l, __s, __osz) \
> - ((__builtin_constant_p (__osz) && (__osz) == (__SIZE_TYPE__) -1) \
> + ((__builtin_constant_p (__osz) && (__osz) == (size_t) -1) \
> || (__glibc_unsigned_or_positive (__l) \
> - && __builtin_constant_p (__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), \
> + && __builtin_constant_p (__glibc_safe_len_cond ((size_t) (__l), \
> (__s), (__osz))) \
> - && __glibc_safe_len_cond ((__SIZE_TYPE__) (__l), (__s), (__osz))))
> + && __glibc_safe_len_cond ((size_t) (__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
> false. */
> #define __glibc_unsafe_len(__l, __s, __osz) \
> (__glibc_unsigned_or_positive (__l) \
> - && __builtin_constant_p (__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), \
> + && __builtin_constant_p (__glibc_safe_len_cond ((size_t) (__l), \
> __s, __osz)) \
> - && !__glibc_safe_len_cond ((__SIZE_TYPE__) (__l), __s, __osz))
> + && !__glibc_safe_len_cond ((size_t) (__l), __s, __osz))
>
> /* To correctly instrument the fortify wrapper clang requires the
> pass_object_size attribute, and the attribute has the restriction that the
> @@ -338,7 +338,7 @@
> : __ ## f ## _chk (__VA_ARGS__, __osz)))
> #else
> # define __glibc_fortify(f, __l, __s, __osz, ...) \
> - (__osz == (__SIZE_TYPE__) -1) \
> + (__osz == (size_t) -1) \
> ? __ ## f ## _alias (__VA_ARGS__) \
> : __ ## f ## _chk (__VA_ARGS__, __osz)
> #endif
> @@ -355,7 +355,7 @@
> : __ ## f ## _chk (__VA_ARGS__, (__osz) / (__s))))
> # else
> # define __glibc_fortify_n(f, __l, __s, __osz, ...) \
> - (__osz == (__SIZE_TYPE__) -1) \
> + (__osz == (size_t) -1) \
> ? __ ## f ## _alias (__VA_ARGS__) \
> : __ ## f ## _chk (__VA_ARGS__, (__osz) / (__s))
> #endif
I think these changes are unnecessary because they concern code that
uses extensions already.
Thanks,
Florian
More information about the Libc-alpha
mailing list