Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1515026imm; Tue, 3 Jul 2018 12:38:35 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLJeQtQ7OHPLLHGxKzbCc1aO26N0GB9L8bRslHh8SCBmVaK/uXf0kOJ8XV5Lmy1a/jrxUAo X-Received: by 2002:a17:902:5a3:: with SMTP id f32-v6mr31024830plf.109.1530646715761; Tue, 03 Jul 2018 12:38:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530646715; cv=none; d=google.com; s=arc-20160816; b=TvwsdF5F6dbbrgcbKyZb/ikuWVL5UbVAUTPQ4f4hcsC7PlkhHZMPFLDPnJpAjaUQFl E0zi2u/GZjTncThpsOmKkDTKOZauzu5UV2QJoh+r948RmT1UVo8oESMYyP/e0DENyIZw KW5yeo0kl3/LpTGCtYYtlzqeWfvkvR2E/VSnncNqQyqYcN/OOF5ZzSOqfUodfkWtKas2 +pSfaOOUj/7fruR+S5k7v1equujy/s039lHG/U7JoRyBpeVyuKQJotvIMeeUwozxpmWG imyJ3Rk+KU60UW0dOZTHk/dPyUueUHtOQs9oZDaAZDEYWTvupMWOVEFU5OBFpxufj9UQ EqYw== 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=vzhTLj3hb2Sfux0zqggLuoCHo8p8msJjDDaPLSCL3hc=; b=qLOrUhHTbomiRH0PaSbyRftyh9qApdoxxqeRx3bY9TDjjeI66AfStSbV7deeRz1YA4 LrvZtmcjOQ1u7nOaC2JzbQvNkF/iAXZjLACuNRA4EUrzpLs/ZQ/8Hux1apABV+UJqQgz epuRnUjJ8A2PWnoVXNiVqi36kDxQmQUWq2mFi5W0/1TXEHRF824LDOn2vuwjWQtcCUw+ bJYdXnHwYcbgklzRbv3HS0yBHNcIYhRDYfjIrMjmVtRug1oqou9f1gQVjsh88aqLO+hX zv6XRTCJ8UR33fxujexqeYZKQqoM4sPGq3dwa0k+S+3RMPP26NFBa5ZQosXVWvjlipO+ Ndnw== 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 d37-v6si1759910pla.85.2018.07.03.12.38.21; Tue, 03 Jul 2018 12:38:35 -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 S1752684AbeGCTh3 (ORCPT + 99 others); Tue, 3 Jul 2018 15:37:29 -0400 Received: from smtprelay0125.hostedemail.com ([216.40.44.125]:37743 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752237AbeGCTh2 (ORCPT ); Tue, 3 Jul 2018 15:37:28 -0400 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay08.hostedemail.com (Postfix) with ESMTP id 6A1B6182CF671; Tue, 3 Jul 2018 19:37:27 +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:1431: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:3354:3622:3653:3865:3866:3867:3868:3870:3871:3872:3873:3874:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4250:4321:4605:5007:6119:6691:7875:7903:9025:9388:10007:10049:10400:10848:11026:11232:11473:11658:11914:12043:12555:12663:12740:12760:12895:13069:13095:13149:13230:13311:13357:13439:14181:14659:14721:21060:21080:21433: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: hill76_5dfe7096c720e X-Filterd-Recvd-Size: 2750 Received: from XPS-9350.home (unknown [47.151.153.53]) (Authenticated sender: joe@perches.com) by omf06.hostedemail.com (Postfix) with ESMTPA; Tue, 3 Jul 2018 19:37:25 +0000 (UTC) Message-ID: <4c9b77cb32c022c93851e8a812e4c076dfd30e5f.camel@perches.com> Subject: Re: [PATCH] checkpatch: Check for illegal return codes From: Joe Perches To: pheragu@codeaurora.org Cc: apw@canonical.com, linux-kernel@vger.kernel.org, ckadabi@codeaurora.org, tsoni@codeaurora.org, bryanh@codeaurora.org, Patrick Pannuto , Stepan Moskovchenko Date: Tue, 03 Jul 2018 12:37:24 -0700 In-Reply-To: References: <1530641369-31098-1-git-send-email-pheragu@codeaurora.org> <7cce1fcb751a2ffe89af02bcb05f295879ed1040.camel@perches.com> 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 12:07 -0700, pheragu@codeaurora.org wrote: > On 2018-07-03 11:19, Joe Perches wrote: > > 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. [] > > > diff --git 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 > > True. However, this would be helpful to avoid usage of such return > statements in the future. Maybe use CHK and not ERROR and maybe the output message could be something like "Prefer 'return -'"