Received: by 10.223.176.5 with SMTP id f5csp2396772wra; Thu, 8 Feb 2018 13:23:53 -0800 (PST) X-Google-Smtp-Source: AH8x224aBEfFZWvws3eTOHI4TfGU+3k/ltABlIJjSv4gSHM9dG8XcjgG0o8QOO17tUlzNxPr1Bc3 X-Received: by 10.101.72.197 with SMTP id o5mr418702pgs.303.1518125033852; Thu, 08 Feb 2018 13:23:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518125033; cv=none; d=google.com; s=arc-20160816; b=iuosCWhW78zVXuGBDsDfCiSlQf1FTYCpSPX9XTM8jgndPlOGG6aPx05xKrDyPTAAJq XxNsEY5xvm2uwiaUcwhXJ2s1ucU+eEQke0gDaVZnghUIdmSQG5LRc48XMXz8DIv/316i dqWc80xbUctz5s0C6kY1n1rb9FbyiQAn+zoYpVFzUYWr0DGz9krAcGA3C5FC0n2YjuIB uB4yHoqWoUgbqwITzvADmc2RatD1Vtx7WXSMM868ItrKkR9Hp+yNceIM3jSXQx+//1VM hWcOUP6YHbd2Ms/xrSTFOp8aDRo/sMoqIKz3QuXgK4MBAtyCETeGQHgSoY0dgIPVUoGI XkNg== 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=ohS2V8dS80nLrgvWurcdwBJDsxnbnwgOP/WDJqF6H2Q=; b=Si3sliVIJXfvpMqKfa81idSgn9JgEt3Ti5WMGrR8G4HOK+s9Y4RldMBN+aIaAqZNzT V5pxM5gmCWpkW0lXYvycnuZSgSoE7qeIrkMjxSalcdR5qHxEWraI6Yv+2gW/2ZTJobko UfYjJQMFGlgYCurbqY++SUPlBoWxXz8TtZ6PLYq/QhbnAbVMxlmO8UHYOKwqD4B57EAp 8s2uOE2sEcp2oDDoEYFwxWlTOIIeosDzHL2HaGxqCNP00BvcxKQKWZyJjGY8DFnuaQi2 F2fGX7QSjaDIVMBP99dMZC3meuLI2JWGVJYg3hCvCgel+ayZm5jLBSm8jEi9l/KjY1eh RVgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Iv7RsJ9y; 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=QUARANTINE 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 z1-v6si150728pll.381.2018.02.08.13.23.38; Thu, 08 Feb 2018 13:23:53 -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=@gmail.com header.s=20161025 header.b=Iv7RsJ9y; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752508AbeBHVVg (ORCPT + 99 others); Thu, 8 Feb 2018 16:21:36 -0500 Received: from mail-ua0-f196.google.com ([209.85.217.196]:44886 "EHLO mail-ua0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752135AbeBHVVe (ORCPT ); Thu, 8 Feb 2018 16:21:34 -0500 Received: by mail-ua0-f196.google.com with SMTP id x4so3837322uaj.11; Thu, 08 Feb 2018 13:21:34 -0800 (PST) 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=ohS2V8dS80nLrgvWurcdwBJDsxnbnwgOP/WDJqF6H2Q=; b=Iv7RsJ9yGqc652zL0fL6QUqZm9Z6ZCWOR505RToTaR8DrzRZ9Ouqaw/pTN14aT1PrB DY9MuEXuPe+iI8JJSNspTklfaPtgzMKxTauQz7Ln/yoYG/oAoehDOQnbk3oR+lk8O+Y9 1CfMTL0+W2UI06J3A6CdT6OEKUQf4ullA0HNOrKJfX63Q1WWckyO9SsuhB9O8oCmzKFa PhEeR2FyJvoin2P4g+o+R1/beZOs+q1No6pqyK6vPL56f6mxvH1+/gCsJpKbxzmONs7V EVsoirsTUBIBa7o++ZN2AG4u7bjyM8GiLV72aU4sj40IXK8HL+XU6VG3Qjxsb90Z41qm W0TA== 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=ohS2V8dS80nLrgvWurcdwBJDsxnbnwgOP/WDJqF6H2Q=; b=F8ya1ToyqXQqklHFP2uPJYAQXtq7Mukf8VY6V6+9J72xjxQNSHomRe40yFXu7otHC0 IJBksnJkrzcIeV3tVcFZWs0kLw0AAmiMsE5MKlAYudQXyB53ces/J+3tIIWE/1M95dB+ noSKKixg6CQNPBx0km6Gs8AD48kE9tMsVlLV7NsXufJCnznwLjZuLEvulV28bmxUNpL0 bdB4shEHYWJwJncp8vER5B2mWDMTyUkNVOgBRv110D0tGzYPLkEM1CWzjBL7iQ7ykt/I 1kKrqs4D0GlqFvhB27iUUzPZRtfkUDN0ST3xfoWvyGGus9MSyGEnk04jIrH4rtC5jaVT 5sKQ== X-Gm-Message-State: APf1xPD3IJsKCJkLOS0QkNMB1NqlWM9VK2ooJVvFMLEgAGaIVUS78T4o 26gFG3G8FqBjWlh9KmSTgYdyp+dNjRrg0dZXlpg= X-Received: by 10.159.34.102 with SMTP id 93mr609113uad.74.1518124893881; Thu, 08 Feb 2018 13:21:33 -0800 (PST) MIME-Version: 1.0 Received: by 10.103.70.21 with HTTP; Thu, 8 Feb 2018 13:21:33 -0800 (PST) In-Reply-To: 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: Ulf Magnusson Date: Thu, 8 Feb 2018 22:21:33 +0100 Message-ID: Subject: Re: [PATCH 02/14] kconfig: do not write choice values when their dependency becomes n To: Masahiro Yamada 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 On Thu, Feb 8, 2018 at 3:46 AM, Ulf Magnusson wrote: > On Thu, Feb 8, 2018 at 3:42 AM, Masahiro Yamada > wrote: >> 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. >> > > Could just mod the existing patch. Saves the hassle of creating a new one. :) > >> I confirmed the same results were produced. >> >> -- >> Best Regards >> Masahiro Yamada > > Cheers, > Ulf I might've misunderstood. Should I prepare a separate patch that adds the simplification, assuming your patch? I'm fine with whatever approach. Could always say "includes a simplification suggested by..." if you go with a single patch and want to give credit (which isn't required). Cheers, Ulf