From patchwork Mon Feb 14 03:19:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 12744852 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7C6EEC433EF for ; Mon, 14 Feb 2022 03:20:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230124AbiBNDUJ (ORCPT ); Sun, 13 Feb 2022 22:20:09 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:52868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229488AbiBNDUJ (ORCPT ); Sun, 13 Feb 2022 22:20:09 -0500 Received: from conuserg-12.nifty.com (conuserg-12.nifty.com [210.131.2.79]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 51AE9517CF; Sun, 13 Feb 2022 19:20:02 -0800 (PST) Received: from grover.. (133-32-232-101.west.xps.vectant.ne.jp [133.32.232.101]) (authenticated) by conuserg-12.nifty.com with ESMTP id 21E3JJ7a001202; Mon, 14 Feb 2022 12:19:19 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com 21E3JJ7a001202 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1644808759; bh=ql8+b3TEYomACRoOIs8g23qHNaRl+z76CCcop7mRJqI=; h=From:To:Cc:Subject:Date:From; b=htKOIDI5i7hKnZkGAg0/MKZx3Bp7CN1FTfRppi4pIpLyTtEn91ZY8sFxsewY2ylPN xXDOl+CTQvrekzEuLVRfZ4VtKcbp+mhlCuqxtsmDdUPOZ94gImkbpwTVk2UyPfoaCX Ma48G/GstG8NC6I16Gy7mcqCXBJU4wlbjO63OFgy++R2LRZ3vvX6BjMT9vJlN5QB/I K8O1/g86KDo3GLUT9cRXooa1ozyyKchuEzofouONSlGUu/4rDTmK2PRJ9ZG19Hq9Cv 3YRsTFk3msIHRczGN5mVNZV5387Ee4X9k1NCkpPplC0DxvDpw3MGW6Lu5wwf2N767R PKEoVe4UROjoQ== X-Nifty-SrcIP: [133.32.232.101] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH] kconfig: fix missing '# end of' for empty menu Date: Mon, 14 Feb 2022 12:19:18 +0900 Message-Id: <20220214031918.2407212-1-masahiroy@kernel.org> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Currently, "# end of ..." is inserted when the menu goes back to its parent. Hence, an empty menu: menu "Foo" endmenu ... ends up with unbalanced menu comments, like this: # # Foo # Let's close the menu comments properly: # # Foo # # end of Foo Signed-off-by: Masahiro Yamada --- scripts/kconfig/confdata.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index d3c3a61308ad..36fd254fcaa1 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -903,19 +903,20 @@ int conf_write(const char *name) menu = menu->list; continue; } - if (menu->next) + +end_check: + if (!menu->sym && menu_is_visible(menu) && menu != &rootmenu && + menu->prompt->type == P_MENU) { + fprintf(out, "# end of %s\n", menu_get_prompt(menu)); + need_newline = true; + } + + if (menu->next) { menu = menu->next; - else while ((menu = menu->parent)) { - if (!menu->sym && menu_is_visible(menu) && - menu != &rootmenu) { - str = menu_get_prompt(menu); - fprintf(out, "# end of %s\n", str); - need_newline = true; - } - if (menu->next) { - menu = menu->next; - break; - } + } else { + menu = menu->parent; + if (menu) + goto end_check; } } fclose(out);