mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] commands: digest: show area info only if necessary
@ 2017-04-05 10:02 Antony Pavlov
  2017-04-06  7:00 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Antony Pavlov @ 2017-04-05 10:02 UTC (permalink / raw)
  To: barebox

Area info "0x00000000 ... 0xffffffffffffffff" in digest
commands output is something strange and misleading, e.g.

  barebox@barebox sandbox:/ md5sum logo/barebox-logo-240.png
  d3226a0eba3fd49af6bd190b077a3466  logo/barebox-logo-240.png 0x00000000 ... 0xffffffffffffffff

Also skipping area info in the barebox digets commands
output for every file makes it more similar to traditional
*nix digest commands output.

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
 commands/digest.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/commands/digest.c b/commands/digest.c
index 02a9f6f0d..0edbbec32 100644
--- a/commands/digest.c
+++ b/commands/digest.c
@@ -36,12 +36,16 @@ int __do_digest(struct digest *d, unsigned char *sig,
 	while (*argv) {
 		char *filename = "/dev/mem";
 		loff_t start = 0, size = ~0;
+		int show_area = 1;
 
 		/* arguments are either file, file+area or area */
 		if (parse_area_spec(*argv, &start, &size)) {
 			filename = *argv;
-			if (argv[1] && !parse_area_spec(argv[1], &start, &size))
+			show_area = 0;
+			if (argv[1] && !parse_area_spec(argv[1], &start, &size)) {
 				argv++;
+				show_area = 1;
+			}
 		}
 
 		ret = digest_file_window(d, filename,
@@ -53,8 +57,12 @@ int __do_digest(struct digest *d, unsigned char *sig,
 				for (i = 0; i < digest_length(d); i++)
 					printf("%02x", hash[i]);
 
-				printf("  %s\t0x%08llx ... 0x%08llx\n",
-					filename, start, start + size);
+				printf("  %s", filename);
+				if (show_area)
+					printf("\t0x%08llx ... 0x%08llx",
+						start, start + size);
+
+				puts("\n");
 			}
 		}
 
-- 
2.11.0


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH] commands: digest: show area info only if necessary
  2017-04-05 10:02 [PATCH] commands: digest: show area info only if necessary Antony Pavlov
@ 2017-04-06  7:00 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2017-04-06  7:00 UTC (permalink / raw)
  To: Antony Pavlov; +Cc: barebox

On Wed, Apr 05, 2017 at 01:02:38PM +0300, Antony Pavlov wrote:
> Area info "0x00000000 ... 0xffffffffffffffff" in digest
> commands output is something strange and misleading, e.g.
> 
>   barebox@barebox sandbox:/ md5sum logo/barebox-logo-240.png
>   d3226a0eba3fd49af6bd190b077a3466  logo/barebox-logo-240.png 0x00000000 ... 0xffffffffffffffff
> 
> Also skipping area info in the barebox digets commands
> output for every file makes it more similar to traditional
> *nix digest commands output.
> 
> Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>

Applied, thanks. This really looks nicer now.

Sascha

> ---
>  commands/digest.c | 14 +++++++++++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
> 
> diff --git a/commands/digest.c b/commands/digest.c
> index 02a9f6f0d..0edbbec32 100644
> --- a/commands/digest.c
> +++ b/commands/digest.c
> @@ -36,12 +36,16 @@ int __do_digest(struct digest *d, unsigned char *sig,
>  	while (*argv) {
>  		char *filename = "/dev/mem";
>  		loff_t start = 0, size = ~0;
> +		int show_area = 1;
>  
>  		/* arguments are either file, file+area or area */
>  		if (parse_area_spec(*argv, &start, &size)) {
>  			filename = *argv;
> -			if (argv[1] && !parse_area_spec(argv[1], &start, &size))
> +			show_area = 0;
> +			if (argv[1] && !parse_area_spec(argv[1], &start, &size)) {
>  				argv++;
> +				show_area = 1;
> +			}
>  		}
>  
>  		ret = digest_file_window(d, filename,
> @@ -53,8 +57,12 @@ int __do_digest(struct digest *d, unsigned char *sig,
>  				for (i = 0; i < digest_length(d); i++)
>  					printf("%02x", hash[i]);
>  
> -				printf("  %s\t0x%08llx ... 0x%08llx\n",
> -					filename, start, start + size);
> +				printf("  %s", filename);
> +				if (show_area)
> +					printf("\t0x%08llx ... 0x%08llx",
> +						start, start + size);
> +
> +				puts("\n");
>  			}
>  		}
>  
> -- 
> 2.11.0
> 
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2017-04-06  7:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-05 10:02 [PATCH] commands: digest: show area info only if necessary Antony Pavlov
2017-04-06  7:00 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox