Skip to contentSkip to conversation

trace-cmd library: Set the correct file state when reading file with no ftrace printk data

PATCH New Tzvetomir Stoyanov (VMware) 1 participant 1 message Nov 11, 2021

lore
Share & tools
lore
#0 lore raw

PATCH v5 6/6 trace-cmd library: Set the correct file state when reading file with no ftrace printk data

The ftrace printk section of the trace file can contain no data, this is valid use case. When such file is read and parsed by read_ftrace_printk, the file state should be set to TRACECMD_FILE_PRINTK in that case.

---
 lib/trace-cmd/trace-input.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
lib/trace-cmd/trace-input.c +3 -1
index f02d7e31..31e5e674 100644
@@ -783,8 +783,10 @@ static int read_ftrace_printk(struct tracecmd_input *handle)
 
 	if (read4(handle, &size) < 0)
 		return -1;
-	if (!size)
+	if (!size) {
+		handle->file_state = TRACECMD_FILE_PRINTK;
 		return 0; /* OK? */
+	}
 
 	buf = malloc(size + 1);
 	if (!buf)
Signature · 1 line
2.33.1