Received: by 10.223.176.5 with SMTP id f5csp1383722wra; Wed, 7 Feb 2018 18:44:18 -0800 (PST) X-Google-Smtp-Source: AH8x226G2J2GyxOH9xlRR/crCh8djxbJ01ZiGoj3nIj+jfhC35NBHaWuuwwEMOsoLXz3lEaFUxsF X-Received: by 10.99.166.2 with SMTP id t2mr5748512pge.234.1518057858638; Wed, 07 Feb 2018 18:44:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518057858; cv=none; d=google.com; s=arc-20160816; b=fFZu4N+RyMegY8rgSFmAdsXZgIRVzmLX4DCxRKqghSBoJL67ON+fyVnKwcnWkniWT2 3RJVp6wcuc2q3Pgcy6cX99FHGS+7wmiYC3TZQE+bJiDr7ekhe8S5wiT1LcqB2ufde8uK MXnYjKm4DZrbpHUcaKN3lJG7cVId5p45dKzzCojpp/3UbPzYQhkz6DC7Hl6QqMLmRV+H VMJurRPTDLsjkxvEvrK4JF0HBEo1HkaatJeaTr6LlSQxsm3yZmpLcykQfnf2IT/vjHkI SLJJaHnb/woc2+KqesqHIZmsufJB/744NmsSOzxQO5XXzzi/fNl+X/l79kbDiSBK0/im UEOA== 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:dkim-filter :arc-authentication-results; bh=yap983M9UEA9YfZ2etakViDM2fA9I/vL5crctb77zzs=; b=OTVEF6Ps2hA007Xzy7VFoYTuCflfiNMmqinl9VIg+12Prynwrs3dOXXtKWP75KozZa UgVVzd0577D9QX2coFaQDEtvrooNWNawQXQiO0zz4QicD7eCsJQycpLNBr3AZc1ye7pW dXh8G0kUdKg8+GNHbj835Uhz+UdMS84oBJcnHK5V2ktlTrHDhU2l0zAeQnwsRl+SM5yD x446aS5kxxIid+juBdlNxfIU7ZR5Bg1EdV/Adex3ZI3RJycJO4UjJycDEJQGNH1vqqI8 uBtvxUfIWwlcgfA1NZT9nuFA7hS/vMGvsvNg72PQLFsUBRda/jPbzSloFgTF+7YJzrPk pFOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=SvzQmyRB; 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 z1si1753558pgb.461.2018.02.07.18.44.04; Wed, 07 Feb 2018 18:44:18 -0800 (PST) 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=@nifty.com header.s=dec2015msa header.b=SvzQmyRB; 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 S1752110AbeBHCn1 (ORCPT + 99 others); Wed, 7 Feb 2018 21:43:27 -0500 Received: from conssluserg-05.nifty.com ([210.131.2.90]:25482 "EHLO conssluserg-05.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751700AbeBHCnZ (ORCPT ); Wed, 7 Feb 2018 21:43:25 -0500 Received: from mail-vk0-f47.google.com (mail-vk0-f47.google.com [209.85.213.47]) (authenticated) by conssluserg-05.nifty.com with ESMTP id w182h0j6023673; Thu, 8 Feb 2018 11:43:00 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-05.nifty.com w182h0j6023673 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1518057781; bh=yap983M9UEA9YfZ2etakViDM2fA9I/vL5crctb77zzs=; h=In-Reply-To:References:From:Date:Subject:To:Cc:From; b=SvzQmyRBagGz3QWges+DMDJ57B6M1Y174brLJQ8JaHdAq7jWH7shmnGXlKvC2W7il vCFWUTj6gGL/4LSuvODOjamiTbrQ9BrgRcILytmF9nhYOqrtMQNIqWIAS126ZYrqOJ GwqF6iZJY1C/j5n9yTd8S/6r4cGoT+M/JmG5Vzs8hXxqHyUzxSjFoE1m1nVOoLQE4y fz5ckXDsKUBevq9XHBT9K1Ig0EHNLRPpT9oehvqloM+jYcndoF51xS73TDH5L6b+V5 VyipoNYXFBR+pxhk6omm4cxzoL4QndSrQz+7Q7J0MpQJrOQL6ZA9FpwoGF1X7YmkOO AbVRwVfZCbeGA== X-Nifty-SrcIP: [209.85.213.47] Received: by mail-vk0-f47.google.com with SMTP id x203so1876348vkx.10; Wed, 07 Feb 2018 18:43:00 -0800 (PST) X-Gm-Message-State: APf1xPD8uuWAn3tsztT8RI1VUi5sXXRsx5QsiJwPeEB437iYWP5McRbe E9UToD7MBi9PEwvjxeqKhOne3FH4uoP/byvSANM= X-Received: by 10.31.151.147 with SMTP id z141mr7156173vkd.113.1518057779511; Wed, 07 Feb 2018 18:42:59 -0800 (PST) MIME-Version: 1.0 Received: by 10.176.83.212 with HTTP; Wed, 7 Feb 2018 18:42:19 -0800 (PST) In-Reply-To: <20180207225551.imdp6gqbdwzyvhwm@huvuddator> References: <1517877294-4826-1-git-send-email-yamada.masahiro@socionext.com> <1517877294-4826-3-git-send-email-yamada.masahiro@socionext.com> <20180207225551.imdp6gqbdwzyvhwm@huvuddator> From: Masahiro Yamada Date: Thu, 8 Feb 2018 11:42:19 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 02/14] kconfig: do not write choice values when their dependency becomes n To: Ulf Magnusson Cc: Linux Kbuild mailing list , Greg Kroah-Hartman , Andrew Morton , Nicolas Pitre , "Luis R . Rodriguez" , Randy Dunlap , Sam Ravnborg , Michal Marek , Linus Torvalds , "Luis R. Rodriguez" , Linux Kernel Mailing List , Heinrich Schuchardt 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 2018-02-08 7:55 GMT+09:00 Ulf Magnusson : > On Tue, Feb 06, 2018 at 09:34:42AM +0900, Masahiro Yamada wrote: >> "# CONFIG_... is not set" for choice values are wrongly written into >> the .config file if they are once visible, then become invisible later. >> >> Test case >> --------- >> >> ---------------------------(Kconfig)---------------------------- >> config A >> bool "A" >> >> choice >> prompt "Choice ?" >> depends on A >> >> config CHOICE_B >> bool "Choice B" >> >> config CHOICE_C >> bool "Choice C" >> >> endchoice >> ---------------------------------------------------------------- >> >> ---------------------------(.config)---------------------------- >> CONFIG_A=y >> ---------------------------------------------------------------- >> >> With the Kconfig and .config above, >> >> $ make config >> scripts/kconfig/conf --oldaskconfig Kconfig >> * >> * Linux Kernel Configuration >> * >> A (A) [Y/n] n >> # >> # configuration written to .config >> # >> $ cat .config >> # >> # Automatically generated file; DO NOT EDIT. >> # Linux Kernel Configuration >> # >> # CONFIG_A is not set >> # CONFIG_CHOICE_B is not set >> # CONFIG_CHOICE_C is not set >> >> Here, >> >> # CONFIG_CHOICE_B is not set >> # CONFIG_CHOICE_C is not set >> >> should not be written into the .config file because their dependency >> "depends on A" is unmet. >> >> Currently, there is no code that clears SYMBOL_WRITE of choice values. >> >> Clear SYMBOL_WRITE for all symbols in sym_calc_value(), then set it >> again after calculating visibility. >> >> Signed-off-by: Masahiro Yamada >> --- > >> scripts/kconfig/symbol.c | 4 ++-- >> 1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c >> index c9123ed..5d6f6b1 100644 >> --- a/scripts/kconfig/symbol.c >> +++ b/scripts/kconfig/symbol.c >> @@ -371,8 +371,7 @@ void sym_calc_value(struct symbol *sym) >> sym->curr.tri = no; >> return; >> } >> - if (!sym_is_choice_value(sym)) >> - sym->flags &= ~SYMBOL_WRITE; >> + sym->flags &= ~SYMBOL_WRITE; >> >> sym_calc_visibility(sym); >> >> @@ -385,6 +384,7 @@ void sym_calc_value(struct symbol *sym) >> if (sym_is_choice_value(sym) && sym->visible == yes) { >> prop = sym_get_choice_prop(sym); >> newval.tri = (prop_get_symbol(prop)->curr.val == sym) ? yes : no; >> + sym->flags |= SYMBOL_WRITE; >> } else { >> if (sym->visible != no) { >> /* if the symbol is visible use the user value >> -- >> 2.7.4 >> > > Reviewed-by: Ulf Magnusson > > There's a possible simplification here: > > All defined symbols, regardless of type, and regardless of whether > they're choice value symbols or not, always get written out if they have > non-n visibility. Therefore, the sym->visible != no check for > SYMBOL_WRITE can be moved to before the symbol type check, which gets > rid of two SYMBOL_WRITE assignments and makes it clear that the logic is > the same for all paths. > > This is safe for symbols defined without a type (S_UNKNOWN) too, because > conf_write() skips those (plus they already generate a warning). > > This matches how I do it in the tri_value() function in Kconfiglib: > https://github.com/ulfalizer/Kconfiglib/blob/master/kconfiglib.py#L2574. > SYMBOL_WRITE corresponds to _write_to_conf. > > I've included a patch below. I tested it with the Kconfiglib test suite, > which verifies that the C implementation still generates the same > .config file for all defconfig files as well as for > all{no,yes,def}config, for all ARCHes. > > (The Kconfiglib test suite runs scripts/kconfig/conf and compares its > output against it, which means it doubles as a regression test for the C > tools.) Thank you for this. This is simpler, and please let me take it. I confirmed the same results were produced. -- Best Regards Masahiro Yamada