Define __container_of only if not defined yet.

Silence warnings.

Signed-off-by: Enrico Weigelt, metux IT consult <info@metux.net>
This commit is contained in:
Enrico Weigelt, metux IT consult
2024-06-27 13:54:10 +02:00
parent 7f83eb6586
commit 5b60b8c27b
3 changed files with 7 additions and 0 deletions

View File

@@ -110,8 +110,10 @@ list_move(struct list *list, struct list *head)
}
}
#ifndef __container_of
#define __container_of(ptr, sample, member) \
(void *)((char *)(ptr) - ((char *)&(sample)->member - (char *)(sample)))
#endif
#define list_for_each_entry(pos, head, member) \
for (pos = __container_of((head)->next, pos, member); \

View File

@@ -305,8 +305,11 @@ list_is_empty(const struct list *head)
#define list_last_entry(ptr, type, member) \
list_entry((ptr)->prev, type, member)
#ifndef __container_of
#define __container_of(ptr, sample, member) \
(void *)((char *)(ptr) - ((char *)&(sample)->member - (char *)(sample)))
#endif
/**
* Loop through the list given by head and set pos to struct in the list.
*

View File

@@ -108,8 +108,10 @@ list_move(struct list *list, struct list *head)
}
}
#ifndef __container_of
#define __container_of(ptr, sample, member) \
(void *)((char *)(ptr) - ((char *)&(sample)->member - (char *)(sample)))
#endif
#define list_for_each_entry(pos, head, member) \
for (pos = __container_of((head)->next, pos, member); \