From: Eric Biggers <ebiggers@kernel.org>
To: Chuck Lever <chuck.lever@oracle.com>,
Jeff Layton <jlayton@kernel.org>,
linux-nfs@vger.kernel.org
Cc: NeilBrown <neil@brown.name>,
Olga Kornievskaia <okorniev@redhat.com>,
Dai Ngo <Dai.Ngo@oracle.com>, Tom Talpey <tom@talpey.com>,
Eric Biggers <ebiggers@kernel.org>
Subject: [PATCH v2 1/2] nfsd: Replace open-coded conversion of bytes to hex
Date: Mon, 4 Aug 2025 22:46:59 +0000 [thread overview]
Message-ID: <20250804224701.2278773-2-ebiggers@kernel.org> (raw)
In-Reply-To: <20250804224701.2278773-1-ebiggers@kernel.org>
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>
---
fs/nfsd/nfs4recover.c | 18 ++----------------
1 file changed, 2 insertions(+), 16 deletions(-)
diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c
index 2231192ec33f..54f5e5392ef9 100644
--- a/fs/nfsd/nfs4recover.c
+++ b/fs/nfsd/nfs4recover.c
@@ -90,26 +90,12 @@ static void
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;
int status;
@@ -131,11 +117,11 @@ nfs4_make_rec_clidname(char *dname, const struct xdr_netobj *clname)
status = crypto_shash_tfm_digest(tfm, clname->data, clname->len,
cksum.data);
if (status)
goto out;
- md5_to_hex(dname, cksum.data);
+ sprintf(dname, "%*phN", 16, cksum.data);
status = 0;
out:
kfree(cksum.data);
crypto_free_shash(tfm);
--
2.50.1.565.gc32cd1483b-goog
next prev parent reply other threads:[~2025-08-04 22:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-04 22:46 [PATCH v2 0/2] nfsd: Clean up nfs4_make_rec_clidname() Eric Biggers
2025-08-04 22:46 ` Eric Biggers [this message]
2025-08-04 22:47 ` [PATCH v2 2/2] nfsd: Eliminate an allocation in nfs4_make_rec_clidname() Eric Biggers
2025-08-05 14:29 ` Jeff Layton
2025-08-05 14:24 ` [PATCH v2 0/2] nfsd: Clean up nfs4_make_rec_clidname() Chuck Lever
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250804224701.2278773-2-ebiggers@kernel.org \
--to=ebiggers@kernel.org \
--cc=Dai.Ngo@oracle.com \
--cc=chuck.lever@oracle.com \
--cc=jlayton@kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=neil@brown.name \
--cc=okorniev@redhat.com \
--cc=tom@talpey.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).