Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1383100

Re: [Cocci] coccinelle: bool if (foo) return true; else return false;

From Michael Stefaniuc <mstefani@redhat.com>
Newsgroups linux.kernel
Subject Re: [Cocci] coccinelle: bool if (foo) return true; else return false;
Date 2016-04-20 09:20 +0200
Message-ID <rpUAy-3Ut-9@gated-at.bofh.it> (permalink)
References (7 earlier) <rpJlM-3mj-11@gated-at.bofh.it> <rpJlM-3mj-13@gated-at.bofh.it> <rpJlM-3mj-15@gated-at.bofh.it> <rpJlM-3mj-9@gated-at.bofh.it> <rpJlM-3mj-25@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH -next] kernel: Replace ACCESS_ONCE with READ/WRITE_ONCE Davidlohr Bueso <dave@stgolabs.net> - 2016-04-16 19:40 +0200
  [PATCH] checkpatch: Whine about ACCESS_ONCE Joe Perches <joe@perches.com> - 2016-04-16 21:10 +0200
    Re: [PATCH] checkpatch: Whine about ACCESS_ONCE Joe Perches <joe@perches.com> - 2016-04-16 21:50 +0200
      Re: [PATCH] checkpatch: Whine about ACCESS_ONCE Julia Lawall <julia.lawall@lip6.fr> - 2016-04-17 07:50 +0200
        Re: [PATCH] checkpatch: Whine about ACCESS_ONCE Joe Perches <joe@perches.com> - 2016-04-17 10:30 +0200
          Re: [PATCH] checkpatch: Whine about ACCESS_ONCE Julia Lawall <julia.lawall@lip6.fr> - 2016-04-17 13:20 +0200
          Re: [PATCH] checkpatch: Whine about ACCESS_ONCE Julia Lawall <julia.lawall@lip6.fr> - 2016-04-17 13:40 +0200
            Re: [PATCH] checkpatch: Whine about ACCESS_ONCE Joe Perches <joe@perches.com> - 2016-04-17 18:10 +0200
              coccinelle: bool if (foo) return true; else return false; Joe Perches <joe@perches.com> - 2016-04-19 21:20 +0200
                Re: coccinelle: bool if (foo) return true; else return false; Julia Lawall <julia.lawall@lip6.fr> - 2016-04-19 21:20 +0200
                Re: [Cocci] coccinelle: bool if (foo) return true; else return false; Michael Stefaniuc <mstefani@redhat.com> - 2016-04-20 09:20 +0200
                Re: [Cocci] coccinelle: bool if (foo) return true; else return  false; Joe Perches <joe@perches.com> - 2016-04-20 09:30 +0200
    [PATCH V2] checkpatch: Whine about ACCESS_ONCE Joe Perches <joe@perches.com> - 2016-04-17 19:30 +0200

csiph-web