From: Josef 'Jeff' Sipek Date: Mon, 22 Jan 2018 20:58:51 +0000 (-0500) Subject: lib: cast {,CONST_}PTR_OFFSET's offset argument to size_t X-Git-Tag: 2.3.9~2460 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e3440f3861208b263b31912bf4c81e04b7f22c62;p=thirdparty%2Fdovecot%2Fcore.git lib: cast {,CONST_}PTR_OFFSET's offset argument to size_t This fixes build on 32-bit systems where the addition may cause integer promotion to an integer type larger than uintptr_t. gcc 6.3.0 warning: file-cache.c: In function 'file_cache_write': macros.h:25:3: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast] ((void *) (((uintptr_t) (ptr)) + (offset))) --- diff --git a/src/lib/macros.h b/src/lib/macros.h index 8c4e0df489..22e4ef8ef0 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 *) (((uintptr_t) (ptr)) + (offset))) + ((void *) (((uintptr_t) (ptr)) + ((size_t) (offset)))) #define CONST_PTR_OFFSET(ptr, offset) \ - ((const void *) (((uintptr_t) (ptr)) + (offset))) + ((const void *) (((uintptr_t) (ptr)) + ((size_t) (offset)))) #define container_of(ptr, type, name) \ (type *)((uintptr_t)(ptr) - (uintptr_t)offsetof(type, name) + \