tools: dumpimage: Provide more feedback on internal errors
PATCH 1/3 tools: dumpimage: Provide more feedback on internal errors
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.
--- tools/dumpimage.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)
tools/dumpimage.c +13 -1
@@ -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, ¶ms); -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, ¶ms); +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
Signature · 1 line
2.17.1
PATCH 2/3 tools: fit_image: Use fit_image_get_data_and_size for getting offset/size
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.
--- tools/fit_image.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
tools/fit_image.c +7 -2
@@ -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);
Signature · 1 line
2.17.1
PATCH 3/3 tools: dumpimage: Fall-though to print usage for help command
In reply to Andrew F. DavisThis has the same result but some compilers will warn about this fall-through if there are statements as part of the label block.
--- tools/dumpimage.c | 1 - 1 file changed, 1 deletion(-)
tools/dumpimage.c +0 -1
@@ -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 ;
Signature · 1 line
2.17.1
PATCH 1/3 tools: dumpimage: Provide more feedback on internal errors
In reply to Andrew F. DavisQuoted 7 lines · Andrew F. Davis
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 <[email protected]>---
ping
Quoted 43 lines
tools/dumpimage.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)tools/dumpimage.c +13
-1@@ -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, ¶ms); -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, ¶ms); +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
PATCH 1/3 tools: dumpimage: Provide more feedback on internal errors
In reply to Andrew F. DavisQuoted 6 lines · Andrew F. Davis
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 <[email protected]>
Thanks and regards,
Lokesh
Quoted 44 lines
--- tools/dumpimage.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)tools/dumpimage.c +13
-1@@ -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, ¶ms); -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, ¶ms); +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
PATCH 2/3 tools: fit_image: Use fit_image_get_data_and_size for getting offset/size
In reply to Andrew F. DavisQuoted 7 lines · Andrew F. Davis
This is very similar to
fit_image_get_databut has the benefit of working on FIT images with external data unlikefit_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 <[email protected]>
Thanks and regards,
Lokesh
PATCH 3/3 tools: dumpimage: Fall-though to print usage for help command
In reply to Andrew F. DavisQuoted 4 lines · Andrew F. Davis
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 <[email protected]>
Thanks and regards,
Lokesh
PATCH 1/3 tools: dumpimage: Provide more feedback on internal errors
In reply to Andrew F. DavisQuoted 6 lines · Andrew F. Davis
Quoted 5 lines · Andrew F. Davis
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.
Quoted 6 lines
Quoted 2 lines
Signed-off-by Andrew F. Davis <[email protected]>---
ping
ping #2
Quoted 49 lines
Quoted 35 lines
tools/dumpimage.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)tools/dumpimage.c +10
-1@@ -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, ¶ms); -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, ¶ms); +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",tools/dumpimage.c int main(int argc, char **argv) · line 192
Quoted 9 lines
tools/dumpimage.c +3
-0@@ -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
PATCH 1/3 tools: dumpimage: Provide more feedback on internal errors
In reply to Andrew F. DavisQuoted 7 lines · Andrew F. Davis
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 <[email protected]>Reviewed-by Lokesh Vutla <[email protected]>
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: 833 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200108/9db90b23/attachment.sig>
PATCH 2/3 tools: fit_image: Use fit_image_get_data_and_size for getting offset/size
In reply to Andrew F. DavisQuoted 8 lines · Andrew F. Davis
This is very similar to
fit_image_get_databut has the benefit of working on FIT images with external data unlikefit_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 <[email protected]>Reviewed-by Lokesh Vutla <[email protected]>
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: 833 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200108/9fe6b88c/attachment.sig>
PATCH 3/3 tools: dumpimage: Fall-though to print usage for help command
In reply to Andrew F. DavisQuoted 5 lines · Andrew F. Davis
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 <[email protected]>Reviewed-by Lokesh Vutla <[email protected]>
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: 833 bytes Desc: not available URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200108/4148d18b/attachment.sig>