From: Aki Tuomi Date: Sun, 14 Jan 2018 17:21:36 +0000 (+0200) Subject: lib: Use uintptr_t in PTR_OFFSET and POINTER_CAST X-Git-Tag: 2.3.9~2531 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=ac7aa955db4c77bbb169baa5d104a4c128674646;p=thirdparty%2Fdovecot%2Fcore.git lib: Use uintptr_t in PTR_OFFSET and POINTER_CAST Use uintptr_t instead of pointers. Fixes clang 6.0 warning: arithmetic on a null pointer treated as a cast from integer to pointer is a GNU extension --- diff --git a/src/lib/macros.h b/src/lib/macros.h index eec7cd2f02..8c4e0df489 100644 --- a/src/lib/macros.h +++ b/src/lib/macros.h @@ -22,9 +22,9 @@ (((size) + MEM_ALIGN_SIZE-1) & ~((size_t) MEM_ALIGN_SIZE-1)) #define PTR_OFFSET(ptr, offset) \ - ((void *) (((unsigned char *) (ptr)) + (offset))) + ((void *) (((uintptr_t) (ptr)) + (offset))) #define CONST_PTR_OFFSET(ptr, offset) \ - ((const void *) (((const unsigned char *) (ptr)) + (offset))) + ((const void *) (((uintptr_t) (ptr)) + (offset))) #define container_of(ptr, type, name) \ (type *)((uintptr_t)(ptr) - (uintptr_t)offsetof(type, name) + \ @@ -39,7 +39,7 @@ sizeof(size_t) == sizeof(void *) and they're both the largest datatypes that are allowed to be used. so, long long isn't safe with these. */ #define POINTER_CAST(i) \ - ((void *) ((char *) NULL + (i))) + ((void *) (((uintptr_t)NULL) + (i))) #define POINTER_CAST_TO(p, type) \ ((type) ((const char *) (p) - (const char *) NULL))