Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1954244ybi; Thu, 4 Jul 2019 02:41:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqx2XugleMV5Dht0o9nB0/47CE4EaQVw9ca5eJ/k2TOYOFFjYPQYOpEnrIUvGB/qNpfsZ+S+ X-Received: by 2002:a65:4786:: with SMTP id e6mr33946554pgs.448.1562233281452; Thu, 04 Jul 2019 02:41:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562233281; cv=none; d=google.com; s=arc-20160816; b=OaidvAbBrwTVJwFqAmcYPEzwbTuBOMKg7GyaUm5pOgaSpMHsm6puMyE3y90Nnav1eG SoVUPsZE7i54VrlSCcTkyvw6nXiYnwxdEA7ayqzXqEI78nTZ6dNsUXd9xNQRoXHyoplx WbNsU1dD/E8E04Y0J+griZiQZQoaEg2rxDHYT2oQRuKBIJMtdgw6Yt7mkEY9b2ETQIaB VCHK+2rdMpFyP9k+gooFIfKbktqupMZUcbcCTEpbnqK1yL6Rs0YNVLkTWCtbU3FcdxqY NAlRR96hr35aB5LJ1voAURN/I+R9uf+ARQwP+wj3ka5yyF/sX1B7vqxs/PZBC2f5TIbr Fm6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=iinTgjQ+QzjMVzOFbYLwQIHtQOznTgradBG2/uWkNis=; b=0l9vTztrKALdO6nwB7+seTY15l/NrdQotEobCirvyUz+CDBXskXLp8d5aCjpA43L+r EjuTvDrW8XxJTq/M2F+PWNtj7ns0zIEuv+mUpyaV0UDCEQKdZJSxxJBlyqBDCkGCdg65 IIyqDAWEdGI5dhFOUNhdnm71voXYkhyLPJXsOmsmw8kBdmyKYZra52/5ZV2pF6o08MRq DNYwfaBY6APzAZ/dDk/RQ0h+2Xty8QnLieHv+Ckf/uJeGJrAeuBeYBxlHDSbIMF5NA1k pt5Qhyr/Eu9hnhZX1czOUsqLQqR/z8E7n/SkjFg/IU4siSNJX39c8p0BwkSzG+u7HIs9 A45A== ARC-Authentication-Results: i=1; mx.google.com; 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 z24si4817699plo.159.2019.07.04.02.41.06; Thu, 04 Jul 2019 02:41:21 -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; 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 S1727393AbfGDJkk (ORCPT + 99 others); Thu, 4 Jul 2019 05:40:40 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:38817 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1727269AbfGDJkk (ORCPT ); Thu, 4 Jul 2019 05:40:40 -0400 X-UUID: cc07f368726f42b8b1108f7c792871fb-20190704 X-UUID: cc07f368726f42b8b1108f7c792871fb-20190704 Received: from mtkcas08.mediatek.inc [(172.21.101.126)] by mailgw02.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 570256049; Thu, 04 Jul 2019 17:40:27 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs07n2.mediatek.inc (172.21.101.141) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Thu, 4 Jul 2019 17:40:25 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Thu, 4 Jul 2019 17:40:25 +0800 From: Miles Chen To: Andy Whitcroft , Joe Perches CC: , , , Miles Chen , Yingjoe Chen Subject: [PATCH v2] checkpatch: add several Kconfig default value tests Date: Thu, 4 Jul 2019 17:40:24 +0800 Message-ID: <20190704094024.16162-1-miles.chen@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This change adds 3 Kconfig default value tests: 1. discourage default n cases: e.g., default n 2. discourage default "[ynm]" cases: e.g., arch/powerpc/Kconfig: default "y" if PPC_POWERNV arch/powerpc/Kconfig: default "y" if PPC_POWERNV arch/powerpc/Kconfig: default "n" drivers/auxdisplay/Kconfig: default "n" drivers/crypto/Kconfig: default "m" drivers/rapidio/devices/Kconfig: default "n" 3. discourage default \!?EXPERT cases: e.g., drivers/hid/Kconfig: default !EXPERT tested cases: default m default n if ALPHA_EV5 || ALPHA_EV56 || (ALPHA_EV4 && !ALPHA_LCA) default y if ALPHA_QEMU default n if PPC_POWERNV default n default EXPERT default !EXPERT default "m" default "n" default "y" if EXPERT default "y" if PPC_POWERNV test result: WARNING: 'default n' is the default value, no need to write it explicitly. + default n WARNING: Avoid default turn on kernel configs by default !?EXPERT + default EXPERT WARNING: Avoid default turn on kernel configs by default !?EXPERT + default !EXPERT WARNING: Use default [ynm] instead of default "[ynm]" + default "m" WARNING: Use default [ynm] instead of default "[ynm]" + default "n" WARNING: Use default [ynm] instead of default "[ynm]" + default "y" if EXPERT WARNING: Use default [ynm] instead of default "[ynm]" + default "y" if PPC_POWERNV Change since v1: discourage default n$ discourage default "[ynm]" discourage default \!?EXPERT Cc: Joe Perches Cc: Yingjoe Chen Signed-off-by: Miles Chen --- scripts/checkpatch.pl | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 342c7c781ba5..c1de50202a18 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -3005,6 +3005,27 @@ sub process { "Use of boolean is deprecated, please use bool instead.\n" . $herecurr); } +# discourage redundant 'default n' + if ($realfile =~ /Kconfig/ && + $line =~ /^\+\s*default n$/) { + WARN("DEFAULT_VALUE_STYLE", + "'default n' is the default value, no need to write it explicitly.\n" . $herecurr); + } + +# discourage quote: use default [ynm], not default "[ynm]" + if ($realfile =~ /Kconfig/ && + $rawline =~ /^\+\s*default\s*"[ynm]"/) { + WARN("DEFAULT_VALUE_STYLE", + "Use default [ynm] instead of default \"[ynm]\"\n" . $herecurr); + } + +# discourage default \!?EXPERT + if ($realfile =~ /Kconfig/ && + $line =~ /^\+\s*default \!?EXPERT/) { + WARN("DEFAULT_VALUE_STYLE", + "Avoid default turn on kernel configs by default !?EXPERT\n" . $herecurr); + } + if (($realfile =~ /Makefile.*/ || $realfile =~ /Kbuild.*/) && ($line =~ /\+(EXTRA_[A-Z]+FLAGS).*/)) { my $flag = $1; -- 2.18.0