From a85d569caaf2aefeefeeb12b8264b5d5d26d9568 Mon Sep 17 00:00:00 2001 From: leitner Date: Mon, 17 Apr 2006 17:35:33 +0000 Subject: [PATCH] gcc 4.1 version of the code also works with other compilers, so make it default and get rid of #ifdef hell --- rangecheck.h | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/rangecheck.h b/rangecheck.h index 70b0f3f..137be58 100644 --- a/rangecheck.h +++ b/rangecheck.h @@ -16,12 +16,9 @@ __static inline int range_ptrinbuf(const void* buf,size_t len,const void* ptr) { register const char* c=(const char*)buf; /* no pointer arithmetic on void* */ return (c && /* is buf non-NULL? */ -#if (__GNUC__ == 4) && (__GNUC_MINOR__ == 1) - ((uintptr_t)c)+len>(uintptr_t)c && /* gcc 4.1 miscompiles this test */ -#else - c+len>c && /* catch integer overflows and fail if buffer is 0 bytes long */ + ((uintptr_t)c)+len>(uintptr_t)c && /* gcc 4.1 miscompiles without (uintptr_t) */ + /* catch integer overflows and fail if buffer is 0 bytes long */ /* because then ptr can't point _in_ the buffer */ -#endif (uintptr_t)((const char*)ptr-c)=(uintptr_t)buf); /* gcc 4.1 miscompiles this test */ -#else - return (buf && (const char*)buf+len>=(const char*)buf); -#endif + return (buf && (uintptr_t)buf+len>=(uintptr_t)buf); } /* is buf2[0..len2-1] inside buf1[0..len-1]? */