Skip to contentSkip to conversation

trace-cmd library: Set the correct file state when reading file with no kallsyms

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

lore
Share & tools
lore
#0 lore raw

PATCH v5 5/6 trace-cmd library: Set the correct file state when reading file with no kallsyms

The kallsyms section of the trace file can contain no data, this is valid use case. When such file is read and parsed by read_proc_kallsyms(), the file state should be set to TRACECMD_FILE_KALLSYMS in that case.

Renamed a local variable from pevent to tep, to be consistent with the libtraceevent prefix.

---
 lib/trace-cmd/trace-input.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
lib/trace-cmd/trace-input.c +5 -3
index edf84993..f02d7e31 100644
@@ -741,7 +741,7 @@ static int read_event_files(struct tracecmd_input *handle, const char *regex)
 
 static int read_proc_kallsyms(struct tracecmd_input *handle)
 {
-	struct tep_handle *pevent = handle->pevent;
+	struct tep_handle *tep = handle->pevent;
 	unsigned int size;
 	char *buf;
 
@@ -750,8 +750,10 @@ static int read_proc_kallsyms(struct tracecmd_input *handle)
 
 	if (read4(handle, &size) < 0)
 		return -1;
-	if (!size)
+	if (!size) {
+		handle->file_state = TRACECMD_FILE_KALLSYMS;
 		return 0; /* OK? */
+	}
 
 	buf = malloc(size+1);
 	if (!buf)
@@ -762,7 +764,7 @@ static int read_proc_kallsyms(struct tracecmd_input *handle)
 	}
 	buf[size] = 0;
 
-	tep_parse_kallsyms(pevent, buf);
+	tep_parse_kallsyms(tep, buf);
 
 	free(buf);
 
Signature · 1 line
2.33.1