All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/3] tools: dumpimage: Provide more feedback on internal errors
@ 2019-09-17 21:09 Andrew F. Davis
  2019-09-17 21:09 ` [U-Boot] [PATCH 2/3] tools: fit_image: Use fit_image_get_data_and_size for getting offset/size Andrew F. Davis
                   ` (4 more replies)
  0 siblings, 5 replies; 11+ messages in thread
From: Andrew F. Davis @ 2019-09-17 21:09 UTC (permalink / raw)
  To: u-boot

The dumpimage utility errors out in a number of places without providing
sufficient feedback to allow the user to easily determine what has gone
wrong. Add additional error messages to make the cause of the failure
more obvious.

Signed-off-by: Andrew F. Davis <afd@ti.com>
---
 tools/dumpimage.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/tools/dumpimage.c b/tools/dumpimage.c
index ee3d41dda4..d5f893daf1 100644
--- a/tools/dumpimage.c
+++ b/tools/dumpimage.c
@@ -35,14 +35,23 @@ static int dumpimage_extract_subimage(struct image_type_params *tparams,
 	if (tparams->verify_header) {
 		retval = tparams->verify_header((unsigned char *)ptr,
 				sbuf->st_size, &params);
-		if (retval != 0)
+		if (retval != 0) {
+			fprintf(stderr, "%s: failed to verify header of %s\n",
+				params.cmdname, tparams->name);
 			return -1;
+		}
+
 		/*
 		 * Extract the file from the image
 		 * if verify is successful
 		 */
 		if (tparams->extract_subimage) {
 			retval = tparams->extract_subimage(ptr, &params);
+			if (retval != 0) {
+				fprintf(stderr, "%s: extract_subimage failed for %s\n",
+					params.cmdname, tparams->name);
+				return -3;
+			}
 		} else {
 			fprintf(stderr,
 				"%s: extract_subimage undefined for %s\n",
@@ -175,6 +184,9 @@ int main(int argc, char **argv)
 		 * image type. Returns the error code if not matched
 		 */
 		retval = dumpimage_extract_subimage(tparams, ptr, &sbuf);
+		if (retval)
+			fprintf(stderr, "%s: Can't extract subimage from %s\n",
+				params.cmdname, params.imagefile);
 	} else {
 		/*
 		 * Print the image information for matched image type
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH 2/3] tools: fit_image: Use fit_image_get_data_and_size for getting offset/size
  2019-09-17 21:09 [U-Boot] [PATCH 1/3] tools: dumpimage: Provide more feedback on internal errors Andrew F. Davis
@ 2019-09-17 21:09 ` Andrew F. Davis
  2019-11-14 11:46   ` Lokesh Vutla
  2020-01-08 20:10   ` Tom Rini
  2019-09-17 21:09 ` [U-Boot] [PATCH 3/3] tools: dumpimage: Fall-though to print usage for help command Andrew F. Davis
                   ` (3 subsequent siblings)
  4 siblings, 2 replies; 11+ messages in thread
From: Andrew F. Davis @ 2019-09-17 21:09 UTC (permalink / raw)
  To: u-boot

This is very similar to fit_image_get_data but has the benefit of working
on FIT images with external data unlike fit_image_get_data. This is
useful for extracting sub-images from type of FIT image as this would
previously just silently fail. Add an error message also so if this
still fails it is easier to find out why.

Signed-off-by: Andrew F. Davis <afd@ti.com>
---
 tools/fit_image.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/tools/fit_image.c b/tools/fit_image.c
index 5aca634b5e..0e4c2271ce 100644
--- a/tools/fit_image.c
+++ b/tools/fit_image.c
@@ -738,9 +738,14 @@ static int fit_image_extract(
 {
 	const void *file_data;
 	size_t file_size = 0;
+	int ret;
 
-	/* get the "data" property of component at offset "image_noffset" */
-	fit_image_get_data(fit, image_noffset, &file_data, &file_size);
+	/* get the data address and size of component at offset "image_noffset" */
+	ret = fit_image_get_data_and_size(fit, image_noffset, &file_data, &file_size);
+	if (ret) {
+		fprintf(stderr, "Could not get component information\n");
+		return ret;
+	}
 
 	/* save the "file_data" into the file specified by "file_name" */
 	return imagetool_save_subimage(file_name, (ulong) file_data, file_size);
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH 3/3] tools: dumpimage: Fall-though to print usage for help command
  2019-09-17 21:09 [U-Boot] [PATCH 1/3] tools: dumpimage: Provide more feedback on internal errors Andrew F. Davis
  2019-09-17 21:09 ` [U-Boot] [PATCH 2/3] tools: fit_image: Use fit_image_get_data_and_size for getting offset/size Andrew F. Davis
@ 2019-09-17 21:09 ` Andrew F. Davis
  2019-11-14 11:46   ` Lokesh Vutla
  2020-01-08 20:10   ` Tom Rini
  2019-11-13 16:14 ` [U-Boot] [PATCH 1/3] tools: dumpimage: Provide more feedback on internal errors Andrew F. Davis
                   ` (2 subsequent siblings)
  4 siblings, 2 replies; 11+ messages in thread
From: Andrew F. Davis @ 2019-09-17 21:09 UTC (permalink / raw)
  To: u-boot

This has the same result but some compilers will warn about this
fall-through if there are statements as part of the label block.

Signed-off-by: Andrew F. Davis <afd@ti.com>
---
 tools/dumpimage.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/tools/dumpimage.c b/tools/dumpimage.c
index d5f893daf1..e5481435a7 100644
--- a/tools/dumpimage.c
+++ b/tools/dumpimage.c
@@ -104,7 +104,6 @@ int main(int argc, char **argv)
 			printf("dumpimage version %s\n", PLAIN_VERSION);
 			exit(EXIT_SUCCESS);
 		case 'h':
-			usage();
 		default:
 			usage();
 			break;
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH 1/3] tools: dumpimage: Provide more feedback on internal errors
  2019-09-17 21:09 [U-Boot] [PATCH 1/3] tools: dumpimage: Provide more feedback on internal errors Andrew F. Davis
  2019-09-17 21:09 ` [U-Boot] [PATCH 2/3] tools: fit_image: Use fit_image_get_data_and_size for getting offset/size Andrew F. Davis
  2019-09-17 21:09 ` [U-Boot] [PATCH 3/3] tools: dumpimage: Fall-though to print usage for help command Andrew F. Davis
@ 2019-11-13 16:14 ` Andrew F. Davis
  2020-01-07 14:07   ` Andrew F. Davis
  2019-11-14 11:46 ` Lokesh Vutla
  2020-01-08 20:10 ` Tom Rini
  4 siblings, 1 reply; 11+ messages in thread
From: Andrew F. Davis @ 2019-11-13 16:14 UTC (permalink / raw)
  To: u-boot

On 9/17/19 5:09 PM, Andrew F. Davis wrote:
> The dumpimage utility errors out in a number of places without providing
> sufficient feedback to allow the user to easily determine what has gone
> wrong. Add additional error messages to make the cause of the failure
> more obvious.
> 
> Signed-off-by: Andrew F. Davis <afd@ti.com>
> ---


ping


>  tools/dumpimage.c | 14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/dumpimage.c b/tools/dumpimage.c
> index ee3d41dda4..d5f893daf1 100644
> --- a/tools/dumpimage.c
> +++ b/tools/dumpimage.c
> @@ -35,14 +35,23 @@ static int dumpimage_extract_subimage(struct image_type_params *tparams,
>  	if (tparams->verify_header) {
>  		retval = tparams->verify_header((unsigned char *)ptr,
>  				sbuf->st_size, &params);
> -		if (retval != 0)
> +		if (retval != 0) {
> +			fprintf(stderr, "%s: failed to verify header of %s\n",
> +				params.cmdname, tparams->name);
>  			return -1;
> +		}
> +
>  		/*
>  		 * Extract the file from the image
>  		 * if verify is successful
>  		 */
>  		if (tparams->extract_subimage) {
>  			retval = tparams->extract_subimage(ptr, &params);
> +			if (retval != 0) {
> +				fprintf(stderr, "%s: extract_subimage failed for %s\n",
> +					params.cmdname, tparams->name);
> +				return -3;
> +			}
>  		} else {
>  			fprintf(stderr,
>  				"%s: extract_subimage undefined for %s\n",
> @@ -175,6 +184,9 @@ int main(int argc, char **argv)
>  		 * image type. Returns the error code if not matched
>  		 */
>  		retval = dumpimage_extract_subimage(tparams, ptr, &sbuf);
> +		if (retval)
> +			fprintf(stderr, "%s: Can't extract subimage from %s\n",
> +				params.cmdname, params.imagefile);
>  	} else {
>  		/*
>  		 * Print the image information for matched image type
> 

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH 1/3] tools: dumpimage: Provide more feedback on internal errors
  2019-09-17 21:09 [U-Boot] [PATCH 1/3] tools: dumpimage: Provide more feedback on internal errors Andrew F. Davis
                   ` (2 preceding siblings ...)
  2019-11-13 16:14 ` [U-Boot] [PATCH 1/3] tools: dumpimage: Provide more feedback on internal errors Andrew F. Davis
@ 2019-11-14 11:46 ` Lokesh Vutla
  2020-01-08 20:10 ` Tom Rini
  4 siblings, 0 replies; 11+ messages in thread
From: Lokesh Vutla @ 2019-11-14 11:46 UTC (permalink / raw)
  To: u-boot



On 18/09/19 2:39 AM, Andrew F. Davis wrote:
> The dumpimage utility errors out in a number of places without providing
> sufficient feedback to allow the user to easily determine what has gone
> wrong. Add additional error messages to make the cause of the failure
> more obvious.
> 
> Signed-off-by: Andrew F. Davis <afd@ti.com>

Reviewed-by: Lokesh Vutla <lokeshvutla@ti.com>

Thanks and regards,
Lokesh

> ---
>  tools/dumpimage.c | 14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/dumpimage.c b/tools/dumpimage.c
> index ee3d41dda4..d5f893daf1 100644
> --- a/tools/dumpimage.c
> +++ b/tools/dumpimage.c
> @@ -35,14 +35,23 @@ static int dumpimage_extract_subimage(struct image_type_params *tparams,
>  	if (tparams->verify_header) {
>  		retval = tparams->verify_header((unsigned char *)ptr,
>  				sbuf->st_size, &params);
> -		if (retval != 0)
> +		if (retval != 0) {
> +			fprintf(stderr, "%s: failed to verify header of %s\n",
> +				params.cmdname, tparams->name);
>  			return -1;
> +		}
> +
>  		/*
>  		 * Extract the file from the image
>  		 * if verify is successful
>  		 */
>  		if (tparams->extract_subimage) {
>  			retval = tparams->extract_subimage(ptr, &params);
> +			if (retval != 0) {
> +				fprintf(stderr, "%s: extract_subimage failed for %s\n",
> +					params.cmdname, tparams->name);
> +				return -3;
> +			}
>  		} else {
>  			fprintf(stderr,
>  				"%s: extract_subimage undefined for %s\n",
> @@ -175,6 +184,9 @@ int main(int argc, char **argv)
>  		 * image type. Returns the error code if not matched
>  		 */
>  		retval = dumpimage_extract_subimage(tparams, ptr, &sbuf);
> +		if (retval)
> +			fprintf(stderr, "%s: Can't extract subimage from %s\n",
> +				params.cmdname, params.imagefile);
>  	} else {
>  		/*
>  		 * Print the image information for matched image type
> 

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH 2/3] tools: fit_image: Use fit_image_get_data_and_size for getting offset/size
  2019-09-17 21:09 ` [U-Boot] [PATCH 2/3] tools: fit_image: Use fit_image_get_data_and_size for getting offset/size Andrew F. Davis
@ 2019-11-14 11:46   ` Lokesh Vutla
  2020-01-08 20:10   ` Tom Rini
  1 sibling, 0 replies; 11+ messages in thread
From: Lokesh Vutla @ 2019-11-14 11:46 UTC (permalink / raw)
  To: u-boot



On 18/09/19 2:39 AM, Andrew F. Davis wrote:
> This is very similar to fit_image_get_data but has the benefit of working
> on FIT images with external data unlike fit_image_get_data. This is
> useful for extracting sub-images from type of FIT image as this would
> previously just silently fail. Add an error message also so if this
> still fails it is easier to find out why.
> 
> Signed-off-by: Andrew F. Davis <afd@ti.com>

Reviewed-by: Lokesh Vutla <lokeshvutla@ti.com>

Thanks and regards,
Lokesh

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH 3/3] tools: dumpimage: Fall-though to print usage for help command
  2019-09-17 21:09 ` [U-Boot] [PATCH 3/3] tools: dumpimage: Fall-though to print usage for help command Andrew F. Davis
@ 2019-11-14 11:46   ` Lokesh Vutla
  2020-01-08 20:10   ` Tom Rini
  1 sibling, 0 replies; 11+ messages in thread
From: Lokesh Vutla @ 2019-11-14 11:46 UTC (permalink / raw)
  To: u-boot



On 18/09/19 2:39 AM, Andrew F. Davis wrote:
> This has the same result but some compilers will warn about this
> fall-through if there are statements as part of the label block.
> 
> Signed-off-by: Andrew F. Davis <afd@ti.com>

Reviewed-by: Lokesh Vutla <lokeshvutla@ti.com>

Thanks and regards,
Lokesh

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH 1/3] tools: dumpimage: Provide more feedback on internal errors
  2019-11-13 16:14 ` [U-Boot] [PATCH 1/3] tools: dumpimage: Provide more feedback on internal errors Andrew F. Davis
@ 2020-01-07 14:07   ` Andrew F. Davis
  0 siblings, 0 replies; 11+ messages in thread
From: Andrew F. Davis @ 2020-01-07 14:07 UTC (permalink / raw)
  To: u-boot

On 11/13/19 11:14 AM, Andrew F. Davis wrote:
> On 9/17/19 5:09 PM, Andrew F. Davis wrote:
>> The dumpimage utility errors out in a number of places without providing
>> sufficient feedback to allow the user to easily determine what has gone
>> wrong. Add additional error messages to make the cause of the failure
>> more obvious.
>>
>> Signed-off-by: Andrew F. Davis <afd@ti.com>
>> ---
> 
> 
> ping
> 


ping #2


> 
>>  tools/dumpimage.c | 14 +++++++++++++-
>>  1 file changed, 13 insertions(+), 1 deletion(-)
>>
>> diff --git a/tools/dumpimage.c b/tools/dumpimage.c
>> index ee3d41dda4..d5f893daf1 100644
>> --- a/tools/dumpimage.c
>> +++ b/tools/dumpimage.c
>> @@ -35,14 +35,23 @@ static int dumpimage_extract_subimage(struct image_type_params *tparams,
>>  	if (tparams->verify_header) {
>>  		retval = tparams->verify_header((unsigned char *)ptr,
>>  				sbuf->st_size, &params);
>> -		if (retval != 0)
>> +		if (retval != 0) {
>> +			fprintf(stderr, "%s: failed to verify header of %s\n",
>> +				params.cmdname, tparams->name);
>>  			return -1;
>> +		}
>> +
>>  		/*
>>  		 * Extract the file from the image
>>  		 * if verify is successful
>>  		 */
>>  		if (tparams->extract_subimage) {
>>  			retval = tparams->extract_subimage(ptr, &params);
>> +			if (retval != 0) {
>> +				fprintf(stderr, "%s: extract_subimage failed for %s\n",
>> +					params.cmdname, tparams->name);
>> +				return -3;
>> +			}
>>  		} else {
>>  			fprintf(stderr,
>>  				"%s: extract_subimage undefined for %s\n",
>> @@ -175,6 +184,9 @@ int main(int argc, char **argv)
>>  		 * image type. Returns the error code if not matched
>>  		 */
>>  		retval = dumpimage_extract_subimage(tparams, ptr, &sbuf);
>> +		if (retval)
>> +			fprintf(stderr, "%s: Can't extract subimage from %s\n",
>> +				params.cmdname, params.imagefile);
>>  	} else {
>>  		/*
>>  		 * Print the image information for matched image type
>>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> https://lists.denx.de/listinfo/u-boot
> 

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH 1/3] tools: dumpimage: Provide more feedback on internal errors
  2019-09-17 21:09 [U-Boot] [PATCH 1/3] tools: dumpimage: Provide more feedback on internal errors Andrew F. Davis
                   ` (3 preceding siblings ...)
  2019-11-14 11:46 ` Lokesh Vutla
@ 2020-01-08 20:10 ` Tom Rini
  4 siblings, 0 replies; 11+ messages in thread
From: Tom Rini @ 2020-01-08 20:10 UTC (permalink / raw)
  To: u-boot

On Tue, Sep 17, 2019 at 05:09:33PM -0400, Andrew F. Davis wrote:

> The dumpimage utility errors out in a number of places without providing
> sufficient feedback to allow the user to easily determine what has gone
> wrong. Add additional error messages to make the cause of the failure
> more obvious.
> 
> Signed-off-by: Andrew F. Davis <afd@ti.com>
> Reviewed-by: Lokesh Vutla <lokeshvutla@ti.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200108/9db90b23/attachment.sig>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH 2/3] tools: fit_image: Use fit_image_get_data_and_size for getting offset/size
  2019-09-17 21:09 ` [U-Boot] [PATCH 2/3] tools: fit_image: Use fit_image_get_data_and_size for getting offset/size Andrew F. Davis
  2019-11-14 11:46   ` Lokesh Vutla
@ 2020-01-08 20:10   ` Tom Rini
  1 sibling, 0 replies; 11+ messages in thread
From: Tom Rini @ 2020-01-08 20:10 UTC (permalink / raw)
  To: u-boot

On Tue, Sep 17, 2019 at 05:09:34PM -0400, Andrew F. Davis wrote:

> This is very similar to fit_image_get_data but has the benefit of working
> on FIT images with external data unlike fit_image_get_data. This is
> useful for extracting sub-images from type of FIT image as this would
> previously just silently fail. Add an error message also so if this
> still fails it is easier to find out why.
> 
> Signed-off-by: Andrew F. Davis <afd@ti.com>
> Reviewed-by: Lokesh Vutla <lokeshvutla@ti.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200108/9fe6b88c/attachment.sig>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [U-Boot] [PATCH 3/3] tools: dumpimage: Fall-though to print usage for help command
  2019-09-17 21:09 ` [U-Boot] [PATCH 3/3] tools: dumpimage: Fall-though to print usage for help command Andrew F. Davis
  2019-11-14 11:46   ` Lokesh Vutla
@ 2020-01-08 20:10   ` Tom Rini
  1 sibling, 0 replies; 11+ messages in thread
From: Tom Rini @ 2020-01-08 20:10 UTC (permalink / raw)
  To: u-boot

On Tue, Sep 17, 2019 at 05:09:35PM -0400, Andrew F. Davis wrote:

> This has the same result but some compilers will warn about this
> fall-through if there are statements as part of the label block.
> 
> Signed-off-by: Andrew F. Davis <afd@ti.com>
> Reviewed-by: Lokesh Vutla <lokeshvutla@ti.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200108/4148d18b/attachment.sig>

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2020-01-08 20:10 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-17 21:09 [U-Boot] [PATCH 1/3] tools: dumpimage: Provide more feedback on internal errors Andrew F. Davis
2019-09-17 21:09 ` [U-Boot] [PATCH 2/3] tools: fit_image: Use fit_image_get_data_and_size for getting offset/size Andrew F. Davis
2019-11-14 11:46   ` Lokesh Vutla
2020-01-08 20:10   ` Tom Rini
2019-09-17 21:09 ` [U-Boot] [PATCH 3/3] tools: dumpimage: Fall-though to print usage for help command Andrew F. Davis
2019-11-14 11:46   ` Lokesh Vutla
2020-01-08 20:10   ` Tom Rini
2019-11-13 16:14 ` [U-Boot] [PATCH 1/3] tools: dumpimage: Provide more feedback on internal errors Andrew F. Davis
2020-01-07 14:07   ` Andrew F. Davis
2019-11-14 11:46 ` Lokesh Vutla
2020-01-08 20:10 ` Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.