* [PATCH 0/2] *** jffs2: fix debug outputs ***
@ 2014-10-21 8:04 Cyrille Pitchen
2014-10-21 8:04 ` [PATCH 1/2] jffs2: fix wrong offset in an error msg from __jff2_dbg_prewrite_paranoia_check Cyrille Pitchen
2014-10-21 8:05 ` [PATCH 2/2] jffs2: fix buffer dump debug output Cyrille Pitchen
0 siblings, 2 replies; 7+ messages in thread
From: Cyrille Pitchen @ 2014-10-21 8:04 UTC (permalink / raw)
To: dwmw2, linux-mtd, nicolas.ferre; +Cc: linux-kernel, Cyrille Pitchen
Hi,
This series of patches fixes some bugs in the output of jffs2 debug functions.
Cyrille Pitchen (2):
jffs2: fix wrong offset in an error msg from
__jff2_dbg_prewrite_paranoia_check
jffs2: fix buffer dump debug output
fs/jffs2/debug.c | 26 ++++++++++----------------
1 file changed, 10 insertions(+), 16 deletions(-)
--
1.8.2.2
^ permalink raw reply [flat|nested] 7+ messages in thread* [PATCH 1/2] jffs2: fix wrong offset in an error msg from __jff2_dbg_prewrite_paranoia_check 2014-10-21 8:04 [PATCH 0/2] *** jffs2: fix debug outputs *** Cyrille Pitchen @ 2014-10-21 8:04 ` Cyrille Pitchen 2014-10-21 8:05 ` [PATCH 2/2] jffs2: fix buffer dump debug output Cyrille Pitchen 1 sibling, 0 replies; 7+ messages in thread From: Cyrille Pitchen @ 2014-10-21 8:04 UTC (permalink / raw) To: dwmw2, linux-mtd, nicolas.ferre; +Cc: linux-kernel, Cyrille Pitchen When a none 0xff character is found in the flash buffer, an error message is printed. This error message claims to provide the offset of the FIRST corrupted byte but due to a missing break in the for loop, the former code always prints the offset of the byte immediately after the end of the tested buffer. Signed-off-by: Cyrille Pitchen <cyrille.pitchen@atmel.com> --- fs/jffs2/debug.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/jffs2/debug.c b/fs/jffs2/debug.c index 1090eb6..07bd5bc 100644 --- a/fs/jffs2/debug.c +++ b/fs/jffs2/debug.c @@ -141,12 +141,11 @@ __jffs2_dbg_prewrite_paranoia_check(struct jffs2_sb_info *c, return; } - ret = 0; for (i = 0; i < len; i++) if (buf[i] != 0xff) - ret = 1; + break; - if (ret) { + if (i != len) { JFFS2_ERROR("argh, about to write node to %#08x on flash, but there are data already there. The first corrupted byte is at %#08x offset.\n", ofs, ofs + i); __jffs2_dbg_dump_buffer(buf, len, ofs); -- 1.8.2.2 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/2] jffs2: fix buffer dump debug output 2014-10-21 8:04 [PATCH 0/2] *** jffs2: fix debug outputs *** Cyrille Pitchen 2014-10-21 8:04 ` [PATCH 1/2] jffs2: fix wrong offset in an error msg from __jff2_dbg_prewrite_paranoia_check Cyrille Pitchen @ 2014-10-21 8:05 ` Cyrille Pitchen 2014-10-21 8:17 ` Joe Perches 1 sibling, 1 reply; 7+ messages in thread From: Cyrille Pitchen @ 2014-10-21 8:05 UTC (permalink / raw) To: dwmw2, linux-mtd, nicolas.ferre; +Cc: linux-kernel, Cyrille Pitchen This patch fixes __jffs2_dbg_dump_buffer(): this function prints a message claiming to dump len bytes. However, depending on the start offset, the former code drops up to 31 (JFFS2_BUFDUMP_BYTES_PER_LINE - 1) bytes. Signed-off-by: Cyrille Pitchen <cyrille.pitchen@atmel.com> --- fs/jffs2/debug.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/fs/jffs2/debug.c b/fs/jffs2/debug.c index 07bd5bc..1b515b2 100644 --- a/fs/jffs2/debug.c +++ b/fs/jffs2/debug.c @@ -736,30 +736,25 @@ void __jffs2_dbg_dump_buffer(unsigned char *buf, int len, uint32_t offs) { int skip; - int i; + int i, pos; printk(JFFS2_DBG_MSG_PREFIX " dump from offset %#08x to offset %#08x (%x bytes).\n", offs, offs + len, len); - i = skip = offs % JFFS2_BUFDUMP_BYTES_PER_LINE; + i = skip = offs & (JFFS2_BUFDUMP_BYTES_PER_LINE - 1); offs = offs & ~(JFFS2_BUFDUMP_BYTES_PER_LINE - 1); - if (skip != 0) - printk(JFFS2_DBG "%#08x: ", offs); - + printk(JFFS2_DBG "%#08x: ", offs); while (skip--) printk(" "); - while (i < len) { - if ((i % JFFS2_BUFDUMP_BYTES_PER_LINE) == 0 && i != len -1) { - if (i != 0) - printk("\n"); + for (pos = 0; pos < len; ++pos, ++i) { + if (i == JFFS2_BUFDUMP_BYTES_PER_LINE) { offs += JFFS2_BUFDUMP_BYTES_PER_LINE; - printk(JFFS2_DBG "%0#8x: ", offs); + printk(JFFS2_DBG "\n%0#8x: ", offs); + i = 0; } - printk("%02x ", buf[i]); - - i += 1; + printk("%02x ", buf[pos]); } printk("\n"); -- 1.8.2.2 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] jffs2: fix buffer dump debug output 2014-10-21 8:05 ` [PATCH 2/2] jffs2: fix buffer dump debug output Cyrille Pitchen @ 2014-10-21 8:17 ` Joe Perches 2014-10-21 9:47 ` Cyrille Pitchen 0 siblings, 1 reply; 7+ messages in thread From: Joe Perches @ 2014-10-21 8:17 UTC (permalink / raw) To: Cyrille Pitchen; +Cc: dwmw2, linux-mtd, nicolas.ferre, linux-kernel On Tue, 2014-10-21 at 10:05 +0200, Cyrille Pitchen wrote: > This patch fixes __jffs2_dbg_dump_buffer(): this function prints a message > claiming to dump len bytes. However, depending on the start offset, the former > code drops up to 31 (JFFS2_BUFDUMP_BYTES_PER_LINE - 1) bytes. > > Signed-off-by: Cyrille Pitchen <cyrille.pitchen@atmel.com> > --- > fs/jffs2/debug.c | 21 ++++++++------------- > 1 file changed, 8 insertions(+), 13 deletions(-) > > diff --git a/fs/jffs2/debug.c b/fs/jffs2/debug.c > index 07bd5bc..1b515b2 100644 > --- a/fs/jffs2/debug.c > +++ b/fs/jffs2/debug.c > @@ -736,30 +736,25 @@ void > __jffs2_dbg_dump_buffer(unsigned char *buf, int len, uint32_t offs) > { > int skip; > - int i; > + int i, pos; > > printk(JFFS2_DBG_MSG_PREFIX " dump from offset %#08x to offset %#08x (%x bytes).\n", > offs, offs + len, len); > - i = skip = offs % JFFS2_BUFDUMP_BYTES_PER_LINE; > + i = skip = offs & (JFFS2_BUFDUMP_BYTES_PER_LINE - 1); > offs = offs & ~(JFFS2_BUFDUMP_BYTES_PER_LINE - 1); > > - if (skip != 0) > - printk(JFFS2_DBG "%#08x: ", offs); > - > + printk(JFFS2_DBG "%#08x: ", offs); > while (skip--) > printk(" "); > > - while (i < len) { > - if ((i % JFFS2_BUFDUMP_BYTES_PER_LINE) == 0 && i != len -1) { > - if (i != 0) > - printk("\n"); > + for (pos = 0; pos < len; ++pos, ++i) { > + if (i == JFFS2_BUFDUMP_BYTES_PER_LINE) { > offs += JFFS2_BUFDUMP_BYTES_PER_LINE; > - printk(JFFS2_DBG "%0#8x: ", offs); > + printk(JFFS2_DBG "\n%0#8x: ", offs); > + i = 0; print_hex_dump would be better ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] jffs2: fix buffer dump debug output 2014-10-21 8:17 ` Joe Perches @ 2014-10-21 9:47 ` Cyrille Pitchen 2014-10-21 9:54 ` Artem Bityutskiy 0 siblings, 1 reply; 7+ messages in thread From: Cyrille Pitchen @ 2014-10-21 9:47 UTC (permalink / raw) To: Joe Perches; +Cc: dwmw2, linux-mtd, nicolas.ferre, linux-kernel Le 21/10/2014 10:17, Joe Perches a écrit : > On Tue, 2014-10-21 at 10:05 +0200, Cyrille Pitchen wrote: >> This patch fixes __jffs2_dbg_dump_buffer(): this function prints a message >> claiming to dump len bytes. However, depending on the start offset, the former >> code drops up to 31 (JFFS2_BUFDUMP_BYTES_PER_LINE - 1) bytes. >> >> Signed-off-by: Cyrille Pitchen <cyrille.pitchen@atmel.com> >> --- >> fs/jffs2/debug.c | 21 ++++++++------------- >> 1 file changed, 8 insertions(+), 13 deletions(-) >> >> diff --git a/fs/jffs2/debug.c b/fs/jffs2/debug.c >> index 07bd5bc..1b515b2 100644 >> --- a/fs/jffs2/debug.c >> +++ b/fs/jffs2/debug.c >> @@ -736,30 +736,25 @@ void >> __jffs2_dbg_dump_buffer(unsigned char *buf, int len, uint32_t offs) >> { >> int skip; >> - int i; >> + int i, pos; >> >> printk(JFFS2_DBG_MSG_PREFIX " dump from offset %#08x to offset %#08x (%x bytes).\n", >> offs, offs + len, len); >> - i = skip = offs % JFFS2_BUFDUMP_BYTES_PER_LINE; >> + i = skip = offs & (JFFS2_BUFDUMP_BYTES_PER_LINE - 1); >> offs = offs & ~(JFFS2_BUFDUMP_BYTES_PER_LINE - 1); >> >> - if (skip != 0) >> - printk(JFFS2_DBG "%#08x: ", offs); >> - >> + printk(JFFS2_DBG "%#08x: ", offs); >> while (skip--) >> printk(" "); >> >> - while (i < len) { >> - if ((i % JFFS2_BUFDUMP_BYTES_PER_LINE) == 0 && i != len -1) { >> - if (i != 0) >> - printk("\n"); >> + for (pos = 0; pos < len; ++pos, ++i) { >> + if (i == JFFS2_BUFDUMP_BYTES_PER_LINE) { >> offs += JFFS2_BUFDUMP_BYTES_PER_LINE; >> - printk(JFFS2_DBG "%0#8x: ", offs); >> + printk(JFFS2_DBG "\n%0#8x: ", offs); >> + i = 0; > > print_hex_dump would be better > > Hi Joe, thanks for your comment. Indeed using print_hex_dump() would be a good idea since it would avoid each driver to implement its own version of buffer dumps. Reading the source code of print_hex_dump(), the output format would change a little bit: the output would no longer be aligned to JFFS2_BUFDUMP_BYTES_PER_LINE boundary using leading spaces. If it's ok to change the output format it's good for me as well. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] jffs2: fix buffer dump debug output 2014-10-21 9:47 ` Cyrille Pitchen @ 2014-10-21 9:54 ` Artem Bityutskiy 2014-10-21 10:17 ` Cyrille Pitchen 0 siblings, 1 reply; 7+ messages in thread From: Artem Bityutskiy @ 2014-10-21 9:54 UTC (permalink / raw) To: Cyrille Pitchen Cc: Joe Perches, linux-mtd, dwmw2, linux-kernel, nicolas.ferre On Tue, 2014-10-21 at 11:47 +0200, Cyrille Pitchen wrote: > thanks for your comment. Indeed using print_hex_dump() would be a good idea > since it would avoid each driver to implement its own version of buffer dumps. > Reading the source code of print_hex_dump(), the output format would change a > little bit: > the output would no longer be aligned to JFFS2_BUFDUMP_BYTES_PER_LINE boundary > using leading spaces. > If it's ok to change the output format it's good for me as well. Changing format is OK, this is just a debugging cruft. But it is OK only if you test the changes. If you are unable to test the changes, it is better to avoid doing non-trivial changes. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] jffs2: fix buffer dump debug output 2014-10-21 9:54 ` Artem Bityutskiy @ 2014-10-21 10:17 ` Cyrille Pitchen 0 siblings, 0 replies; 7+ messages in thread From: Cyrille Pitchen @ 2014-10-21 10:17 UTC (permalink / raw) To: dedekind1; +Cc: Joe Perches, linux-mtd, dwmw2, linux-kernel, nicolas.ferre Le 21/10/2014 11:54, Artem Bityutskiy a écrit : > On Tue, 2014-10-21 at 11:47 +0200, Cyrille Pitchen wrote: >> thanks for your comment. Indeed using print_hex_dump() would be a good idea >> since it would avoid each driver to implement its own version of buffer dumps. >> Reading the source code of print_hex_dump(), the output format would change a >> little bit: >> the output would no longer be aligned to JFFS2_BUFDUMP_BYTES_PER_LINE boundary >> using leading spaces. >> If it's ok to change the output format it's good for me as well. > > Changing format is OK, this is just a debugging cruft. But it is OK only > if you test the changes. If you are unable to test the changes, it is > better to avoid doing non-trivial changes. > The version provided in this patch was tested. However I don't know how to cope with the offs parameter of __jffs2_dbg_dump_buffer() if I replace the current source code by a call to print_hex_dump(). If I use DUMP_PREFIX_ADDRESS as prefix_type value, the printed offsets are relative to the address of buf in RAM, not to the hardware offset in my dataflash provided by the offs parameter. Also, if I use DUMP_PREFIX_OFFSET, the printed offsets start from 0 instead of offs value. I think keeping the right offsets in the output dump is helpfull. ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-10-21 10:17 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2014-10-21 8:04 [PATCH 0/2] *** jffs2: fix debug outputs *** Cyrille Pitchen 2014-10-21 8:04 ` [PATCH 1/2] jffs2: fix wrong offset in an error msg from __jff2_dbg_prewrite_paranoia_check Cyrille Pitchen 2014-10-21 8:05 ` [PATCH 2/2] jffs2: fix buffer dump debug output Cyrille Pitchen 2014-10-21 8:17 ` Joe Perches 2014-10-21 9:47 ` Cyrille Pitchen 2014-10-21 9:54 ` Artem Bityutskiy 2014-10-21 10:17 ` Cyrille Pitchen
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox