From patchwork Tue Sep 30 18:09:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Bolle X-Patchwork-Id: 5006371 Return-Path: X-Original-To: patchwork-linux-kbuild@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9C5789F327 for ; Tue, 30 Sep 2014 18:09:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BC7512011B for ; Tue, 30 Sep 2014 18:09:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A00BD200F2 for ; Tue, 30 Sep 2014 18:09:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751729AbaI3SJr (ORCPT ); Tue, 30 Sep 2014 14:09:47 -0400 Received: from cpsmtpb-ews09.kpnxchange.com ([213.75.39.14]:57470 "EHLO cpsmtpb-ews09.kpnxchange.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751347AbaI3SJq (ORCPT ); Tue, 30 Sep 2014 14:09:46 -0400 Received: from cpsps-ews25.kpnxchange.com ([10.94.84.191]) by cpsmtpb-ews09.kpnxchange.com with Microsoft SMTPSVC(7.5.7601.17514); Tue, 30 Sep 2014 20:09:44 +0200 Received: from CPSMTPM-TLF103.kpnxchange.com ([195.121.3.6]) by cpsps-ews25.kpnxchange.com with Microsoft SMTPSVC(7.5.7601.17514); Tue, 30 Sep 2014 20:09:44 +0200 Received: from [192.168.10.104] ([77.173.140.92]) by CPSMTPM-TLF103.kpnxchange.com with Microsoft SMTPSVC(7.5.7601.17514); Tue, 30 Sep 2014 20:09:43 +0200 Message-ID: <1412100583.21730.31.camel@x220> Subject: [PATCH 1/1] kconfig: warn if an unknown symbol is selected From: Paul Bolle To: "Yann E. MORIN" Cc: Michal Marek , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org Date: Tue, 30 Sep 2014 20:09:44 +0200 X-Mailer: Evolution 3.10.4 (3.10.4-4.fc20) Mime-Version: 1.0 X-OriginalArrivalTime: 30 Sep 2014 18:09:44.0032 (UTC) FILETIME=[B63A4600:01CFDCD9] X-RcptDomain: vger.kernel.org Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP A select of an unknown symbol is basically treated as a nop and is silently skipped. This is annoying if the selected symbol contains a typo. It can also hide the fact that a treewide symbol cleanup was only done partially. There are also a few cases were this might have been done on purpose. But that anti-pattern should be discouraged. Almost all select statements point to a known and reachable symbol. So people will likely assume that any selected symbol is actually set. Selects that violate this assumption can only be spotted by checking multiple Kconfig files, often across architectures. It is unlikely that people will do this regularly. So let's warn when we notice a select of a symbol that is not known in the configuration we're creating. Signed-off-by: Paul Bolle Acked-by: Michal Marek --- First sent as an RFC in https://lkml.org/lkml/2014/9/26/887 (and https://lkml.org/lkml/2014/9/26/886 for the cover letter). Small modification to the commit explanation in comparison to the RFC, but identical patch. Minor edits to the cover-letter too. scripts/kconfig/conf.c | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index fef75fc756f4..de8406287531 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c @@ -446,6 +446,45 @@ static void check_conf(struct menu *menu) check_conf(child); } +static void check_selects(struct menu *menu) +{ + struct symbol *sym, *sel; + struct property *prop; + + while (menu) { + sym = menu->sym; + + if (sym && !sym_is_choice(sym) && + sym->type != S_UNKNOWN && + sym->flags & SYMBOL_WRITE) { + for_all_properties(sym, prop, P_SELECT) { + sel = prop->expr->left.sym; + if (sel->type == S_UNKNOWN && + expr_calc_value(prop->visible.expr) != no) { + fprintf(stderr, "%s:%d:warning: ", + prop->file->name, + prop->lineno); + fprintf(stderr, + "'%s' selects unknown symbol '%s'\n", + sym->name, + sel->name); + } + } + } + + if (menu->list) { + menu = menu->list; + } else if (menu->next) { + menu = menu->next; + } else while ((menu = menu->parent)) { + if (menu->next) { + menu = menu->next; + break; + } + } + } +} + static struct option long_opts[] = { {"oldaskconfig", no_argument, NULL, oldaskconfig}, {"oldconfig", no_argument, NULL, oldconfig}, @@ -681,6 +720,8 @@ int main(int ac, char **av) break; } + check_selects(rootmenu.list); + if (sync_kconfig) { /* silentoldconfig is used during the build so we shall update autoconf. * All other commands are only used to generate a config.