diff mbox series

trace-cmd split: Initialize current in parse_file()

Message ID 20240124123439.3441eb6f@gandalf.local.home (mailing list archive)
State Superseded
Headers show
Series trace-cmd split: Initialize current in parse_file() | expand

Commit Message

Steven Rostedt Jan. 24, 2024, 5:34 p.m. UTC
From: "Steven Rostedt (Google)" <rostedt@goodmis.org>

The code fix to correctly split start/end/time-window parameters removed
an initialization of "current" which can now fall out being uninitialized
and used for a later compare.

Found with valgrind that reported uninitialized variable in the loop condition:

	do {
		if (repeat)
			sprintf(output_file, "%s.%04d", output, c++);
		else
			strcpy(output_file, output);
			
		current = parse_file(handle, output_file, start_ns, end_ns,
				     percpu, cpu, count, type, &end_reached);

		if (!repeat)
			break;
		start_ns = 0;
	} while (!end_reached && (current && (!end_ns || current < end_ns)));

Link: https://lore.kernel.org/linux-trace-devel/20240124122832.4e0b33b7@gandalf.local.home/

Fixes: 1439b8f518 ("trace-cmd split: Correctly split with start/end/time-window parameters")
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 tracecmd/trace-split.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/tracecmd/trace-split.c b/tracecmd/trace-split.c
index 0820a3bb0721..2c311b3d6be3 100644
--- a/tracecmd/trace-split.c
+++ b/tracecmd/trace-split.c
@@ -480,7 +480,7 @@  static unsigned long long parse_file(struct tracecmd_input *handle,
 				     enum split_types type,
 				     bool *end_reached)
 {
-	unsigned long long current;
+	unsigned long long current = 0;
 	struct handle_list *handle_entry;
 	struct tracecmd_output *ohandle;
 	struct cpu_data *cpu_data;