mirror of
https://github.com/CTCaer/switch-l4t-atf.git
synced 2025-02-09 04:07:56 +00:00
fiptool: refactor remove_image()
We need not handle the image_head as a special case. Just use a double-pointer to simplify the traverse. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
This commit is contained in:
parent
e9e0d2877f
commit
9e866d34ed
@ -276,20 +276,20 @@ static void free_image(image_t *image)
|
||||
|
||||
static void remove_image(image_t *image)
|
||||
{
|
||||
image_t *tmp = image_head, *prev;
|
||||
image_t *tmp, **p = &image_head;
|
||||
|
||||
if (tmp == image) {
|
||||
image_head = tmp->next;
|
||||
free_image(tmp);
|
||||
} else {
|
||||
while (tmp != NULL && tmp != image) {
|
||||
prev = tmp;
|
||||
tmp = tmp->next;
|
||||
}
|
||||
assert(tmp != NULL);
|
||||
prev->next = tmp->next;
|
||||
free_image(tmp);
|
||||
while (*p) {
|
||||
if (*p == image)
|
||||
break;
|
||||
p = &(*p)->next;
|
||||
}
|
||||
|
||||
assert(*p != NULL);
|
||||
|
||||
tmp = *p;
|
||||
*p = tmp->next;
|
||||
free_image(tmp);
|
||||
|
||||
nr_images--;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user