Stefan Hajnoczi writes: > On Tue, May 8, 2012 at 3:38 PM, Lluís Vilanova <vilan...@ac.upc.edu> wrote: >> Signed-off-by: Lluís Vilanova <vilan...@ac.upc.edu> >> --- >> monitor.c | 15 ++++++++++++--- >> 1 file changed, 12 insertions(+), 3 deletions(-) >> >> diff --git a/monitor.c b/monitor.c >> index 8946a10..86c2538 100644 >> --- a/monitor.c >> +++ b/monitor.c >> @@ -625,10 +625,19 @@ static void do_trace_event_set_state(Monitor *mon, >> const QDict *qdict) >> { >> const char *tp_name = qdict_get_str(qdict, "name"); >> bool new_state = qdict_get_bool(qdict, "option"); >> - int ret = trace_event_set_state(tp_name, new_state); >> >> - if (!ret) { >> - monitor_printf(mon, "unknown event name \"%s\"\n", tp_name); >> + if (trace_event_is_pattern(tp_name)) { >> + TraceEvent *ev = NULL; >> + while ((ev = trace_event_pattern(tp_name, ev)) != NULL) { >> + trace_event_set_state_dynamic(ev, new_state); >> + } >> + } else { >> + TraceEvent *ev = trace_event_name(tp_name); >> + if (ev == NULL) { >> + monitor_printf(mon, "unknown event name \"%s\"\n", tp_name); >> + } else { >> + trace_event_set_state_dynamic(ev, new_state); >> + }
> Why check for a pattern and split the code in two? How about just: > while ((ev = trace_event_pattern(tp_name, ev)) != NULL) { > ... > } > That should cover both the single trace event name case and the wildcard case. That's true... it's just that somehow I thought it was abusive to use pattern matching on a string without patterns :) Lluis -- "And it's much the same thing with knowledge, for whenever you learn something new, the whole world becomes that much richer." -- The Princess of Pure Reason, as told by Norton Juster in The Phantom Tollbooth