Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1450841imm; Tue, 3 Jul 2018 11:20:24 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe5SDcW3h6Z0j5r1shtKHYFYDhqGYgLq4kiEBKZbDuhn9lxhRFK8F2W1e7RKmEMh3RN2TTv X-Received: by 2002:a62:3783:: with SMTP id e125-v6mr30685352pfa.232.1530642024363; Tue, 03 Jul 2018 11:20:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530642024; cv=none; d=google.com; s=arc-20160816; b=SjnuymROBi/GjyxjrvlMwbiL8N9I6NsAPP6Lot3WHbNIkBOUQtAZZCVmtiivd0eYqj Tvb6V980BxIreOdD6SEBVOMxVly9GBSL5aUnK9XvwXjDCKZsUGoNyAryNgQhO8wwYn/w waprwI9mc3LfUX/fFnO/oZO9bXg9q2eeLsqvmnqiBuuN7j8RolcjS/kRQtLs/Z8edpvc YvbhhvXVTrvVbJiwKdIrGuEQJPmNe3GxAMacQisdpxs2T/gvWBkHpFKbyoOtGPAdLZEj WdI7ghMiYAs5UxGooIjJm5hxI9+Edx308s0i3G/oNu/k7kCQ1LZI8vVCE8DORD3gm9t+ IqOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :arc-authentication-results; bh=olHOJkraHiLFWB/NST1D5tEc2IS2zxpeSBG7mNGVEOk=; b=BMlPEhybWY3PW3t5KNYOB29B/n3yHUAKQ2psfa9XnZ1eNIjnvQtbVOGxUUzdEAJapY Reh2DjDoyvodvqowW45prL++kYWnOrM7iclXtCNk0TcV8p4zwjU/HAaxwsbGGKqOlDPL XKiZU2gSKup3NyeMw+ALYnfQ1ekEwJd88GVfjJ+LxL1WrFbxkqTca2QH4qI3nFP686r+ ppfdOZ8NkwXlW5HCNLRPYLIQkEgUvMr9X2vyQk6lQy3RRM3U6Vh9wd1Ku7YpPsCBxCXd 32w3g7BHrxz7ZWvGmOWXrSnxQpCqe00JkwxXy1L1f9GMpl81n74dVE+AA3zpMJKRIf2L KmKg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e85-v6si1727892pfl.132.2018.07.03.11.20.08; Tue, 03 Jul 2018 11:20:24 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934441AbeGCSTc (ORCPT + 99 others); Tue, 3 Jul 2018 14:19:32 -0400 Received: from smtprelay0237.hostedemail.com ([216.40.44.237]:48597 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S934381AbeGCSTb (ORCPT ); Tue, 3 Jul 2018 14:19:31 -0400 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay03.hostedemail.com (Postfix) with ESMTP id 67E21837F24D; Tue, 3 Jul 2018 18:19:30 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 10,1,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::::,RULES_HIT:41:355:379:541:599:800:960:967:973:982:988:989:1260:1263:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2525:2559:2563:2682:2685:2828:2859:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3353:3622:3653:3865:3866:3867:3868:3870:3871:3872:3873:3874:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4321:4605:5007:6691:7875:7903:9025:9388:10007:10049:10400:10848:11026:11232:11473:11658:11914:12043:12555:12663:12740:12760:12895:12986:13069:13161:13229:13311:13357:13439:14181:14659:14721:21060:21080:21451:21627:21781:21788:30012:30054:30070:30091,0,RBL:error,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:neutral,Custom_rules:0:1:0,LFtime:26,LUA_SUMMARY:none X-HE-Tag: lead82_8cfdd5665a841 X-Filterd-Recvd-Size: 2555 Received: from XPS-9350.home (unknown [47.151.153.53]) (Authenticated sender: joe@perches.com) by omf10.hostedemail.com (Postfix) with ESMTPA; Tue, 3 Jul 2018 18:19:28 +0000 (UTC) Message-ID: <7cce1fcb751a2ffe89af02bcb05f295879ed1040.camel@perches.com> Subject: Re: [PATCH] checkpatch: Check for illegal return codes From: Joe Perches To: Prakruthi Deepak Heragu , apw@canonical.com Cc: linux-kernel@vger.kernel.org, ckadabi@codeaurora.org, tsoni@codeaurora.org, bryanh@codeaurora.org, Patrick Pannuto , Stepan Moskovchenko Date: Tue, 03 Jul 2018 11:19:27 -0700 In-Reply-To: <1530641369-31098-1-git-send-email-pheragu@codeaurora.org> References: <1530641369-31098-1-git-send-email-pheragu@codeaurora.org> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.28.1-2 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2018-07-03 at 11:09 -0700, Prakruthi Deepak Heragu wrote: > The only legal integer return is 0, anything else > following "return" should be -ERRCODE or a function. > > http://lkml.org/lkml/2010/7/23/318 > There's lots of "return -1;" statements in this patch - it's obscene > that this is used to indicate "some error occurred" in kernel space > rather than a real errno value - even when an existing function > (eg, request_irq) gave you an error code already. > > Signed-off-by: Patrick Pannuto > Signed-off-by: Stepan Moskovchenko > Signed-off-by: Prakruthi Deepak Heragu > --- > scripts/checkpatch.pl | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl > index a9c0550..260d252 100755 > --- a/scripts/checkpatch.pl > +++ b/scripts/checkpatch.pl > @@ -6197,6 +6197,12 @@ sub process { > "switch default: should use break\n" . $herectx); > } > > +# check for return codes on error paths > + if ($line =~ /\breturn\s+-\d+/) { > + ERROR("NO_ERROR_CODE", > + "illegal return value, please use an error code"); > + } > + Substitute illegal to invalid as this wouldn't be illegal. It might be invalid and this needs a newline and $herecurr I'm not sure this is even useful. There are _way_ too many of these already existing and simple return identifiers can be OK. $ git grep -P '\breturn\s*\-(?!0)\d+' | wc -l 10193 and $ git grep -P '\breturn\s*\-(?!1)\d+' | wc -l 240