From patchwork Tue Dec 17 04:14:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 11296519 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 44F99138C for ; Tue, 17 Dec 2019 04:14:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 22029206E6 for ; Tue, 17 Dec 2019 04:14:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576556097; bh=cOk6IIlH6PebtbSxCJ8oriLNKUaqEMp/IBEKTp999QU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=Un80303aTP0zWnopxp4JIAIaj/i4GdNSXmBy2C8bW+9/adxg1udhgxji58lsGfIdF QDoNhMnIxgH7Bu9uQWRbwaIjJ5akZQVCEE3sfW6IcFZM+4YFqvauY/j8eX2lkHxD5o fWZ2OYw+l2LXranA6tIR/TlqFjx4scdijGpX5rNA= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727324AbfLQEOw (ORCPT ); Mon, 16 Dec 2019 23:14:52 -0500 Received: from conuserg-12.nifty.com ([210.131.2.79]:49416 "EHLO conuserg-12.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727683AbfLQEOw (ORCPT ); Mon, 16 Dec 2019 23:14:52 -0500 Received: from localhost.localdomain (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-12.nifty.com with ESMTP id xBH4EPAF024524; Tue, 17 Dec 2019 13:14:29 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-12.nifty.com xBH4EPAF024524 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1576556069; bh=zTfsz4q4N5zqvuqTxH8EVK2Vwep22Qgk0oB4uevhHXM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LdvTRScsLP6hfOvy61kc3+9uLpg3c0hbsdIBe+3gew4wfgJvCrAljsUdiU8TyQDUt SC82+xqVm9kmodzGUADghrVn8JNR3MwJd1go3b9kv1Vs1WhFlhXAwrzITP/W2SqYGd Bhzm4TOM39+pcdSPF5+vxXtgxNHuN0SQ63SBfvDwjQFo+Slo82viULRbp4lx4S2K+G O175ZhHxQVfGAXg1IqvWv/Ac6L9mmLjb71WtEdzcHC5/13PVbjdmZebUatBuunXpv5 ILJrfBAR616w0Rc+ZZ/8pWb9TJ6G53AqUVdzUR1BlEWMhOnREk3jq+XOtQ8fMp6YyA CpG90L5J8s2eA== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Ulf Magnusson , Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH 5/8] kconfig: move prompt handling to menu_add_prompt() from menu_add_prop() Date: Tue, 17 Dec 2019 13:14:20 +0900 Message-Id: <20191217041424.29285-6-masahiroy@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191217041424.29285-1-masahiroy@kernel.org> References: <20191217041424.29285-1-masahiroy@kernel.org> Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org menu_add_prompt() is the only function that calls menu_add_prop() with non-NULL prompt. So, the code inside the if-conditional block of menu_add_prop() can be moved to menu_add_prompt(). Signed-off-by: Masahiro Yamada --- scripts/kconfig/menu.c | 70 ++++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 36 deletions(-) diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index bbabf0a59ac4..45daece8d983 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -132,53 +132,51 @@ static struct property *menu_add_prop(enum prop_type type, char *prompt, struct prop->expr = expr; prop->visible.expr = dep; - if (prompt) { - if (isspace(*prompt)) { - prop_warn(prop, "leading whitespace ignored"); - while (isspace(*prompt)) - prompt++; - } - if (current_entry->prompt) - prop_warn(prop, "prompt redefined"); + return prop; +} - /* Apply all upper menus' visibilities to actual prompts. */ - if(type == P_PROMPT) { - struct menu *menu = current_entry; +struct property *menu_add_prompt(enum prop_type type, char *prompt, + struct expr *dep) +{ + struct property *prop = menu_add_prop(type, prompt, NULL, dep); - while ((menu = menu->parent) != NULL) { - struct expr *dup_expr; + if (isspace(*prompt)) { + prop_warn(prop, "leading whitespace ignored"); + while (isspace(*prompt)) + prompt++; + } + if (current_entry->prompt) + prop_warn(prop, "prompt redefined"); - if (!menu->visibility) - continue; - /* - * Do not add a reference to the - * menu's visibility expression but - * use a copy of it. Otherwise the - * expression reduction functions - * will modify expressions that have - * multiple references which can - * cause unwanted side effects. - */ - dup_expr = expr_copy(menu->visibility); + /* Apply all upper menus' visibilities to actual prompts. */ + if (type == P_PROMPT) { + struct menu *menu = current_entry; - prop->visible.expr - = expr_alloc_and(prop->visible.expr, - dup_expr); - } - } + while ((menu = menu->parent) != NULL) { + struct expr *dup_expr; - current_entry->prompt = prop; + if (!menu->visibility) + continue; + /* + * Do not add a reference to the menu's visibility + * expression but use a copy of it. Otherwise the + * expression reduction functions will modify + * expressions that have multiple references which + * can cause unwanted side effects. + */ + dup_expr = expr_copy(menu->visibility); + + prop->visible.expr = expr_alloc_and(prop->visible.expr, + dup_expr); + } } + + current_entry->prompt = prop; prop->text = prompt; return prop; } -struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep) -{ - return menu_add_prop(type, prompt, NULL, dep); -} - void menu_add_visibility(struct expr *expr) { current_entry->visibility = expr_alloc_and(current_entry->visibility,