Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933690AbcDSTMr (ORCPT ); Tue, 19 Apr 2016 15:12:47 -0400 Received: from smtprelay0098.hostedemail.com ([216.40.44.98]:54026 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752651AbcDSTMq (ORCPT ); Tue, 19 Apr 2016 15:12:46 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::,RULES_HIT:41:334:355:368:369:379:541:960:982:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1538:1566:1593:1594:1711:1714:1730:1747:1777:1792:2393:2559:2562:2828:3138:3139:3140:3141:3142:3865:3866:3867:3870:5007:7903:10004:10400:10848:11658:11914:12043:12517:12519:13069:13161:13229:13311:13357:13439:13894:14181:14659:14721:21080:30054:30089,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:2,LUA_SUMMARY:none X-HE-Tag: scene97_17dbc722c9c1c X-Filterd-Recvd-Size: 1757 Message-ID: <1461093152.1917.26.camel@perches.com> Subject: coccinelle: bool if (foo) return true; else return false; From: Joe Perches To: Julia Lawall Cc: cocci , LKML Date: Tue, 19 Apr 2016 12:12:32 -0700 In-Reply-To: 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> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.18.5.2-0ubuntu1 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 464 Lines: 36 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; ...> } @@ identifier fn; expression e; @@ bool fn ( ... ) { <... - if (e) return false; else return true; + return !e; ...> }