public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Frederic Weisbecker <fweisbec@gmail.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Li Zefan <lizf@cn.fujitsu.com>, Ingo Molnar <mingo@elte.hu>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 1/2] tracing/events: clean up for ftrace_set_clr_event()
Date: Fri, 8 May 2009 13:47:45 +0200	[thread overview]
Message-ID: <20090508114744.GF6417@nowhere> (raw)
In-Reply-To: <alpine.DEB.2.00.0905080727290.28378@gandalf.stny.rr.com>

On Fri, May 08, 2009 at 07:35:22AM -0400, Steven Rostedt wrote:
> 
> On Fri, 8 May 2009, Frederic Weisbecker wrote:
> > >  
> > > -static int ftrace_set_clr_event(char *buf, int set)
> > > +/*
> > > + * __ftrace_set_clr_event(NULL, NULL, NULL, set) will set/unset all events.
> > > + */
> > > +static int __ftrace_set_clr_event(const char *match, const char *sub,
> > > +				  const char *event, int set)
> > >  {
> > >  	struct ftrace_event_call *call;
> > > +	int ret;
> > > +
> > > +	mutex_lock(&event_mutex);
> > > +	list_for_each_entry(call, &ftrace_events, list) {
> > > +
> > > +		if (!call->name || !call->regfunc)
> > > +			continue;
> > > +
> > > +		if (match &&
> > > +		    strcmp(match, call->name) != 0 &&
> > > +		    strcmp(match, call->system) != 0)
> > > +			continue;
> > > +
> > > +		if (sub && strcmp(sub, call->system) != 0)
> > > +			continue;
> > > +
> > > +		if (event && strcmp(event, call->name) != 0)
> > > +			continue;
> > 
> > 
> > Neat: You can simply use !strcmp(...)
> 
> Hehe, no he can't. It would be "strcmp(...)" for the true case. This is 
> exactly why I prefer to use "strcmp(...) != 0" over "!strcmp(...)". 
> Because, like you, I've confused "!strcmp(...)" too many times as "not a 
> match" when it in fact means "is a match".
> 
> I've made this mistake enough that I've given up on using just "strcmp" or 
> "!strcmp". "strcmp() != 0" and "strcmp() == 0" show what you want much 
> better.
> 

You're right. It provides a good disambiguation.
The C philosophy has this 0 == SUCCESS convention which doesn't match
the human brain logic that expect 0 is a false and 1 is a true....

I guess that's because "!" provides quick checks about non-failures
and detailed errors can then fit in custom values. But still, I guess
we all stuck in this scheme, at least in a last remaining nerve cell
which says "hell, but look! wtf...", though this poor neurone ends
up being punched and kicked by the rest of the brain folks...


Frederic.


  reply	other threads:[~2009-05-08 11:47 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-08  2:31 [PATCH 1/2] tracing/events: clean up for ftrace_set_clr_event() Li Zefan
2009-05-08  2:32 ` [PATCH 2/2] tracing/events: simplify system_enable_read() Li Zefan
2009-05-08  2:44   ` Steven Rostedt
2009-05-08 11:03   ` Frederic Weisbecker
2009-05-08 18:27   ` [tip:tracing/core] " tip-bot for Li Zefan
2009-05-08 22:52   ` [PATCH 2/2] " Andrew Morton
2009-05-11 12:40     ` Ingo Molnar
2009-05-08  2:52 ` [PATCH 1/2] tracing/events: clean up for ftrace_set_clr_event() Steven Rostedt
2009-05-08  3:03   ` Li Zefan
2009-05-08 10:50 ` Frederic Weisbecker
2009-05-08 11:16   ` Li Zefan
2009-05-08 11:27     ` Frederic Weisbecker
2009-05-08 12:05       ` Ingo Molnar
2009-05-08 12:01     ` Steven Rostedt
2009-05-08 11:35   ` Steven Rostedt
2009-05-08 11:47     ` Frederic Weisbecker [this message]
2009-05-08 18:27 ` [tip:tracing/core] " tip-bot for Li Zefan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090508114744.GF6417@nowhere \
    --to=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizf@cn.fujitsu.com \
    --cc=mingo@elte.hu \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox