Skip to content

Commit 25c9a4a

Browse files
andy-shevMike Snitzer
authored andcommitted
dm integrity: Use %*ph for printing hexdump of a small buffer
The kernel already has a helper to print a hexdump of a small buffer via pointer extension. Use that instead of open coded variant. In long term it helps to kill pr_cont() or at least narrow down its use. Note, the format is slightly changed, i.e. the trailing space is always printed. Also the IV dump is limited by 64 bytes which seems fine. Signed-off-by: Andy Shevchenko <[email protected]> Signed-off-by: Mike Snitzer <[email protected]>
1 parent fa37564 commit 25c9a4a

File tree

1 file changed

+3
-18
lines changed

1 file changed

+3
-18
lines changed

drivers/md/dm-integrity.c

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -342,24 +342,9 @@ static struct kmem_cache *journal_io_cache;
342342
#define JOURNAL_IO_MEMPOOL 32
343343

344344
#ifdef DEBUG_PRINT
345-
#define DEBUG_print(x, ...) printk(KERN_DEBUG x, ##__VA_ARGS__)
346-
static void __DEBUG_bytes(__u8 *bytes, size_t len, const char *msg, ...)
347-
{
348-
va_list args;
349-
350-
va_start(args, msg);
351-
vprintk(msg, args);
352-
va_end(args);
353-
if (len)
354-
pr_cont(":");
355-
while (len) {
356-
pr_cont(" %02x", *bytes);
357-
bytes++;
358-
len--;
359-
}
360-
pr_cont("\n");
361-
}
362-
#define DEBUG_bytes(bytes, len, msg, ...) __DEBUG_bytes(bytes, len, KERN_DEBUG msg, ##__VA_ARGS__)
345+
#define DEBUG_print(x, ...) printk(KERN_DEBUG x, ##__VA_ARGS__)
346+
#define DEBUG_bytes(bytes, len, msg, ...) printk(KERN_DEBUG msg "%s%*ph\n", ##__VA_ARGS__, \
347+
len ? ": " : "", len, bytes)
363348
#else
364349
#define DEBUG_print(x, ...) do { } while (0)
365350
#define DEBUG_bytes(bytes, len, msg, ...) do { } while (0)

0 commit comments

Comments
 (0)