[for-next][PATCH 02/12] tools/latency-collector: Use correct size when writing queue_full_warning
From: Steven Rostedt
Date: Tue Oct 26 2021 - 12:23:56 EST
From: Viktor Rosendahl <Viktor.Rosendahl@xxxxxx>
queue_full_warning is a pointer, so it is wrong to use sizeof to calculate
the number of characters of the string it points to. The effect is that we
only print out the first few characters of the warning string.
The correct way is to use strlen(). We don't need to add 1 to the strlen()
because we don't want to write the terminating null character to stdout.
Link: https://lkml.kernel.org/r/20211019160701.15587-1-Viktor.Rosendahl@xxxxxx
Link: https://lore.kernel.org/r/8fd4bb65ef3da67feac9ce3258cdbe9824752cf1.1629198502.git.jing.yangyang@xxxxxxxxxx
Link: https://lore.kernel.org/r/20211012025424.180781-1-davidcomponentone@xxxxxxxxx
Reported-by: Zeal Robot <zealci@xxxxxxxxxx>
Signed-off-by: Viktor Rosendahl <Viktor.Rosendahl@xxxxxx>
Signed-off-by: Steven Rostedt (VMware) <rostedt@xxxxxxxxxxx>
---
tools/tracing/latency/latency-collector.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/tracing/latency/latency-collector.c b/tools/tracing/latency/latency-collector.c
index 3a2e6bb781a8..59a7f2346eab 100644
--- a/tools/tracing/latency/latency-collector.c
+++ b/tools/tracing/latency/latency-collector.c
@@ -1538,7 +1538,7 @@ static void tracing_loop(void)
mutex_lock(&print_mtx);
check_signals();
write_or_die(fd_stdout, queue_full_warning,
- sizeof(queue_full_warning));
+ strlen(queue_full_warning));
mutex_unlock(&print_mtx);
}
modified--;
--
2.33.0