diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2014-08-27 09:49:43 -0400 |
---|---|---|
committer | Steve French <steve.french@primarydata.com> | 2014-12-07 23:48:01 -0500 |
commit | 55d83e0dbb3ed91e05b11ef32afb30acfbf8ba45 (patch) | |
tree | a92417e84b7ea72828b1667821813fe8b04ddc80 | |
parent | 28e2aed244b1b81e45b105d90ffb82384665dfb7 (diff) |
cifs: convert to print_hex_dump() instead of custom implementation
This patch converts custom dumper to use native print_hex_dump() instead. The
cifs_dump_mem() will have an offsets per each line which differs it from the
original code.
In the dump_smb() we may use native print_hex_dump() as well. It will show
slightly different output in ASCII part when character is unprintable,
otherwise it keeps same structure.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Steve French <steve.french@primarydata.com>
-rw-r--r-- | fs/cifs/cifs_debug.c | 21 | ||||
-rw-r--r-- | fs/cifs/misc.c | 32 |
2 files changed, 4 insertions, 49 deletions
diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c index 7c50bfa9c438..14e082ff1944 100644 --- a/fs/cifs/cifs_debug.c +++ b/fs/cifs/cifs_debug.c | |||
@@ -34,27 +34,10 @@ | |||
34 | void | 34 | void |
35 | cifs_dump_mem(char *label, void *data, int length) | 35 | cifs_dump_mem(char *label, void *data, int length) |
36 | { | 36 | { |
37 | int i, j; | ||
38 | int *intptr = data; | ||
39 | char *charptr = data; | ||
40 | char buf[10], line[80]; | ||
41 | |||
42 | printk(KERN_DEBUG "%s: dump of %d bytes of data at 0x%p\n", | 37 | printk(KERN_DEBUG "%s: dump of %d bytes of data at 0x%p\n", |
43 | label, length, data); | 38 | label, length, data); |
44 | for (i = 0; i < length; i += 16) { | 39 | print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_OFFSET, 16, 4, |
45 | line[0] = 0; | 40 | data, length, true); |
46 | for (j = 0; (j < 4) && (i + j * 4 < length); j++) { | ||
47 | sprintf(buf, " %08x", intptr[i / 4 + j]); | ||
48 | strcat(line, buf); | ||
49 | } | ||
50 | buf[0] = ' '; | ||
51 | buf[2] = 0; | ||
52 | for (j = 0; (j < 16) && (i + j < length); j++) { | ||
53 | buf[1] = isprint(charptr[i + j]) ? charptr[i + j] : '.'; | ||
54 | strcat(line, buf); | ||
55 | } | ||
56 | printk(KERN_DEBUG "%s\n", line); | ||
57 | } | ||
58 | } | 41 | } |
59 | 42 | ||
60 | #ifdef CONFIG_CIFS_DEBUG | 43 | #ifdef CONFIG_CIFS_DEBUG |
diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c index b7415d596dbd..337946355b29 100644 --- a/fs/cifs/misc.c +++ b/fs/cifs/misc.c | |||
@@ -513,39 +513,11 @@ is_valid_oplock_break(char *buffer, struct TCP_Server_Info *srv) | |||
513 | void | 513 | void |
514 | dump_smb(void *buf, int smb_buf_length) | 514 | dump_smb(void *buf, int smb_buf_length) |
515 | { | 515 | { |
516 | int i, j; | ||
517 | char debug_line[17]; | ||
518 | unsigned char *buffer = buf; | ||
519 | |||
520 | if (traceSMB == 0) | 516 | if (traceSMB == 0) |
521 | return; | 517 | return; |
522 | 518 | ||
523 | for (i = 0, j = 0; i < smb_buf_length; i++, j++) { | 519 | print_hex_dump(KERN_DEBUG, "", DUMP_PREFIX_NONE, 8, 2, buf, |
524 | if (i % 8 == 0) { | 520 | smb_buf_length, true); |
525 | /* have reached the beginning of line */ | ||
526 | printk(KERN_DEBUG "| "); | ||
527 | j = 0; | ||
528 | } | ||
529 | printk("%0#4x ", buffer[i]); | ||
530 | debug_line[2 * j] = ' '; | ||
531 | if (isprint(buffer[i])) | ||
532 | debug_line[1 + (2 * j)] = buffer[i]; | ||
533 | else | ||
534 | debug_line[1 + (2 * j)] = '_'; | ||
535 | |||
536 | if (i % 8 == 7) { | ||
537 | /* reached end of line, time to print ascii */ | ||
538 | debug_line[16] = 0; | ||
539 | printk(" | %s\n", debug_line); | ||
540 | } | ||
541 | } | ||
542 | for (; j < 8; j++) { | ||
543 | printk(" "); | ||
544 | debug_line[2 * j] = ' '; | ||
545 | debug_line[1 + (2 * j)] = ' '; | ||
546 | } | ||
547 | printk(" | %s\n", debug_line); | ||
548 | return; | ||
549 | } | 521 | } |
550 | 522 | ||
551 | void | 523 | void |