diff mbox

[U-Boot] Change dead code in "test" cmd to debug output

Message ID 1345236972-20010-1-git-send-email-joe.hershberger@ni.com
State Accepted
Delegated to: Tom Rini
Headers show

Commit Message

Joe Hershberger Aug. 17, 2012, 8:56 p.m. UTC
Improve debug output for test by indicating the number of parameters
and quoting the parameters to make it clear exactly what each contains

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
---
 common/cmd_test.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Mike Frysinger Aug. 17, 2012, 11:41 p.m. UTC | #1
On Friday 17 August 2012 16:56:12 Joe Hershberger wrote:
> --- a/common/cmd_test.c
> +++ b/common/cmd_test.c
> 
> -#if 0
> +#ifdef DEBUG
>  	{
> -		printf("test:");
> +		debug("test(%d):", argc);
>  		left = 1;
>  		while (argv[left])
> -			printf(" %s", argv[left++]);
> +			debug(" '%s'", argv[left++]);
>  	}
>  #endif

i think you can even remove the #ifdef DEBUG here since debug() will expand to 
nothing, and gcc should do DCE on the whole block
-mike
Joe Hershberger Oct. 3, 2012, 8:46 p.m. UTC | #2
Hi Mike,

On Fri, Aug 17, 2012 at 6:41 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> On Friday 17 August 2012 16:56:12 Joe Hershberger wrote:
>> --- a/common/cmd_test.c
>> +++ b/common/cmd_test.c
>>
>> -#if 0
>> +#ifdef DEBUG
>>       {
>> -             printf("test:");
>> +             debug("test(%d):", argc);
>>               left = 1;
>>               while (argv[left])
>> -                     printf(" %s", argv[left++]);
>> +                     debug(" '%s'", argv[left++]);
>>       }
>>  #endif
>
> i think you can even remove the #ifdef DEBUG here since debug() will expand to
> nothing, and gcc should do DCE on the whole block

It looks to me like it would end up with:

>>               while (argv[left]);

which would be an infinite loop, no?

The only reason I changed the printf's to debug is so that the macro
is used consistently and changes to it (like fprintf(stderr, ...) )
would have the intended effect.

Thanks,
-Joe
Tom Rini Oct. 4, 2012, 1:19 a.m. UTC | #3
On Fri, Aug 17, 2012 at 10:56:12AM -0000, Joe Hershberger wrote:

> Improve debug output for test by indicating the number of parameters
> and quoting the parameters to make it clear exactly what each contains
> 
> Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>

Applied to u-boot/master, thanks!
diff mbox

Patch

diff --git a/common/cmd_test.c b/common/cmd_test.c
index fcb5ef2..6da06b9 100644
--- a/common/cmd_test.c
+++ b/common/cmd_test.c
@@ -33,12 +33,12 @@  int do_test(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	if (argc < 3)
 		return 1;
 
-#if 0
+#ifdef DEBUG
 	{
-		printf("test:");
+		debug("test(%d):", argc);
 		left = 1;
 		while (argv[left])
-			printf(" %s", argv[left++]);
+			debug(" '%s'", argv[left++]);
 	}
 #endif