[U-Boot] [PATCH 1/2] image-fit: Don't display an error in fit_set_timestamp()

This function returns an error code and its caller may be able to fix the error. For example fit_handle_file() expands the device tree to fit if there is a lack of space.
In this case the caller does not want an error displayed. It is confusing, since it suggests that something is wrong, when it fact everything is fine. Drop the error.
Signed-off-by: Simon Glass sjg@chromium.org ---
common/image-fit.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/common/image-fit.c b/common/image-fit.c index 25f8a11..c86b7c6 100644 --- a/common/image-fit.c +++ b/common/image-fit.c @@ -886,9 +886,9 @@ int fit_set_timestamp(void *fit, int noffset, time_t timestamp) ret = fdt_setprop(fit, noffset, FIT_TIMESTAMP_PROP, &t, sizeof(uint32_t)); if (ret) { - printf("Can't set '%s' property for '%s' node (%s)\n", - FIT_TIMESTAMP_PROP, fit_get_name(fit, noffset, NULL), - fdt_strerror(ret)); + debug("Can't set '%s' property for '%s' node (%s)\n", + FIT_TIMESTAMP_PROP, fit_get_name(fit, noffset, NULL), + fdt_strerror(ret)); return ret == -FDT_ERR_NOSPACE ? -ENOSPC : -1; }

Some build systems want to be quiet unless there is a problem. At present mkimage displays quite a bit of information when generating a FIT file. Add a '-q' flag to silence this.
Signed-off-by: Simon Glass sjg@chromium.org ---
tools/imagetool.c | 3 ++- tools/imagetool.h | 1 + tools/mkimage.c | 5 ++++- 3 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/tools/imagetool.c b/tools/imagetool.c index 916ab96..08d191d 100644 --- a/tools/imagetool.c +++ b/tools/imagetool.c @@ -51,7 +51,8 @@ int imagetool_verify_print_header( * successful */ if ((*curr)->print_header) { - (*curr)->print_header(ptr); + if (!params->quiet) + (*curr)->print_header(ptr); } else { fprintf(stderr, "%s: print_header undefined for %s\n", diff --git a/tools/imagetool.h b/tools/imagetool.h index 24f8f4b..a3ed0f4 100644 --- a/tools/imagetool.h +++ b/tools/imagetool.h @@ -73,6 +73,7 @@ struct image_tool_params { struct content_info *content_head; /* List of files to include */ struct content_info *content_tail; bool external_data; /* Store data outside the FIT */ + bool quiet; /* Don't output text in normal operation */ };
/* diff --git a/tools/mkimage.c b/tools/mkimage.c index 2931783..5e883d7 100644 --- a/tools/mkimage.c +++ b/tools/mkimage.c @@ -138,7 +138,7 @@ static void process_args(int argc, char **argv)
expecting = IH_TYPE_COUNT; /* Unknown */ while ((opt = getopt(argc, argv, - "-a:A:bcC:d:D:e:Ef:Fk:K:ln:O:rR:sT:vVx")) != -1) { + "-a:A:bcC:d:D:e:Ef:Fk:K:ln:O:rR:qsT:vVx")) != -1) { switch (opt) { case 'a': params.addr = strtoull(optarg, &ptr, 16); @@ -213,6 +213,9 @@ static void process_args(int argc, char **argv) if (params.os < 0) usage("Invalid operating system"); break; + case 'q': + params.quiet = 1; + break; case 'r': params.require_keys = 1; break;

Hi Simon,
On Sun, May 1, 2016 at 2:55 PM, Simon Glass sjg@chromium.org wrote:
Some build systems want to be quiet unless there is a problem. At present mkimage displays quite a bit of information when generating a FIT file. Add a '-q' flag to silence this.
Signed-off-by: Simon Glass sjg@chromium.org
Acked-by: Joe Hershberger joe.hershberger@ni.com
With one nit below...
tools/imagetool.c | 3 ++- tools/imagetool.h | 1 + tools/mkimage.c | 5 ++++- 3 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/tools/imagetool.c b/tools/imagetool.c index 916ab96..08d191d 100644 --- a/tools/imagetool.c +++ b/tools/imagetool.c @@ -51,7 +51,8 @@ int imagetool_verify_print_header( * successful */ if ((*curr)->print_header) {
(*curr)->print_header(ptr);
if (!params->quiet)
This test should be before the test for print_header being NULL above. It would be silly to get an error saying that print_header is undefined when you just asked to not call it.
(*curr)->print_header(ptr); } else { fprintf(stderr, "%s: print_header undefined for %s\n",
<snip>

On Sun, May 01, 2016 at 01:55:38PM -0600, Simon Glass wrote:
Some build systems want to be quiet unless there is a problem. At present mkimage displays quite a bit of information when generating a FIT file. Add a '-q' flag to silence this.
Signed-off-by: Simon Glass sjg@chromium.org Acked-by: Joe Hershberger joe.hershberger@ni.com
Applied to u-boot/master, thanks!

On Sun, May 01, 2016 at 01:55:37PM -0600, Simon Glass wrote:
This function returns an error code and its caller may be able to fix the error. For example fit_handle_file() expands the device tree to fit if there is a lack of space.
In this case the caller does not want an error displayed. It is confusing, since it suggests that something is wrong, when it fact everything is fine. Drop the error.
Signed-off-by: Simon Glass sjg@chromium.org
Applied to u-boot/master, thanks!
participants (3)
-
Joe Hershberger
-
Simon Glass
-
Tom Rini