]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ksmbd: Convert to use sysfs_emit()/sysfs_emit_at() APIs
authorye xingchen <ye.xingchen@zte.com.cn>
Mon, 18 Dec 2023 15:33:28 +0000 (00:33 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 23 Dec 2023 09:41:53 +0000 (10:41 +0100)
[ Upstream commit 72ee45fd46d0d3578c4e6046f66fae3218543ce3 ]

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>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/ksmbd/server.c

index 1d5e46d710704b7044284267a0523ebcc49b2d6f..b9f11ef91ee467e1d134154d700b861b2d141f04 100644 (file)
@@ -439,11 +439,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,
@@ -475,19 +473,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;
 }