From 3f2a09842f989af020b8355622d5f7fa9bdeb832 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Tue, 1 Jun 2021 15:24:05 +0200 Subject: trace/simple: pass iter to st_write_event_mapping Pass an iter to st_write_event_mapping, so the function can interate different things depending on how we initialize the iter. Signed-off-by: Gerd Hoffmann Reviewed-by: Stefan Hajnoczi Message-id: 20210601132414.432430-5-kraxel@redhat.com Signed-off-by: Stefan Hajnoczi --- trace/simple.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'trace/simple.c') diff --git a/trace/simple.c b/trace/simple.c index 97b6f85168..ec2156d135 100644 --- a/trace/simple.c +++ b/trace/simple.c @@ -280,14 +280,12 @@ void trace_record_finish(TraceBufferRecord *rec) } } -static int st_write_event_mapping(void) +static int st_write_event_mapping(TraceEventIter *iter) { uint64_t type = TRACE_RECORD_TYPE_MAPPING; - TraceEventIter iter; TraceEvent *ev; - trace_event_iter_init_all(&iter); - while ((ev = trace_event_iter_next(&iter)) != NULL) { + while ((ev = trace_event_iter_next(iter)) != NULL) { uint64_t id = trace_event_get_id(ev); const char *name = trace_event_get_name(ev); uint32_t len = strlen(name); @@ -309,6 +307,7 @@ static int st_write_event_mapping(void) */ bool st_set_trace_file_enabled(bool enable) { + TraceEventIter iter; bool was_enabled = trace_fp; if (enable == !!trace_fp) { @@ -333,8 +332,9 @@ bool st_set_trace_file_enabled(bool enable) return was_enabled; } + trace_event_iter_init_all(&iter); if (fwrite(&header, sizeof header, 1, trace_fp) != 1 || - st_write_event_mapping() < 0) { + st_write_event_mapping(&iter) < 0) { fclose(trace_fp); trace_fp = NULL; return was_enabled; -- cgit v1.2.3