Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932446AbcDTHTZ (ORCPT ); Wed, 20 Apr 2016 03:19:25 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33917 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932256AbcDTHTY (ORCPT ); Wed, 20 Apr 2016 03:19:24 -0400 Subject: Re: [Cocci] coccinelle: bool if (foo) return true; else return false; To: Julia Lawall , Joe Perches References: <1460828078-5224-1-git-send-email-dave@stgolabs.net> <1460833453.19090.79.camel@perches.com> <1460836099.19090.82.camel@perches.com> <1460881671.19090.90.camel@perches.com> <1460908959.19090.95.camel@perches.com> <1460915801.19090.100.camel@perches.com> <1461093152.1917.26.camel@perches.com> Cc: cocci , LKML From: Michael Stefaniuc Message-ID: <57172D78.707@redhat.com> Date: Wed, 20 Apr 2016 09:19:20 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 776 Lines: 51 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