All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ecryptfs: use print_hex_dump_bytes for hexdump
@ 2019-05-17 10:45 Sascha Hauer
  2019-06-19  6:35 ` Tyler Hicks
  0 siblings, 1 reply; 2+ messages in thread
From: Sascha Hauer @ 2019-05-17 10:45 UTC (permalink / raw)
  To: ecryptfs; +Cc: Tyler Hicks, linux-kernel, kernel, Sascha Hauer

The Kernel has nice hexdump facilities, use them rather a homebrew
hexdump function.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 fs/ecryptfs/debug.c | 22 +++-------------------
 1 file changed, 3 insertions(+), 19 deletions(-)

diff --git a/fs/ecryptfs/debug.c b/fs/ecryptfs/debug.c
index 3d2bdf546ec6..ee9d8ac4a809 100644
--- a/fs/ecryptfs/debug.c
+++ b/fs/ecryptfs/debug.c
@@ -97,25 +97,9 @@ void ecryptfs_dump_auth_tok(struct ecryptfs_auth_tok *auth_tok)
  */
 void ecryptfs_dump_hex(char *data, int bytes)
 {
-	int i = 0;
-	int add_newline = 1;
-
 	if (ecryptfs_verbosity < 1)
 		return;
-	if (bytes != 0) {
-		printk(KERN_DEBUG "0x%.2x.", (unsigned char)data[i]);
-		i++;
-	}
-	while (i < bytes) {
-		printk("0x%.2x.", (unsigned char)data[i]);
-		i++;
-		if (i % 16 == 0) {
-			printk("\n");
-			add_newline = 0;
-		} else
-			add_newline = 1;
-	}
-	if (add_newline)
-		printk("\n");
-}
 
+	print_hex_dump(KERN_DEBUG, "ecryptfs: ", DUMP_PREFIX_OFFSET, 16, 1,
+		       data, bytes, false);
+}
-- 
2.20.1


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

* Re: [PATCH] ecryptfs: use print_hex_dump_bytes for hexdump
  2019-05-17 10:45 [PATCH] ecryptfs: use print_hex_dump_bytes for hexdump Sascha Hauer
@ 2019-06-19  6:35 ` Tyler Hicks
  0 siblings, 0 replies; 2+ messages in thread
From: Tyler Hicks @ 2019-06-19  6:35 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: ecryptfs, linux-kernel, kernel

On 2019-05-17 12:45:15, Sascha Hauer wrote:
> The Kernel has nice hexdump facilities, use them rather a homebrew
> hexdump function.
> 
> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>

Thanks! This is much nicer. I've pushed the commit to the eCryptfs next
branch.

Tyler

> ---
>  fs/ecryptfs/debug.c | 22 +++-------------------
>  1 file changed, 3 insertions(+), 19 deletions(-)
> 
> diff --git a/fs/ecryptfs/debug.c b/fs/ecryptfs/debug.c
> index 3d2bdf546ec6..ee9d8ac4a809 100644
> --- a/fs/ecryptfs/debug.c
> +++ b/fs/ecryptfs/debug.c
> @@ -97,25 +97,9 @@ void ecryptfs_dump_auth_tok(struct ecryptfs_auth_tok *auth_tok)
>   */
>  void ecryptfs_dump_hex(char *data, int bytes)
>  {
> -	int i = 0;
> -	int add_newline = 1;
> -
>  	if (ecryptfs_verbosity < 1)
>  		return;
> -	if (bytes != 0) {
> -		printk(KERN_DEBUG "0x%.2x.", (unsigned char)data[i]);
> -		i++;
> -	}
> -	while (i < bytes) {
> -		printk("0x%.2x.", (unsigned char)data[i]);
> -		i++;
> -		if (i % 16 == 0) {
> -			printk("\n");
> -			add_newline = 0;
> -		} else
> -			add_newline = 1;
> -	}
> -	if (add_newline)
> -		printk("\n");
> -}
>  
> +	print_hex_dump(KERN_DEBUG, "ecryptfs: ", DUMP_PREFIX_OFFSET, 16, 1,
> +		       data, bytes, false);
> +}
> -- 
> 2.20.1
> 

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

end of thread, other threads:[~2019-06-19  6:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-17 10:45 [PATCH] ecryptfs: use print_hex_dump_bytes for hexdump Sascha Hauer
2019-06-19  6:35 ` Tyler Hicks

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.