From nobody Wed Oct 8 22:32:51 2025 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 CBBEE2E11B9; Tue, 24 Jun 2025 15:07:52 +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=1750777672; cv=none; b=Bww0A87EDALOSwJAJeOpi61u4Gt2R80X/Ih0ZlXrd6Ut9/trXemWe4HxrtK07/ORi32AfqpiK2uZMtkTxESdNicFWvJCB3hIa4SXzbTpaEpKfVyjIgPjKWLhe472AhvpzPiy8i6Sws19uKPyxfPT55xB3cvoIDuryatajNdE5ko= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750777672; c=relaxed/simple; bh=LW+bB5SVKxnHDdlR8+C2VtbTMAf1SYKnEZ4+zHYx3jE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MrEAO/ldzNZ1C9U0Sq20v8wmPCB2WWEHqeUsqX5PXt5wy94eukghJDT+OBxA4XXc3Tw/H3H+9MJCu1qzXJpFl79UTtSO2dZqPUQNKX6WzaAvvuGAfB93VohEvBcfIKPMCpzrN2wZWDH4RJVzotTXZ6S63ZeYH0G8L6awTd6s8wM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cs5qKqBG; 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="cs5qKqBG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7A4E1C4CEF1; Tue, 24 Jun 2025 15:07:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1750777672; bh=LW+bB5SVKxnHDdlR8+C2VtbTMAf1SYKnEZ4+zHYx3jE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cs5qKqBGh9lGex1o6gNRe7LL7VvrhO10i6R4hAaPHFk656rhoDvBawdxzv16yyKUu aet9VPAwl3CB5uyxql5JOJZuYP373eI+fttAXG4ZWWl18l1KMIcvpykd1NqK2bxbsl EnD5YUAkkbTuijuKOwSUma44ba/gBbVgpdbnnau8nrTT5eETIna0WS3IWNgJBiIKuI T3+8JQI8nLTVVVOdSyHvp6p0yCuw3osowTO4jCbtCYFly8IgqjV6/9TTUvrcWeFD8Z dWojR3g1OyuqIViNF9EeAsZ+joPtiSAXsyudGF99YzZ7QEKwlO/iAAa+rS7tQs9vKT 4AN4N/GQkkbvg== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH 18/66] kconfig: gconf: remove parents[] array and indent variable Date: Wed, 25 Jun 2025 00:05:06 +0900 Message-ID: <20250624150645.1107002-19-masahiroy@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250624150645.1107002-1-masahiroy@kernel.org> References: <20250624150645.1107002-1-masahiroy@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The parents[] array is used to store the GtkTreeIter of parent nodes, but this can be simplified: we can pass a GtkTreeIter pointer down when _display_tree() recurses. Signed-off-by: Masahiro Yamada --- scripts/kconfig/gconf.c | 49 ++++++++++++----------------------------- 1 file changed, 14 insertions(+), 35 deletions(-) diff --git a/scripts/kconfig/gconf.c b/scripts/kconfig/gconf.c index 3e632a325c10..432a467e3250 100644 --- a/scripts/kconfig/gconf.c +++ b/scripts/kconfig/gconf.c @@ -47,8 +47,6 @@ GdkColor color; =20 GtkTreeStore *tree1, *tree2, *tree; GtkTreeModel *model1, *model2; -static GtkTreeIter *parents[256]; -static gint indent; =20 static struct menu *current; // current node for SINGLE view static struct menu *browsed; // browsed node for SPLIT view @@ -153,8 +151,6 @@ static void init_main_window(const gchar *glade_file) =20 static void init_tree_model(void) { - gint i; - tree =3D tree2 =3D gtk_tree_store_new(COL_NUMBER, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, @@ -166,9 +162,6 @@ static void init_tree_model(void) G_TYPE_BOOLEAN); model2 =3D GTK_TREE_MODEL(tree2); =20 - for (parents[0] =3D NULL, i =3D 1; i < 256; i++) - parents[i] =3D (GtkTreeIter *) g_malloc(sizeof(GtkTreeIter)); - tree1 =3D gtk_tree_store_new(COL_NUMBER, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, @@ -1131,18 +1124,6 @@ static void set_node(GtkTreeIter * node, struct menu= *menu, gchar ** row) g_object_unref(pix); } =20 - -/* Add a node to the tree */ -static void place_node(struct menu *menu, char **row) -{ - GtkTreeIter *parent =3D parents[indent - 1]; - GtkTreeIter *node =3D parents[indent]; - - gtk_tree_store_append(tree, node, parent); - set_node(node, menu, row); -} - - /* Find a node in the GTK+ tree */ static GtkTreeIter found; =20 @@ -1193,9 +1174,6 @@ static void update_tree(struct menu *src, GtkTreeIter= * dst) struct symbol *sym; struct menu *menu1, *menu2; =20 - if (src =3D=3D &rootmenu) - indent =3D 1; - valid =3D gtk_tree_model_iter_children(model2, child2, dst); for (child1 =3D src->list; child1; child1 =3D child1->next) { =20 @@ -1253,9 +1231,7 @@ static void update_tree(struct menu *src, GtkTreeIter= * dst) set_node(child2, menu1, fill_row(menu1)); } =20 - indent++; update_tree(child1, child2); - indent--; =20 valid =3D gtk_tree_model_iter_next(model2, child2); } @@ -1263,16 +1239,15 @@ static void update_tree(struct menu *src, GtkTreeIt= er * dst) =20 =20 /* Display the whole tree (single/split/full view) */ -static void display_tree(struct menu *menu) +static void _display_tree(struct menu *menu, GtkTreeIter *parent) { struct property *prop; struct menu *child; enum prop_type ptype; + GtkTreeIter iter; =20 - if (menu =3D=3D &rootmenu) { - indent =3D 1; + if (menu =3D=3D &rootmenu) current =3D &rootmenu; - } =20 for (child =3D menu->list; child; child =3D child->next) { prop =3D child->prompt; @@ -1290,8 +1265,10 @@ static void display_tree(struct menu *menu) =20 if ((opt_mode =3D=3D OPT_NORMAL && menu_is_visible(child)) || (opt_mode =3D=3D OPT_PROMPT && menu_has_prompt(child)) || - (opt_mode =3D=3D OPT_ALL && menu_get_prompt(child))) - place_node(child, fill_row(child)); + (opt_mode =3D=3D OPT_ALL && menu_get_prompt(child))) { + gtk_tree_store_append(tree, &iter, parent); + set_node(&iter, child, fill_row(child)); + } =20 if ((view_mode !=3D FULL_VIEW) && (ptype =3D=3D P_MENU) && (tree =3D=3D tree2)) @@ -1308,14 +1285,16 @@ static void display_tree(struct menu *menu) =20 if (((view_mode =3D=3D SINGLE_VIEW) && (menu->flags & MENU_ROOT)) || (view_mode =3D=3D FULL_VIEW) - || (view_mode =3D=3D SPLIT_VIEW)) { - indent++; - display_tree(child); - indent--; - } + || (view_mode =3D=3D SPLIT_VIEW)) + _display_tree(child, &iter); } } =20 +static void display_tree(struct menu *menu) +{ + _display_tree(menu, NULL); +} + /* Display a part of the tree starting at current node (single/split view)= */ static void display_tree_part(void) { --=20 2.43.0