Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756922AbdIHTI0 (ORCPT ); Fri, 8 Sep 2017 15:08:26 -0400 Received: from mga04.intel.com ([192.55.52.120]:31687 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756650AbdIHTIX (ORCPT ); Fri, 8 Sep 2017 15:08:23 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,363,1500966000"; d="scan'208";a="147118600" Message-ID: <1504897701.5276.5.camel@tzanussi-mobl.amr.corp.intel.com> Subject: Re: [PATCH v2 31/40] tracing: Allow whitespace to surround hist trigger filter From: Tom Zanussi To: Steven Rostedt Cc: tglx@linutronix.de, mhiramat@kernel.org, namhyung@kernel.org, vedang.patel@intel.com, bigeasy@linutronix.de, joel.opensrc@gmail.com, joelaf@google.com, mathieu.desnoyers@efficios.com, baohong.liu@intel.com, linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org Date: Fri, 08 Sep 2017 14:08:21 -0500 In-Reply-To: <20170908145023.462c3a79@gandalf.local.home> References: <9e6d9f17bcd71f29dec9039ab00d316ca2965c43.1504642143.git.tom.zanussi@linux.intel.com> <20170908145023.462c3a79@gandalf.local.home> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.10.4 (3.10.4-4.fc20) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1788 Lines: 59 On Fri, 2017-09-08 at 14:50 -0400, Steven Rostedt wrote: > On Tue, 5 Sep 2017 16:57:43 -0500 > Tom Zanussi wrote: > > > The existing code only allows for one space before and after the 'if' > > specifying the filter for a hist trigger. Add code to make that more > > permissive as far as whitespace goes. > > > > Signed-off-by: Tom Zanussi > > --- > > kernel/trace/trace_events_hist.c | 19 +++++++++++++++---- > > 1 file changed, 15 insertions(+), 4 deletions(-) > > > > diff --git a/kernel/trace/trace_events_hist.c b/kernel/trace/trace_events_hist.c > > index 0a398f3..4f66f2e 100644 > > --- a/kernel/trace/trace_events_hist.c > > +++ b/kernel/trace/trace_events_hist.c > > @@ -4819,7 +4819,7 @@ static int event_hist_trigger_func(struct event_command *cmd_ops, > > struct synth_event *se; > > const char *se_name; > > bool remove = false; > > - char *trigger; > > + char *trigger, *p; > > int ret = 0; > > > > if (!param) > > @@ -4829,9 +4829,19 @@ static int event_hist_trigger_func(struct event_command *cmd_ops, > > remove = true; > > > > /* separate the trigger from the filter (k:v [if filter]) */ > > - trigger = strsep(¶m, " \t"); > > - if (!trigger) > > - return -EINVAL; > > + trigger = param; > > + p = strstr(param, " if"); > > + if (!p) > > + p = strstr(param, "\tif"); > > + if (p) { > > + if (p == trigger) > > + return -EINVAL; > > + param = p + 1; > > + param = strstrip(param); > > + *p = '\0'; > > + trigger = strstrip(trigger); > > + } else > > + param = NULL; > > This seems rather complex. Wouldn't the following work? > > param = skip_spaces(param); > trigger = strsep(¶m, " \t"); > if (param) > param = strstrip(param); > Yes, much better ;-) Tom