diff mbox series

[v3,7/8] trace/simple: pass iter to st_write_event_mapping

Message ID 20210121125028.3247190-8-kraxel@redhat.com (mailing list archive)
State New, archived
Headers show
Series fix tracing for modules | expand

Commit Message

Gerd Hoffmann Jan. 21, 2021, 12:50 p.m. UTC
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 <kraxel@redhat.com>
---
 trace/simple.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Stefan Hajnoczi Feb. 3, 2021, 4:17 p.m. UTC | #1
On Thu, Jan 21, 2021 at 01:50:27PM +0100, Gerd Hoffmann wrote:
> 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 <kraxel@redhat.com>
> ---
>  trace/simple.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
diff mbox series

Patch

diff --git a/trace/simple.c b/trace/simple.c
index 97b6f85168e7..ec2156d135cb 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;