Skip to contentSkip to conversation

fs: dlm: use sysfs_emit() instead of snprintf()

PATCH New Anish Mulay 1 participant 1 message Feb 8 Distributed lock manager (DLM)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 fs: dlm: use sysfs_emit() instead of snprintf()

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.

---
 fs/dlm/lockspace.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
fs/dlm/lockspace.c +4 -4
index ddaa76558706..23975bb394eb 100644
@@ -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 {
Signature · 1 line
2.43.0