mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-06 07:07:04 +02:00
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:
parent
75e480d107
commit
d3b46cca7b
@ -350,7 +350,7 @@
|
|||||||
* <type> which has its member <name> stored at address <ptr>.
|
* <type> which has its member <name> stored at address <ptr>.
|
||||||
*/
|
*/
|
||||||
#ifndef container_of
|
#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
|
#endif
|
||||||
|
|
||||||
/* returns a pointer to the structure of type <type> which has its member <name>
|
/* returns a pointer to the structure of type <type> which has its member <name>
|
||||||
@ -359,7 +359,7 @@
|
|||||||
#ifndef container_of_safe
|
#ifndef container_of_safe
|
||||||
#define container_of_safe(ptr, type, name) \
|
#define container_of_safe(ptr, type, name) \
|
||||||
({ void *__p = (ptr); \
|
({ void *__p = (ptr); \
|
||||||
__p ? (type *)(__p - ((long)&((type *)0)->name)) : (type *)0; \
|
__p ? (type *)((char *)__p - ((long)&((type *)0)->name)) : (type *)0; \
|
||||||
})
|
})
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user