Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1442404imm; Tue, 3 Jul 2018 11:10:50 -0700 (PDT) X-Google-Smtp-Source: ADUXVKI1DT6Q1PPmPp3IRAB8yMl7KJLY4E4Xb8npy0OBG+EZAuKQsf+QBC9WiKbaeP3GTV4fq2QJ X-Received: by 2002:a65:621a:: with SMTP id d26-v6mr26985192pgv.305.1530641450612; Tue, 03 Jul 2018 11:10:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530641450; cv=none; d=google.com; s=arc-20160816; b=YTbrYPgp6+d2FYqrXtiijyWxbB9/9yyNg9hjeLrzf6/XlhXev+Y6BWmEUh9/36YXNM KNpMBV9zL89ss58zhEgZQVuBKbniAPfy0KpXBsyjNLdZXt9Dw5ayOMhSl2vLmk6bmT9S AGLaCgd/yVqdN+zWmzMAqGd8ccbec+tjBkOLh93bHbTBE/dSuhbdifcgavENCDoHDYDe TxEyNDYYwzCZbr543JxIMukk5PI2Bbwzk6X7vKbZBa6q9l77EB12vT8Q+6Bd6nDAopiH 6MlMUjNRiQLLZCljqw9G2b13qyGuFeoJekR5wlj1RT4lCFAXPLXyYwB+BJurOjW5hVqc sfyg== 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=iPdnvbr1gTWso2RaQD0Yv3zmgCUy5EL2A+TatNUaISU=; b=l++gYalz6UAfE/olC6cYIVzMeLdvHGRkW0WH2PEPS1G3IIez7JCvDoJNucwoES+yhB 6oa237s8ByER4oBn5SW5UORVWC2k3ekoLf+mthO9/GQISjOmH9TSMv6b/FKSJNc4yKow JTcI7Pif+GGtJuVXO+KqfOW+u8FAnqNNzm8cB1XegV+mXx83F2rxlIZM+gAFuJ5EJix6 7rudv7yHxVy3ulPkUk+cunTCOU67Kk6KZDPi1tNQYu29E1FF4/oxXXg5DZ8dQuwUcUN4 HkS6uBlFuyyU6XO16wPueufNqrZ7gFZ/Qs4nAsPa/SzrrNOjFO+n3Mdr6qsNAbwmvcI9 JO2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=Lmxoagvr; dkim=pass header.i=@codeaurora.org header.s=default header.b=Lmxoagvr; 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 u8-v6si1595794pfm.63.2018.07.03.11.10.36; Tue, 03 Jul 2018 11:10:50 -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=Lmxoagvr; dkim=pass header.i=@codeaurora.org header.s=default header.b=Lmxoagvr; 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 S934452AbeGCSJr (ORCPT + 99 others); Tue, 3 Jul 2018 14:09:47 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:35424 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934195AbeGCSJq (ORCPT ); Tue, 3 Jul 2018 14:09:46 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id C4BBA601CF; Tue, 3 Jul 2018 18:09:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1530641385; bh=rL/ljN7umr3/KHvvo68viD/g72BeW6syn82xZpqQG9M=; h=From:To:Cc:Subject:Date:From; b=Lmxoagvr7vtbxrzrGXgBOCRAaXr4dUZ34QyvJX0out7ygoKCnY0xZhxPCspjLmfiW T5gBb1+SEjAclf9beGTWfwDAc4rDgjqDxVXO6co6OrWT215XCC+13mTr8Pm5iIzXyj rP4c3N/VeWK8lhnnABnQe6eHlaOWYI/PpyMnKMnQ= 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 C856960249; Tue, 3 Jul 2018 18:09:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1530641385; bh=rL/ljN7umr3/KHvvo68viD/g72BeW6syn82xZpqQG9M=; h=From:To:Cc:Subject:Date:From; b=Lmxoagvr7vtbxrzrGXgBOCRAaXr4dUZ34QyvJX0out7ygoKCnY0xZhxPCspjLmfiW T5gBb1+SEjAclf9beGTWfwDAc4rDgjqDxVXO6co6OrWT215XCC+13mTr8Pm5iIzXyj rP4c3N/VeWK8lhnnABnQe6eHlaOWYI/PpyMnKMnQ= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org C856960249 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, tsoni@codeaurora.org, bryanh@codeaurora.org, Patrick Pannuto , Stepan Moskovchenko , Prakruthi Deepak Heragu Subject: [PATCH] checkpatch: Check for illegal return codes Date: Tue, 3 Jul 2018 11:09:29 -0700 Message-Id: <1530641369-31098-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 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"); + } + # 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