[kernel] 解决rt_slist_for_each_entry宏不能正常遍历slist链表中元素的问题
因rt_slist_for_each_entry宏不能正常调用,在实际开发中去循环再调用rt_slist_entry很不简洁,所以修改了rt_slist_for_each_entry宏中关于链表next的判空处理。目前相关代码在GD32系统的MCU上均能正常工作,相关应用也在生产产品中经过验证。
This commit is contained in:
parent
bb8667e13b
commit
b51a3420b0
|
@ -280,9 +280,9 @@ rt_inline int rt_slist_isempty(rt_slist_t *l)
|
|||
* @param member the name of the list_struct within the struct.
|
||||
*/
|
||||
#define rt_slist_for_each_entry(pos, head, member) \
|
||||
for (pos = rt_slist_entry((head)->next, typeof(*pos), member); \
|
||||
&pos->member != (RT_NULL); \
|
||||
pos = rt_slist_entry(pos->member.next, typeof(*pos), member))
|
||||
for (pos = ((head)->next == (RT_NULL) ? (RT_NULL) : rt_slist_entry((head)->next, typeof(*pos), member)); \
|
||||
pos != (RT_NULL) && &pos->member != (RT_NULL); \
|
||||
pos = (pos->member.next == (RT_NULL) ? (RT_NULL) : rt_slist_entry(pos->member.next, typeof(*pos), member)))
|
||||
|
||||
/**
|
||||
* rt_slist_first_entry - get the first element from a slist
|
||||
|
|
Loading…
Reference in New Issue