Skip to content

Commit 17695d7

Browse files
Eric Biggerschucklever
authored andcommitted
nfsd: Replace open-coded conversion of bytes to hex
Since the Linux kernel's sprintf() has conversion to hex built-in via "%*phN", delete md5_to_hex() and just use that. Also add an explicit array bound to the dname parameter of nfs4_make_rec_clidname() to make its size clear. No functional change. Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Eric Biggers <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
1 parent 6ecdfd7 commit 17695d7

File tree

1 file changed

+2
-16
lines changed

1 file changed

+2
-16
lines changed

fs/nfsd/nfs4recover.c

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -92,22 +92,8 @@ nfs4_reset_creds(const struct cred *original)
9292
put_cred(revert_creds(original));
9393
}
9494

95-
static void
96-
md5_to_hex(char *out, char *md5)
97-
{
98-
int i;
99-
100-
for (i=0; i<16; i++) {
101-
unsigned char c = md5[i];
102-
103-
*out++ = '0' + ((c&0xf0)>>4) + (c>=0xa0)*('a'-'9'-1);
104-
*out++ = '0' + (c&0x0f) + ((c&0x0f)>=0x0a)*('a'-'9'-1);
105-
}
106-
*out = '\0';
107-
}
108-
10995
static int
110-
nfs4_make_rec_clidname(char *dname, const struct xdr_netobj *clname)
96+
nfs4_make_rec_clidname(char dname[HEXDIR_LEN], const struct xdr_netobj *clname)
11197
{
11298
struct xdr_netobj cksum;
11399
struct crypto_shash *tfm;
@@ -133,7 +119,7 @@ nfs4_make_rec_clidname(char *dname, const struct xdr_netobj *clname)
133119
if (status)
134120
goto out;
135121

136-
md5_to_hex(dname, cksum.data);
122+
sprintf(dname, "%*phN", 16, cksum.data);
137123

138124
status = 0;
139125
out:

0 commit comments

Comments
 (0)