Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1370645imm; Tue, 3 Jul 2018 09:57:28 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeuCJwFBOqzrzpOdI1/Q0q2TulLXHxWVGbBjnproT02SdAJy6Scm2THglzQ0m2HSeIeG76p X-Received: by 2002:a63:5463:: with SMTP id e35-v6mr11620312pgm.115.1530637048188; Tue, 03 Jul 2018 09:57:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530637048; cv=none; d=google.com; s=arc-20160816; b=09mErghdCB/2cIWIuFcR+q051MCna7Sj9iZP08+VV005+kVJjvy17ut4sC7LhXw5fW zco7tRjTtGN+5NbuFyCiWwCjNL4AHRYGmUOvT9sujBQ8WL1vuHmtNJCHoj0fiQfI9UMr Krtiy/Tnqo7ck/a+t57a6HPvvoPTSZ9xdKSAiFD9czV9aWL4vOsAImnp0NJB1b7v8j2x 49cEfmiYtFniUHyO+QXmHvdXyDBnBMLXPJNuq3b1/+JSt092k848pHSekt4gs6KtxBMW xhL/TWWJNLoKEIdlIHfZtg6OkNDvPNa2T/350TT/N/tcaBOxn3QhqjGhmBqS8ohO79g/ KbRw== 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=iOGR8R3b5Z280fWt8ZQa9ktfjBAMiFrZWB9np4YF/3U=; b=m/1Go5dbU2w88UgEyUDKKKNFXePXmNRN0PP1RZgsyMnoU0d3zTIRRepkGI/vPOydV3 3wOVXr206r7RiSJifUgu6bhs8f6Tj9gZwDAAIoW20riR15a0teZUe0/TNnrwssJiqQQW WJ/yb8E414MqIM1bUT4D71tf2JUy3MnKXvTEh4Km7HJUoxxsZRqJvPr5grHtjT3idl3+ ANKELmOpXnc2Sxer14QFJbXOIiaLTb8XFzCNP5g07i982gUAXPPgQCsHG0DmItMwiU+5 zje4hJ00xo5Bw06FWxMmG2L+O7vPfR7RZP17byEBaDDAM6zTgrjZx2z6jKjFuT12nURX Swxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=DxawjJi6; dkim=pass header.i=@codeaurora.org header.s=default header.b=DxawjJi6; 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 g70-v6si1145548pfe.4.2018.07.03.09.57.12; Tue, 03 Jul 2018 09:57:28 -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=DxawjJi6; dkim=pass header.i=@codeaurora.org header.s=default header.b=DxawjJi6; 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 S933788AbeGCQ4b (ORCPT + 99 others); Tue, 3 Jul 2018 12:56:31 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:43518 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932392AbeGCQ4a (ORCPT ); Tue, 3 Jul 2018 12:56:30 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 8BDCC606FA; Tue, 3 Jul 2018 16:56:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1530636989; bh=jqi4BWqFSZJJ1xstAtSdcsqPY3+uTMbrWZtQjvJ06qI=; h=From:To:Cc:Subject:Date:From; b=DxawjJi6XJw28GSrXCSZcfgt7a5rJUB/N0ico78weTd6C1OCywscqUuISW13tKGhg eqLV1ujXcdXeb/ghSHJr2J5Q/z4m+n/RCr8cLblBfFTcm5W+dTu/HCskDJlasJHxJE Q8SCr82BRySwGy7SiWiqtggzcq6htWnkljP/EvcE= 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 E071C6028D; Tue, 3 Jul 2018 16:56:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1530636989; bh=jqi4BWqFSZJJ1xstAtSdcsqPY3+uTMbrWZtQjvJ06qI=; h=From:To:Cc:Subject:Date:From; b=DxawjJi6XJw28GSrXCSZcfgt7a5rJUB/N0ico78weTd6C1OCywscqUuISW13tKGhg eqLV1ujXcdXeb/ghSHJr2J5Q/z4m+n/RCr8cLblBfFTcm5W+dTu/HCskDJlasJHxJE Q8SCr82BRySwGy7SiWiqtggzcq6htWnkljP/EvcE= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org E071C6028D 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, Abhijeet Dharmapurikar , Stepan Moskovchenko , Murali Nalajala Subject: [PATCH] checkpatch: check for #if 0/#if 1 Date: Tue, 3 Jul 2018 09:56:08 -0700 Message-Id: <1530636968-17906-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 From: Abhijeet Dharmapurikar The #if 0 and #if 1 are used to toggle features. Warn if #if 1 or #if 0 is present. If #if 0 is present, warn about that part of code being redundant and that it could be removed. Also, if #if 1 is present, suggest that if the code is required then the #if 1 can be removed. In either case, the preprocessor directives can be removed. Signed-off-by: Abhijeet Dharmapurikar Signed-off-by: Stepan Moskovchenko Signed-off-by: Murali Nalajala --- scripts/checkpatch.pl | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index a9c0550..a3dc0c8 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -5374,9 +5374,16 @@ 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", + "if this code is redundant consider removing it\n" + . $herecurr); + } + +# warn about #if 1 + if ($line =~ /^.\s*\#\s*if\s+1\b/) { + WARN("IF_1", + "if this code is required consider removing" + . " #if 1\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