Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp776973imm; Thu, 26 Jul 2018 11:48:45 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeyxEhkIxhafWRpo5/35GIGUlJcwPqK1IXDbYjROLw7Lgrngv5KGu9d6gwJ2FhJSYM33sQs X-Received: by 2002:a63:6004:: with SMTP id u4-v6mr2977103pgb.441.1532630925038; Thu, 26 Jul 2018 11:48:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532630925; cv=none; d=google.com; s=arc-20160816; b=NGTVg68eVCntpchhvxogQtQI9Nv77YmbemkqMgzwpejh+mohsSZqSMAKHXV8g1tPxE ioqc5TI05VkCuf+NT2EJHd7okRHlUVRa3tPP0hr1N1iXnyOOKKqA6Eajl21HBfNov/wj oncZdRqO0L9W0++mzV3uvU5m6ci6GlY4yfUnuCGeRYCBj8VDqO1nNsOWMxPD/3m1irtZ iizsnUpI1zo10qd7Vxb1+p6HF/cjKB5KBWJQzscKUEcPoZFfQVHJl1lHyn6epqbhCeI2 3UzVNs8gWFRTVOHwxiVv754BzpxgQTxFsg2kUzESiXmlm93xkdeocEbCJP+UpqXLcuGc WUiQ== 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=2rnFo/2oYI98Mi0t2keDpQX0ZF6+eE/KLthqDY1gnNQ=; b=MLwPyQZkdORENdO3bxXrGW9hvoXr7f6RfC6bOkyjd6uDUujBSzpWttWR9l+A/rO+S7 EQIcE2NGwlj3Wg5hICvqlbM5eMg+wtPh3RHQm9+N9pcSanpHQ86NeEWwDh+4BnHNDT00 0BAcOx138dzvrmilC7CiCqzxrIE0P+IIPBOsKgUznlpc9qb44RFYiK7EpAu1hZ/Ct+hz WtCzmkNz7XmydTNuJS93B+cSKLHJEPqOfRNzVYTCqFE/bqcHNjzRZk+Zc4uIW6O2koEQ xTq+0wG2ZnIyqvCEOkJG1jymQUj9GABfCK5IdtnStbRjPjgbI7Bur9eBcULRThcp71mt sM3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=cP9rko6c; dkim=pass header.i=@codeaurora.org header.s=default header.b=YtC8RdOj; 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 w1-v6si1996751pgo.87.2018.07.26.11.48.30; Thu, 26 Jul 2018 11:48:45 -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=cP9rko6c; dkim=pass header.i=@codeaurora.org header.s=default header.b=YtC8RdOj; 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 S2388636AbeGZSbr (ORCPT + 99 others); Thu, 26 Jul 2018 14:31:47 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:55218 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730095AbeGZSbq (ORCPT ); Thu, 26 Jul 2018 14:31:46 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 904D0607B9; Thu, 26 Jul 2018 17:14:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1532625242; bh=ZHJb8Jr1BxVCVwX4Qlk7PnqxLmowZsWG09QmBn6nBxg=; h=From:To:Cc:Subject:Date:From; b=cP9rko6c1OBBLYDfWDnBd19SUomVEJu12GU2PUNGZ+QwCUQTY7SeJeC18QUOrJVUG 6ulEC5ZX4i3YvSgKogd//HbBtGTTwT/REtAOFA6OS+ZQob1iI9jxL38TDcnD1BFCvr tjJMQZOoRVwe8FhvrYXHLIV6iozjd4NWf1qsGxAY= 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 4F27D60C1C; Thu, 26 Jul 2018 17:14:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1532625241; bh=ZHJb8Jr1BxVCVwX4Qlk7PnqxLmowZsWG09QmBn6nBxg=; h=From:To:Cc:Subject:Date:From; b=YtC8RdOj8ZO8Ev9t6SEWi4GOB/MMgd1e66GTadRagVGU98tdQfhmSIhq7TfAEJvm+ 98fB2/YLs03S8eB4ND9v0HiE3Ft2Gd19fXVMNkOyT4XAEwqZHHAR3TBUS7zCKeVrwF H7I/ag8TrrODu0Mto/TKHOSQZ6tI+KF66RUfXzYk= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 4F27D60C1C 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, Abhijeet Dharmapurikar , Prakruthi Deepak Heragu Subject: [PATCH v2] checkpatch: check for #if 0/#if 1 Date: Thu, 26 Jul 2018 10:13:38 -0700 Message-Id: <1532625218-24321-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 #if 0 or #if 1 is used to toggle features. Warn if #if 0 or #if 1 is present and suggest that they can be removed. Signed-off-by: Abhijeet Dharmapurikar Signed-off-by: Prakruthi Deepak Heragu --- Changes in v2: - Rephrase the warning for #if 0 Changes in v1: - Rephrase the warning message to fit in a single line without 80 column limit scripts/checkpatch.pl | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 3394ed8..1dfe83f 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -5383,9 +5383,14 @@ sub process { # warn about #if 0 if ($line =~ /^.\s*\#\s*if\s+0\b/) { - CHK("REDUNDANT_CODE", - "if this code is redundant consider removing it\n" . - $herecurr); + WARN("IF_0", + "Consider removing the code enclosed by this #if 0 and its #endif\n". $herecurr); + } + +# warn about #if 1 + if ($line =~ /^.\s*\#\s*if\s+1\b/) { + WARN("IF_1", + "Consider removing the #if 1 and its #endif\n". $herecurr); } # check for needless "if () fn()" uses -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project