From ab6d34e043a499dcd940402a0e8c34e1c0ab4da4 Mon Sep 17 00:00:00 2001 From: pooler Date: Fri, 16 May 2014 11:06:02 +0200 Subject: [PATCH] Do not use the non-standard typeof operator --- elist.h | 23 +++++++++++++---------- util.c | 2 +- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/elist.h b/elist.h index b2e8263..5703c39 100644 --- a/elist.h +++ b/elist.h @@ -215,11 +215,12 @@ static inline void list_splice_init(struct list_head *list, * @pos: the type * to use as a loop counter. * @head: the head for your list. * @member: the name of the list_struct within the struct. + * @type: the type of the struct. */ -#define list_for_each_entry(pos, head, member) \ - for (pos = list_entry((head)->next, typeof(*pos), member); \ +#define list_for_each_entry(pos, head, member, type) \ + for (pos = list_entry((head)->next, type, member); \ &pos->member != (head); \ - pos = list_entry(pos->member.next, typeof(*pos), member)) + pos = list_entry(pos->member.next, type, member)) /** * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry @@ -227,12 +228,13 @@ static inline void list_splice_init(struct list_head *list, * @n: another type * to use as temporary storage * @head: the head for your list. * @member: the name of the list_struct within the struct. + * @type: the type of the struct. */ -#define list_for_each_entry_safe(pos, n, head, member) \ - for (pos = list_entry((head)->next, typeof(*pos), member), \ - n = list_entry(pos->member.next, typeof(*pos), member); \ +#define list_for_each_entry_safe(pos, n, head, member, type) \ + for (pos = list_entry((head)->next, type, member), \ + n = list_entry(pos->member.next, type, member); \ &pos->member != (head); \ - pos = n, n = list_entry(n->member.next, typeof(*n), member)) + pos = n, n = list_entry(n->member.next, type, member)) /** * list_for_each_entry_continue - iterate over list of given type @@ -240,12 +242,13 @@ static inline void list_splice_init(struct list_head *list, * @pos: the type * to use as a loop counter. * @head: the head for your list. * @member: the name of the list_struct within the struct. + * @type: the type of the struct. */ -#define list_for_each_entry_continue(pos, head, member) \ - for (pos = list_entry(pos->member.next, typeof(*pos), member), \ +#define list_for_each_entry_continue(pos, head, member, type) \ + for (pos = list_entry(pos->member.next, type, member), \ prefetch(pos->member.next); \ &pos->member != (head); \ - pos = list_entry(pos->member.next, typeof(*pos), member), \ + pos = list_entry(pos->member.next, type, member), \ prefetch(pos->member.next)) #endif diff --git a/util.c b/util.c index d69f146..9be17f6 100644 --- a/util.c +++ b/util.c @@ -1417,7 +1417,7 @@ void tq_free(struct thread_q *tq) if (!tq) return; - list_for_each_entry_safe(ent, iter, &tq->q, q_node) { + list_for_each_entry_safe(ent, iter, &tq->q, q_node, struct tq_ent) { list_del(&ent->q_node); free(ent); }