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.
* <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>
#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