]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: Use uintptr_t in PTR_OFFSET and POINTER_CAST
authorAki Tuomi <aki.tuomi@dovecot.fi>
Sun, 14 Jan 2018 17:21:36 +0000 (19:21 +0200)
committerVille Savolainen <ville.savolainen@dovecot.fi>
Mon, 1 Apr 2019 07:34:20 +0000 (10:34 +0300)
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

src/lib/macros.h

index 55e60567501fb1175ee40e00f1ecc5a66152655c..abcb101d641cd8715d54b9ef4bcbb6e6c1b63315 100644 (file)
@@ -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))