Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751656AbdFZWyG (ORCPT ); Mon, 26 Jun 2017 18:54:06 -0400 Received: from mga09.intel.com ([134.134.136.24]:44464 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752098AbdFZWuq (ORCPT ); Mon, 26 Jun 2017 18:50:46 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,397,1493708400"; d="scan'208";a="117715502" From: Tom Zanussi To: rostedt@goodmis.org Cc: tglx@linutronix.de, mhiramat@kernel.org, namhyung@kernel.org, vedang.patel@intel.com, linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org, Tom Zanussi Subject: [PATCH 25/32] tracing: Allow whitespace to surround hist trigger filter Date: Mon, 26 Jun 2017 17:49:26 -0500 Message-Id: X-Mailer: git-send-email 1.9.3 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1667 Lines: 55 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 d191f1a..53a0634 100644 --- a/kernel/trace/trace_events_hist.c +++ b/kernel/trace/trace_events_hist.c @@ -4632,7 +4632,7 @@ static int event_hist_trigger_func(struct event_command *cmd_ops, struct event_trigger_ops *trigger_ops; struct hist_trigger_data *hist_data; bool remove = false; - char *trigger; + char *trigger, *p; int ret = 0; if (!param) @@ -4642,9 +4642,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; attrs = parse_hist_trigger_attrs(trigger); if (IS_ERR(attrs)) @@ -4694,6 +4704,7 @@ static int event_hist_trigger_func(struct event_command *cmd_ops, } ret = cmd_ops->reg(glob, trigger_ops, trigger_data, file); + /* * The above returns on success the # of triggers registered, * but if it didn't register any it returns zero. Consider no -- 1.9.3