Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1491080imm; Tue, 3 Jul 2018 12:08:55 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKTHLbo+wr46Ydpcq82HFgIy7YCoQfs6qAEDNQq9/qFv68ZABmXuSXYmn0lISdSpc/iKiNT X-Received: by 2002:a17:902:ac1:: with SMTP id 59-v6mr30439538plp.36.1530644935207; Tue, 03 Jul 2018 12:08:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530644935; cv=none; d=google.com; s=arc-20160816; b=VhTpIHVKEDNQaD6a3tk8tim4SBw4/0oc4mdbj0QZ3K1R4vhQktcWIP4GscJAe0wlui /CkKuvCg4TZDRkCGE9umP+mejECruHa4wklAhOkWYFkHHml7uiLyjohi6NaOFa62jToa aW71MBA926b7gkihemrZRHf26y/drRp34okoXlrQA76iyzdAldLId3Oo4k2B0XTF1p/d QxVcxIDL/mVF74iAvMbfyTHtTWrrWNXQIUA7ciTiUtzbC3ne3ds6HVoo8aW8I3BVF7A6 8t4FRE9XGLzm2t+worDE+INR2Cyvecj6y5WJ760byH4Ffey86pSxwc6zhlnvKsjiHQ7x 0gNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version:dkim-signature:dkim-signature :arc-authentication-results; bh=qfxXtGd+0Jj6mNlitEqot9FDNSQXreaTpCsLgDwjKY0=; b=QnP5rm7JK9WaXUOWtYpXvoST7xzkue+EKrOOvB7v5PbAE/l9vRLF681XkCaQ0nRoOk htUuSH3fKAch5dhHMpgAeC1CAd1EP12ecispw4irPv+5Mra3hn5jasU03mI4eqRbOLRJ MTQPUn1xPWpI35vfonkcLr0PT1U8etyfab1T8FmOAsRYlGejZzi8w4Z3tpM6f0xt2SSx 8WKCrSMsb/qdc8RK6WGoO19DIVwC6VZmw2AlIKpotNa2emygGU/GgAF3pHk0X4n0nm2g j27eCayHGWGkdkhcbdepARgQ5/jXUcfOVhxm7e9gUgYOjA98P6aS6+TBE7L2IiqbL2wt ldgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=Ilmnv+E3; dkim=pass header.i=@codeaurora.org header.s=default header.b=Ilmnv+E3; 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 f8-v6si1716357plb.381.2018.07.03.12.08.40; Tue, 03 Jul 2018 12:08:55 -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; dkim=pass header.i=@codeaurora.org header.s=default header.b=Ilmnv+E3; dkim=pass header.i=@codeaurora.org header.s=default header.b=Ilmnv+E3; 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 S934607AbeGCTHx (ORCPT + 99 others); Tue, 3 Jul 2018 15:07:53 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:37060 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933265AbeGCTHw (ORCPT ); Tue, 3 Jul 2018 15:07:52 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id E28D9606FC; Tue, 3 Jul 2018 19:07:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1530644871; bh=9sz0uVBULJUKndbKw9VAjYgwOng3Yiep83zUqJLuXbc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Ilmnv+E3qzs9EHIxO5L2fQNrOzJ9RWsQbY1C4KURK0k7Ow1vou30v2ehiSKr95wZc g6huSun0dyWiaHPFpkRRuRqgoCE8XMyEXwla22R7ovEYqggMgeLJ76BIav2xTQVqwR 2aEUTOEf1/3sMTDvfef3q/iGooTOS4wr1jzYDwDs= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id 321766028D; Tue, 3 Jul 2018 19:07:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1530644871; bh=9sz0uVBULJUKndbKw9VAjYgwOng3Yiep83zUqJLuXbc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Ilmnv+E3qzs9EHIxO5L2fQNrOzJ9RWsQbY1C4KURK0k7Ow1vou30v2ehiSKr95wZc g6huSun0dyWiaHPFpkRRuRqgoCE8XMyEXwla22R7ovEYqggMgeLJ76BIav2xTQVqwR 2aEUTOEf1/3sMTDvfef3q/iGooTOS4wr1jzYDwDs= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Tue, 03 Jul 2018 12:07:51 -0700 From: pheragu@codeaurora.org To: Joe Perches Cc: apw@canonical.com, linux-kernel@vger.kernel.org, ckadabi@codeaurora.org, tsoni@codeaurora.org, bryanh@codeaurora.org, Patrick Pannuto , Stepan Moskovchenko Subject: Re: [PATCH] checkpatch: Check for illegal return codes In-Reply-To: <7cce1fcb751a2ffe89af02bcb05f295879ed1040.camel@perches.com> References: <1530641369-31098-1-git-send-email-pheragu@codeaurora.org> <7cce1fcb751a2ffe89af02bcb05f295879ed1040.camel@perches.com> Message-ID: X-Sender: pheragu@codeaurora.org User-Agent: Roundcube Webmail/1.2.5 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. >> >> 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 True. However, this would be helpful to avoid usage of such return statements in the future.