Replace list.h undefined behavior with offsetof.

master
AliceLR 5 years ago committed by Ozkan Sezer
parent 030907d14b
commit d741e61abd
  1. 4
      src/list.h

@ -4,6 +4,8 @@
#ifndef __LINUX_LIST_H
#define __LINUX_LIST_H
#include <stddef.h> /* offsetof */
#ifdef _MSC_VER
#define __inline__ __inline
#endif
@ -136,7 +138,7 @@ static __inline__ void list_splice(struct list_head *list, struct list_head *hea
* @member: the name of the list_struct within the struct.
*/
#define list_entry(ptr, type, member) \
((type *)((char *)(ptr)-(size_t)(&((type *)0)->member)))
((type *)((char *)(ptr) - offsetof(type, member)))
/**
* list_for_each - iterate over a list

Loading…
Cancel
Save