From ad5fb9f2e66e605941f78791f552c6bf6e522a9d Mon Sep 17 00:00:00 2001 From: Naoki Hayama Date: Wed, 7 Oct 2020 11:21:55 +0900 Subject: 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 Reviewed-by: Simon Glass --- tools/mkimage.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'tools') 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); -- cgit From 3311eda658e0d800eec1aae4e608726a00e19865 Mon Sep 17 00:00:00 2001 From: Heinrich Schuchardt Date: Thu, 8 Oct 2020 20:51:24 +0200 Subject: tools: image-host.c: use correct output format MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When building on a 32bit host the following warning occurs: tools/image-host.c: In function ‘fit_image_read_data’: tools/image-host.c:296:56: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 3 has type ‘__off64_t’ {aka ‘long long int’} [-Wformat=] printf("File %s don't have the expected size (size=%ld, expected=%d)\n", ~~^ %lld filename, sbuf.st_size, expected_size); ~~~~~~~~~~~~ tools/image-host.c:311:62: warning: format ‘%ld’ expects argument of type ‘long int’, but argument 4 has type ‘__off64_t’ {aka ‘long long int’} [-Wformat=] printf("Can't read all file %s (read %zd bytes, expexted %ld)\n", ~~^ %lld filename, n, sbuf.st_size); ~~~~~~~~~~~~ Fix the format strings. Signed-off-by: Heinrich Schuchardt Reviewed-by: Simon Glass --- tools/image-host.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tools') diff --git a/tools/image-host.c b/tools/image-host.c index 8886beff17..7cef78eab8 100644 --- a/tools/image-host.c +++ b/tools/image-host.c @@ -293,8 +293,8 @@ static int fit_image_read_data(char *filename, unsigned char *data, /* Check file size */ if (sbuf.st_size != expected_size) { - printf("File %s don't have the expected size (size=%ld, expected=%d)\n", - filename, sbuf.st_size, expected_size); + printf("File %s don't have the expected size (size=%lld, expected=%d)\n", + filename, (long long)sbuf.st_size, expected_size); goto err; } @@ -308,8 +308,8 @@ static int fit_image_read_data(char *filename, unsigned char *data, /* Check that we have read all the file */ if (n != sbuf.st_size) { - printf("Can't read all file %s (read %zd bytes, expexted %ld)\n", - filename, n, sbuf.st_size); + printf("Can't read all file %s (read %zd bytes, expexted %lld)\n", + filename, n, (long long)sbuf.st_size); goto err; } -- cgit