* [PATCH v1 1/1] dm integrity: Use %*ph for printing hexdump of a small buffer
@ 2023-06-12 21:47 Andy Shevchenko
2023-06-13 13:13 ` David Laight
0 siblings, 1 reply; 3+ messages in thread
From: Andy Shevchenko @ 2023-06-12 21:47 UTC (permalink / raw)
To: Mike Snitzer, Heinz Mauelshagen, dm-devel, linux-kernel
Cc: Alasdair Kergon, Andy Shevchenko
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 colon is not printed
before the buffer dump and the trailing space is always printed.
These are not a problem since it's a debug message. Also the IV dump
is limited by 64 bytes which seems fine.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/md/dm-integrity.c | 23 ++++-------------------
1 file changed, 4 insertions(+), 19 deletions(-)
diff --git a/drivers/md/dm-integrity.c b/drivers/md/dm-integrity.c
index 63ec502fcb12..e5b9a6bab3dd 100644
--- a/drivers/md/dm-integrity.c
+++ b/drivers/md/dm-integrity.c
@@ -342,24 +342,8 @@ static struct kmem_cache *journal_io_cache;
#define JOURNAL_IO_MEMPOOL 32
#ifdef DEBUG_PRINT
-#define DEBUG_print(x, ...) printk(KERN_DEBUG x, ##__VA_ARGS__)
-static void __DEBUG_bytes(__u8 *bytes, size_t len, const char *msg, ...)
-{
- va_list args;
-
- va_start(args, msg);
- vprintk(msg, args);
- va_end(args);
- if (len)
- pr_cont(":");
- while (len) {
- pr_cont(" %02x", *bytes);
- bytes++;
- len--;
- }
- pr_cont("\n");
-}
-#define DEBUG_bytes(bytes, len, msg, ...) __DEBUG_bytes(bytes, len, KERN_DEBUG msg, ##__VA_ARGS__)
+#define DEBUG_print(x, ...) printk(KERN_DEBUG x, ##__VA_ARGS__)
+#define DEBUG_bytes(bytes, len, msg, ...) printk(KERN_DEBUG msg " %*ph\n", ##__VA_ARGS__, len, bytes)
#else
#define DEBUG_print(x, ...) do { } while (0)
#define DEBUG_bytes(bytes, len, msg, ...) do { } while (0)
@@ -3781,8 +3765,9 @@ static int create_journal(struct dm_integrity_c *ic, char **error)
goto bad;
}
if (ic->journal_crypt_alg.alg_string) {
- unsigned int ivsize, blocksize;
struct journal_completion comp;
+ unsigned int blocksize;
+ int ivsize;
comp.ic = ic;
ic->journal_crypt = crypto_alloc_skcipher(ic->journal_crypt_alg.alg_string, 0, CRYPTO_ALG_ALLOCATES_MEMORY);
--
2.40.0.1.gaa8946217a0b
^ permalink raw reply related [flat|nested] 3+ messages in thread* RE: [PATCH v1 1/1] dm integrity: Use %*ph for printing hexdump of a small buffer
2023-06-12 21:47 [PATCH v1 1/1] dm integrity: Use %*ph for printing hexdump of a small buffer Andy Shevchenko
@ 2023-06-13 13:13 ` David Laight
2023-06-13 15:10 ` 'Andy Shevchenko'
0 siblings, 1 reply; 3+ messages in thread
From: David Laight @ 2023-06-13 13:13 UTC (permalink / raw)
To: 'Andy Shevchenko', Mike Snitzer, Heinz Mauelshagen,
dm-devel@redhat.com, linux-kernel@vger.kernel.org
Cc: Alasdair Kergon
From: Andy Shevchenko
> Sent: 12 June 2023 22:48
>
> 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 colon is not printed
> before the buffer dump and the trailing space is always printed.
> These are not a problem since it's a debug message. Also the IV dump
> is limited by 64 bytes which seems fine.
...
> +#define DEBUG_bytes(bytes, len, msg, ...) printk(KERN_DEBUG msg " %*ph\n", ##__VA_ARGS__, len,
> bytes)
Using:
printf(KERN_DEBUG msg "%s%*ph\n", ##__VA_ARGS__, len ? ": " : "", len, bytes)
would add back the optional ':'.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v1 1/1] dm integrity: Use %*ph for printing hexdump of a small buffer
2023-06-13 13:13 ` David Laight
@ 2023-06-13 15:10 ` 'Andy Shevchenko'
0 siblings, 0 replies; 3+ messages in thread
From: 'Andy Shevchenko' @ 2023-06-13 15:10 UTC (permalink / raw)
To: David Laight
Cc: Mike Snitzer, Heinz Mauelshagen, dm-devel@redhat.com,
linux-kernel@vger.kernel.org, Alasdair Kergon
On Tue, Jun 13, 2023 at 01:13:54PM +0000, David Laight wrote:
> From: Andy Shevchenko
> > Sent: 12 June 2023 22:48
> >
> > 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 colon is not printed
> > before the buffer dump and the trailing space is always printed.
> > These are not a problem since it's a debug message. Also the IV dump
> > is limited by 64 bytes which seems fine.
> ...
> > +#define DEBUG_bytes(bytes, len, msg, ...) printk(KERN_DEBUG msg " %*ph\n", ##__VA_ARGS__, len,
> > bytes)
>
> Using:
> printf(KERN_DEBUG msg "%s%*ph\n", ##__VA_ARGS__, len ? ": " : "", len, bytes)
> would add back the optional ':'.
Yes, I considered that and decided to avoid. This is debug and hence the format
may vary anyway. That said, up to maintainers.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-06-13 15:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-12 21:47 [PATCH v1 1/1] dm integrity: Use %*ph for printing hexdump of a small buffer Andy Shevchenko
2023-06-13 13:13 ` David Laight
2023-06-13 15:10 ` 'Andy Shevchenko'
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox