Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp262043imm; Tue, 3 Jul 2018 18:41:58 -0700 (PDT) X-Google-Smtp-Source: AAOMgpc9e5Kfz7xAzGB/1Y6Ngy8axfZroKbvMwkvqxdVZnGylcaOnEdzktZaj9+mySbsWlmuwIWz X-Received: by 2002:a17:902:5501:: with SMTP id f1-v6mr76969pli.108.1530668518131; Tue, 03 Jul 2018 18:41:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530668518; cv=none; d=google.com; s=arc-20160816; b=kQhjn10WSeSArcIQg8Sgz4SGWwsCHx1yPtSO+QSzd6PO+3RW4TGaF2p5g9fkpH2big yOixZk+T1dZQsfnj255GR42E5rwY0ot4gq053aZr4neB7GvO2dxTF9Nec6sv6ziWuR+x pFqRS/n4v0xgaeic9s9+EjVfJO6TuBaKhYjRl2C6hOHRJwm6HKP5fhwwnJLeRvL9vq57 UZwyqFWwWmRll6E9zoGF0vqOFtvwk8Jo3XOpzOwKzJ2884zSY5vx0Jr+Bj/bDdEmkGvb G5EcA+YYMMo7tQ2rjrA9iKWH1ahOQCPaC2WJxrDC6Mct99llG5bb3CJVCBfYSFwZVhFA FFiw== 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=9+noTI4ybXRIVNoEfJ5MHMQ2T8ABWndx6hvDm0UACac=; b=kNFB2WTwmdwXjGP8Kka4qLGJpoQOn2EAWr6S7h5i4rwxpDyaGj6Mk175yaQOqB8Qv2 G03ZDGpD1JC5kq9gJPhoPq/2ti+PdhmJwrKGGt4My4OPMpLYL4PHv+txYeng868q0H8t Tkx5d6hKy+k2uGEB34kpI8XmeoRL5NodpgP+21/c6p64KYY9GswHye2Q+PoaCAynFUbU EzUj1uLTBtFoIRhhmGzByZ3ZLJBv3+Ah1BrX4wbVoca2wNnMRpJyV++H6YxXp5wNwEFG RNEKACyU3qcm1Evuo/egCysUUMY06LMW4UI2wBdwL4dI9deeCp3Y/Fhxm8gwVe40y6Xm hhTg== 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 l1-v6si2129890pgb.464.2018.07.03.18.41.43; Tue, 03 Jul 2018 18:41:58 -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 S932701AbeGDBk7 (ORCPT + 99 others); Tue, 3 Jul 2018 21:40:59 -0400 Received: from smtprelay0145.hostedemail.com ([216.40.44.145]:50214 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932263AbeGDBk6 (ORCPT ); Tue, 3 Jul 2018 21:40:58 -0400 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay06.hostedemail.com (Postfix) with ESMTP id C7FBB18224D93; Wed, 4 Jul 2018 01:40:57 +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:1542:1593:1594:1711:1730:1747:1777:1792:2198:2199:2393:2525:2559:2563:2682:2685:2828:2859:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3353:3622:3865:3866:3867:3868:3870:3871:3872:3873:3874:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4250:4321:4605:5007:6119:7875:7903:9025:9388:10007:10049:10400:10848:11026:11232:11473:11658:11914:12043:12296:12555:12679:12740:12760:12895:13019:13095:13439:14181:14659:14721:21060:21080:21433:21451:21627:21781:21788:21795:30012:30029:30034:30051: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: ocean31_426aebf250844 X-Filterd-Recvd-Size: 3026 Received: from XPS-9350.home (unknown [47.151.153.53]) (Authenticated sender: joe@perches.com) by omf03.hostedemail.com (Postfix) with ESMTPA; Wed, 4 Jul 2018 01:40:56 +0000 (UTC) Message-ID: <907f271cbeabec61b796ed220d425eb2ce2499db.camel@perches.com> Subject: Re: [PATCH v1] checkpatch: Check for invalid return codes From: Joe Perches To: Prakruthi Deepak Heragu , apw@canonical.com Cc: linux-kernel@vger.kernel.org, ckadabi@codeaurora.org, bryanh@codeaurora.org, tsoni@codeaurora.org, Patrick Pannuto , Stepan Moskovchenko Date: Tue, 03 Jul 2018 18:40:54 -0700 In-Reply-To: <1530661305-11959-1-git-send-email-pheragu@codeaurora.org> References: <1530661305-11959-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 16:41 -0700, Prakruthi Deepak Heragu wrote: > The only valid integer return is 0, anything else > following "return" should be -ERRCODE or a function. Integer return values can be positive constant and correct. So perhaps better: Negative integer return codes should prefer to use #define - values instead of negative numbers. > Also, display context > so that the user knows where the return value is incorrect. > > 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. This bit is superfluous and if you are going to quote someone in a patch commit, it's nice to cc: them. > Signed-off-by: Patrick Pannuto > Signed-off-by: Stepan Moskovchenko > Signed-off-by: Prakruthi Deepak Heragu Does it really take 3 people to sign-off on this patch? > --- > Changes in v1: > - Use CHK instead of ERROR > - Rephrase the warning message > - Provide the file name and line number where return value is incorrect > > scripts/checkpatch.pl | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl > index a9c0550..2808c27 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+/) { > + CHK("NO_ERROR_CODE", NO_ERROR_CODE isn't very obvious to me. How about NEGATIVE_ERRNO or APPROPRIATE_ERRNO > + "invalid return value, please return -\n" . $herecurr); > + } > + > # check for gcc specific __FUNCTION__ > if ($line =~ /\b__FUNCTION__\b/) { > if (WARN("USE_FUNC",