From: Marcelo Moreira <marcelomoreira1905@gmail.com>
To: cem@kernel.org, linux-xfs@vger.kernel.org,
linux-kernel@vger.kernel.org, skhan@linuxfoundation.org,
linux-kernel-mentees@lists.linuxfoundation.org
Subject: [PATCH v2] xfs: Replace strncpy with memcpy
Date: Sun, 17 Aug 2025 12:50:41 -0300 [thread overview]
Message-ID: <20250817155053.15856-1-marcelomoreira1905@gmail.com> (raw)
Following a suggestion from Dave and everyone who contributed to v1, this
changes modernizes the code by aligning it with current kernel best practices.
It improves code clarity and consistency, as strncpy is deprecated as explained
in Documentation/process/deprecated.rst. Furthermore, this change was tested
by xfstests and as it was not an easy task I decided to document on my blog
the step by step of how I did it https://meritissimo1.com/blog/2-xfs-tests :).
This change does not alter the functionality or introduce any behavioral
changes.
Changes include:
- Replace strncpy with memcpy.
---
Changelog:
Changes since v1:
- Replace strncpy with memcpy instead of strscpy.
- The change was tested using xfstests.
Link to v1: https://lore.kernel.org/linux-kernel-mentees/CAPZ3m_jXwp1FfsvtR2s3nwATT3fER=Mc6qj+GzKuUhY5tjQFNQ@mail.gmail.com/T/#t
Suggested-by: Dave Chinner <david@fromorbit.com>
Signed-off-by: Marcelo Moreira <marcelomoreira1905@gmail.com>
---
fs/xfs/scrub/symlink_repair.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/xfs/scrub/symlink_repair.c b/fs/xfs/scrub/symlink_repair.c
index 953ce7be78dc..5902398185a8 100644
--- a/fs/xfs/scrub/symlink_repair.c
+++ b/fs/xfs/scrub/symlink_repair.c
@@ -185,7 +185,7 @@ xrep_symlink_salvage_inline(
return 0;
nr = min(XFS_SYMLINK_MAXLEN, xfs_inode_data_fork_size(ip));
- strncpy(target_buf, ifp->if_data, nr);
+ memcpy(target_buf, ifp->if_data, nr);
return nr;
}
--
2.50.1
next reply other threads:[~2025-08-17 15:51 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <DgC9ldLgYmvzXaAZpH-XsBCKhwKSRirv1SdyNKAyWkv0buVk8ZXruCVWp7pYeSa6Ogg-jj6hxYTLAxC0m0FYeg==@protonmail.internalid>
2025-08-17 15:50 ` Marcelo Moreira [this message]
2025-08-18 4:43 ` [PATCH v2] xfs: Replace strncpy with memcpy Christoph Hellwig
2025-08-18 4:46 ` Christoph Hellwig
2025-08-20 13:47 ` Marcelo Moreira
2025-08-21 8:47 ` Christoph Hellwig
2025-08-23 17:41 ` Marcelo Moreira
2025-08-21 9:39 ` Carlos Maiolino
2025-08-23 17:34 ` Marcelo Moreira
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=20250817155053.15856-1-marcelomoreira1905@gmail.com \
--to=marcelomoreira1905@gmail.com \
--cc=cem@kernel.org \
--cc=linux-kernel-mentees@lists.linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=skhan@linuxfoundation.org \
/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