]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: container_of() - Avoid uintptr_t
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Wed, 22 Sep 2021 15:40:11 +0000 (18:40 +0300)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Wed, 29 Sep 2021 14:44:22 +0000 (14:44 +0000)
Using uintptr_t confused Coverity, but char* works fine.

src/lib/macros.h

index d41570a2827cb16cfc89392097c141ce3fc46c5c..fb5923dc3c620289daca88e060a1ed1c626687b5 100644 (file)
@@ -27,7 +27,7 @@
        ((const void *) (((uintptr_t) (ptr)) + ((size_t) (offset))))
 
 #define container_of(ptr, type, name) \
-       (type *)((uintptr_t)(ptr) - (uintptr_t)offsetof(type, name) + \
+       (type *)((char *)(ptr) - offsetof(type, name) + \
                 COMPILE_ERROR_IF_TYPES_NOT_COMPATIBLE(ptr, &((type *) 0)->name))
 
 /* Don't use simply MIN/MAX, as they're often defined elsewhere in include