--- ptrlist.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/ptrlist.c b/ptrlist.c index bae5512f3..1957baf1f 100644 --- a/ptrlist.c +++ b/ptrlist.c @@ -207,20 +207,21 @@ void * undo_ptr_list_last(struct ptr_list **head) void * delete_ptr_list_last(struct ptr_list **head) { - void *ptr = NULL; - struct ptr_list *last, *first = *head; + struct ptr_cur cur; + void *ptr; - if (!first) + if (!ptr_cur_end(&cur, *head) || !ptr_cur_prev(&cur)) return NULL; - last = first->prev; - if (last->nr) - ptr = last->list[--last->nr]; - if (last->nr <=0) { - first->prev = last->prev; - last->prev->next = first; - if (last == first) + + ptr = ptr_cur_entry(&cur); + if (--cur.l->nr == 0) { + if (cur.l == cur.h) *head = NULL; - __free_ptrlist(last); + else { + cur.h->prev = cur.l->prev; + cur.l->prev->next = cur.h; + } + __free_ptrlist(cur.l); } return ptr; } -- 2.13.0 -- To unsubscribe from this list: send the line "unsubscribe linux-sparse" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html