Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp184037imm; Tue, 3 Jul 2018 16:43:44 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ2FAEfuwLkRUrw2ZuZSV97zcMFd0wMTSzFIqZbWYsqG6J/8eZbdQHeYnSeOXkk2hX3zScq X-Received: by 2002:a17:902:6686:: with SMTP id e6-v6mr32148460plk.35.1530661424363; Tue, 03 Jul 2018 16:43:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530661424; cv=none; d=google.com; s=arc-20160816; b=0/Ih9nIpnL/T3E7SIGQmHlm2ZMkiDwSKTPNJRXxo+IQs4RunFyYh7CDHAl7mm7Sk8m PMuMUUnMpkLBI4ejh6stE0W2TbdgtmFj0WYC3hFbO9qkUgMNgftHrxy9qZift/EQBgxb BzQqtKfge4x1G9Vd/A9D466oxZi5ocwDV8kDk4uI6stubFq5dGaF917wiMdsteLpcEGZ euuFncvNZIw6aSLgR5bLiazmaf/7F3TAUqdH2xFBiHAZhECBromjDOJzbMYLcI4ydxN4 F/umyEQ3xf5fWxkgZyJc5ApuBpu0F5A2YGlyJM2KSX2/VWM44ZeZtVaTJgh3MQmmmCmz dj4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dmarc-filter:dkim-signature:dkim-signature :arc-authentication-results; bh=Hipxhow6rPMJLxAfg3WYXOYSt9QtYXqsn1vgUjPjgc4=; b=f0DWIcYSIKqRy+dMCD7gct3vnvMMX14VyUr2yVCJr3YAuzTOy3AFwZo4MgfF8TL6NN 1tl0mhSsjMTj7sfajZNSOXr04RItWjIldWlPY+usa/UtYfz5hDeWEwmVGlvAwwi4Khzu A3Ppqdpa8ZVsNJIACEu0Br2Qc/YqHxT1JeNka+UC+m1hO3tKaTfpvynIkkzBHEKeHAYF GnPmokr9OzuU8uyUuCCFLKSHld4dkMjO84yGAoELbSqCLvn1rSHB1ORQNnC/UMBp0gM2 gj+GBJBlCOVIwy2uNHErlyVhqwCRt+HBkWN7UInvR/d5My1qDn74rohTA3Y87a6Yr6a8 kJhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b="cW/wQPTs"; dkim=pass header.i=@codeaurora.org header.s=default header.b=QTcGJMY1; 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 h1-v6si1986463pgn.69.2018.07.03.16.43.29; Tue, 03 Jul 2018 16:43:44 -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="cW/wQPTs"; dkim=pass header.i=@codeaurora.org header.s=default header.b=QTcGJMY1; 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 S1753082AbeGCXmJ (ORCPT + 99 others); Tue, 3 Jul 2018 19:42:09 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:46614 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752271AbeGCXmH (ORCPT ); Tue, 3 Jul 2018 19:42:07 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 7E44E60B19; Tue, 3 Jul 2018 23:42:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1530661327; bh=+ys1m+dBbM6TyCUtxKUQye6tNlkZiGjWtkhhfk6rI/c=; h=From:To:Cc:Subject:Date:From; b=cW/wQPTsDRRw5JjU7JjOp6Mr53sURjFFt7pDP0CRAcJEV/H//uGoqQEJ4PJ5RCkKN QDxYsYHfmkOjNFZkxRWb8h5hA4+ZpI6RplTFEpwJvUAQN/jMEAX9lKZMNf+wWM2SpV ekGgLvl2FAtnI+PM0HW1r5P+P/eUEU9V2RkzA8zc= 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 pheragu-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: pheragu@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 7A3CA6028D; Tue, 3 Jul 2018 23:42:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1530661326; bh=+ys1m+dBbM6TyCUtxKUQye6tNlkZiGjWtkhhfk6rI/c=; h=From:To:Cc:Subject:Date:From; b=QTcGJMY1JnpzAnt1OMEpsCzxw7+D9HBe1DGVc5/RgLV34BvG+LLLzzjVHEPKCY8z9 xMguu4FJjZVzNaTonTwjpjcDrCB4EOWAioJsfm8mrQq8V8cHKH43dOW8h/VJYipwJW y4UM53i2ccgMDVFAAPf3WpPJno8mt/LV8OuZfZOs= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 7A3CA6028D Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=pheragu@codeaurora.org From: Prakruthi Deepak Heragu To: apw@canonical.com, joe@perches.com Cc: linux-kernel@vger.kernel.org, ckadabi@codeaurora.org, bryanh@codeaurora.org, tsoni@codeaurora.org, Patrick Pannuto , Stepan Moskovchenko , Prakruthi Deepak Heragu Subject: [PATCH v1] checkpatch: Check for invalid return codes Date: Tue, 3 Jul 2018 16:41:45 -0700 Message-Id: <1530661305-11959-1-git-send-email-pheragu@codeaurora.org> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The only valid integer return is 0, anything else following "return" should be -ERRCODE or a function. 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. Signed-off-by: Patrick Pannuto Signed-off-by: Stepan Moskovchenko Signed-off-by: Prakruthi Deepak Heragu --- 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", + "invalid return value, please return -\n" . $herecurr); + } + # check for gcc specific __FUNCTION__ if ($line =~ /\b__FUNCTION__\b/) { if (WARN("USE_FUNC", -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project