Skip to contentSkip to conversation

command, log: print with "log show" a full logbuffer

PATCH New Heiko Schocher 3 participants 3 messages Feb 16, 2012 – Mar 30, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 command, log: print with "log show" a full logbuffer

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.

---
 common/cmd_log.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
common/cmd_log.c +3 -1
index ff5924c..b98a091 100644
@@ -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);
 			}
Signature · 1 line
1.7.7.6
#1 lore raw

PATCH 1/1 command, log: print with "log show" a full logbuffer

Hi Heiko,

Quoted 4 lines

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:

Quoted 8 lines

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

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

Fix this.

Indeed a good catch!

Signature · 9 lines
LISP is the most powerful programming language, and if you want an inter-
preter, LISP is the best.  None of the other languages come anywhere near
LISP in their power.  The most exciting things about LISP are read, eval,
and print.  If you look at other languages,  they have no equivalent for
any of those.                             -- Richard Stallman
--
DENX Software Engineering GmbH,      MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich,  Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: dzu at denx.de
#2 lore raw

PATCH 1/1 command, log: print with "log show" a full logbuffer

In reply to Heiko Schocher

Dear Heiko Schocher,

Quoted 9 lines · In message <[email protected]> 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 ...

Quoted 6 lines

Fix this.

---
 common/cmd_log.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"This is a test of the Emergency Broadcast System. If this had been an
actual emergency, do you really think we'd stick around to tell you?"