[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).
Signed-off-by: Naoki Hayama naoki.hayama@lineo.co.jp ---
tools/mkimage.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/tools/mkimage.c b/tools/mkimage.c index 43078d075c..e78608293e 100644 --- a/tools/mkimage.c +++ b/tools/mkimage.c @@ -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);

On Tue, 6 Oct 2020 at 20:22, Naoki Hayama naoki.hayama@lineo.co.jp wrote:
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).
Signed-off-by: Naoki Hayama naoki.hayama@lineo.co.jp
tools/mkimage.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
Reviewed-by: Simon Glass sjg@chromium.org

On Wed, Oct 07, 2020 at 11:21:55AM +0900, Naoki Hayama wrote:
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).
Signed-off-by: Naoki Hayama naoki.hayama@lineo.co.jp Reviewed-by: Simon Glass sjg@chromium.org
Applied to u-boot/master, thanks!
participants (3)
-
Naoki Hayama
-
Simon Glass
-
Tom Rini