From patchwork Fri Mar 19 19:32:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Lobakin X-Patchwork-Id: 12151789 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 562FAC433E3 for ; Fri, 19 Mar 2021 19:33:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 26A756197E for ; Fri, 19 Mar 2021 19:33:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230449AbhCSTcl (ORCPT ); Fri, 19 Mar 2021 15:32:41 -0400 Received: from mail-40133.protonmail.ch ([185.70.40.133]:60886 "EHLO mail-40133.protonmail.ch" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230468AbhCSTcS (ORCPT ); Fri, 19 Mar 2021 15:32:18 -0400 Date: Fri, 19 Mar 2021 19:32:08 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail; t=1616182335; bh=9VUmIi1F2KHRER9ZPKT/CtMwZl7ibuhBjeNeVtnTB7I=; h=Date:To:From:Cc:Reply-To:Subject:In-Reply-To:References:From; b=PZWFLKKr7qHfHgEOTKyn1JZPkr3cdQGkwOgIGihn78WrspEgMvi14MAWXtE/lBLVt N3MF7k6Wo1e9WrVZnVm6AaJt7tI8qZKGlZPlN6Vco6mtyhnF1EQn4XsAq2Wbf8r9QF oPdxUKae89Z41PsKAU+jPL6H59F2sNWNEMkIugorYcik1GTzxwm2sGEowj3uH+Lwm5 IX/FnZ99nNsTVUTao5rDhjJFi0a2T6GrUTqdnIeUI8qqAD1rA0d1R5jFQ2CYbqKU8n KTU5mTmgwMfoLtygFeAHXF+8bZXYfzJwHMbBFv2542EJvpgNQ/qZ5QcrbYa8CwUpbo DAuRYtXcG3Txw== To: Masahiro Yamada From: Alexander Lobakin Cc: Alexander Lobakin , linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org Reply-To: Alexander Lobakin Subject: [PATCH 1/2] kconfig: fence choices and menuconfigs with comments in .config too Message-ID: <20210319193150.267510-2-alobakin@pm.me> In-Reply-To: <20210319193150.267510-1-alobakin@pm.me> References: <20210319193150.267510-1-alobakin@pm.me> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Comment blocks are now generated in .config only for menus. Provide them for choices and menuconfigs too to greatly improve dotconfig readability. Choices before: CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE=y CONFIG_HAVE_LD_DEAD_CODE_DATA_ELIMINATION=y Choices after: CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE=y CONFIG_HAVE_LD_DEAD_CODE_DATA_ELIMINATION=y Menuconfigs before: CONFIG_RESET_CONTROLLER=y Menuconfigs after: CONFIG_RESET_CONTROLLER=y Signed-off-by: Alexander Lobakin --- scripts/kconfig/confdata.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) -- 2.31.0 diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 2568dbe16ed6..e4f0a21fd469 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -869,17 +869,20 @@ int conf_write(const char *name) menu = rootmenu.list; while (menu) { sym = menu->sym; - if (!sym) { - if (!menu_is_visible(menu)) - goto next; + + if ((!sym || (sym->flags & SYMBOL_CHOICE) || + (menu->prompt && menu->prompt->type == P_MENU)) && + menu_is_visible(menu)) { str = menu_get_prompt(menu); fprintf(out, "\n" "#\n" "# %s\n" "#\n", str); need_newline = false; - } else if (!(sym->flags & SYMBOL_CHOICE) && - !(sym->flags & SYMBOL_WRITTEN)) { + } + + if (sym && !(sym->flags & SYMBOL_CHOICE) && + !(sym->flags & SYMBOL_WRITTEN)) { sym_calc_value(sym); if (!(sym->flags & SYMBOL_WRITE)) goto next; @@ -896,11 +899,11 @@ int conf_write(const char *name) menu = menu->list; continue; } - if (menu->next) - menu = menu->next; - else while ((menu = menu->parent)) { - if (!menu->sym && menu_is_visible(menu) && - menu != &rootmenu) { + + do { + if (((menu->sym && menu->sym->flags & SYMBOL_CHOICE) || + (menu->prompt && menu->prompt->type == P_MENU)) && + menu_is_visible(menu) && menu != &rootmenu) { str = menu_get_prompt(menu); fprintf(out, "# end of %s\n", str); need_newline = true; @@ -909,7 +912,7 @@ int conf_write(const char *name) menu = menu->next; break; } - } + } while ((menu = menu->parent)); } fclose(out);