linux-cifs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ksmbd: Convert to use sysfs_emit()/sysfs_emit_at() APIs
@ 2022-12-07  1:29 ye.xingchen
  2022-12-08 13:35 ` Namjae Jeon
  2022-12-09  1:07 ` Sergey Senozhatsky
  0 siblings, 2 replies; 3+ messages in thread
From: ye.xingchen @ 2022-12-07  1:29 UTC (permalink / raw)
  To: linkinjeon; +Cc: sfrench, senozhatsky, tom, linux-cifs, linux-kernel

From: ye xingchen <ye.xingchen@zte.com.cn>

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

Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
---
 fs/ksmbd/server.c | 20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/fs/ksmbd/server.c b/fs/ksmbd/server.c
index a0d635304754..394b6ceac431 100644
--- a/fs/ksmbd/server.c
+++ b/fs/ksmbd/server.c
@@ -432,11 +432,9 @@ static ssize_t stats_show(struct class *class, struct class_attribute *attr,
 		"reset",
 		"shutdown"
 	};
-
-	ssize_t sz = scnprintf(buf, PAGE_SIZE, "%d %s %d %lu\n", stats_version,
-			       state[server_conf.state], server_conf.tcp_port,
-			       server_conf.ipc_last_active / HZ);
-	return sz;
+	return sysfs_emit(buf, "%d %s %d %lu\n", stats_version,
+			  state[server_conf.state], server_conf.tcp_port,
+			  server_conf.ipc_last_active / HZ);
 }

 static ssize_t kill_server_store(struct class *class,
@@ -468,19 +466,13 @@ static ssize_t debug_show(struct class *class, struct class_attribute *attr,

 	for (i = 0; i < ARRAY_SIZE(debug_type_strings); i++) {
 		if ((ksmbd_debug_types >> i) & 1) {
-			pos = scnprintf(buf + sz,
-					PAGE_SIZE - sz,
-					"[%s] ",
-					debug_type_strings[i]);
+			pos = sysfs_emit_at(buf, sz, "[%s] ", debug_type_strings[i]);
 		} else {
-			pos = scnprintf(buf + sz,
-					PAGE_SIZE - sz,
-					"%s ",
-					debug_type_strings[i]);
+			pos = sysfs_emit_at(buf, sz, "%s ", debug_type_strings[i]);
 		}
 		sz += pos;
 	}
-	sz += scnprintf(buf + sz, PAGE_SIZE - sz, "\n");
+	sz += sysfs_emit_at(buf, sz, "\n");
 	return sz;
 }

-- 
2.25.1

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

* Re: [PATCH] ksmbd: Convert to use sysfs_emit()/sysfs_emit_at() APIs
  2022-12-07  1:29 [PATCH] ksmbd: Convert to use sysfs_emit()/sysfs_emit_at() APIs ye.xingchen
@ 2022-12-08 13:35 ` Namjae Jeon
  2022-12-09  1:07 ` Sergey Senozhatsky
  1 sibling, 0 replies; 3+ messages in thread
From: Namjae Jeon @ 2022-12-08 13:35 UTC (permalink / raw)
  To: ye.xingchen; +Cc: sfrench, senozhatsky, tom, linux-cifs, linux-kernel

2022-12-07 10:29 GMT+09:00, ye.xingchen@zte.com.cn <ye.xingchen@zte.com.cn>:
> From: ye xingchen <ye.xingchen@zte.com.cn>
>
> Follow the advice of the Documentation/filesystems/sysfs.rst and show()
> should only use sysfs_emit() or sysfs_emit_at() when formatting the
> value to be returned to user space.
>
> Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>

Thanks!

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

* Re: [PATCH] ksmbd: Convert to use sysfs_emit()/sysfs_emit_at() APIs
  2022-12-07  1:29 [PATCH] ksmbd: Convert to use sysfs_emit()/sysfs_emit_at() APIs ye.xingchen
  2022-12-08 13:35 ` Namjae Jeon
@ 2022-12-09  1:07 ` Sergey Senozhatsky
  1 sibling, 0 replies; 3+ messages in thread
From: Sergey Senozhatsky @ 2022-12-09  1:07 UTC (permalink / raw)
  To: ye.xingchen
  Cc: linkinjeon, sfrench, senozhatsky, tom, linux-cifs, linux-kernel

On (22/12/07 09:29), ye.xingchen@zte.com.cn wrote:
> From: ye xingchen <ye.xingchen@zte.com.cn>
> 
> Follow the advice of the Documentation/filesystems/sysfs.rst and show()
> should only use sysfs_emit() or sysfs_emit_at() when formatting the
> value to be returned to user space.
> 
> Signed-off-by: ye xingchen <ye.xingchen@zte.com.cn>

Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>

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

end of thread, other threads:[~2022-12-09  1:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-07  1:29 [PATCH] ksmbd: Convert to use sysfs_emit()/sysfs_emit_at() APIs ye.xingchen
2022-12-08 13:35 ` Namjae Jeon
2022-12-09  1:07 ` Sergey Senozhatsky

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