All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] cifs: call print_hex_dump instead of custom implementation
@ 2014-05-12 15:15 Andy Shevchenko
       [not found] ` <1399907720-18622-1-git-send-email-andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2014-05-12 15:15 UTC (permalink / raw)
  To: Alexander Bokovoy, Jeff Layton, Steve French, linux-cifs,
	samba-technical
  Cc: Andy Shevchenko

This patch converts custom dumper to use native print_hex_dump() instead. The
dump will have a given label and addresses per each line which differs it from
the original code.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 fs/cifs/cifs_debug.c | 21 ++-------------------
 1 file changed, 2 insertions(+), 19 deletions(-)

diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
index fa78b68..e7b87ce 100644
--- a/fs/cifs/cifs_debug.c
+++ b/fs/cifs/cifs_debug.c
@@ -34,27 +34,10 @@
 void
 cifs_dump_mem(char *label, void *data, int length)
 {
-	int i, j;
-	int *intptr = data;
-	char *charptr = data;
-	char buf[10], line[80];
-
 	printk(KERN_DEBUG "%s: dump of %d bytes of data at 0x%p\n",
 		label, length, data);
-	for (i = 0; i < length; i += 16) {
-		line[0] = 0;
-		for (j = 0; (j < 4) && (i + j * 4 < length); j++) {
-			sprintf(buf, " %08x", intptr[i / 4 + j]);
-			strcat(line, buf);
-		}
-		buf[0] = ' ';
-		buf[2] = 0;
-		for (j = 0; (j < 16) && (i + j < length); j++) {
-			buf[1] = isprint(charptr[i + j]) ? charptr[i + j] : '.';
-			strcat(line, buf);
-		}
-		printk(KERN_DEBUG "%s\n", line);
-	}
+	print_hex_dump(KERN_DEBUG, label, DUMP_PREFIX_ADDRESS, 16, 4,
+		       data, length, true);
 }
 
 #ifdef CONFIG_CIFS_DEBUG
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] cifs: call print_hex_dump instead of custom implementation
       [not found] ` <1399907720-18622-1-git-send-email-andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
@ 2014-05-12 15:41   ` Alexander Bokovoy
  2014-05-12 15:42   ` Jeff Layton
  1 sibling, 0 replies; 6+ messages in thread
From: Alexander Bokovoy @ 2014-05-12 15:41 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Jeff Layton, Steve French, linux-cifs-u79uwXL29TY76Z2rM5mHXA,
	samba-technical-w/Ol4Ecudpl8XjKLYN78aQ

On Mon, May 12, 2014 at 06:15:20PM +0300, Andy Shevchenko wrote:
> This patch converts custom dumper to use native print_hex_dump() instead. The
> dump will have a given label and addresses per each line which differs it from
> the original code.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
> ---
>  fs/cifs/cifs_debug.c | 21 ++-------------------
>  1 file changed, 2 insertions(+), 19 deletions(-)
> 
> diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
> index fa78b68..e7b87ce 100644
> --- a/fs/cifs/cifs_debug.c
> +++ b/fs/cifs/cifs_debug.c
> @@ -34,27 +34,10 @@
>  void
>  cifs_dump_mem(char *label, void *data, int length)
>  {
> -	int i, j;
> -	int *intptr = data;
> -	char *charptr = data;
> -	char buf[10], line[80];
> -
>  	printk(KERN_DEBUG "%s: dump of %d bytes of data at 0x%p\n",
>  		label, length, data);
> -	for (i = 0; i < length; i += 16) {
> -		line[0] = 0;
> -		for (j = 0; (j < 4) && (i + j * 4 < length); j++) {
> -			sprintf(buf, " %08x", intptr[i / 4 + j]);
> -			strcat(line, buf);
> -		}
> -		buf[0] = ' ';
> -		buf[2] = 0;
> -		for (j = 0; (j < 16) && (i + j < length); j++) {
> -			buf[1] = isprint(charptr[i + j]) ? charptr[i + j] : '.';
> -			strcat(line, buf);
> -		}
> -		printk(KERN_DEBUG "%s\n", line);
> -	}
> +	print_hex_dump(KERN_DEBUG, label, DUMP_PREFIX_ADDRESS, 16, 4,
> +		       data, length, true);
>  }
>  
>  #ifdef CONFIG_CIFS_DEBUG
Looks good, thanks for this. You can add my Reviewed-By.

-- 
/ Alexander Bokovoy

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] cifs: call print_hex_dump instead of custom implementation
       [not found] ` <1399907720-18622-1-git-send-email-andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
  2014-05-12 15:41   ` Alexander Bokovoy
@ 2014-05-12 15:42   ` Jeff Layton
  2014-05-12 16:15     ` Andy Shevchenko
  1 sibling, 1 reply; 6+ messages in thread
From: Jeff Layton @ 2014-05-12 15:42 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Alexander Bokovoy, Steve French,
	linux-cifs-u79uwXL29TY76Z2rM5mHXA,
	samba-technical-w/Ol4Ecudpl8XjKLYN78aQ

On Mon, 12 May 2014 18:15:20 +0300
Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> wrote:

> This patch converts custom dumper to use native print_hex_dump() instead. The
> dump will have a given label and addresses per each line which differs it from
> the original code.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
> ---
>  fs/cifs/cifs_debug.c | 21 ++-------------------
>  1 file changed, 2 insertions(+), 19 deletions(-)
> 
> diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
> index fa78b68..e7b87ce 100644
> --- a/fs/cifs/cifs_debug.c
> +++ b/fs/cifs/cifs_debug.c
> @@ -34,27 +34,10 @@
>  void
>  cifs_dump_mem(char *label, void *data, int length)
>  {
> -	int i, j;
> -	int *intptr = data;
> -	char *charptr = data;
> -	char buf[10], line[80];
> -
>  	printk(KERN_DEBUG "%s: dump of %d bytes of data at 0x%p\n",
>  		label, length, data);
> -	for (i = 0; i < length; i += 16) {
> -		line[0] = 0;
> -		for (j = 0; (j < 4) && (i + j * 4 < length); j++) {
> -			sprintf(buf, " %08x", intptr[i / 4 + j]);
> -			strcat(line, buf);
> -		}
> -		buf[0] = ' ';
> -		buf[2] = 0;
> -		for (j = 0; (j < 16) && (i + j < length); j++) {
> -			buf[1] = isprint(charptr[i + j]) ? charptr[i + j] : '.';
> -			strcat(line, buf);
> -		}
> -		printk(KERN_DEBUG "%s\n", line);
> -	}
> +	print_hex_dump(KERN_DEBUG, label, DUMP_PREFIX_ADDRESS, 16, 4,
> +		       data, length, true);

I'm not sure we want "label" as the prefix_str as it'll go on every
line. Maybe just use "" in place of "label" there?

>  }
>  
>  #ifdef CONFIG_CIFS_DEBUG

Otherwise, this looks good.

Acked-by: Jeff Layton <jlayton-vpEMnDpepFuMZCB2o+C8xQ@public.gmane.org>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] cifs: call print_hex_dump instead of custom implementation
  2014-05-12 15:42   ` Jeff Layton
@ 2014-05-12 16:15     ` Andy Shevchenko
  2014-05-12 16:23       ` Jeff Layton
  0 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2014-05-12 16:15 UTC (permalink / raw)
  To: Jeff Layton; +Cc: Steve French, linux-cifs, Alexander Bokovoy, samba-technical

On Mon, 2014-05-12 at 11:42 -0400, Jeff Layton wrote:
> On Mon, 12 May 2014 18:15:20 +0300
> Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
> 
> > This patch converts custom dumper to use native print_hex_dump() instead. The
> > dump will have a given label and addresses per each line which differs it from
> > the original code.
> > 
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > ---
> >  fs/cifs/cifs_debug.c | 21 ++-------------------
> >  1 file changed, 2 insertions(+), 19 deletions(-)
> > 
> > diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
> > index fa78b68..e7b87ce 100644
> > --- a/fs/cifs/cifs_debug.c
> > +++ b/fs/cifs/cifs_debug.c
> > @@ -34,27 +34,10 @@
> >  void
> >  cifs_dump_mem(char *label, void *data, int length)
> >  {
> > -	int i, j;
> > -	int *intptr = data;
> > -	char *charptr = data;
> > -	char buf[10], line[80];
> > -
> >  	printk(KERN_DEBUG "%s: dump of %d bytes of data at 0x%p\n",
> >  		label, length, data);
> > -	for (i = 0; i < length; i += 16) {
> > -		line[0] = 0;
> > -		for (j = 0; (j < 4) && (i + j * 4 < length); j++) {
> > -			sprintf(buf, " %08x", intptr[i / 4 + j]);
> > -			strcat(line, buf);
> > -		}
> > -		buf[0] = ' ';
> > -		buf[2] = 0;
> > -		for (j = 0; (j < 16) && (i + j < length); j++) {
> > -			buf[1] = isprint(charptr[i + j]) ? charptr[i + j] : '.';
> > -			strcat(line, buf);
> > -		}
> > -		printk(KERN_DEBUG "%s\n", line);
> > -	}
> > +	print_hex_dump(KERN_DEBUG, label, DUMP_PREFIX_ADDRESS, 16, 4,
> > +		       data, length, true);
> 
> I'm not sure we want "label" as the prefix_str as it'll go on every
> line. Maybe just use "" in place of "label" there?

It was in my initial v1. I thought it would be better to have.
What about addresses? Would you like to see it or offset is enough, or
drop them as well?

Moreover, I found another place where similar change could be done
(dump_smb), so, would it be better to do in separate patch?

> 
> >  }
> >  
> >  #ifdef CONFIG_CIFS_DEBUG
> 
> Otherwise, this looks good.
> 
> Acked-by: Jeff Layton <jlayton@poochiereds.net>


-- 
Andy Shevchenko <andriy.shevchenko@intel.com>
Intel Finland Oy

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] cifs: call print_hex_dump instead of custom implementation
  2014-05-12 16:15     ` Andy Shevchenko
@ 2014-05-12 16:23       ` Jeff Layton
       [not found]         ` <20140512122356.1143f317-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
  0 siblings, 1 reply; 6+ messages in thread
From: Jeff Layton @ 2014-05-12 16:23 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Steve French, linux-cifs, Alexander Bokovoy, samba-technical

On Mon, 12 May 2014 19:15:09 +0300
Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:

> On Mon, 2014-05-12 at 11:42 -0400, Jeff Layton wrote:
> > On Mon, 12 May 2014 18:15:20 +0300
> > Andy Shevchenko <andriy.shevchenko@linux.intel.com> wrote:
> > 
> > > This patch converts custom dumper to use native print_hex_dump() instead. The
> > > dump will have a given label and addresses per each line which differs it from
> > > the original code.
> > > 
> > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > > ---
> > >  fs/cifs/cifs_debug.c | 21 ++-------------------
> > >  1 file changed, 2 insertions(+), 19 deletions(-)
> > > 
> > > diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
> > > index fa78b68..e7b87ce 100644
> > > --- a/fs/cifs/cifs_debug.c
> > > +++ b/fs/cifs/cifs_debug.c
> > > @@ -34,27 +34,10 @@
> > >  void
> > >  cifs_dump_mem(char *label, void *data, int length)
> > >  {
> > > -	int i, j;
> > > -	int *intptr = data;
> > > -	char *charptr = data;
> > > -	char buf[10], line[80];
> > > -
> > >  	printk(KERN_DEBUG "%s: dump of %d bytes of data at 0x%p\n",
> > >  		label, length, data);
> > > -	for (i = 0; i < length; i += 16) {
> > > -		line[0] = 0;
> > > -		for (j = 0; (j < 4) && (i + j * 4 < length); j++) {
> > > -			sprintf(buf, " %08x", intptr[i / 4 + j]);
> > > -			strcat(line, buf);
> > > -		}
> > > -		buf[0] = ' ';
> > > -		buf[2] = 0;
> > > -		for (j = 0; (j < 16) && (i + j < length); j++) {
> > > -			buf[1] = isprint(charptr[i + j]) ? charptr[i + j] : '.';
> > > -			strcat(line, buf);
> > > -		}
> > > -		printk(KERN_DEBUG "%s\n", line);
> > > -	}
> > > +	print_hex_dump(KERN_DEBUG, label, DUMP_PREFIX_ADDRESS, 16, 4,
> > > +		       data, length, true);
> > 
> > I'm not sure we want "label" as the prefix_str as it'll go on every
> > line. Maybe just use "" in place of "label" there?
> 
> It was in my initial v1. I thought it would be better to have.

Most of the labels are stuff like "Bad SMB:" and I'm not sure there's a
lot of value in repeating that on every line. The existing code
certainly doesn't and that sort of thing tends to clutter up logfiles.

> What about addresses? Would you like to see it or offset is enough, or
> drop them as well?
> 

The addresses aren't terribly helpful in general, and printing them
might be considered information leakage. I'd suggest going with just
the offsets.

> Moreover, I found another place where similar change could be done
> (dump_smb), so, would it be better to do in separate patch?
> 

Sure, that certainly wouldn't hurt. Your call on whether to do two
patches or one.


> > 
> > >  }
> > >  
> > >  #ifdef CONFIG_CIFS_DEBUG
> > 
> > Otherwise, this looks good.
> > 
> > Acked-by: Jeff Layton <jlayton@poochiereds.net>
> 
> 

-- 
Jeff Layton <jlayton@poochiereds.net>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2] cifs: call print_hex_dump instead of custom implementation
       [not found]         ` <20140512122356.1143f317-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
@ 2014-05-12 16:30           ` Andy Shevchenko
  0 siblings, 0 replies; 6+ messages in thread
From: Andy Shevchenko @ 2014-05-12 16:30 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Alexander Bokovoy, Steve French,
	linux-cifs-u79uwXL29TY76Z2rM5mHXA,
	samba-technical-w/Ol4Ecudpl8XjKLYN78aQ

On Mon, 2014-05-12 at 12:23 -0400, Jeff Layton wrote:
> On Mon, 12 May 2014 19:15:09 +0300
> Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> wrote:
> 
> > On Mon, 2014-05-12 at 11:42 -0400, Jeff Layton wrote:
> > > On Mon, 12 May 2014 18:15:20 +0300
> > > Andy Shevchenko <andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> wrote:
> > > 
> > > > This patch converts custom dumper to use native print_hex_dump() instead. The
> > > > dump will have a given label and addresses per each line which differs it from
> > > > the original code.
> > > > 
> > > > Signed-off-by: Andy Shevchenko <andriy.shevchenko-VuQAYsv1563A2t4k+OOtxA@public.gmane.orgom>
> > > > ---
> > > >  fs/cifs/cifs_debug.c | 21 ++-------------------
> > > >  1 file changed, 2 insertions(+), 19 deletions(-)
> > > > 
> > > > diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
> > > > index fa78b68..e7b87ce 100644
> > > > --- a/fs/cifs/cifs_debug.c
> > > > +++ b/fs/cifs/cifs_debug.c
> > > > @@ -34,27 +34,10 @@
> > > >  void
> > > >  cifs_dump_mem(char *label, void *data, int length)
> > > >  {
> > > > -	int i, j;
> > > > -	int *intptr = data;
> > > > -	char *charptr = data;
> > > > -	char buf[10], line[80];
> > > > -
> > > >  	printk(KERN_DEBUG "%s: dump of %d bytes of data at 0x%p\n",
> > > >  		label, length, data);
> > > > -	for (i = 0; i < length; i += 16) {
> > > > -		line[0] = 0;
> > > > -		for (j = 0; (j < 4) && (i + j * 4 < length); j++) {
> > > > -			sprintf(buf, " %08x", intptr[i / 4 + j]);
> > > > -			strcat(line, buf);
> > > > -		}
> > > > -		buf[0] = ' ';
> > > > -		buf[2] = 0;
> > > > -		for (j = 0; (j < 16) && (i + j < length); j++) {
> > > > -			buf[1] = isprint(charptr[i + j]) ? charptr[i + j] : '.';
> > > > -			strcat(line, buf);
> > > > -		}
> > > > -		printk(KERN_DEBUG "%s\n", line);
> > > > -	}
> > > > +	print_hex_dump(KERN_DEBUG, label, DUMP_PREFIX_ADDRESS, 16, 4,
> > > > +		       data, length, true);
> > > 
> > > I'm not sure we want "label" as the prefix_str as it'll go on every
> > > line. Maybe just use "" in place of "label" there?
> > 
> > It was in my initial v1. I thought it would be better to have.
> 
> Most of the labels are stuff like "Bad SMB:" and I'm not sure there's a
> lot of value in repeating that on every line. The existing code
> certainly doesn't and that sort of thing tends to clutter up logfiles.

Got it.

> 
> > What about addresses? Would you like to see it or offset is enough, or
> > drop them as well?
> > 
> 
> The addresses aren't terribly helpful in general, and printing them
> might be considered information leakage. I'd suggest going with just
> the offsets.

Yeah, but since printk at the top of function already prints virtual
address... Maybe you could fix it in separate patch if you want, I leave
as agreed — just offsets and no label.

> 
> > Moreover, I found another place where similar change could be done
> > (dump_smb), so, would it be better to do in separate patch?
> > 
> 
> Sure, that certainly wouldn't hurt. Your call on whether to do two
> patches or one.

I'm going to resend a whole patchseries as v3 with coverletter and
changelog, since I missed CC you in previous patch, and AB's
Reviewed-by. Also found rebase error which makes compilation fail.
And printk->pr_* change as new patch as well, will be 3 all together.

> 
> 
> > > 
> > > >  }
> > > >  
> > > >  #ifdef CONFIG_CIFS_DEBUG
> > > 
> > > Otherwise, this looks good.
> > > 
> > > Acked-by: Jeff Layton <jlayton-vpEMnDpepFuMZCB2o+C8xQ@public.gmane.org>
> > 
> > 
> 


-- 
Andy Shevchenko <andriy.shevchenko-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Intel Finland Oy

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-05-12 16:30 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-12 15:15 [PATCH v2] cifs: call print_hex_dump instead of custom implementation Andy Shevchenko
     [not found] ` <1399907720-18622-1-git-send-email-andriy.shevchenko-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2014-05-12 15:41   ` Alexander Bokovoy
2014-05-12 15:42   ` Jeff Layton
2014-05-12 16:15     ` Andy Shevchenko
2014-05-12 16:23       ` Jeff Layton
     [not found]         ` <20140512122356.1143f317-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2014-05-12 16:30           ` Andy Shevchenko

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.