Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1333862imm; Wed, 25 Jul 2018 16:18:28 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcQPzgaUG+s5iHW52KhDy6YlLWf90NnBypOsPmt0qCPvVpo+KOjNUIW0znLjrfGjJlg6Ijg X-Received: by 2002:a65:5004:: with SMTP id f4-v6mr22496596pgo.54.1532560708328; Wed, 25 Jul 2018 16:18:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532560708; cv=none; d=google.com; s=arc-20160816; b=OP0yaviVwEWvoL27gVHKZBm59ebpDvvJusUg5t7mde10dzAgQ4+Qo4/z7vTay35czN LfufAleYdaUtyeAlE2Mm+SoHUjEu/e8D/lsISSrHbLjkXN3wFh31IZPAyjk7H1rlPgoU WZwbDnVAkit/qGPdNSGicy5Jod25xEPsHfXcEI7LaMzJ8K9uFOuJq74kTVUhSbnQE2Xi 3OuV5BIBlcKSBikbB9KCdQgPz06s2fja5dQb2PWEkLZwpgpkLg0vcIOk1qPxYZvsH2Px QRnmxiAotnUoiEHXUC/WsHsEG0nhDm/JUio9wBrE9k56MZuNFefT/hsnaIqngWP2xFJC k6hw== 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=y+JYWGa9mwWg6h6orN+pm8oJK9ouZUdVcALkj6oES8U=; b=SF8W+j0sgpeelr0wfCPqoM5aVEuahYdV11aoCUb4GFuDFyyZtCUnkGJqThIPkK6mtd UXYw2+uUFZXt6x2X2SGCeinVVf1j6rNOSa1bW0hlcyQVedv9+VavUY3yhVgns0mmMtxS W0b4Sx6exD0sBprZtmd4PqcDuC6OyqPp2rAxdhFpg2wloRpH1UlO+Xw3ZUQ0XPfXYRN3 T5j34acYFlbOEHoA71O3OuJEDVoFdkd8ctXJV1aa0M2cCIKoI8pB9LW3dKtwQFCNY+El j2tQmcOt0Qo4byk2BUdTmTQ5DrRIu56hCu3fsyfNBbYi2yU1+xBVjK6lvclW4pbSITuS Wk1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b="POjXu/Co"; dkim=pass header.i=@codeaurora.org header.s=default header.b=cjAErDUx; 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 z64-v6si15715880pgb.79.2018.07.25.16.18.13; Wed, 25 Jul 2018 16:18: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="POjXu/Co"; dkim=pass header.i=@codeaurora.org header.s=default header.b=cjAErDUx; 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 S1731589AbeGZA3e (ORCPT + 99 others); Wed, 25 Jul 2018 20:29:34 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:44008 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731515AbeGZA3e (ORCPT ); Wed, 25 Jul 2018 20:29:34 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id D65B360B11; Wed, 25 Jul 2018 23:15:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1532560539; bh=FOoQYDNMd4CA/tCAHrwJLafeYwxz7FMrYGZ1CPZhz6c=; h=From:To:Cc:Subject:Date:From; b=POjXu/CoPIJEpk0KrPrTOtnx321adFAx55anoHB3wDNATWOD9oblNG9vH/KmdJQic 7sKTpdyAaRgMfrs5TeqpNhp/CwEzswjpi51aT8J6cHWpqrz7g1sJEICo9etufaC8pm INhiAgv0Wndp6XzGjjreSZRGPMhZL3rmnrPuS6ps= 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 3CBA5605BD; Wed, 25 Jul 2018 23:15:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1532560538; bh=FOoQYDNMd4CA/tCAHrwJLafeYwxz7FMrYGZ1CPZhz6c=; h=From:To:Cc:Subject:Date:From; b=cjAErDUx1a4/rTckvYNgnDCsUz4q6ceeFdy0Tc75/IP1xFTgCQ07L3zpzCntxxFiX h0M7iL2tdas2IIIo6cfrz1i/InfEXbIuO4goplhrvX49aFjQr3SeFqKHLb9pTz9JD+ /zy7/XzwqcMY+YvDQcWi9AHAe0dxKrnb+YaZ2q+Q= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 3CBA5605BD 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 v1] checkpatch: check for #if 0/#if 1 Date: Wed, 25 Jul 2018 16:14:05 -0700 Message-Id: <1532560446-15827-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 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..72513c2 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 #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