CLEANUP: compiler: prefer char * over void * for pointer arithmetic

This patch changes two instances of pointer arithmetic on void *
to use char * instead, to avoid UB. This is essentially to please
UB analyzers, though.
This commit is contained in:
Ben Kallus 2025-07-20 12:48:07 -04:00 committed by Willy Tarreau
parent 75e480d107
commit d3b46cca7b

View File

@ -350,7 +350,7 @@
* <type> which has its member <name> stored at address <ptr>.
*/
#ifndef container_of
#define container_of(ptr, type, name) ((type *)(((void *)(ptr)) - ((long)&((type *)0)->name)))
#define container_of(ptr, type, name) ((type *)(((char *)(ptr)) - ((long)&((type *)0)->name)))
#endif
/* returns a pointer to the structure of type <type> which has its member <name>
@ -359,7 +359,7 @@
#ifndef container_of_safe
#define container_of_safe(ptr, type, name) \
({ void *__p = (ptr); \
__p ? (type *)(__p - ((long)&((type *)0)->name)) : (type *)0; \
__p ? (type *)((char *)__p - ((long)&((type *)0)->name)) : (type *)0; \
})
#endif