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

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(-)
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

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:");
left = 1; while (argv[left])debug("test(%d):", argc);
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

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

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!
participants (4)
-
Joe Hershberger
-
Joe Hershberger
-
Mike Frysinger
-
Tom Rini