]> www.infradead.org Git - users/hch/misc.git/commitdiff
nfsd: Replace open-coded conversion of bytes to hex
authorEric Biggers <ebiggers@kernel.org>
Mon, 4 Aug 2025 22:46:59 +0000 (22:46 +0000)
committerChuck Lever <chuck.lever@oracle.com>
Sun, 21 Sep 2025 23:24:50 +0000 (19:24 -0400)
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 <jlayton@kernel.org>
Signed-off-by: Eric Biggers <ebiggers@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
fs/nfsd/nfs4recover.c

index 2231192ec33f57eeb9b0f9a7810ee121d0d2feb1..54f5e5392ef9d925c245defd2b181904c2d823e0 100644 (file)
@@ -92,22 +92,8 @@ nfs4_reset_creds(const struct cred *original)
        put_cred(revert_creds(original));
 }
 
-static void
-md5_to_hex(char *out, char *md5)
-{
-       int i;
-
-       for (i=0; i<16; i++) {
-               unsigned char c = md5[i];
-
-               *out++ = '0' + ((c&0xf0)>>4) + (c>=0xa0)*('a'-'9'-1);
-               *out++ = '0' + (c&0x0f) + ((c&0x0f)>=0x0a)*('a'-'9'-1);
-       }
-       *out = '\0';
-}
-
 static int
-nfs4_make_rec_clidname(char *dname, const struct xdr_netobj *clname)
+nfs4_make_rec_clidname(char dname[HEXDIR_LEN], const struct xdr_netobj *clname)
 {
        struct xdr_netobj cksum;
        struct crypto_shash *tfm;
@@ -133,7 +119,7 @@ nfs4_make_rec_clidname(char *dname, const struct xdr_netobj *clname)
        if (status)
                goto out;
 
-       md5_to_hex(dname, cksum.data);
+       sprintf(dname, "%*phN", 16, cksum.data);
 
        status = 0;
 out: