From patchwork Sun Jul 7 15:38:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13726027 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2D26B1865B; Sun, 7 Jul 2024 15:39:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720366743; cv=none; b=ec3XewRUIk1Ncw9jCTD/poOLNfB2RteEML11YsupaS5TDElbc5v+s31e+m4BrmAhiXXbcofGEV22EsUI2bqjwJUc3UNmlZ/lc+rMbtNWaeU83XS10ZFRvQPdaX3VW0uBldjuKxkGhP5O/onlYnUN8XVdeXZsw6GghEsxCeJCIqE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720366743; c=relaxed/simple; bh=uWSCu9FKRpxsc31Anmfae7tDKV0+IKVLEdfz3P7wDSs=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=h7FhAk6uPKZcZDse4DPlfoykNLyXQixUojVHsRfsR4TJwb2Zhuo5cyL3nALPoCqCXs6ZvKLDQRRNWVP/Njvzp8QNC9coKNpRdXnGp1iPcvL9m7RxzSHO+p5UgF+hOj2SDZsDBnjaus4HBb8MhSFo9RZdsO79xAtVmi18mx36CS0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lxulsIlo; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lxulsIlo" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EBB20C4AF0B; Sun, 7 Jul 2024 15:39:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720366742; bh=uWSCu9FKRpxsc31Anmfae7tDKV0+IKVLEdfz3P7wDSs=; h=From:To:Cc:Subject:Date:From; b=lxulsIloRg2CeJk6OvWo43kBw/+RNw55JopxJWzamG/222fdI1IEgsYfv/sOdO2/i XMaZs2iPsqhheTW1sb5PNnYA6kbt7N4dk2HF5Bz03e6SoffnxXjqLANWJHE5iXNeWe mKj4EsFcCH9RwSc/okKYTSG088iHU2GxTLXvCVk+8wq8KABeDOqE+WIWQXYkrZ7sOF f83jQUKvJrPCQqkX8CfwlPxYEjNGg+mSYrCee5DxkkYYuRpaE4NeIqtksFRjv9HKHz WZN9quY0MGRJ7lpp8TNkXNBpuS3gPQZArA1oEizZiLX7Eyosj9CVarPNWMs6tbrx2P on5O1w4hnqD+Q== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 1/4] kconfig: call expr_eliminate_yn() at least once in expr_eliminate_dups() Date: Mon, 8 Jul 2024 00:38:04 +0900 Message-ID: <20240707153856.2483047-1-masahiroy@kernel.org> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Kconfig simplifies expressions, but redundant '&&' and '||' operators involving constant symbols 'y' and 'n' are sometimes trimmed and sometimes not. [Test Code] config DEP def_bool y config A bool "A" depends on DEP && y config B bool "B" depends on DEP && y && y [Result] $ make helpnewconfig [ snip ] ----- There is no help available for this option. Symbol: A [=n] Type : bool Defined at Kconfig:4 Prompt: A Depends on: DEP [=y] && y [=y] Location: -> A (A [=n]) ----- ----- There is no help available for this option. Symbol: B [=n] Type : bool Defined at Kconfig:8 Prompt: B Depends on: DEP [=y] Location: -> B (B [=n]) ----- The dependency for A, 'DEP && y', remains as-is, while that for B, 'DEP && y && y', has been reduced to 'DEP'. Currently, expr_eliminate_dups() calls expr_eliminate_yn() only when trans_count != 0, in other words, only when expr_eliminate_dups1() has trimmed at least one leaf. It fails to trim a single '&& y', etc. To fix this inconsistent behavior, expr_eliminate_yn() should be called at least once even if no leaf has been trimmed. Signed-off-by: Masahiro Yamada --- scripts/kconfig/expr.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c index 6d4b5a5a1e62..b2dfd3123a5d 100644 --- a/scripts/kconfig/expr.c +++ b/scripts/kconfig/expr.c @@ -637,7 +637,7 @@ struct expr *expr_eliminate_dups(struct expr *e) return e; oldcount = trans_count; - while (1) { + do { trans_count = 0; switch (e->type) { case E_OR: case E_AND: @@ -645,11 +645,8 @@ struct expr *expr_eliminate_dups(struct expr *e) default: ; } - if (!trans_count) - /* No simplifications done in this pass. We're done */ - break; e = expr_eliminate_yn(e); - } + } while (trans_count); /* repeat until we get no more simplifications */ trans_count = oldcount; return e; } From patchwork Sun Jul 7 15:38:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13726028 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5F1003B182; Sun, 7 Jul 2024 15:39:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720366744; cv=none; b=ceEmFnTujDddBNoX0e4fstY1DA0LGGL9BUH1qZMPZFJvfM+MTbh7ZMJRhNwX4CdOSxDbfgrqJVCpsWS03iYsRabcXwvjQIbYYNW8KapLJnVl3zQh4i7VKaUUltrBvOme4OvaEdStIRj7h1YYAoqvth/AeUbvZpRN+/NsK9q4n+M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720366744; c=relaxed/simple; bh=Ftgt30ANGetkuj6XeBhv1Ks1vUAgfzD5fF7fymxtJJw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=rRpGy/W0KSKAHbO9TQN9CYaZsF53ceaQWv0RucHvB9c41spE4kq9bCdS/vTSIh+FMwnyq1ulsonorUzO5QGGvoZL+f8AR6GYyd+2GiQigaqdAtmDuhPmbfOdb9xHwnoUT15bN1wTCBHNpPKT8pg4tJAcoSxvx5rdYJFvpXZErUY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=EqMAt2xz; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="EqMAt2xz" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4597AC4AF0C; Sun, 7 Jul 2024 15:39:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720366743; bh=Ftgt30ANGetkuj6XeBhv1Ks1vUAgfzD5fF7fymxtJJw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EqMAt2xz86dG0DgjUsowFy5Prv3ZIAkvsUU/TH04vRJvCgCYAL2sKV3oPI0tkNmtS FBoARkoUcdIjcLojVzmOe1tD3LI3RVated+oseNkgc+Bi7s/+xmGgp/KN1hfV8x4k6 XkNiBNrw0Tc4PJ9AyF/+/xP4S7epsMrP98b4H19S9mxAErHhFpGkLvPJoSFZYBHwoD MEPXIG2NKmMdMCkWlJIMpcqH/CRrGZxvg7o3V0eghFFrwna2U8TYvZOdomEgazP6l3 aAOUZQFeKnPgROh5+UNMFx+PsU0JfYb5xx6F6/QcGwxPT7qD2uJ081km12lbyjHJ5C wpuf8AscNEomA== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 2/4] kconfig: add const qualifiers to several function arguments Date: Mon, 8 Jul 2024 00:38:05 +0900 Message-ID: <20240707153856.2483047-2-masahiroy@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240707153856.2483047-1-masahiroy@kernel.org> References: <20240707153856.2483047-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Clarify that the given structures are not modified. Signed-off-by: Masahiro Yamada --- scripts/kconfig/expr.c | 4 ++-- scripts/kconfig/expr.h | 4 ++-- scripts/kconfig/lkc.h | 21 +++++++++++---------- scripts/kconfig/lkc_proto.h | 12 +++++++----- scripts/kconfig/menu.c | 15 ++++++++------- scripts/kconfig/parser.y | 4 ++-- scripts/kconfig/symbol.c | 14 +++++++------- scripts/kconfig/util.c | 2 +- 8 files changed, 40 insertions(+), 36 deletions(-) diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c index b2dfd3123a5d..a85e0d603322 100644 --- a/scripts/kconfig/expr.c +++ b/scripts/kconfig/expr.c @@ -1096,7 +1096,7 @@ static int expr_compare_type(enum expr_type t1, enum expr_type t2) return 0; } -void expr_print(struct expr *e, +void expr_print(const struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken) { @@ -1221,7 +1221,7 @@ static void expr_print_gstr_helper(void *data, struct symbol *sym, const char *s str_printf(gs, " [=%s]", sym_str); } -void expr_gstr_print(struct expr *e, struct gstr *gs) +void expr_gstr_print(const struct expr *e, struct gstr *gs) { expr_print(e, expr_print_gstr_helper, gs, E_NONE); } diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index 8849a243b5e7..54b008c0161d 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h @@ -291,11 +291,11 @@ struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symb void expr_fprint(struct expr *e, FILE *out); struct gstr; /* forward */ -void expr_gstr_print(struct expr *e, struct gstr *gs); +void expr_gstr_print(const struct expr *e, struct gstr *gs); void expr_gstr_print_revdep(struct expr *e, struct gstr *gs, tristate pr_type, const char *title); -static inline int expr_is_yes(struct expr *e) +static inline int expr_is_yes(const struct expr *e) { return !e || (e->type == E_SYMBOL && e->left.sym == &symbol_yes); } diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index 586a5e11f51e..3fa46610f25f 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h @@ -75,7 +75,7 @@ struct gstr str_new(void); void str_free(struct gstr *gs); void str_append(struct gstr *gs, const char *s); void str_printf(struct gstr *gs, const char *fmt, ...); -char *str_get(struct gstr *gs); +char *str_get(const struct gstr *gs); /* menu.c */ struct menu *menu_next(struct menu *menu, struct menu *root); @@ -84,13 +84,14 @@ struct menu *menu_next(struct menu *menu, struct menu *root); #define menu_for_each_entry(menu) \ menu_for_each_sub_entry(menu, &rootmenu) void _menu_init(void); -void menu_warn(struct menu *menu, const char *fmt, ...); +void menu_warn(const struct menu *menu, const char *fmt, ...); struct menu *menu_add_menu(void); void menu_end_menu(void); void menu_add_entry(struct symbol *sym); void menu_add_dep(struct expr *dep); void menu_add_visibility(struct expr *dep); -struct property *menu_add_prompt(enum prop_type type, char *prompt, struct expr *dep); +struct property *menu_add_prompt(enum prop_type type, const char *prompt, + struct expr *dep); void menu_add_expr(enum prop_type type, struct expr *expr, struct expr *dep); void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep); void menu_finalize(void); @@ -100,8 +101,8 @@ extern struct menu rootmenu; bool menu_is_empty(struct menu *menu); bool menu_is_visible(struct menu *menu); -bool menu_has_prompt(struct menu *menu); -const char *menu_get_prompt(struct menu *menu); +bool menu_has_prompt(const struct menu *menu); +const char *menu_get_prompt(const struct menu *menu); struct menu *menu_get_parent_menu(struct menu *menu); int get_jump_key_char(void); struct gstr get_relations_str(struct symbol **sym_arr, struct list_head *head); @@ -114,25 +115,25 @@ struct symbol *sym_calc_choice(struct menu *choice); struct property *sym_get_range_prop(struct symbol *sym); const char *sym_get_string_default(struct symbol *sym); struct symbol *sym_check_deps(struct symbol *sym); -struct symbol *prop_get_symbol(struct property *prop); +struct symbol *prop_get_symbol(const struct property *prop); -static inline tristate sym_get_tristate_value(struct symbol *sym) +static inline tristate sym_get_tristate_value(const struct symbol *sym) { return sym->curr.tri; } -static inline bool sym_is_choice(struct symbol *sym) +static inline bool sym_is_choice(const struct symbol *sym) { /* A choice is a symbol with no name */ return sym->name == NULL; } -static inline bool sym_is_choice_value(struct symbol *sym) +static inline bool sym_is_choice_value(const struct symbol *sym) { return sym->flags & SYMBOL_CHOICEVAL ? true : false; } -static inline bool sym_has_value(struct symbol *sym) +static inline bool sym_has_value(const struct symbol *sym) { return sym->flags & SYMBOL_DEF_USER ? true : false; } diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h index 49cc649d2810..63519cd24bc7 100644 --- a/scripts/kconfig/lkc_proto.h +++ b/scripts/kconfig/lkc_proto.h @@ -25,21 +25,23 @@ struct symbol ** sym_re_search(const char *pattern); const char * sym_type_name(enum symbol_type type); void sym_calc_value(struct symbol *sym); bool sym_dep_errors(void); -enum symbol_type sym_get_type(struct symbol *sym); -bool sym_tristate_within_range(struct symbol *sym,tristate tri); +enum symbol_type sym_get_type(const struct symbol *sym); +bool sym_tristate_within_range(const struct symbol *sym, tristate tri); bool sym_set_tristate_value(struct symbol *sym,tristate tri); void choice_set_value(struct menu *choice, struct symbol *sym); tristate sym_toggle_tristate_value(struct symbol *sym); bool sym_string_valid(struct symbol *sym, const char *newval); bool sym_string_within_range(struct symbol *sym, const char *str); bool sym_set_string_value(struct symbol *sym, const char *newval); -bool sym_is_changeable(struct symbol *sym); -struct menu *sym_get_choice_menu(struct symbol *sym); +bool sym_is_changeable(const struct symbol *sym); +struct menu *sym_get_choice_menu(const struct symbol *sym); const char * sym_get_string_value(struct symbol *sym); const char * prop_get_type_name(enum prop_type type); /* expr.c */ -void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int prevtoken); +void expr_print(const struct expr *e, + void (*fn)(void *, struct symbol *, const char *), + void *data, int prevtoken); #endif /* LKC_PROTO_H */ diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index b1fbaf2ff792..2a9b4c4f4428 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -38,7 +38,7 @@ struct menu *menu_next(struct menu *menu, struct menu *root) return menu->next; } -void menu_warn(struct menu *menu, const char *fmt, ...) +void menu_warn(const struct menu *menu, const char *fmt, ...) { va_list ap; va_start(ap, fmt); @@ -48,7 +48,7 @@ void menu_warn(struct menu *menu, const char *fmt, ...) va_end(ap); } -static void prop_warn(struct property *prop, const char *fmt, ...) +static void prop_warn(const struct property *prop, const char *fmt, ...) { va_list ap; va_start(ap, fmt); @@ -175,7 +175,7 @@ static struct property *menu_add_prop(enum prop_type type, struct expr *expr, return prop; } -struct property *menu_add_prompt(enum prop_type type, char *prompt, +struct property *menu_add_prompt(enum prop_type type, const char *prompt, struct expr *dep) { struct property *prop = menu_add_prop(type, NULL, dep); @@ -527,7 +527,7 @@ void menu_finalize(void) _menu_finalize(&rootmenu, false); } -bool menu_has_prompt(struct menu *menu) +bool menu_has_prompt(const struct menu *menu) { if (!menu->prompt) return false; @@ -573,7 +573,7 @@ bool menu_is_visible(struct menu *menu) return visible != no; } -const char *menu_get_prompt(struct menu *menu) +const char *menu_get_prompt(const struct menu *menu) { if (menu->prompt) return menu->prompt->text; @@ -594,13 +594,14 @@ struct menu *menu_get_parent_menu(struct menu *menu) return menu; } -static void get_def_str(struct gstr *r, struct menu *menu) +static void get_def_str(struct gstr *r, const struct menu *menu) { str_printf(r, "Defined at %s:%d\n", menu->filename, menu->lineno); } -static void get_dep_str(struct gstr *r, struct expr *expr, const char *prefix) +static void get_dep_str(struct gstr *r, const struct expr *expr, + const char *prefix) { if (!expr_is_yes(expr)) { str_append(r, prefix); diff --git a/scripts/kconfig/parser.y b/scripts/kconfig/parser.y index 745c82ee15d0..61900feb4254 100644 --- a/scripts/kconfig/parser.y +++ b/scripts/kconfig/parser.y @@ -489,7 +489,7 @@ assign_val: * * Return: -1 if an error is found, 0 otherwise. */ -static int choice_check_sanity(struct menu *menu) +static int choice_check_sanity(const struct menu *menu) { struct property *prop; int ret = 0; @@ -644,7 +644,7 @@ static void print_quoted_string(FILE *out, const char *str) putc('"', out); } -static void print_symbol(FILE *out, struct menu *menu) +static void print_symbol(FILE *out, const struct menu *menu) { struct symbol *sym = menu->sym; struct property *prop; diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index c05d188a1857..3255bf310cb2 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c @@ -40,7 +40,7 @@ struct symbol *modules_sym; static tristate modules_val; static int sym_warnings; -enum symbol_type sym_get_type(struct symbol *sym) +enum symbol_type sym_get_type(const struct symbol *sym) { enum symbol_type type = sym->type; @@ -75,7 +75,7 @@ const char *sym_type_name(enum symbol_type type) * * Return: a choice menu if this function is called against a choice member. */ -struct menu *sym_get_choice_menu(struct symbol *sym) +struct menu *sym_get_choice_menu(const struct symbol *sym) { struct menu *menu = NULL; struct menu *m; @@ -355,7 +355,7 @@ struct symbol *sym_calc_choice(struct menu *choice) return res; } -static void sym_warn_unmet_dep(struct symbol *sym) +static void sym_warn_unmet_dep(const struct symbol *sym) { struct gstr gs = str_new(); @@ -521,7 +521,7 @@ void sym_clear_all_valid(void) sym_calc_value(modules_sym); } -bool sym_tristate_within_range(struct symbol *sym, tristate val) +bool sym_tristate_within_range(const struct symbol *sym, tristate val) { int type = sym_get_type(sym); @@ -866,7 +866,7 @@ const char *sym_get_string_value(struct symbol *sym) return (const char *)sym->curr.val; } -bool sym_is_changeable(struct symbol *sym) +bool sym_is_changeable(const struct symbol *sym) { return !sym_is_choice(sym) && sym->visible > sym->rev_dep.tri; } @@ -1150,7 +1150,7 @@ static void sym_check_print_recursive(struct symbol *last_sym) dep_stack_remove(); } -static struct symbol *sym_check_expr_deps(struct expr *e) +static struct symbol *sym_check_expr_deps(const struct expr *e) { struct symbol *sym; @@ -1309,7 +1309,7 @@ struct symbol *sym_check_deps(struct symbol *sym) return sym2; } -struct symbol *prop_get_symbol(struct property *prop) +struct symbol *prop_get_symbol(const struct property *prop) { if (prop->expr && prop->expr->type == E_SYMBOL) return prop->expr->left.sym; diff --git a/scripts/kconfig/util.c b/scripts/kconfig/util.c index 439c131b424e..1ea78927121d 100644 --- a/scripts/kconfig/util.c +++ b/scripts/kconfig/util.c @@ -98,7 +98,7 @@ void str_printf(struct gstr *gs, const char *fmt, ...) } /* Retrieve value of growable string */ -char *str_get(struct gstr *gs) +char *str_get(const struct gstr *gs) { return gs->s; } From patchwork Sun Jul 7 15:38:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13726029 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ACF23405E6; Sun, 7 Jul 2024 15:39:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720366745; cv=none; b=MLOpYEZZcbsjF8+vjT2+gU/cf825135N9moe0c9xtNCYrXUOkBIjVuDYhM0oT4wHMae3JIOxxxsr9hQ8OlK0eb203pe8wm03RhLqr5+UL+9oYNjeb7uAGB5NAt73YzWU5DDSEX4fQ46rr5zok5x5VUQ5w/urc1b2ztDDPIfrEg8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720366745; c=relaxed/simple; bh=Bvgq5Dh/o3TVhL4qcwFRWp1OFJpVti4RsoXG1ndKF1s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Rpva1mzW/jkWy9+KbVgHYQjj3BpxQmU0jXvASUYpVyr/6CL3/QPB9E50zrRh7vLw3IkgNrr/9FKUANHKjGUgeiuROlzMG8Wh3xidKgHrg7XWmTFa7zcq6rnOYiPlDOFA5UTcg9O2Huz+RqRpYkNcVyWoLY4o6xz9to+kT9JJC9A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Y37mgM+y; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Y37mgM+y" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 648C8C4AF0E; Sun, 7 Jul 2024 15:39:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720366745; bh=Bvgq5Dh/o3TVhL4qcwFRWp1OFJpVti4RsoXG1ndKF1s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y37mgM+y88H3AZSDnbM1b43qAjGPcDB+EC+dylnzbafZqvI24n2zp7SpIZtcmZaHf U/nkJM4h5HC/1Fli572CD7/S6Lamj5IKtXIkcGft7Ejnlt085XNpdI9P1myNFxnBr3 cBQ3rMQqkjQNX0MONyIP1K9/znFM7yvvLSbagjFtvaohP53k8QOtl2fWpPx7aheq6s a1T4rq2W+PHy+wGpc8xqlIJhI2ByZDg1/Ua+2uZKW4BJhvGKALmFkUpXdKLMaA94gt dYiS0XWReWRxfc9ZCNeNSDtHJUPMKAovTd5QsQ+JAl7Bal+Ga6HgdTivAG3CuGRd7B ZO1s57mL1AV/g== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 3/4] kconfig: remove P_CHOICEVAL property Date: Mon, 8 Jul 2024 00:38:06 +0900 Message-ID: <20240707153856.2483047-3-masahiroy@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240707153856.2483047-1-masahiroy@kernel.org> References: <20240707153856.2483047-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This flag is unneeded because a choice member can be detected by other means. Signed-off-by: Masahiro Yamada --- scripts/kconfig/expr.h | 1 - scripts/kconfig/gconf.c | 2 +- scripts/kconfig/lkc.h | 5 +---- scripts/kconfig/menu.c | 5 ----- scripts/kconfig/symbol.c | 6 ++++++ 5 files changed, 8 insertions(+), 11 deletions(-) diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index 54b008c0161d..6e47e0ad6e6e 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h @@ -131,7 +131,6 @@ struct symbol { #define SYMBOL_CONST 0x0001 /* symbol is const */ #define SYMBOL_CHECK 0x0008 /* used during dependency checking */ -#define SYMBOL_CHOICEVAL 0x0020 /* used as a value in a choice block */ #define SYMBOL_VALID 0x0080 /* set when symbol.curr is calculated */ #define SYMBOL_WRITE 0x0200 /* write symbol to file (KCONFIG_CONFIG) */ #define SYMBOL_WRITTEN 0x0800 /* track info to avoid double-write to .config */ diff --git a/scripts/kconfig/gconf.c b/scripts/kconfig/gconf.c index 6b50e25133e3..c0f46f189060 100644 --- a/scripts/kconfig/gconf.c +++ b/scripts/kconfig/gconf.c @@ -1070,7 +1070,7 @@ static gchar **fill_row(struct menu *menu) row[COL_BTNVIS] = GINT_TO_POINTER(FALSE); return row; } - if (sym->flags & SYMBOL_CHOICEVAL) + if (sym_is_choice_value(sym)) row[COL_BTNRAD] = GINT_TO_POINTER(TRUE); stype = sym_get_type(sym); diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index 3fa46610f25f..401bdf36323a 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h @@ -128,10 +128,7 @@ static inline bool sym_is_choice(const struct symbol *sym) return sym->name == NULL; } -static inline bool sym_is_choice_value(const struct symbol *sym) -{ - return sym->flags & SYMBOL_CHOICEVAL ? true : false; -} +bool sym_is_choice_value(const struct symbol *sym); static inline bool sym_has_value(const struct symbol *sym) { diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index 2a9b4c4f4428..cd34cc5aefcf 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -467,11 +467,6 @@ static void _menu_finalize(struct menu *parent, bool inside_choice) sym->dir_dep.expr = expr_alloc_or(sym->dir_dep.expr, parent->dep); } for (menu = parent->list; menu; menu = menu->next) { - if (sym && sym_is_choice(sym) && - menu->sym && !sym_is_choice_value(menu->sym)) { - menu->sym->flags |= SYMBOL_CHOICEVAL; - } - /* * This code serves two purposes: * diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index 3255bf310cb2..6c6f238c4f7b 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c @@ -871,6 +871,11 @@ bool sym_is_changeable(const struct symbol *sym) return !sym_is_choice(sym) && sym->visible > sym->rev_dep.tri; } +bool sym_is_choice_value(const struct symbol *sym) +{ + return !list_empty(&sym->choice_link); +} + HASHTABLE_DEFINE(sym_hashtable, SYMBOL_HASHSIZE); struct symbol *sym_lookup(const char *name, int flags) @@ -908,6 +913,7 @@ struct symbol *sym_lookup(const char *name, int flags) symbol->type = S_UNKNOWN; symbol->flags = flags; INIT_LIST_HEAD(&symbol->menus); + INIT_LIST_HEAD(&symbol->choice_link); hash_add(sym_hashtable, &symbol->node, hash); From patchwork Sun Jul 7 15:38:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13726030 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E3D714596F; Sun, 7 Jul 2024 15:39:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720366747; cv=none; b=skF5b8JwpB+xWLsNSu5unvH7SgIKUzIGKXD3qIsSDaJen8YNzPzo9shgU7vly/ez0Xd8piC4YN4r4ykMHfGWLtKmEt7Qju4hb45pPbKMM7WtqQP4uFr9XkTvcAZbKRltD4VhJOOe13oODtAP+0omdXfVY4b26XizgpEv4+KMBm4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720366747; c=relaxed/simple; bh=Szn9QbqU+k18L3rnViBkFWEjGJmTSkPDDXuoWw9cflU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=t4F/Vb0YtHVFLyshfOqih8qSjDpVCGh35di6TJcHpBtne7nvh/ucX/pHRiTyUTgdkZJiOjVLsB6AyxxyxMyDFR1Tyza+lDx9PspDTEqOCzYt6sci9HbHt+LGwoqdJLQFzN7aR0k4+r1/dVkw/+AhlbyRtvPfLbZeT2OnQZwWjqg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=vBPn59u5; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="vBPn59u5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B5405C4AF07; Sun, 7 Jul 2024 15:39:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1720366746; bh=Szn9QbqU+k18L3rnViBkFWEjGJmTSkPDDXuoWw9cflU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vBPn59u5BGNUUFMGWQSpgZOwbXi+vvzNSRvDqQ0q6Hgz7Vwt9A5gJDRd47pbBR5B7 6MWLL+fXD8EjbCxco2khJyJphOFm14mnJy0VzuIpPS4xY5rfTVP3eVsVu4rfunXFf6 t92HlVDDLlehmpLyxh+Uw0KCcsdzs8/MGKnlJ/+/626XWTe8IvcYAv7U7/m4aOG5Xn BnU48flpyVKc+fWPlc5/B2erminukKtGSoZRgUFM+T5jOjYMRHPyvLRzNcV07Zjsj8 i0/lf1bj6Cb2HCaQ+MHg2clRaN5SwaK8Op5Po6zt02fhxVz9domZCPCkgFIHUngy5K dB+IMh4PA96JA== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada Subject: [PATCH 4/4] kconfig: remove 'e1' and 'e2' macros from expressoin deduplication Date: Mon, 8 Jul 2024 00:38:07 +0900 Message-ID: <20240707153856.2483047-4-masahiroy@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240707153856.2483047-1-masahiroy@kernel.org> References: <20240707153856.2483047-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kbuild@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 I do not think the macros 'e1' and 'e2' are readable. The statement: e1 = expr_alloc_symbol(...); affects the caller's variable, but this is not sufficiently clear from the code. Remove the macros. No functional change intended. Signed-off-by: Masahiro Yamada --- scripts/kconfig/expr.c | 94 +++++++++++++++++++----------------------- 1 file changed, 42 insertions(+), 52 deletions(-) diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c index a85e0d603322..c349da7fe3f8 100644 --- a/scripts/kconfig/expr.c +++ b/scripts/kconfig/expr.c @@ -135,9 +135,6 @@ void expr_free(struct expr *e) static int trans_count; -#define e1 (*ep1) -#define e2 (*ep2) - /* * expr_eliminate_eq() helper. * @@ -150,38 +147,38 @@ static void __expr_eliminate_eq(enum expr_type type, struct expr **ep1, struct e { /* Recurse down to leaves */ - if (e1->type == type) { - __expr_eliminate_eq(type, &e1->left.expr, &e2); - __expr_eliminate_eq(type, &e1->right.expr, &e2); + if ((*ep1)->type == type) { + __expr_eliminate_eq(type, &(*ep1)->left.expr, ep2); + __expr_eliminate_eq(type, &(*ep1)->right.expr, ep2); return; } - if (e2->type == type) { - __expr_eliminate_eq(type, &e1, &e2->left.expr); - __expr_eliminate_eq(type, &e1, &e2->right.expr); + if ((*ep2)->type == type) { + __expr_eliminate_eq(type, ep1, &(*ep2)->left.expr); + __expr_eliminate_eq(type, ep1, &(*ep2)->right.expr); return; } - /* e1 and e2 are leaves. Compare them. */ + /* *ep1 and *ep2 are leaves. Compare them. */ - if (e1->type == E_SYMBOL && e2->type == E_SYMBOL && - e1->left.sym == e2->left.sym && - (e1->left.sym == &symbol_yes || e1->left.sym == &symbol_no)) + if ((*ep1)->type == E_SYMBOL && (*ep2)->type == E_SYMBOL && + (*ep1)->left.sym == (*ep2)->left.sym && + ((*ep1)->left.sym == &symbol_yes || (*ep1)->left.sym == &symbol_no)) return; - if (!expr_eq(e1, e2)) + if (!expr_eq(*ep1, *ep2)) return; - /* e1 and e2 are equal leaves. Prepare them for elimination. */ + /* *ep1 and *ep2 are equal leaves. Prepare them for elimination. */ trans_count++; - expr_free(e1); expr_free(e2); + expr_free(*ep1); expr_free(*ep2); switch (type) { case E_OR: - e1 = expr_alloc_symbol(&symbol_no); - e2 = expr_alloc_symbol(&symbol_no); + *ep1 = expr_alloc_symbol(&symbol_no); + *ep2 = expr_alloc_symbol(&symbol_no); break; case E_AND: - e1 = expr_alloc_symbol(&symbol_yes); - e2 = expr_alloc_symbol(&symbol_yes); + *ep1 = expr_alloc_symbol(&symbol_yes); + *ep2 = expr_alloc_symbol(&symbol_yes); break; default: ; @@ -219,29 +216,26 @@ static void __expr_eliminate_eq(enum expr_type type, struct expr **ep1, struct e */ void expr_eliminate_eq(struct expr **ep1, struct expr **ep2) { - if (!e1 || !e2) + if (!*ep1 || !*ep2) return; - switch (e1->type) { + switch ((*ep1)->type) { case E_OR: case E_AND: - __expr_eliminate_eq(e1->type, ep1, ep2); + __expr_eliminate_eq((*ep1)->type, ep1, ep2); default: ; } - if (e1->type != e2->type) switch (e2->type) { + if ((*ep1)->type != (*ep2)->type) switch ((*ep2)->type) { case E_OR: case E_AND: - __expr_eliminate_eq(e2->type, ep1, ep2); + __expr_eliminate_eq((*ep2)->type, ep1, ep2); default: ; } - e1 = expr_eliminate_yn(e1); - e2 = expr_eliminate_yn(e2); + *ep1 = expr_eliminate_yn(*ep1); + *ep2 = expr_eliminate_yn(*ep2); } -#undef e1 -#undef e2 - /* * Returns true if 'e1' and 'e2' are equal, after minor simplification. Two * &&/|| expressions are considered equal if every operand in one expression @@ -564,59 +558,55 @@ static struct expr *expr_join_and(struct expr *e1, struct expr *e2) */ static void expr_eliminate_dups1(enum expr_type type, struct expr **ep1, struct expr **ep2) { -#define e1 (*ep1) -#define e2 (*ep2) struct expr *tmp; /* Recurse down to leaves */ - if (e1->type == type) { - expr_eliminate_dups1(type, &e1->left.expr, &e2); - expr_eliminate_dups1(type, &e1->right.expr, &e2); + if ((*ep1)->type == type) { + expr_eliminate_dups1(type, &(*ep1)->left.expr, ep2); + expr_eliminate_dups1(type, &(*ep1)->right.expr, ep2); return; } - if (e2->type == type) { - expr_eliminate_dups1(type, &e1, &e2->left.expr); - expr_eliminate_dups1(type, &e1, &e2->right.expr); + if ((*ep2)->type == type) { + expr_eliminate_dups1(type, ep1, &(*ep2)->left.expr); + expr_eliminate_dups1(type, ep1, &(*ep2)->right.expr); return; } - /* e1 and e2 are leaves. Compare and process them. */ + /* *ep1 and *ep2 are leaves. Compare and process them. */ - if (e1 == e2) + if (*ep1 == *ep2) return; - switch (e1->type) { + switch ((*ep1)->type) { case E_OR: case E_AND: - expr_eliminate_dups1(e1->type, &e1, &e1); + expr_eliminate_dups1((*ep1)->type, ep1, ep1); default: ; } switch (type) { case E_OR: - tmp = expr_join_or(e1, e2); + tmp = expr_join_or(*ep1, *ep2); if (tmp) { - expr_free(e1); expr_free(e2); - e1 = expr_alloc_symbol(&symbol_no); - e2 = tmp; + expr_free(*ep1); expr_free(*ep2); + *ep1 = expr_alloc_symbol(&symbol_no); + *ep2 = tmp; trans_count++; } break; case E_AND: - tmp = expr_join_and(e1, e2); + tmp = expr_join_and(*ep1, *ep2); if (tmp) { - expr_free(e1); expr_free(e2); - e1 = expr_alloc_symbol(&symbol_yes); - e2 = tmp; + expr_free(*ep1); expr_free(*ep2); + *ep1 = expr_alloc_symbol(&symbol_yes); + *ep2 = tmp; trans_count++; } break; default: ; } -#undef e1 -#undef e2 } /*