summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorMasahiro Yamada <yamada.masahiro@socionext.com>2017-01-27 13:31:40 +0900
committerMasahiro Yamada <yamada.masahiro@socionext.com>2017-01-27 15:03:46 +0900
commit9e866d34edded882052c5a9c6dba0885639f3441 (patch)
tree0e8db112727b5fbf190490f4fbcd8e0629bf9e59 /tools
parente9e0d2877fb27b81c6b55b57fad684e3f15c15bf (diff)
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>
Diffstat (limited to 'tools')
-rw-r--r--tools/fiptool/fiptool.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/tools/fiptool/fiptool.c b/tools/fiptool/fiptool.c
index 7a5c2cd7..fef1ea83 100644
--- a/tools/fiptool/fiptool.c
+++ b/tools/fiptool/fiptool.c
@@ -276,20 +276,20 @@ static void free_image(image_t *image)
static void remove_image(image_t *image)
{
- image_t *tmp = image_head, *prev;
-
- 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);
+ image_t *tmp, **p = &image_head;
+
+ while (*p) {
+ if (*p == image)
+ break;
+ p = &(*p)->next;
}
+
+ assert(*p != NULL);
+
+ tmp = *p;
+ *p = tmp->next;
+ free_image(tmp);
+
nr_images--;
}