diff options
author | Andy Shevchenko <andriy.shevchenko@linux.intel.com> | 2019-10-11 19:02:58 +0300 |
---|---|---|
committer | J. Bruce Fields <bfields@redhat.com> | 2019-10-11 12:49:14 -0400 |
commit | 12b4157b7d3b666b1296b5cd4f1b675f102e2126 (patch) | |
tree | ce618430813747f6137b27c5285fa940eca1db5a /fs | |
parent | 6e73e92b155c868ff7fce9d108839668caf1d9be (diff) | |
download | linux-12b4157b7d3b666b1296b5cd4f1b675f102e2126.tar.gz linux-12b4157b7d3b666b1296b5cd4f1b675f102e2126.tar.bz2 linux-12b4157b7d3b666b1296b5cd4f1b675f102e2126.zip |
nfsd: remove private bin2hex implementation
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>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/nfsd/nfs4recover.c | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c index cdc75ad4438b..29dff4c6e752 100644 --- a/fs/nfsd/nfs4recover.c +++ b/fs/nfsd/nfs4recover.c @@ -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; } |