Skip to content

Commit 12b4157

Browse files
andy-shevJ. Bruce Fields
authored andcommitted
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 <[email protected]> Signed-off-by: J. Bruce Fields <[email protected]>
1 parent 6e73e92 commit 12b4157

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

fs/nfsd/nfs4recover.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1850,19 +1850,14 @@ nfsd4_umh_cltrack_upcall(char *cmd, char *arg, char *env0, char *env1)
18501850
static char *
18511851
bin_to_hex_dup(const unsigned char *src, int srclen)
18521852
{
1853-
int i;
1854-
char *buf, *hex;
1853+
char *buf;
18551854

18561855
/* +1 for terminating NULL */
1857-
buf = kmalloc((srclen * 2) + 1, GFP_KERNEL);
1856+
buf = kzalloc((srclen * 2) + 1, GFP_KERNEL);
18581857
if (!buf)
18591858
return buf;
18601859

1861-
hex = buf;
1862-
for (i = 0; i < srclen; i++) {
1863-
sprintf(hex, "%2.2x", *src++);
1864-
hex += 2;
1865-
}
1860+
bin2hex(buf, src, srclen);
18661861
return buf;
18671862
}
18681863

0 commit comments

Comments
 (0)