[PATCH] trace/hwlat: remove extra space at the end of hwlat_detector/mode

Mikhail Kobuk posted 1 patch 2 years, 3 months ago
kernel/trace/trace_hwlat.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] trace/hwlat: remove extra space at the end of hwlat_detector/mode
Posted by Mikhail Kobuk 2 years, 3 months ago
Space is printed after each mode value including the last one:
$ echo \"$(sudo cat /sys/kernel/tracing/hwlat_detector/mode)\"
"none [round-robin] per-cpu "

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 8fa826b7344d ("trace/hwlat: Implement the mode config option")
Signed-off-by: Mikhail Kobuk <m.kobuk@ispras.ru>
Reviewed-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
---
 kernel/trace/trace_hwlat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/trace/trace_hwlat.c b/kernel/trace/trace_hwlat.c
index 2f37a6e68aa9..b791524a6536 100644
--- a/kernel/trace/trace_hwlat.c
+++ b/kernel/trace/trace_hwlat.c
@@ -635,7 +635,7 @@ static int s_mode_show(struct seq_file *s, void *v)
 	else
 		seq_printf(s, "%s", thread_mode_str[mode]);
 
-	if (mode != MODE_MAX)
+	if (mode < MODE_MAX - 1) /* if mode is any but last */
 		seq_puts(s, " ");
 
 	return 0;
-- 
2.42.0
Re: [PATCH] trace/hwlat: remove extra space at the end of hwlat_detector/mode
Posted by Daniel Bristot de Oliveira 2 years, 3 months ago
On 8/25/23 12:34, Mikhail Kobuk wrote:
> Space is printed after each mode value including the last one:
> $ echo \"$(sudo cat /sys/kernel/tracing/hwlat_detector/mode)\"
> "none [round-robin] per-cpu "
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Fixes: 8fa826b7344d ("trace/hwlat: Implement the mode config option")
> Signed-off-by: Mikhail Kobuk <m.kobuk@ispras.ru>
> Reviewed-by: Alexey Khoroshilov <khoroshilov@ispras.ru>

Acked-by: Daniel Bristot de Oliveira <bristot@kernel.org>

Thanks!
-- Daniel