Skip to contentSkip to conversation

mkimage: Skip adding non-existent IDs to a list

PATCH New Naoki Hayama 3 participants 3 messages Oct 7, 2020 – Oct 23, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 2/3 mkimage: Skip adding non-existent IDs to a list

In show_valid_options(), this patch introduces checking whether a category has an entry ID. If not, adding it to a list for output is skipped before calling qsort().
This patch will affect all kinds of image header categories (-A, -C, -O and -T flags).

---

 tools/mkimage.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
tools/mkimage.c +7 -2
index 43078d075c..e78608293e 100644
@@ -51,8 +51,13 @@ static int show_valid_options(enum ih_category category)
 		return -ENOMEM;
 
 	/* Sort the names in order of short name for easier reading */
-	for (item = 0; item < count; item++)
-		order[item] = item;
+	for (i = 0, item = 0; i < count; i++, item++) {
+		while (!genimg_cat_has_id(category, item) && i < count) {
+			item++;
+			count--;
+		}
+		order[i] = item;
+	}
 	cur_category = category;
 	qsort(order, count, sizeof(int), h_compare_category_name);
 
Signature · 1 line
2.17.1
#1 lore raw

PATCH 2/3 mkimage: Skip adding non-existent IDs to a list

Quoted 7 lines · Naoki Hayama

In show_valid_options(), this patch introduces checking whether a category has an entry ID. If not, adding it to a list for output is skipped before calling qsort().
This patch will affect all kinds of image header categories (-A, -C, -O and -T flags).

Quoted 5 lines

---

 tools/mkimage.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
#2 lore raw

PATCH 2/3 mkimage: Skip adding non-existent IDs to a list

In reply to Naoki Hayama
Quoted 8 lines · Naoki Hayama

In show_valid_options(), this patch introduces checking whether a category has an entry ID. If not, adding it to a list for output is skipped before calling qsort().
This patch will affect all kinds of image header categories (-A, -C, -O and -T flags).

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20201022/0158999f/attachment.sig>