mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] dyndbg: use sysfs_emit() instead of scnprintf()
@ 2025-03-17  2:03 xie.ludan
  2025-03-17  6:26 ` Jiri Slaby
  0 siblings, 1 reply; 4+ messages in thread
From: xie.ludan @ 2025-03-17  2:03 UTC (permalink / raw)
  To: akpm; +Cc: jbaron, jim.cromie, linux-kernel, xie.ludan

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>
---
lib/dynamic_debug.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index 5a007952f7f2..83ce3f310ab9 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -795,11 +795,11 @@ int param_get_dyndbg_classes(char *buffer, const struct kernel_param *kp)

case DD_CLASS_TYPE_DISJOINT_NAMES:
case DD_CLASS_TYPE_DISJOINT_BITS:
- return scnprintf(buffer, PAGE_SIZE, "0x%lx\n", *dcp->bits);
+ return sysfs_emit(buffer, "0x%lx\n", *dcp->bits);

case DD_CLASS_TYPE_LEVEL_NAMES:
case DD_CLASS_TYPE_LEVEL_NUM:
- return scnprintf(buffer, PAGE_SIZE, "%d\n", *dcp->lvl);
+ return sysfs_emit(buffer, "%d\n", *dcp->lvl);
default:
return -1;
}
--
2.25.1

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

* Re: [PATCH] dyndbg: use sysfs_emit() instead of scnprintf()
  2025-03-17  2:03 [PATCH] dyndbg: use sysfs_emit() instead of scnprintf() xie.ludan
@ 2025-03-17  6:26 ` Jiri Slaby
  0 siblings, 0 replies; 4+ messages in thread
From: Jiri Slaby @ 2025-03-17  6:26 UTC (permalink / raw)
  To: xie.ludan, akpm; +Cc: jbaron, jim.cromie, linux-kernel

On 17. 03. 25, 3:03, 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>
> ---
> lib/dynamic_debug.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
> index 5a007952f7f2..83ce3f310ab9 100644
> --- a/lib/dynamic_debug.c
> +++ b/lib/dynamic_debug.c
> @@ -795,11 +795,11 @@ int param_get_dyndbg_classes(char *buffer, const struct kernel_param *kp)
> 
> case DD_CLASS_TYPE_DISJOINT_NAMES:
> case DD_CLASS_TYPE_DISJOINT_BITS:
> - return scnprintf(buffer, PAGE_SIZE, "0x%lx\n", *dcp->bits);
> + return sysfs_emit(buffer, "0x%lx\n", *dcp->bits);
> 
> case DD_CLASS_TYPE_LEVEL_NAMES:
> case DD_CLASS_TYPE_LEVEL_NUM:
> - return scnprintf(buffer, PAGE_SIZE, "%d\n", *dcp->lvl);
> + return sysfs_emit(buffer, "%d\n", *dcp->lvl);

Is this a sysfs callback at all?

-- 
js
suse labs


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

* Re: [PATCH] dyndbg: use sysfs_emit() instead of scnprintf()
  2025-03-15  6:07 xie.ludan
@ 2025-03-17  6:29 ` Jiri Slaby
  0 siblings, 0 replies; 4+ messages in thread
From: Jiri Slaby @ 2025-03-17  6:29 UTC (permalink / raw)
  To: xie.ludan, akpm; +Cc: jbaron, jim.cromie, linux-kernel

You sent a couple of patches multiple times without a reason?

On 15. 03. 25, 7:07, xie.ludan@zte.com.cn wrote:
> From: XieLudan
> 
> 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
> ---
> lib/dynamic_debug.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
> index 5a007952f7f2..83ce3f310ab9 100644
> --- a/lib/dynamic_debug.c
> +++ b/lib/dynamic_debug.c
> @@ -795,11 +795,11 @@ int param_get_dyndbg_classes(char *buffer, const struct kernel_param *kp)
> 
> case DD_CLASS_TYPE_DISJOINT_NAMES:
> case DD_CLASS_TYPE_DISJOINT_BITS:
> - return scnprintf(buffer, PAGE_SIZE, "0x%lx\n", *dcp->bits);
> + return sysfs_emit(buffer, "0x%lx\n", *dcp->bits);
> 
> case DD_CLASS_TYPE_LEVEL_NAMES:
> case DD_CLASS_TYPE_LEVEL_NUM:
> - return scnprintf(buffer, PAGE_SIZE, "%d\n", *dcp->lvl);
> + return sysfs_emit(buffer, "%d\n", *dcp->lvl);
> default:
> return -1;
> }
> --
> 2.25.1
> 

-- 
js
suse labs


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

* [PATCH] dyndbg: use sysfs_emit() instead of scnprintf()
@ 2025-03-15  6:07 xie.ludan
  2025-03-17  6:29 ` Jiri Slaby
  0 siblings, 1 reply; 4+ messages in thread
From: xie.ludan @ 2025-03-15  6:07 UTC (permalink / raw)
  To: akpm; +Cc: jbaron, jim.cromie, linux-kernel, xie.ludan

From: XieLudan

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
---
lib/dynamic_debug.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
index 5a007952f7f2..83ce3f310ab9 100644
--- a/lib/dynamic_debug.c
+++ b/lib/dynamic_debug.c
@@ -795,11 +795,11 @@ int param_get_dyndbg_classes(char *buffer, const struct kernel_param *kp)

case DD_CLASS_TYPE_DISJOINT_NAMES:
case DD_CLASS_TYPE_DISJOINT_BITS:
- return scnprintf(buffer, PAGE_SIZE, "0x%lx\n", *dcp->bits);
+ return sysfs_emit(buffer, "0x%lx\n", *dcp->bits);

case DD_CLASS_TYPE_LEVEL_NAMES:
case DD_CLASS_TYPE_LEVEL_NUM:
- return scnprintf(buffer, PAGE_SIZE, "%d\n", *dcp->lvl);
+ return sysfs_emit(buffer, "%d\n", *dcp->lvl);
default:
return -1;
}
--
2.25.1

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

end of thread, other threads:[~2025-03-17  6:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-17  2:03 [PATCH] dyndbg: use sysfs_emit() instead of scnprintf() xie.ludan
2025-03-17  6:26 ` Jiri Slaby
  -- strict thread matches above, loose matches on Subject: below --
2025-03-15  6:07 xie.ludan
2025-03-17  6:29 ` Jiri Slaby

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®