From: Joe Perches <joe@perches.com>
To: Cyrille Pitchen <cyrille.pitchen@atmel.com>
Cc: linux-mtd@lists.infradead.org, dwmw2@infradead.org,
linux-kernel@vger.kernel.org, nicolas.ferre@atmel.com
Subject: Re: [PATCH 2/2] jffs2: fix buffer dump debug output
Date: Tue, 21 Oct 2014 01:17:45 -0700 [thread overview]
Message-ID: <1413879465.12828.1.camel@perches.com> (raw)
In-Reply-To: <21ad981db8c65d3f00be3d9a254cae78cf40b96d.1413878259.git.cyrille.pitchen@atmel.com>
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
WARNING: multiple messages have this Message-ID (diff)
From: Joe Perches <joe@perches.com>
To: Cyrille Pitchen <cyrille.pitchen@atmel.com>
Cc: dwmw2@infradead.org, linux-mtd@lists.infradead.org,
nicolas.ferre@atmel.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] jffs2: fix buffer dump debug output
Date: Tue, 21 Oct 2014 01:17:45 -0700 [thread overview]
Message-ID: <1413879465.12828.1.camel@perches.com> (raw)
In-Reply-To: <21ad981db8c65d3f00be3d9a254cae78cf40b96d.1413878259.git.cyrille.pitchen@atmel.com>
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
next prev parent reply other threads:[~2014-10-21 8:18 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
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:04 ` [PATCH 1/2] jffs2: fix wrong offset in an error msg from __jff2_dbg_prewrite_paranoia_check 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
2014-10-21 8:05 ` Cyrille Pitchen
2014-10-21 8:17 ` Joe Perches [this message]
2014-10-21 8:17 ` Joe Perches
2014-10-21 9:47 ` Cyrille Pitchen
2014-10-21 9:47 ` Cyrille Pitchen
2014-10-21 9:54 ` Artem Bityutskiy
2014-10-21 9:54 ` Artem Bityutskiy
2014-10-21 10:17 ` Cyrille Pitchen
2014-10-21 10:17 ` Cyrille Pitchen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1413879465.12828.1.camel@perches.com \
--to=joe@perches.com \
--cc=cyrille.pitchen@atmel.com \
--cc=dwmw2@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=nicolas.ferre@atmel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.