linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Peter Senna Tschudin <peter.senna@gmail.com>
Cc: a.p.zijlstra@chello.nl, mingo@redhat.com, jolsa@kernel.org,
	matt.fleming@intel.com, namhyung@kernel.org, milos@redhat.com,
	kan.liang@intel.com, rostedt@goodmis.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] tools-perf: Change -1 by false
Date: Thu, 17 Sep 2015 15:33:03 -0300	[thread overview]
Message-ID: <20150917183303.GO11551@kernel.org> (raw)
In-Reply-To: <1442484533-19742-1-git-send-email-peter.senna@gmail.com>

Em Thu, Sep 17, 2015 at 12:08:53PM +0200, Peter Senna Tschudin escreveu:
> Returning a negative value for a boolean function seem to have the
> undesired effect of returning true. Replace -1 by false in a
> bool-returning function.
> 
> The diff of the .s file before and after the change (for x86_64):
> 3907c3907
> < 	movl	$1, %ebx
> ---

Please avoid adding a --- at the start of any changeset comment line, it
breaks scripts.

Thanks, applied.

- Arnaldo

> > 	xorl	%ebx, %ebx
> 
> while if -1 is replaced by true, the diff is empty.
> 
> This issue was found by the following Coccinelle semantic patch:
> <smpl>
> @@
> identifier f;
> constant C;
> typedef bool;
> @@
> bool f (...){
> <+...
> * return -C;
> ...+>
> }
> </smpl>
> 
> Signed-off-by: Peter Senna Tschudin <peter.senna@gmail.com>
> ---
>  tools/perf/util/util.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/perf/util/util.c b/tools/perf/util/util.c
> index 49a5c6a..ce465b2 100644
> --- a/tools/perf/util/util.c
> +++ b/tools/perf/util/util.c
> @@ -639,7 +639,7 @@ bool find_process(const char *name)
>  
>  	dir = opendir(procfs__mountpoint());
>  	if (!dir)
> -		return -1;
> +		return false;
>  
>  	/* Walk through the directory. */
>  	while (ret && (d = readdir(dir)) != NULL) {
> -- 
> 2.1.0

  reply	other threads:[~2015-09-17 18:33 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-17 10:08 [PATCH] tools-perf: Change -1 by false Peter Senna Tschudin
2015-09-17 18:33 ` Arnaldo Carvalho de Melo [this message]
2015-09-18  5:49 ` [tip:perf/urgent] perf tools: Bool functions shouldn't return -1 tip-bot for Peter Senna Tschudin

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=20150917183303.GO11551@kernel.org \
    --to=acme@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=jolsa@kernel.org \
    --cc=kan.liang@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matt.fleming@intel.com \
    --cc=milos@redhat.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peter.senna@gmail.com \
    --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;
as well as URLs for NNTP newsgroup(s).