Re: [PATCH 1/2] list: introduce a new cutting helper

From: Chaitanya Kulkarni
Date: Wed Jun 12 2024 - 13:19:41 EST


On 6/12/24 08:51, Keith Busch wrote:
> From: Keith Busch <kbusch@xxxxxxxxxx>
>
> Provide a helper to remove elements from a list to the end, and place
> those elements in a new list.
>
> Signed-off-by: Keith Busch <kbusch@xxxxxxxxxx>
> ---

Looks good.

Reviewed-by: Chaitanya Kulkarni <kch@xxxxxxxxxx>

-ck

I did quick run before the review if anybody cares :-

          head     entry                      list

node [3 | | 2]    [1 | | 3]     [2 | | 1]    [X | | X]
addr 1             2            3            4

+ list->next = entry;
+ list->prev = head->prev;
node                                         [3 | | 2]
addr                                         4

+ head->prev = entry->prev;
node  [1 | | 2]
addr  1
+ entry->prev->next = head; node [1 | | 1]
addr 1

+ entry->prev = list; node               [4 | | 3]
addr                2

+ list->prev->next = list;
node                          [2 | | 4] addr                          3

reordering with list at front with head  :-
     head
node [1 | | 1]
addr
     list
node [3 | | 2] [4 | | 3] [2 | | 4]
addr  4         2         3