Received: by 10.223.164.221 with SMTP id h29csp119627wrb; Wed, 4 Oct 2017 20:13:39 -0700 (PDT) X-Received: by 10.99.117.10 with SMTP id q10mr14088899pgc.288.1507173218960; Wed, 04 Oct 2017 20:13:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1507173218; cv=none; d=google.com; s=arc-20160816; b=eNWUqZjZbkc8GcVLvNN88Hlhmr45zcAmhbu/zh2eV0pY2k/G1GeGA3TnIk9iFiQig3 vzMjctgrG8pCU0bpClDZnGXfIBMIeFBScCwXL3gMzUcZG5nRlaJNOoLWN1i6idfrcvz+ zEvFssEn3byiZeMuRHJCCu5AmLbkPMME8bMqk/jSt8EgAHbWTIvWAgq4V1mYIh0xq3NV k0qfoEvQjOirhhPUoBgcHh0JuGdQJiwBUMJGQDpAStPLg/FcP3tYrXBXkJGQsYIdKKwl f28vsV9IETj0KmHZAh76Y6d3wnti6qVYXzU/K7GgkDKNRm3vvZP5/AOr3tQ6WDqQK1aW Z43A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=sQM1hOaq5CTAB0PU3tlmipius6n4uXOP0B64X1AvQ24=; b=xByQi2QSk0+MBr7gmHvvhx+RKfYlZPXjMB5dwlD//6EsASUY2DE+M3uNl4pJKHDI/8 lEWHMaVcqBs5P55cCfuhKzSgcdANrAaXYB192T9fVPwddJphfNGP6tOoivVToW5o5k3y MT7a2q1WU/wPvXk6+2oKEDuUKv4KflW883QbI2URnn1sHNiZsfIWgi2XpDjrOc0sPemv PbAfBzSJ0mv46tfYJKPSVWgWTGHr11EW5pUbagybM0XNCLYFHhjzS8A9NHvNx2NGiUlt oITK6tLbydPD+KIlNHHGDh5aXmxOjbMjz/YX9cPg0+OSVHrC8YeIMN2ziFYWnDoEcVTX 1s3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ckY2/Y8k; 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 204si418459pga.745.2017.10.04.20.13.25; Wed, 04 Oct 2017 20:13:38 -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=ckY2/Y8k; 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 S1751505AbdJEDMT (ORCPT + 99 others); Wed, 4 Oct 2017 23:12:19 -0400 Received: from mail-ua0-f194.google.com ([209.85.217.194]:32919 "EHLO mail-ua0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751267AbdJEDMR (ORCPT ); Wed, 4 Oct 2017 23:12:17 -0400 Received: by mail-ua0-f194.google.com with SMTP id 103so2326103uas.0; Wed, 04 Oct 2017 20:12:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=sQM1hOaq5CTAB0PU3tlmipius6n4uXOP0B64X1AvQ24=; b=ckY2/Y8kjZT1UtxAr9EOdAbws6RF+JV4NCBEXEKhjVll/iIIOBGIWvU9BhqNtUFKw9 iwZ+c0bFgD19+8keVNmd/2n2WnNmgFrOfJNZ6ZW9sV0f9vCW9f9AsZ0LioyF7Dibg1OC pOC8iCpraMmU1DqgLRrvGvkAMJC4IFT1Pgxlqob3A2u6ndlEYLHH7bxp7UoKsEyL0S10 drsv52egMvIpLSHbR7G/vx6AQw8O7Zoi6xhVkkcgQIZiJzAkjK7gAuUbuNAy3K/1naUE Zbm7RBJw1+wYAxNA2JIfuapUcJ+CwK3tgOzIbPZUlgzSEz68bIjytUjcoUJLLO32KSTq n7Jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=sQM1hOaq5CTAB0PU3tlmipius6n4uXOP0B64X1AvQ24=; b=M6yv0Nd5hWfpCNcj2gTuGehUW/mC7GUHytxutKG1AgVY3Cx0OWyGucf+kx3RG91hTF h97ZNDAHa0CepZUq5D5nrBI1L8BflwUMK/74eBwUpoViMCu23HVQQ1rjyQw4qqeNzlc7 v+wuFga/KMaF0+jL9+MYlWaruPcA5JRhvEMSh3TuZ4cUi3DzF01/ivBZTy0Cg9pStdpe 5nncI4hqUlCwgEOSKU39B8DBh579b/imVylthQzVZDcY1jxrOTInBRhwXz9ZFYAsALHQ 7PTHmLi3t8l//ZCDPZIXYK6sSjE5mIURfMWNoA9TpZ3TWukhPS0cdTlLKDQ+YupzTer4 rQsQ== X-Gm-Message-State: AHPjjUhL9RPbuWm1emk/VkNfMVnXY4WrVNdZiI9U5eh0qZ6w5MMUVTCY Bubpylv0MCsr9L67gUA0T9QFDapylAJaWrYqeVY= X-Google-Smtp-Source: AOwi7QBJxwtgxch+MOieFoOBAEOfx4c7AakTevuYaxhV6rg3Mir0puGc1yks/Tx7sfxmndJnfuEzdYmr5ErCiY36LgE= X-Received: by 10.176.70.153 with SMTP id r25mr14202070uaa.74.1507173136231; Wed, 04 Oct 2017 20:12:16 -0700 (PDT) MIME-Version: 1.0 Received: by 10.103.68.14 with HTTP; Wed, 4 Oct 2017 20:12:15 -0700 (PDT) In-Reply-To: References: <1507073146-19847-1-git-send-email-ulfalizer@gmail.com> From: Ulf Magnusson Date: Thu, 5 Oct 2017 05:12:15 +0200 Message-ID: Subject: Re: [PATCH] kconfig: Warn if choice default is not in choice To: yann.morin.1998@free.fr, linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Arnd Bergmann , Ulf Magnusson , Masahiro Yamada , Arnaud Lacombe Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 4, 2017 at 2:10 AM, Ulf Magnusson wrote: > On Wed, Oct 4, 2017 at 1:25 AM, Ulf Magnusson wrote: >> 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 >> > > A patch to fix the compiler optimization level choice has been > submitted as well: > https://lkml.org/lkml/2017/10/3/991 > > Cheers, > Ulf Adding some CCs just because I forgot. No panic. Cheers, Ulf From 1580283691539720434@xxx Wed Oct 04 00:12:49 +0000 2017 X-GM-THRID: 1580280844694147464 X-Gmail-Labels: Inbox,Category Forums