Received: by 10.223.164.221 with SMTP id h29csp3060526wrb; Tue, 3 Oct 2017 16:27:34 -0700 (PDT) X-Received: by 10.98.55.3 with SMTP id e3mr9136135pfa.215.1507073254011; Tue, 03 Oct 2017 16:27:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507073254; cv=none; d=google.com; s=arc-20160816; b=EPdJONFxX2iTnAdEC4MxZV6JyvKVZtCD+gupOgb8dpc87koRCByIpMyHUl5Oo9gYM6 pdAMlonzoGedQSpOvG0x5umqM74kjA8yLm+l8KKluYST/IBNV3NbuSDaWpHX64trOsE3 OVTyA7Vs10MTgsYAHLparrk7YNlytrVkWuyK41NhKJYA73/P1OnV8LTgpj+S8c6yv7RL Qd88ocS6rkTb6c5FbfzMBqovBYVbBnE2N/llvedBJQTYFrJMEyrXBI6vhg9EFaYv0Ht7 9/NY7rYAcCNXG4daTlHYp61pxcTZ6uZl6AsP+EuoW1NfEt955X1xJTcLNGtAXA6wRHVE eJsg== 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 :dkim-signature:arc-authentication-results; bh=7AL+3MUCATxMMU/pnYS5VrUfCzC1Odma9eab9522+HE=; b=0CSXXfqGv8lJukasZbHVE4ycUemo7vb2hf/rY7aOFU/JuICzx0gkSiuuCzV42KJ7pl 4BVq3orhis1TRGMa4E4ULh97RptfjLFpMuaxaiC2r/gXOzmzlD6EUem6q4usA/6DoNf/ 5u5R5KYpNwdRVv4w0TFXB3XEWx+JYQO8w6ipwJcv7Cksfqwmt/w1udvwOTIfS1UmLjpw HaLWwZtYPfGvlAwJdmcrDpKZROhCYYqLJvxAcLxL30YXIPjTUapS2VP+MQeXBHaufSO7 ucFT+QfxUGZLfCSA16zxLLnC2BWUK+RXn9rTrxRqVDjBBGeRqvQ7s3CrcePLFp/i3kYG Ooog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=S9jEeTDR; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f30si128215plf.744.2017.10.03.16.27.19; Tue, 03 Oct 2017 16:27:33 -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=@gmail.com header.s=20161025 header.b=S9jEeTDR; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751477AbdJCX0n (ORCPT + 99 others); Tue, 3 Oct 2017 19:26:43 -0400 Received: from mail-lf0-f66.google.com ([209.85.215.66]:48786 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750865AbdJCX0l (ORCPT ); Tue, 3 Oct 2017 19:26:41 -0400 Received: by mail-lf0-f66.google.com with SMTP id q132so11498648lfe.5; Tue, 03 Oct 2017 16:26:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=7AL+3MUCATxMMU/pnYS5VrUfCzC1Odma9eab9522+HE=; b=S9jEeTDRUqQVkNF/8uDXQmNqltt2yppc3e38thSkAZYIFMmSYzKZ23ZzFgSIu7fdmJ 2o4SXWkJ4zrxgMOuy/aRV9oxnHQiVp2E9aRHZfKHSg/W+399ZazVAtWr0vTn1bNgSQO9 RbVXVF9yNjSxPBz0UWbAUZsCHozI9y2ytUvXUccGETSdJJWbezYCDPW+Nj5BjG4zrep8 B6/p2DdFVq4z6+yeVQZv6l9gwoDTkcErW9g15a/JrsxwXaIl8GpJNFRZRmeofDw+TTrW 0QsnCt3rRW0GTQsxGBtr0LDNRd2bdVr6F10t1AvAKq1PMtI3u03egZZ+5Rl0nMM1HIhm TZMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=7AL+3MUCATxMMU/pnYS5VrUfCzC1Odma9eab9522+HE=; b=MxmaW0ewU4bIGDR1hSe0lXS1jNG/edoGKOZ5V6AZ1qCKDb251Siw+FJn8dff9kFHcr vKu7VgDUk5w3MDz1dFJGVZ9m2FsgOQgpF5Z4SNCwuZq6JWGE4jqIoBGnjcYohkb0F1Vs NnU+Xtp6B5tqG48aVXd3TKsumO7UOCRfiAdO0mCkTCNIHJF9V1s+xsRSJ0tsRp9hpb8S 4wR259xX324PbYJeuCYTRXu11tJDlaFO/9A+mjWZTTeY7RM1lPbqZX5D7pYgcb7KggiR Pd1qHU3+ZLjhoyv5XvmQTzzABUriYSq8C9gRIBvNAflS2QrkTF6rXCFkb4Slh1sKrbzU sq2g== X-Gm-Message-State: AMCzsaVpkJVUmxq0/KFGmSctaVxaILA2kD/5g5WB9Cw6Ryd/aNuYjjEp r8mEP6+nZXTxOMMreyYqcGw= X-Google-Smtp-Source: AOwi7QAleVDW+5jVRwK2F/OjdQNzc73URSXKZCyfXaZAzvSb+HhNrbRGyiuk4RkYjj5WBC9+dIzreA== X-Received: by 10.25.204.148 with SMTP id c142mr3329291lfg.49.1507073200194; Tue, 03 Oct 2017 16:26:40 -0700 (PDT) Received: from huvuddator.lan (ua-213-112-0-22.cust.bredbandsbolaget.se. [213.112.0.22]) by smtp.gmail.com with ESMTPSA id d63sm2188844lfg.20.2017.10.03.16.26.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 03 Oct 2017 16:26:39 -0700 (PDT) From: Ulf Magnusson To: yann.morin.1998@free.fr, linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, arnd@arndb.de, Ulf Magnusson Subject: [PATCH] kconfig: Warn if choice default is not in choice Date: Wed, 4 Oct 2017 01:25:46 +0200 Message-Id: <1507073146-19847-1-git-send-email-ulfalizer@gmail.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This will catch mistakes like in the following real-world example, where a "CONFIG_" prefix snuck in, making an undefined symbol the default: choice prompt "Compiler optimization level" default CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE config CC_OPTIMIZE_FOR_PERFORMANCE ... config CC_OPTIMIZE_FOR_SIZE ... endchoice This now prints the following warning: init/Kconfig:1036:warning: choice default symbol 'CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE' is not contained in the choice Cases where the default symbol belongs to the wrong choice are also detected. (The mistake is harmless here: Since the default symbol is not visible, the choice falls back on using the first visible symbol as the default, which is CC_OPTIMIZE_FOR_PERFORMANCE, as intended.) Discovered while playing around with Kconfiglib (https://github.com/ulfalizer/Kconfiglib). Signed-off-by: Ulf Magnusson --- scripts/kconfig/menu.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index e935793..ce88de8 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -252,6 +252,16 @@ static void sym_check_prop(struct symbol *sym) "'%s': number is invalid", sym->name); } + if (sym_is_choice(sym)) { + struct property *choice_prop = + sym_get_choice_prop(sym2); + + if (!choice_prop || + prop_get_symbol(choice_prop) != sym) + prop_warn(prop, + "choice default symbol '%s' is not contained in the choice", + sym2->name); + } break; case P_SELECT: case P_IMPLY: -- 2.7.4 From 1586050257461454745@xxx Wed Dec 06 15:49:55 +0000 2017 X-GM-THRID: 1586050257461454745 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread