ecryptfs: use print_hex_dump_bytes for hexdump
authorSascha Hauer <s.hauer@pengutronix.de>
Fri, 17 May 2019 10:45:15 +0000 (12:45 +0200)
committerTyler Hicks <tyhicks@canonical.com>
Wed, 19 Jun 2019 05:53:37 +0000 (05:53 +0000)
The Kernel has nice hexdump facilities, use them rather a homebrew
hexdump function.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
fs/ecryptfs/debug.c

index 3d2bdf546ec655b05cc0733a55e8f0cba212aeaf..ee9d8ac4a8094ccf0e86541a7e15e11a55ad80a2 100644 (file)
@@ -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);
+}