From: Thorsten Blum <thorsten.blum@linux.dev>
To: Mike Marshall <hubcap@omnibond.com>,
Martin Brandenburg <martin@omnibond.com>
Cc: Thorsten Blum <thorsten.blum@linux.dev>,
devel@lists.orangefs.org, linux-kernel@vger.kernel.org
Subject: [PATCH RESEND] orangefs: use memcpy_and_pad in khandle_to and inode_getxattr
Date: Mon, 4 May 2026 20:05:36 +0200 [thread overview]
Message-ID: <20260504180534.142246-3-thorsten.blum@linux.dev> (raw)
Use memcpy_and_pad() instead of memcpy() followed by memset() to
simplify ORANGEFS_khandle_to() and orangefs_inode_getxattr().
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
fs/orangefs/protocol.h | 5 +----
fs/orangefs/xattr.c | 6 ++----
2 files changed, 3 insertions(+), 8 deletions(-)
diff --git a/fs/orangefs/protocol.h b/fs/orangefs/protocol.h
index d403cf29a99b..bbdbd6a05d0d 100644
--- a/fs/orangefs/protocol.h
+++ b/fs/orangefs/protocol.h
@@ -50,10 +50,7 @@ static inline int ORANGEFS_khandle_cmp(const struct orangefs_khandle *kh1,
static inline void ORANGEFS_khandle_to(const struct orangefs_khandle *kh,
void *p, int size)
{
-
- memcpy(p, kh->u, 16);
- memset(p + 16, 0, size - 16);
-
+ memcpy_and_pad(p, size, kh->u, 16, 0);
}
static inline void ORANGEFS_khandle_from(struct orangefs_khandle *kh,
diff --git a/fs/orangefs/xattr.c b/fs/orangefs/xattr.c
index b6d116302de4..5c061603b29b 100644
--- a/fs/orangefs/xattr.c
+++ b/fs/orangefs/xattr.c
@@ -140,8 +140,7 @@ ssize_t orangefs_inode_getxattr(struct inode *inode, const char *name,
ret = -ERANGE;
goto out_unlock;
}
- memcpy(buffer, cx->val, cx->length);
- memset(buffer + cx->length, 0, size - cx->length);
+ memcpy_and_pad(buffer, size, cx->val, cx->length, 0);
ret = cx->length;
goto out_unlock;
}
@@ -209,8 +208,7 @@ ssize_t orangefs_inode_getxattr(struct inode *inode, const char *name,
goto out_release_op;
}
- memcpy(buffer, new_op->downcall.resp.getxattr.val, length);
- memset(buffer + length, 0, size - length);
+ memcpy_and_pad(buffer, size, new_op->downcall.resp.getxattr.val, length, 0);
gossip_debug(GOSSIP_XATTR_DEBUG,
"orangefs_inode_getxattr: inode %pU "
"key %s key_sz %d, val_len %d\n",
next reply other threads:[~2026-05-04 18:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-04 18:05 Thorsten Blum [this message]
2026-05-05 16:14 ` [PATCH RESEND] orangefs: use memcpy_and_pad in khandle_to and inode_getxattr Mike Marshall
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=20260504180534.142246-3-thorsten.blum@linux.dev \
--to=thorsten.blum@linux.dev \
--cc=devel@lists.orangefs.org \
--cc=hubcap@omnibond.com \
--cc=linux-kernel@vger.kernel.org \
--cc=martin@omnibond.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.