]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
nfsd: remove private bin2hex implementation
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Fri, 11 Oct 2019 16:02:58 +0000 (19:02 +0300)
committerJ. Bruce Fields <bfields@redhat.com>
Fri, 11 Oct 2019 16:49:14 +0000 (12:49 -0400)
Calling sprintf in a loop is not very efficient, and in any case,
we already have an implementation of bin-to-hex conversion in lib/
which we might as well use.

Note that original code used to nul-terminate the destination while
bin2hex doesn't. That's why replace kmalloc() with kzalloc().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
fs/nfsd/nfs4recover.c

index cdc75ad4438b6442fb8bf76b9687b662f3a44bc6..29dff4c6e7528b53e94e9353266267efc8305348 100644 (file)
@@ -1850,19 +1850,14 @@ nfsd4_umh_cltrack_upcall(char *cmd, char *arg, char *env0, char *env1)
 static char *
 bin_to_hex_dup(const unsigned char *src, int srclen)
 {
-       int i;
-       char *buf, *hex;
+       char *buf;
 
        /* +1 for terminating NULL */
-       buf = kmalloc((srclen * 2) + 1, GFP_KERNEL);
+       buf = kzalloc((srclen * 2) + 1, GFP_KERNEL);
        if (!buf)
                return buf;
 
-       hex = buf;
-       for (i = 0; i < srclen; i++) {
-               sprintf(hex, "%2.2x", *src++);
-               hex += 2;
-       }
+       bin2hex(buf, src, srclen);
        return buf;
 }