G
gaoqiang
in linux kernel,there is such code that:
213 /**
214 * list_for_each_entry_safe - iterate over list of given type safe
against removal of list entry
215 * @pos: the type * to use as a loop cursor.
216 * @n: another type * to use as temporary storage
217 * @head: the head for your list.
218 * @member: the name of the list_struct within the struct.
219 */
220 #define list_for_each_entry_safe(pos, n, head, member) \
221 for (pos = list_entry((head)->next, typeof(*pos), member), \
222 n = list_entry(pos->member.next, typeof(*pos), member); \
223 &pos->member != (head); \
224 pos = n, n = list_entry(n->member.next, typeof(*n),
member))
why an additional param "n" should passed in?
I think the following code will work fun....
#define list_for_each_entry_safe(pos, head, member) \
--->> typeof(*pos) *_tmp_n_;
213 /**
214 * list_for_each_entry_safe - iterate over list of given type safe
against removal of list entry
215 * @pos: the type * to use as a loop cursor.
216 * @n: another type * to use as temporary storage
217 * @head: the head for your list.
218 * @member: the name of the list_struct within the struct.
219 */
220 #define list_for_each_entry_safe(pos, n, head, member) \
221 for (pos = list_entry((head)->next, typeof(*pos), member), \
222 n = list_entry(pos->member.next, typeof(*pos), member); \
223 &pos->member != (head); \
224 pos = n, n = list_entry(n->member.next, typeof(*n),
member))
why an additional param "n" should passed in?
I think the following code will work fun....
#define list_for_each_entry_safe(pos, head, member) \
--->> typeof(*pos) *_tmp_n_;