linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fs/xfs: use scnprintf() in show functions
@ 2025-06-16 11:03 Pranav Tyagi
  2025-06-16 14:20 ` Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: Pranav Tyagi @ 2025-06-16 11:03 UTC (permalink / raw)
  To: cem; +Cc: skhan, linux-xfs, linux-kernel, linux-kernel-mentees,
	Pranav Tyagi

Replace all snprintf() instances with scnprintf(). snprintf() returns
the number of bytes that would have been written had there been enough
space. For sysfs attributes, snprintf() should not be used for the
show() method. Instead use scnprintf() which returns the number of bytes
actually written.

Signed-off-by: Pranav Tyagi <pranav.tyagi03@gmail.com>
---
 fs/xfs/xfs_sysfs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/xfs/xfs_sysfs.c b/fs/xfs/xfs_sysfs.c
index 7a5c5ef2db92..f7206e3edea2 100644
--- a/fs/xfs/xfs_sysfs.c
+++ b/fs/xfs/xfs_sysfs.c
@@ -257,7 +257,7 @@ larp_show(
 	struct kobject	*kobject,
 	char		*buf)
 {
-	return snprintf(buf, PAGE_SIZE, "%d\n", xfs_globals.larp);
+	return scnprintf(buf, PAGE_SIZE, "%d\n", xfs_globals.larp);
 }
 XFS_SYSFS_ATTR_RW(larp);
 
@@ -283,7 +283,7 @@ bload_leaf_slack_show(
 	struct kobject	*kobject,
 	char		*buf)
 {
-	return snprintf(buf, PAGE_SIZE, "%d\n", xfs_globals.bload_leaf_slack);
+	return scnprintf(buf, PAGE_SIZE, "%d\n", xfs_globals.bload_leaf_slack);
 }
 XFS_SYSFS_ATTR_RW(bload_leaf_slack);
 
@@ -309,7 +309,7 @@ bload_node_slack_show(
 	struct kobject	*kobject,
 	char		*buf)
 {
-	return snprintf(buf, PAGE_SIZE, "%d\n", xfs_globals.bload_node_slack);
+	return scnprintf(buf, PAGE_SIZE, "%d\n", xfs_globals.bload_node_slack);
 }
 XFS_SYSFS_ATTR_RW(bload_node_slack);
 
-- 
2.49.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-06-17 13:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-16 11:03 [PATCH] fs/xfs: use scnprintf() in show functions Pranav Tyagi
2025-06-16 14:20 ` Greg KH
2025-06-17 13:23   ` Pranav Tyagi

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).