Patchwork [U-Boot] command, log: print with "log show" a full logbuffer

login
register
mail settings
Submitter Heiko Schocher
Date Feb. 16, 2012, 11:02 a.m.
Message ID <1329390141-5356-1-git-send-email-hs@denx.de>
Download mbox | patch
Permalink /patch/141562/
State Accepted
Delegated to: Detlev Zundel
Headers show

Comments

Heiko Schocher - Feb. 16, 2012, 11:02 a.m.
If the logbuffer contains LOGBUFF_LEN chars, they never got
printed with the "log show" command, because chars get
printed with the following for loop:

for (i = 0; i < (size & LOGBUFF_MASK); i++) {

with size = LOGBUFF_LEN and LOGBUFF_MASK = (LOGBUFF_LEN-1)
for loop never executed ...

Fix this.

Signed-off-by: Heiko Schocher <hs@denx.de>
---
 common/cmd_log.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
Detlev Zundel - Feb. 17, 2012, 3:07 p.m.
Hi Heiko,

> If the logbuffer contains LOGBUFF_LEN chars, they never got
> printed with the "log show" command, because chars get
> printed with the following for loop:
>
> for (i = 0; i < (size & LOGBUFF_MASK); i++) {
>
> with size = LOGBUFF_LEN and LOGBUFF_MASK = (LOGBUFF_LEN-1)
> for loop never executed ...
>
> Fix this.
>
> Signed-off-by: Heiko Schocher <hs@denx.de>

Indeed a good catch!

Acked-by: Detlev Zundel <dzu@denx.de>
Wolfgang Denk - March 30, 2012, 8:29 p.m.
Dear Heiko Schocher,

In message <1329390141-5356-1-git-send-email-hs@denx.de> you wrote:
> If the logbuffer contains LOGBUFF_LEN chars, they never got
> printed with the "log show" command, because chars get
> printed with the following for loop:
> 
> for (i = 0; i < (size & LOGBUFF_MASK); i++) {
> 
> with size = LOGBUFF_LEN and LOGBUFF_MASK = (LOGBUFF_LEN-1)
> for loop never executed ...
> 
> Fix this.
> 
> Signed-off-by: Heiko Schocher <hs@denx.de>
> ---
>  common/cmd_log.c |    4 +++-
>  1 files changed, 3 insertions(+), 1 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Patch

diff --git a/common/cmd_log.c b/common/cmd_log.c
index ff5924c..b98a091 100644
--- a/common/cmd_log.c
+++ b/common/cmd_log.c
@@ -220,7 +220,9 @@  int do_log(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 				start = log->v1.start;
 				size = log->v1.size;
 			}
-			for (i = 0; i < (size & LOGBUFF_MASK); i++) {
+			if (size > LOGBUFF_LEN)
+				size = LOGBUFF_LEN;
+			for (i = 0; i < size; i++) {
 				s = lbuf + ((start + i) & LOGBUFF_MASK);
 				putc(*s);
 			}