public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH linux-next] params: use sysfs_emit() instead of scnprintf().
@ 2025-03-15  6:17 xie.ludan
  2025-03-17  6:28 ` Jiri Slaby
  0 siblings, 1 reply; 2+ messages in thread
From: xie.ludan @ 2025-03-15  6:17 UTC (permalink / raw)
  To: petr.pavlu; +Cc: linux, mcgrof, thorsten.blum, linux-kernel


[-- Attachment #1.1.1: Type: text/plain, Size: 1881 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>
---
 kernel/params.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/params.c b/kernel/params.c
index 2509f216c9f3..89ae571af266 100644
--- a/kernel/params.c
+++ b/kernel/params.c
@@ -219,7 +219,7 @@ char *parse_args(const char *doing,
 	}								\
 	int param_get_##name(char *buffer, const struct kernel_param *kp) \
 	{								\
-		return scnprintf(buffer, PAGE_SIZE, format "\n",	\
+		return sysfs_emit(buffer, format "\n",	\
 				*((type *)kp->arg));			\
 	}								\
 	const struct kernel_param_ops param_ops_##name = {			\
@@ -289,7 +289,7 @@ EXPORT_SYMBOL(param_set_charp);
 
 int param_get_charp(char *buffer, const struct kernel_param *kp)
 {
-	return scnprintf(buffer, PAGE_SIZE, "%s\n", *((char **)kp->arg));
+	return sysfs_emit(buffer, "%s\n", *((char **)kp->arg));
 }
 EXPORT_SYMBOL(param_get_charp);
 
@@ -527,7 +527,7 @@ EXPORT_SYMBOL(param_set_copystring);
 int param_get_string(char *buffer, const struct kernel_param *kp)
 {
 	const struct kparam_string *kps = kp->str;
-	return scnprintf(buffer, PAGE_SIZE, "%s\n", kps->string);
+	return sysfs_emit(buffer, "%s\n", kps->string);
 }
 EXPORT_SYMBOL(param_get_string);
 
@@ -860,7 +860,7 @@ ssize_t __modver_version_show(const struct module_attribute *mattr,
 	const struct module_version_attribute *vattr =
 		container_of_const(mattr, struct module_version_attribute, mattr);
 
-	return scnprintf(buf, PAGE_SIZE, "%s\n", vattr->version);
+	return sysfs_emit(buf, "%s\n", vattr->version);
 }
 
 extern const struct module_version_attribute __start___modver[];
-- 
2.25.1

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

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

* Re: [PATCH linux-next] params: use sysfs_emit() instead of scnprintf().
  2025-03-15  6:17 [PATCH linux-next] params: use sysfs_emit() instead of scnprintf() xie.ludan
@ 2025-03-17  6:28 ` Jiri Slaby
  0 siblings, 0 replies; 2+ messages in thread
From: Jiri Slaby @ 2025-03-17  6:28 UTC (permalink / raw)
  To: xie.ludan, petr.pavlu; +Cc: linux, mcgrof, thorsten.blum, linux-kernel

On 15. 03. 25, 7:17, xie.ludan@zte.com.cn wrote:
> 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>
> 
> ---
> 
>   kernel/params.c | 8 ++++----
> 
>   1 file changed, 4 insertions(+), 4 deletions(-)
> 
> 
> diff --git a/kernel/params.c b/kernel/params.c
> 
> index 2509f216c9f3..89ae571af266 100644
> 
> --- a/kernel/params.c
> 
> +++ b/kernel/params.c
> 
> @@ -219,7 +219,7 @@ char *parse_args(const char *doing,
> 
> }\
> 
> int param_get_##name(char *buffer, const struct kernel_param *kp) \
> 
> {\
> 
> -return scnprintf(buffer, PAGE_SIZE, format "\n",\
> 
> +return sysfs_emit(buffer, format "\n",\

This has nothing to do with sysfs, right?

-- 
js
suse labs


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

end of thread, other threads:[~2025-03-17  6:28 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:17 [PATCH linux-next] params: use sysfs_emit() instead of scnprintf() xie.ludan
2025-03-17  6:28 ` Jiri Slaby

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