Skip to contentSkip to conversation

kconfig: remove unneeded variable in get_prompt_str()

PATCH New Masahiro Yamada 1 participant 3 messages Nov 13, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 kconfig: remove unneeded variable in get_prompt_str()

The variable 'accessible' is redundant.

---

 scripts/kconfig/menu.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
scripts/kconfig/menu.c +1 -3
index 109325f31bef..b90fff833588 100644
@@ -724,10 +724,8 @@ static void get_prompt_str(struct gstr *r, struct property *prop,
 
 	menu = prop->menu;
 	for (i = 0; menu != &rootmenu && i < 8; menu = menu->parent) {
-		bool accessible = menu_is_visible(menu);
-
 		submenu[i++] = menu;
-		if (location == NULL && accessible)
+		if (location == NULL && menu_is_visible(menu))
 			location = menu;
 	}
 	if (head && location) {
Signature · 1 line
2.34.1
#1 lore raw

PATCH 2/3 kconfig: remove const qualifier from str_get()

update_text() apparently edits the buffer returned by str_get(). (and there is no reason why it shouldn't)

Remove 'const' quailifier and casting.

---

 scripts/kconfig/lkc.h   | 2 +-
 scripts/kconfig/mconf.c | 4 ++--
 scripts/kconfig/util.c  | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)
scripts/kconfig/lkc.h +1 -1
index 6ac2eabe109d..e7118d62a45f 100644
@@ -76,7 +76,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, ...);
-const char *str_get(struct gstr *gs);
+char *str_get(struct gstr *gs);
 
 /* menu.c */
 void _menu_init(void);
scripts/kconfig/mconf.c +2 -2
index 9d3cf510562f..d7f7e1bf7dd4 100644
@@ -440,8 +440,8 @@ static void search_conf(void)
 
 		res = get_relations_str(sym_arr, &head);
 		set_subtitle();
-		dres = show_textbox_ext("Search Results", (char *)
-					str_get(&res), 0, 0, keys, &vscroll,
+		dres = show_textbox_ext("Search Results", str_get(&res), 0, 0,
+					keys, &vscroll,
 					&hscroll, &update_text, (void *)
 					&data);
 		again = false;
scripts/kconfig/util.c +1 -1
index 29585394df71..b78f114ad48c 100644
@@ -74,7 +74,7 @@ void str_printf(struct gstr *gs, const char *fmt, ...)
 }
 
 /* Retrieve value of growable string */
-const char *str_get(struct gstr *gs)
+char *str_get(struct gstr *gs)
 {
 	return gs->s;
 }
Signature · 1 line
2.34.1
#2 lore raw

PATCH 3/3 kconfig: remove redundant (void *) cast in search_conf()

In reply to Masahiro Yamada

The (void *) cast is redundant because the last argument of show_textbox_ext() is an opaque pointer.

---

 scripts/kconfig/mconf.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
scripts/kconfig/mconf.c +1 -2
index d7f7e1bf7dd4..9c549683c627 100644
@@ -441,8 +441,7 @@ static void search_conf(void)
 		res = get_relations_str(sym_arr, &head);
 		set_subtitle();
 		dres = show_textbox_ext("Search Results", str_get(&res), 0, 0,
-					keys, &vscroll,
-					&hscroll, &update_text, (void *)
+					keys, &vscroll, &hscroll, &update_text,
 					&data);
 		again = false;
 		for (i = 0; i < JUMP_NB && keys[i]; i++)
Signature · 1 line
2.34.1