Use __typeof__(sizeof 0) trickery

We cannot pull stddef.h and since fortify already relies on GCC
features we can use the above typeof trick to get a usable size_t.
This commit is contained in:
sin 2015-02-28 16:01:26 +00:00
parent 4672406edd
commit 7212959240

View File

@ -9,9 +9,9 @@ static inline __attribute__ ((always_inline))
int
__fortify_poll(struct pollfd *fds, nfds_t nfds, int timeout)
{
__typeof__(sizeof 0) bos = __builtin_object_size(fds, 0);
if (__builtin_object_size(fds, 0) != -1 &&
nfds > __builtin_object_size(fds, 0) / sizeof(struct pollfd))
if (bos != -1 && nfds > bos / sizeof(struct pollfd))
__builtin_trap();
return poll(fds, nfds, timeout);
}