mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH linux-next] ocfs2: use sysfs_emit() instead of scnprintf().
@ 2025-03-15  6:16 xie.ludan
  2025-03-17  6:20 ` Jiri Slaby
  0 siblings, 1 reply; 2+ messages in thread
From: xie.ludan @ 2025-03-15  6:16 UTC (permalink / raw)
  To: mark
  Cc: jlbec, joseph.qi, akpm, viro, brauner, danielyangkang, dmantipov,
	ocfs2-devel, linux-kernel


[-- Attachment #1.1.1: Type: text/plain, Size: 1837 bytes --]

From: XieLudan <xie.ludan@zte.com.cn>

Follow the advice in Documentation/filesystems/sysfs.rst:
show() should only use sysfs_emit() or sysfs_emit_at() when formatting
the value to be returned to user space.

Signed-off-by: XieLudan <xie.ludan@zte.com.cn>
---
 fs/ocfs2/cluster/heartbeat.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c
index 724350925aff..8282fc193906 100644
--- a/fs/ocfs2/cluster/heartbeat.c
+++ b/fs/ocfs2/cluster/heartbeat.c
@@ -1308,7 +1308,7 @@ static int o2hb_debug_open(struct inode *inode, struct file *file)
 
 	case O2HB_DB_TYPE_REGION_NUMBER:
 		reg = (struct o2hb_region *)db->db_data;
-		out += scnprintf(buf + out, PAGE_SIZE - out, "%d\n",
+		out += sysfs_emit(buf + out, "%d\n",
 				reg->hr_region_num);
 		goto done;
 
@@ -1318,12 +1318,12 @@ static int o2hb_debug_open(struct inode *inode, struct file *file)
 		/* If 0, it has never been set before */
 		if (lts)
 			lts = jiffies_to_msecs(jiffies - lts);
-		out += scnprintf(buf + out, PAGE_SIZE - out, "%lu\n", lts);
+		out += sysfs_emit(buf + out, "%lu\n", lts);
 		goto done;
 
 	case O2HB_DB_TYPE_REGION_PINNED:
 		reg = (struct o2hb_region *)db->db_data;
-		out += scnprintf(buf + out, PAGE_SIZE - out, "%u\n",
+		out += sysfs_emit(buf + out, "%u\n",
 				!!reg->hr_item_pinned);
 		goto done;
 
@@ -1332,8 +1332,8 @@ static int o2hb_debug_open(struct inode *inode, struct file *file)
 	}
 
 	while ((i = find_next_bit(map, db->db_len, i + 1)) < db->db_len)
-		out += scnprintf(buf + out, PAGE_SIZE - out, "%d ", i);
-	out += scnprintf(buf + out, PAGE_SIZE - out, "\n");
+		out += sysfs_emit(buf + out, "%d ", i);
+	out += sysfs_emit(buf + out, "\n");
 
 done:
 	i_size_write(inode, out);
-- 
2.25.1

[-- Attachment #1.1.2: Type: text/html , Size: 3660 bytes --]

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

end of thread, other threads:[~2025-03-17  6:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-15  6:16 [PATCH linux-next] ocfs2: use sysfs_emit() instead of scnprintf() xie.ludan
2025-03-17  6:20 ` Jiri Slaby

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®