Skip to contentSkip to conversation

image-fit: Don't display an error in fit_set_timestamp()

PATCH New Simon Glass 3 participants 5 messages May 1, 2016 – May 23, 2016

lore
Share & tools
lore
#0 lore raw

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.

---

 common/image-fit.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
common/image-fit.c +3 -3
index 25f8a11..c86b7c6 100644
@@ -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;
 	}
 
Signature · 1 line
2.8.0.rc3.226.g39d4020
#1 lore raw

PATCH 2/2 mkimage: Add a quiet mode

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.

---

 tools/imagetool.c | 3 ++-
 tools/imagetool.h | 1 +
 tools/mkimage.c   | 5 ++++-
 3 files changed, 7 insertions(+), 2 deletions(-)
tools/imagetool.c +2 -1
index 916ab96..08d191d 100644
@@ -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",
tools/imagetool.h +1 -0
index 24f8f4b..a3ed0f4 100644
@@ -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 */
 };
 
 /*
tools/mkimage.c +4 -1
index 2931783..5e883d7 100644
@@ -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;
Signature · 1 line
2.8.0.rc3.226.g39d4020
#2 lore raw

PATCH 2/2 mkimage: Add a quiet mode

Hi Simon,

Quoted 5 lines · Simon Glass

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.

With one nit below...

Quoted 12 lines

---

 tools/imagetool.c | 3 ++-
 tools/imagetool.h | 1 +
 tools/mkimage.c   | 5 ++++-
 3 files changed, 7 insertions(+), 2 deletions(-)
tools/imagetool.c +0 -0
index 916ab96..08d191d 100644

tools/imagetool.c int imagetool_verify_print_header( · line 54

Quoted 5 lines
tools/imagetool.c +1 -1
@@ -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.

Quoted 4 lines
tools/imagetool.c +1 -0
+                                               (*curr)->print_header(ptr);
                                } else {
                                        fprintf(stderr,
                                                "%s: print_header undefined for %s\n",

<snip>

#3 lore raw

PATCH 2/2 mkimage: Add a quiet mode

In reply to Simon Glass
Quoted 6 lines · Simon Glass

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.

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: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160523/b0c2f34f/attachment.sig>
#4 lore raw

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

In reply to Simon Glass
Quoted 9 lines · Simon Glass

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.

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: 819 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160523/0d5cdd80/attachment.sig>