mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] fs: dlm: use sysfs_emit() instead of snprintf()
@ 2026-02-08 22:12 Anish Mulay
  0 siblings, 0 replies; only message in thread
From: Anish Mulay @ 2026-02-08 22:12 UTC (permalink / raw)
  To: aahringo, teigland; +Cc: gfs2, linux-kernel, Anish Mulay

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.

This patch replaces snprintf() with sysfs_emit() in the lockspace
show functions.

Signed-off-by: Anish Mulay <anishm7030@gmail.com>
---
 fs/dlm/lockspace.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/dlm/lockspace.c b/fs/dlm/lockspace.c
index ddaa76558706..23975bb394eb 100644
--- a/fs/dlm/lockspace.c
+++ b/fs/dlm/lockspace.c
@@ -69,7 +69,7 @@ static ssize_t dlm_event_store(struct dlm_ls *ls, const char *buf, size_t len)
 
 static ssize_t dlm_id_show(struct dlm_ls *ls, char *buf)
 {
-	return snprintf(buf, PAGE_SIZE, "%u\n", ls->ls_global_id);
+	return sysfs_emit(buf, "%u\n", ls->ls_global_id);
 }
 
 static ssize_t dlm_id_store(struct dlm_ls *ls, const char *buf, size_t len)
@@ -83,7 +83,7 @@ static ssize_t dlm_id_store(struct dlm_ls *ls, const char *buf, size_t len)
 
 static ssize_t dlm_nodir_show(struct dlm_ls *ls, char *buf)
 {
-	return snprintf(buf, PAGE_SIZE, "%u\n", dlm_no_directory(ls));
+	return sysfs_emit(buf, "%u\n", dlm_no_directory(ls));
 }
 
 static ssize_t dlm_nodir_store(struct dlm_ls *ls, const char *buf, size_t len)
@@ -101,12 +101,12 @@ static ssize_t dlm_nodir_store(struct dlm_ls *ls, const char *buf, size_t len)
 static ssize_t dlm_recover_status_show(struct dlm_ls *ls, char *buf)
 {
 	uint32_t status = dlm_recover_status(ls);
-	return snprintf(buf, PAGE_SIZE, "%x\n", status);
+	return sysfs_emit(buf, "%x\n", status);
 }
 
 static ssize_t dlm_recover_nodeid_show(struct dlm_ls *ls, char *buf)
 {
-	return snprintf(buf, PAGE_SIZE, "%d\n", ls->ls_recover_nodeid);
+	return sysfs_emit(buf, "%d\n", ls->ls_recover_nodeid);
 }
 
 struct dlm_attr {
-- 
2.43.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-02-08 22:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-02-08 22:12 [PATCH] fs: dlm: use sysfs_emit() instead of snprintf() Anish Mulay

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®