From: mstefani@redhat.com (Michael Stefaniuc)
To: cocci@systeme.lip6.fr
Subject: [Cocci] coccinelle: bool if (foo) return true; else return false;
Date: Wed, 20 Apr 2016 09:19:20 +0200 [thread overview]
Message-ID: <57172D78.707@redhat.com> (raw)
In-Reply-To: <alpine.DEB.2.02.1604192115300.2054@localhost6.localdomain6>
On 04/19/2016 09:15 PM, Julia Lawall wrote:
>
>
> On Tue, 19 Apr 2016, Joe Perches wrote:
>
>> There's ~150 of these in the kernel.
>>
>> Maybe there's use for this conversion to be added
>> to scripts/coccinelle/misc/boolreturn.cocci or in
>> a separate file.
>>
>> $ cat booltruefalse.cocci
>> @@
>> identifier fn;
>> expression e;
>> typedef bool;
>> symbol true;
>> symbol false;
>> @@
>>
>> bool fn ( ... )
>> {
>> <...
>> - if (e) return true; else return false;
>> + return e;
Shouldn't that be:
return !!e
?
>> ...>
>> }
>>
>> @@
>> identifier fn;
>> expression e;
>> @@
>>
>> bool fn ( ... )
>> {
>> <...
>> - if (e) return false; else return true;
>> + return !e;
>> ...>
>> }
>
> Thanks for the suggestion. I will take care of it shortly.
bye
michael
WARNING: multiple messages have this Message-ID (diff)
From: Michael Stefaniuc <mstefani@redhat.com>
To: Julia Lawall <julia.lawall@lip6.fr>, Joe Perches <joe@perches.com>
Cc: cocci <cocci@systeme.lip6.fr>, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [Cocci] coccinelle: bool if (foo) return true; else return false;
Date: Wed, 20 Apr 2016 09:19:20 +0200 [thread overview]
Message-ID: <57172D78.707@redhat.com> (raw)
In-Reply-To: <alpine.DEB.2.02.1604192115300.2054@localhost6.localdomain6>
On 04/19/2016 09:15 PM, Julia Lawall wrote:
>
>
> On Tue, 19 Apr 2016, Joe Perches wrote:
>
>> There's ~150 of these in the kernel.
>>
>> Maybe there's use for this conversion to be added
>> to scripts/coccinelle/misc/boolreturn.cocci or in
>> a separate file.
>>
>> $ cat booltruefalse.cocci
>> @@
>> identifier fn;
>> expression e;
>> typedef bool;
>> symbol true;
>> symbol false;
>> @@
>>
>> bool fn ( ... )
>> {
>> <...
>> - if (e) return true; else return false;
>> + return e;
Shouldn't that be:
return !!e
?
>> ...>
>> }
>>
>> @@
>> identifier fn;
>> expression e;
>> @@
>>
>> bool fn ( ... )
>> {
>> <...
>> - if (e) return false; else return true;
>> + return !e;
>> ...>
>> }
>
> Thanks for the suggestion. I will take care of it shortly.
bye
michael
next prev parent reply other threads:[~2016-04-20 7:19 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-16 17:34 [PATCH -next] kernel: Replace ACCESS_ONCE with READ/WRITE_ONCE Davidlohr Bueso
2016-04-16 19:04 ` [PATCH] checkpatch: Whine about ACCESS_ONCE Joe Perches
2016-04-16 19:48 ` Joe Perches
2016-04-17 5:43 ` Julia Lawall
2016-04-17 8:27 ` Joe Perches
2016-04-17 11:17 ` Julia Lawall
2016-04-17 11:39 ` Julia Lawall
2016-04-17 16:02 ` Joe Perches
[not found] ` <alpine.DEB.2.02.1604171944500.2004@localhost6.localdomain6>
[not found] ` <1460915801.19090.100.camel@perches.com>
[not found] ` <alpine.DEB.2.02.1604172001410.2004@localhost6.localdomain6>
2016-04-19 19:12 ` [Cocci] coccinelle: bool if (foo) return true; else return false; Joe Perches
2016-04-19 19:12 ` Joe Perches
2016-04-19 19:15 ` [Cocci] " Julia Lawall
2016-04-19 19:15 ` Julia Lawall
2016-04-20 7:19 ` Michael Stefaniuc [this message]
2016-04-20 7:19 ` [Cocci] " Michael Stefaniuc
2016-04-20 7:25 ` Joe Perches
2016-04-20 7:25 ` Joe Perches
2016-04-17 17:26 ` [PATCH V2] checkpatch: Whine about ACCESS_ONCE Joe Perches
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=57172D78.707@redhat.com \
--to=mstefani@redhat.com \
--cc=cocci@systeme.lip6.fr \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.