--- ptrlist.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/ptrlist.c b/ptrlist.c index b4fb3fd6e..bae5512f3 100644 --- a/ptrlist.c +++ b/ptrlist.c @@ -192,22 +192,17 @@ out: /* This removes the last entry, but doesn't pack the ptr list */ void * undo_ptr_list_last(struct ptr_list **head) { - 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; - do { - last = last->prev; - if (last->nr) { - void *ptr; - int nr = --last->nr; - ptr = last->list[nr]; - last->list[nr] = (void *)0xf1f1f1f1; - return ptr; - } - } while (last != first); - return NULL; + + ptr = cur.l->list[cur.n]; + cur.l->list[cur.n--] = (void *)0xf1f1f1f1; + cur.l->nr--; + + return ptr; } void * delete_ptr_list_last(struct ptr_list **head) -- 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