From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752942AbdJMSYw (ORCPT ); Fri, 13 Oct 2017 14:24:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:40440 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751823AbdJMSYv (ORCPT ); Fri, 13 Oct 2017 14:24:51 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AC7EA2193C Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=goodmis.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=rostedt@goodmis.org Date: Fri, 13 Oct 2017 14:24:49 -0400 From: Steven Rostedt To: Will Hawkins Cc: linux-kernel@vger.kernel.org, hawkinsw@gmail.com Subject: Re: [PATCH] trace-cmd record: Fix syntax in make_pid_filter Message-ID: <20171013142449.27f84c42@gandalf.local.home> In-Reply-To: <1507917432-8110-1-git-send-email-hawkinsw@borlaugic.com> References: <1507917432-8110-1-git-send-email-hawkinsw@borlaugic.com> X-Mailer: Claws Mail 3.14.0 (GTK+ 2.24.31; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 13 Oct 2017 13:57:12 -0400 Will Hawkins wrote: > In older versions of the kernel, event filtering by > pid does not use the set_event_pid file. Instead, > ftrace uses a common filter (created in make_pid_filter) > to filter events based on PID. > > The syntax of the filter generated by this function is > overly permissive. When filtering by pid, || is used > where && should be (in certain cases) which means that > unrelated events are captured. > Thanks for sending this. > Signed-off-by: Will Hawkins > --- > trace-record.c | 17 +++++++++++------ > 1 file changed, 11 insertions(+), 6 deletions(-) > > diff --git a/trace-record.c b/trace-record.c > index a0b6541..d9c2959 100644 > --- a/trace-record.c > +++ b/trace-record.c > @@ -935,14 +935,19 @@ static char *make_pid_filter(char *curr_filter, const char *field) > str = filter + curr_len; > > for (p = filter_pids; p; p = p->next) { > - if (p == filter_pids) > - orit = ""; > - else > - orit = "||"; > - if (p->exclude) > + if (p->exclude) { > match = "!="; > - else > + if (p == filter_pids) > + orit = ""; > + else > + orit = "&&"; > + } else { > match = "=="; > + if (p == filter_pids) > + orit = ""; > + else > + orit = "||"; > + } A little nicer way of doing this is: if (p->exclude) { match = "!="; orit = "&&"; } else { match = "=="; orit = "||"; } if (p == filter_pids) orit = ""; Care to send a v2? -- Steve > len = sprintf(str, "%s(%s%s%d)", orit, field, match, p->pid); > str += len; > }