From 8757e07175bd949eae5839e639ee75f757ba618e Mon Sep 17 00:00:00 2001 From: Steven Rostedt Date: Tue, 22 Feb 2011 14:57:10 -0500 Subject: trace-cmd: Remove redundant type field in list_for_each_entry() The type field in list_for_each_entry() is the same as the type that the ptr field points to. Use typeof(*ptr) instead. Signed-off-by: Steven Rostedt --- list.h | 16 +++++++++++++--- trace-input.c | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/list.h b/list.h index 440d2bd..9d5289c 100644 --- a/list.h +++ b/list.h @@ -45,6 +45,16 @@ static inline void list_add(struct list_head *p, struct list_head *head) head->next = p; } +static inline void list_add_tail(struct list_head *p, struct list_head *head) +{ + struct list_head *prev = head->prev; + + p->prev = prev; + p->next = head; + prev->next = p; + head->prev = p; +} + static inline void list_del(struct list_head *p) { struct list_head *next = p->next; @@ -59,9 +69,9 @@ static inline int list_empty(struct list_head *list) return list->next == list; } -#define list_for_each_entry(p, list, type, field) \ - for (p = container_of((list)->next, type, field); \ +#define list_for_each_entry(p, list, field) \ + for (p = container_of((list)->next, typeof(*p), field); \ &(p)->field != list; \ - p = container_of((p)->field.next, type, field)) + p = container_of((p)->field.next, typeof(*p), field)) #endif /* __LIST_H */ diff --git a/trace-input.c b/trace-input.c index 377ace7..61a02fe 100644 --- a/trace-input.c +++ b/trace-input.c @@ -624,7 +624,7 @@ static struct page *allocate_page(struct tracecmd_input *handle, struct page *page; int ret; - list_for_each_entry(page, &cpu_data->pages, struct page, list) { + list_for_each_entry(page, &cpu_data->pages, list) { if (page->offset == offset) { page->ref_count++; return page; -- cgit v1.2.2