diff mbox series

[U-Boot,1/3] tools: dumpimage: Provide more feedback on internal errors

Message ID 20190917210935.3666-1-afd@ti.com
State Accepted
Commit 79e984c470f7a2bfa4d292214a985ec39185d935
Delegated to: Tom Rini
Headers show
Series [U-Boot,1/3] tools: dumpimage: Provide more feedback on internal errors | expand

Commit Message

Andrew Davis Sept. 17, 2019, 9:09 p.m. UTC
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(-)

Comments

Andrew Davis Nov. 13, 2019, 4:14 p.m. UTC | #1
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
>
Lokesh Vutla Nov. 14, 2019, 11:46 a.m. UTC | #2
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
>
Andrew Davis Jan. 7, 2020, 2:07 p.m. UTC | #3
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@lists.denx.de
> https://lists.denx.de/listinfo/u-boot
>
Tom Rini Jan. 8, 2020, 8:10 p.m. UTC | #4
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!
diff mbox series

Patch

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