]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: Rewrite POINTER_CAST_TO() to avoid new clang warning
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Mon, 23 Aug 2021 11:21:02 +0000 (14:21 +0300)
committerTimo Sirainen <timo.sirainen@open-xchange.com>
Tue, 24 Aug 2021 11:50:39 +0000 (14:50 +0300)
Fixes:
warning: performing pointer subtraction with a null pointer has undefined behavior [-Wnull-pointer-subtraction]

src/lib/macros.h

index cecd56913a081d02cbd8cbf83aa2284ca6b450a6..c264ec6066b052e7bc44c87c5ae7a4b1b929aa3e 100644 (file)
@@ -41,7 +41,7 @@
 #define POINTER_CAST(i) \
        ((void *) (((uintptr_t)NULL) + (i)))
 #define POINTER_CAST_TO(p, type) \
-       ((type) ((const char *) (p) - (const char *) NULL))
+       ((type)(uintptr_t)(p))
 
 /* Define VA_COPY() to do the right thing for copying va_list variables.
    config.h may have already defined VA_COPY as va_copy or __va_copy. */