Commit ba4912cb authored by Markus Armbruster's avatar Markus Armbruster
Browse files

trace: Simplify how st_print_trace_file_status() prints



st_print_trace_file_status() takes an fprintf()-like callback and a
FILE * to pass to it.

Its only caller hmp_trace_file() passes monitor_fprintf() and the
current monitor cast to FILE *.  monitor_fprintf() casts it right
back, and is otherwise identical to monitor_printf().  The
type-punning is ugly.

Drop the callback, and call qemu_printf() instead.

Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
Reviewed-by: default avatarDr. David Alan Gilbert <dgilbert@redhat.com>
Message-Id: <20190417191805.28198-3-armbru@redhat.com>
parent 15ce35fc
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1056,7 +1056,7 @@ static void hmp_trace_file(Monitor *mon, const QDict *qdict)
    const char *arg = qdict_get_try_str(qdict, "arg");

    if (!op) {
        st_print_trace_file_status((FILE *)mon, &monitor_fprintf);
        st_print_trace_file_status();
    } else if (!strcmp(op, "on")) {
        st_set_trace_file_enabled(true);
    } else if (!strcmp(op, "off")) {
+4 −3
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
#include "trace/control.h"
#include "trace/simple.h"
#include "qemu/error-report.h"
#include "qemu/qemu-print.h"

/** Trace file header event ID, picked to avoid conflict with real event IDs */
#define HEADER_EVENT_ID (~(uint64_t)0)
@@ -363,9 +364,9 @@ void st_set_trace_file(const char *file)
    st_set_trace_file_enabled(true);
}

void st_print_trace_file_status(FILE *stream, int (*stream_printf)(FILE *stream, const char *fmt, ...))
void st_print_trace_file_status(void)
{
    stream_printf(stream, "Trace file \"%s\" %s.\n",
    qemu_printf("Trace file \"%s\" %s.\n",
                trace_file_name, trace_fp ? "on" : "off");
}

+1 −1
Original line number Diff line number Diff line
@@ -11,7 +11,7 @@
#ifndef TRACE_SIMPLE_H
#define TRACE_SIMPLE_H

void st_print_trace_file_status(FILE *stream, fprintf_function stream_printf);
void st_print_trace_file_status(void);
void st_set_trace_file_enabled(bool enable);
void st_set_trace_file(const char *file);
bool st_init(void);