Received: by 2002:ac0:a591:0:0:0:0:0 with SMTP id m17-v6csp955643imm; Thu, 5 Jul 2018 11:56:28 -0700 (PDT) X-Google-Smtp-Source: AAOMgpczhQwxcFjRdjnMzzR2bol/MrKa2Ef83El84mkvQrYJbqy23Zk1ET9rfn7TGS+G4XirMBws X-Received: by 2002:a62:ce81:: with SMTP id y123-v6mr7696066pfg.95.1530816988319; Thu, 05 Jul 2018 11:56:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530816988; cv=none; d=google.com; s=arc-20160816; b=BDVymPrx0RXFW0Ulp9bC4Is0hlazcpvpxKApI0Ryp8J8qbrXIBYB4V5YBn4vBA/RJT WlhKIQKk7QBH/Q9BNtDaVz3c+p8QWox5UVnTfzUy1OYMgHOIe/N0ECS1v1gQxI+BV01H YLtOfz9C3qhg/pTWBpaX7gVXB+Dy/IX9OyoPFjTYsWbDnDunTLmjJH9USVMgWG28tPSc j6jNMhCbrvnCw+jq0CXuxU5bJ05KVeyCWSg+zzOt3jtVw61eQv7QisYHIGH17sI0rjYP Qq45sL3fWSBaJs2s+lq4Ru49y78KZPDpb0OWyRLIGyJ4r0kG7jbQRC4K3XD7jm50Vr9T 6Q+Q== 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=kfq0mRtmWtdazrC+1OHQBMRVTCwxKOTPDeq/aOnX3iY=; b=ATO0hB7FvPubPyeIg4RGedSAzkBriphxUT8Xg73RiRja51JJAKdP9LRTU71fYtH6mA /7AdPDucJdgrdDPj/8ncMO8wex/5QnOoakXmnxkoDhXRbY8KdPssH6RQ53MeWUZx+H0o J6ZYjpCSpM7kV7O4jf7/2npps8E7mOL0JWij7UJe7UZPdeOVMViDJgCAsjS6RbllQt6C +XAgszD19AnLiv1OsGtYhee+ohkkSRqTn0UxgTF6sL4FQSpARMSi/KZFjTrxl2CNsJb+ eS1CH+TyHEW0bGWGSMU5TPJyOJaTSX4coZ/oPvkncy5u7DCfPLnwg9i1xYjXM0x4RPbh 0h4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=URrszoyK; dkim=pass header.i=@codeaurora.org header.s=default header.b=FhTeUuwp; 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 j85-v6si7225191pfa.232.2018.07.05.11.56.13; Thu, 05 Jul 2018 11:56: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=URrszoyK; dkim=pass header.i=@codeaurora.org header.s=default header.b=FhTeUuwp; 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 S1754137AbeGESzf (ORCPT + 99 others); Thu, 5 Jul 2018 14:55:35 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:39946 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753846AbeGESze (ORCPT ); Thu, 5 Jul 2018 14:55:34 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 0CE3E60B25; Thu, 5 Jul 2018 18:55:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1530816934; bh=ckD748rq2cXHUU5b17avEUPvP8L3qIIDQv2lYe157Hc=; h=From:To:Cc:Subject:Date:From; b=URrszoyKA9meUZlmADG6dyrN4MacLckSMu513kWTjXbbqxH3uhTnE8fa57WzqQ2TM 0v6o2UQHLuqI70dV4mwBX1rcHUngNks8IQ+H4FCm+piGSyn8SSH++Tzy+ED7j9jloh 0Njp6Cqago7FT8cw7Q0mx0vd4s7Pa7eoBNh7IN1c= 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 E53B360646; Thu, 5 Jul 2018 18:55:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1530816933; bh=ckD748rq2cXHUU5b17avEUPvP8L3qIIDQv2lYe157Hc=; h=From:To:Cc:Subject:Date:From; b=FhTeUuwpufk/Mr3rXpC9fCg4BTAlTCjRNsaLW/l8WnuR9jjjD+rQrKFBpPmrkKVXr KPaE+p/wawTxAfimbUSfPGeQoPr7xzzwzG5YKCjVnthcXwhCKWT38ntE7fsrq9e8nX 8ijIG9J0Miw2mhvxLXrPgzTQ4moHyemMWaRPpxe8= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org E53B360646 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, Prakruthi Deepak Heragu Subject: [PATCH] checkpatch: check for #if 0/#if 1 Date: Thu, 5 Jul 2018 11:55:22 -0700 Message-Id: <1530816922-27100-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 and #if 1 are used to toggle features. Wharn 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, these preprocessor directives can be removed. Signed-off-by: Prakruthi Deepak Heragu --- scripts/checkpatch.pl | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 978c752..fa3e695 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -5378,11 +5378,19 @@ sub process { "Use of dsb is discouranged: prefer mb.\n" . $herecurr); } + # 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