fiptool: simplify assert() for add_image(_desc)
authorMasahiro Yamada <yamada.masahiro@socionext.com>
Fri, 27 Jan 2017 03:53:13 +0000 (12:53 +0900)
committerMasahiro Yamada <yamada.masahiro@socionext.com>
Fri, 27 Jan 2017 06:03:18 +0000 (15:03 +0900)
lookup_image(_desc)_from_uuid() traverses the linked list, so it
is not efficient.  We just want to make sure *p points to NULL here.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
tools/fiptool/fiptool.c

index b79c0d6979b064987fde14c88265d79a2a5de846..7a5c2cd72321db9d8ac80c31051c923ee74ccb5c 100644 (file)
@@ -202,11 +202,10 @@ static void add_image_desc(image_desc_t *desc)
 {
        image_desc_t **p = &image_desc_head;
 
-       assert(lookup_image_desc_from_uuid(&desc->uuid) == NULL);
-
        while (*p)
                p = &(*p)->next;
 
+       assert(*p == NULL);
        *p = desc;
        nr_image_descs++;
 }
@@ -244,11 +243,10 @@ static void add_image(image_t *image)
 {
        image_t **p = &image_head;
 
-       assert(lookup_image_from_uuid(&image->uuid) == NULL);
-
        while (*p)
                p = &(*p)->next;
 
+       assert(*p == NULL);
        *p = image;
 
        nr_images++;