kconfig: gconf: redraw pane correctly after loading a config file
PATCH 1/10 kconfig: gconf: redraw pane correctly after loading a config file
Every time a config file is loaded (either by clicking the "Load" button or selecting "File" -> "Load" from the menu), a new tree structure is appended to the widget.
The current tree needs to be cleared by calling gtk_tree_store_clear().
---
scripts/kconfig/gconf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
scripts/kconfig/gconf.c +3 -1
@@ -487,7 +487,7 @@ load_filename(GtkFileSelection * file_selector, gpointer user_data)if (conf_read (fn))text_insert_msg ("Error" ,"Unable to load configuration !" );else -display_tree (&rootmenu); +display_tree_part (); }void on_load1_activate (GtkMenuItem * menuitem,gpointer user_data)
@@ -1399,6 +1399,8 @@ static void display_tree_part(void)display_tree (current); else if (view_mode == SPLIT_VIEW) display_tree(browsed); + else if (view_mode == FULL_VIEW) + display_tree(&rootmenu);gtk_tree_view_expand_all (GTK_TREE_VIEW (tree2_w )); }
Signature · 1 line
2.40.1
PATCH 2/10 kconfig: gconf: remove debug code
This is not so useful. If necessary, you can insert printf() or whatever during debugging.
---
scripts/kconfig/gconf.c | 49 +---------------------------------------- 1 file changed, 1 insertion(+), 48 deletions(-)
scripts/kconfig/gconf.c +1 -48
@@ -18,8 +18,6 @@#include <unistd.h> #include <time.h> -//#define DEBUG -enum {SINGLE_VIEW ,SPLIT_VIEW ,FULL_VIEW };
@@ -71,33 +69,6 @@ static void set_node(GtkTreeIter * node, struct menu *menu, gchar ** row);static gchar **fill_row (struct menu *menu);static void conf_changed (void ); -/* Helping/Debugging Functions */ -#ifdef DEBUG -static const char *dbg_sym_flags (int val) -{ -static char buf[256 ]; - -bzero (buf,256 ); - -if (val &SYMBOL_CONST ) -strcat (buf,"const/" ); -if (val &SYMBOL_CHECK ) -strcat (buf,"check/" ); -if (val &SYMBOL_CHOICEVAL ) -strcat (buf,"choiceval/" ); -if (val &SYMBOL_VALID ) -strcat (buf,"valid/" ); -if (val &SYMBOL_WRITE ) -strcat (buf,"write/" ); -if (val &SYMBOL_CHANGED ) -strcat (buf,"changed/" ); - - buf[strlen (buf) -1 ] ='\0' ; - -return buf; -} -#endif -static void replace_button_icon (GladeXML *xml,GdkDrawable *window,GtkStyle *style,gchar *btn_name,gchar **xpm) {
@@ -1262,12 +1233,6 @@ static void update_tree(struct menu *src, GtkTreeIter * dst)else menu2 =NULL ;// force adding of a first child -#ifdef DEBUG -printf ("%*c%s | %s\n" , indent,' ' , - menu1 ?menu_get_prompt (menu1) :"nil" , - menu2 ?menu_get_prompt (menu2) :"nil" ); -#endif -if ((opt_mode ==OPT_NORMAL && !menu_is_visible (child1)) || (opt_mode ==OPT_PROMPT && !menu_has_prompt (child1)) || (opt_mode ==OPT_ALL && !menu_get_prompt (child1))) {
@@ -1354,19 +1319,7 @@ static void display_tree(struct menu *menu) (opt_mode == OPT_PROMPT && menu_has_prompt(child)) || (opt_mode == OPT_ALL && menu_get_prompt(child)))place_node (child,fill_row (child)); -#ifdef DEBUG -printf ("%*c%s: " , indent,' ' ,menu_get_prompt (child)); -printf ("%s" , child->flags &MENU_ROOT ?"rootmenu | " :"" ); -printf ("%s" ,prop_get_type_name (ptype)); -printf (" | " ); -if (sym) { -printf ("%s" ,sym_type_name (sym->type)); -printf (" | " ); -printf ("%s" ,dbg_sym_flags (sym->flags)); -printf ("\n" ); - }else -printf ("\n" ); -#endif +if ((view_mode !=FULL_VIEW ) && (ptype ==P_MENU ) && (tree == tree2))continue ;
Signature · 1 line
2.40.1
PATCH 3/10 kconfig: gconf: use MENU_CHANGED instead of SYMBOL_CHANGED
In reply to Masahiro YamadaSYMBOL_CHANGED and MENU_CHANGED are used to update GUI frontends when the symbol value is changed. These are used inconsistently:SYMBOL_CHANGED in gconf.c and MENU_CHANGE in qconf.cc.
MENU_CHANGED works more properly when a symbol has multiple prompts (although such code is not ideal).
[test code]
config FOO
bool "foo prompt 1"
config FOO
bool "foo prompt 2"
In gconfig, if one of the two checkboxes is clicked, only the first one is toggled. In xconfig, the two checkboxes work in sync.
Replace SYMBOL_CHANGED in gconf.c with MENU_CHANGED to align with the xconfig behavior.
---
scripts/kconfig/gconf.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
scripts/kconfig/gconf.c +3 -6
@@ -1047,7 +1047,7 @@ static gchar **fill_row(struct menu *menu) row[COL_NAME ] =g_strdup (sym->name);sym_calc_value (sym); - sym->flags &= ~SYMBOL_CHANGED ; + menu->flags &= ~MENU_CHANGED ;if (sym_is_choice (sym)) {// parse childs for getting final value struct menu *child;
@@ -1273,7 +1273,7 @@ static void update_tree(struct menu *src, GtkTreeIter * dst)else goto reparse;// next child } - }else if (sym && (sym->flags &SYMBOL_CHANGED )) { + }else if (sym && (child1->flags &MENU_CHANGED )) {set_node (child2, menu1,fill_row (menu1)); }
@@ -1289,7 +1289,6 @@ static void update_tree(struct menu *src, GtkTreeIter * dst)/* Display the whole tree (single/split/full view) */ static void display_tree (struct menu *menu) { -struct symbol *sym;struct property *prop;struct menu *child;enum prop_type ptype;
@@ -1301,11 +1300,9 @@ static void display_tree(struct menu *menu)for (child = menu->list; child; child = child->next) { prop = child->prompt; - sym = child->sym; ptype = prop ? prop->type :P_UNKNOWN ; -if (sym) - sym->flags &= ~SYMBOL_CHANGED ; + menu->flags &= ~MENU_CHANGED ;if ((view_mode ==SPLIT_VIEW ) && !(child->flags &MENU_ROOT ) && (tree == tree1))
Signature · 1 line
2.40.1
PATCH 4/10 kconfig: used linked list in sym_set_changed()
In reply to Masahiro YamadaFollowing the approach employed in commit bedf92362317 ("kconfig: use linked list in get_symbol_str() to iterate over menus"), simplify the iteration on the menus of the specified symbol.
---
scripts/kconfig/symbol.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
scripts/kconfig/symbol.c +3 -5
@@ -152,13 +152,11 @@ static void sym_validate_range(struct symbol *sym)static void sym_set_changed (struct symbol *sym) { -struct property *prop; +struct menu *menu; sym->flags |=SYMBOL_CHANGED ; -for (prop = sym->prop; prop; prop = prop->next) { -if (prop->menu) - prop->menu->flags |=MENU_CHANGED ; - } +list_for_each_entry (menu, &sym->menus, link) + menu->flags |=MENU_CHANGED ; }static void sym_set_all_changed (void )
Signature · 1 line
2.40.1
PATCH 5/10 kconfig: add sym_get_choice_menu() helper
In reply to Masahiro YamadaChoices and their members are associated via the P_CHOICE property.
Currently, prop_get_symbol(sym_get_choice_prop(sym)) is used to obtain the choice of the given choice member.
We can do this without relying on P_CHOICE by checking the parent in the menu structure.
Introduce a new helper to retrieve the choice if the given symbol is a choice member.
This is intended to replace prop_get_symbol(sym_get_choice_prop(sym)) and deprecate P_CHOICE eventually.
---
scripts/kconfig/lkc_proto.h | 1 + scripts/kconfig/symbol.c | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+)
scripts/kconfig/lkc_proto.h +1 -0
@@ -34,6 +34,7 @@ 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 property *sym_get_choice_prop (struct symbol *sym); +struct menu *sym_get_choice_menu (struct symbol *sym);const char *sym_get_string_value (struct symbol *sym);const char *prop_get_type_name (enum prop_type type);
scripts/kconfig/symbol.c +35 -0
@@ -78,6 +78,41 @@ struct property *sym_get_choice_prop(struct symbol *sym)return NULL ; } +/** +* sym_get_choice_menu - get the parent choice menu if present +* +* @sym: a symbol pointer +* +* Return: a choice menu if this function is called against a choice member. +*/ +struct menu *sym_get_choice_menu (struct symbol *sym) +{ +struct menu *menu =NULL ; +struct menu *m; + +/* +* Choice members must have a prompt. Find a menu entry with a prompt, +* and assume it resides inside a choice block. +*/ +list_for_each_entry (m, &sym->menus, link) +if (m->prompt) { + menu = m; +break ; + } + +if (!menu) +return NULL ; + +do { + menu = menu->parent; + }while (menu && !menu->sym); + +if (menu && menu->sym &&sym_is_choice (menu->sym)) +return menu; + +return NULL ; +} +static struct property *sym_get_default_prop (struct symbol *sym) {struct property *prop;
Signature · 1 line
2.40.1
PATCH 6/10 kconfig: use sym_get_choice_menu() in conf_write_defconfig()
In reply to Masahiro YamadaChoices and their members are associated via the P_CHOICE property.
Currently, prop_get_symbol(sym_get_choice_prop()) is used to obtain the choice of the given choice member.
Replace it with sym_get_choice_menu(), which retrieves the choice without relying on P_CHOICE.
---
scripts/kconfig/confdata.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
scripts/kconfig/confdata.c +5 -4
@@ -794,6 +794,8 @@ int conf_write_defconfig(const char *filename)sym_clear_all_valid ();menu_for_each_entry (menu) { +struct menu *choice_menu; + sym = menu->sym;if (sym && !sym_is_choice (sym)) {sym_calc_value (sym);
@@ -811,12 +813,11 @@ int conf_write_defconfig(const char *filename)* If symbol is a choice value and equals to the * default for a choice - skip. */ -if (sym_is_choice_value (sym)) { -struct symbol *cs; + choice_menu =sym_get_choice_menu (sym); +if (choice_menu) {struct symbol *ds; - cs =prop_get_symbol (sym_get_choice_prop (sym)); - ds =sym_choice_default (cs); + ds =sym_choice_default (choice_menu->sym);if (sym == ds) {if ((sym->type ==S_BOOLEAN ) &&sym_get_tristate_value (sym) == yes)
Signature · 1 line
2.40.1
PATCH 7/10 kconfig: use menu_list_for_each_sym() in sym_check_choice_deps()
In reply to Masahiro YamadaChoices and their members are associated via the P_CHOICE property.
Currently, sym_get_choice_prop() and expr_list_for_each_sym() are used to iterate on choice members.
Replace them with menu_for_each_sub_entry(), which achieves the same without relying on P_CHOICE.
---
scripts/kconfig/symbol.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-)
scripts/kconfig/symbol.c +15 -10
@@ -1204,16 +1204,18 @@ static struct symbol *sym_check_sym_deps(struct symbol *sym)static struct symbol *sym_check_choice_deps (struct symbol *choice) { -struct symbol *sym, *sym2; -struct property *prop; -struct expr *e; +struct menu *menu, *child; +struct symbol *sym2;struct dep_stack stack;dep_stack_insert (&stack, choice); - prop =sym_get_choice_prop (choice); -expr_list_for_each_sym (prop->expr, e, sym) - sym->flags |= (SYMBOL_CHECK |SYMBOL_CHECKED ); + menu = list_first_entry(&choice->menus, struct menu, link); + +menu_for_each_sub_entry (child, menu) { +if (child->sym) + child->sym->flags |=SYMBOL_CHECK |SYMBOL_CHECKED ; + } choice->flags |= (SYMBOL_CHECK |SYMBOL_CHECKED ); sym2 =sym_check_sym_deps (choice);
@@ -1221,14 +1223,17 @@ static struct symbol *sym_check_choice_deps(struct symbol *choice)if (sym2) goto out; -expr_list_for_each_sym (prop->expr, e, sym) { - sym2 =sym_check_sym_deps (sym); +menu_for_each_sub_entry (child, menu) { +if (!child->sym) +continue ; + sym2 =sym_check_sym_deps (child->sym);if (sym2)break ; } out: -expr_list_for_each_sym (prop->expr, e, sym) - sym->flags &= ~SYMBOL_CHECK ; +menu_for_each_sub_entry (child, menu) +if (child->sym) + child->sym->flags &= ~SYMBOL_CHECK ;if (sym2 &&sym_is_choice_value (sym2) &&prop_get_symbol (sym_get_choice_prop (sym2)) == choice)
Signature · 1 line
2.40.1
PATCH 8/10 kconfig: turn conf_choice() into void function
In reply to Masahiro YamadaThe return value of conf_choice() is not used.
---
scripts/kconfig/conf.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
scripts/kconfig/conf.c +5 -6
@@ -446,7 +446,7 @@ static int conf_sym(struct menu *menu) } } -static int conf_choice (struct menu *menu) +static void conf_choice (struct menu *menu) {struct symbol *sym, *def_sym;struct menu *child;
@@ -459,19 +459,18 @@ static int conf_choice(struct menu *menu)sym_calc_value (sym);switch (sym_get_tristate_value (sym)) {case no: -return 1 ;case mod: -return 0 ; +return ;case yes:break ; } }else {switch (sym_get_tristate_value (sym)) {case no: -return 1 ; +return ;case mod:printf ("%*s%s\n" , indent -1 ,"" ,menu_get_prompt (menu)); -return 0 ; +return ;case yes:break ; }
@@ -551,7 +550,7 @@ static int conf_choice(struct menu *menu)continue ; }sym_set_tristate_value (child->sym, yes); -return 1 ; +return ; } }
Signature · 1 line
2.40.1
PATCH 9/10 kconfig: turn missing prompt for choice members into error
In reply to Masahiro YamadaChoice members must have a prompt; hence make it an error.
While I was here, I moved the check to the parser to slim down _menu_finalize().
---
scripts/kconfig/menu.c | 2 -- scripts/kconfig/parser.y | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-)
scripts/kconfig/menu.c +0 -2
@@ -507,8 +507,6 @@ static void _menu_finalize(struct menu *parent, bool inside_choice) menu->sym && !sym_is_choice_value(menu->sym)) { current_entry = menu; menu->sym->flags |=SYMBOL_CHOICEVAL ; -if (!menu->prompt) -menu_warn (menu,"choice value must have a prompt" );for (prop = menu->sym->prop; prop; prop = prop->next) {if (prop->type ==P_DEFAULT ) prop_warn(prop, "defaults for choice "
scripts/kconfig/parser.y +14 -0
@@ -30,6 +30,8 @@ static bool zconf_endtoken(const char *tokenname, struct menu *current_menu, *current_entry; +static bool inside_choice = false; + %} %union
@@ -145,6 +147,14 @@ config_entry_start: T_CONFIG nonconst_symbol T_EOL config_stmt: config_entry_start config_option_list { + if (inside_choice) { + if (!current_entry->prompt) { + fprintf(stderr, "%s:%d: error: choice member must have a prompt\n", + current_entry->filename, current_entry->lineno); + yynerrs++; + } + } + printd(DEBUG_PARSE, "%s:%d:endconfig\n", cur_filename, cur_lineno); };
@@ -237,10 +247,14 @@ choice_entry: choice choice_option_list } $$ = menu_add_menu(); + + inside_choice = true; }; choice_end: end { + inside_choice = false; + if (zconf_endtoken($1, "choice")) { menu_end_menu(); printd(DEBUG_PARSE, "%s:%d:endchoice\n", cur_filename, cur_lineno);
Signature · 1 line
2.40.1
PATCH 10/10 kconfig: turn defaults and additional prompt for choice members into error
In reply to Masahiro Yamadamenu_finalize() warns default properties for choice members and prompts outside the choice block. These should be hard errors.
While I was here, I moved the checks to slim down menu_finalize().
---
scripts/kconfig/menu.c | 10 ---------- scripts/kconfig/parser.y | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 10 deletions(-)
scripts/kconfig/menu.c +0 -10
@@ -507,16 +507,6 @@ static void _menu_finalize(struct menu *parent, bool inside_choice) menu->sym && !sym_is_choice_value(menu->sym)) { current_entry = menu; menu->sym->flags |=SYMBOL_CHOICEVAL ; -for (prop = menu->sym->prop; prop; prop = prop->next) { -if (prop->type ==P_DEFAULT ) -prop_warn (prop,"defaults for choice " -"values not supported" ); -if (prop->menu == menu) -continue ; -if (prop->type ==P_PROMPT && - prop->menu->parent->sym != sym) -prop_warn (prop,"choice value used outside its choice group" ); - }/* Non-tristate choice values of tristate choices must * depend on the choice being set to Y. The choice * values' dependencies were propagated to their
scripts/kconfig/parser.y +39 -0
@@ -476,6 +476,37 @@ assign_val: %% +/** + * choice_check_sanity - check sanity of a choice member + * + * @menu: menu of the choice member + * + * Return: -1 if an error is found, 0 otherwise. + */ +static int choice_check_sanity(struct menu *menu) +{ + struct property *prop; + int ret = 0; + + for (prop = menu->sym->prop; prop; prop = prop->next) { + if (prop->type == P_DEFAULT) { + fprintf(stderr, "%s:%d: error: %s", + prop->filename, prop->lineno, + "defaults for choice values not supported\n"); + ret = -1; + } + + if (prop->menu != menu && prop->type == P_PROMPT) { + fprintf(stderr, "%s:%d: error: %s", + prop->filename, prop->lineno, + "choice value has a prompt outside its choice group\n"); + ret = -1; + } + } + + return ret; +} + void conf_parse(const char *name) { struct menu *menu;
@@ -523,8 +554,16 @@ void conf_parse(const char *name) menu_finalize(); menu_for_each_entry(menu) { + struct menu *child; + if (menu->sym && sym_check_deps(menu->sym)) yynerrs++; + + if (menu->sym && sym_is_choice(menu->sym)) { + menu_for_each_sub_entry(child, menu) + if (child->sym && choice_check_sanity(child)) + yynerrs++; + } } if (yynerrs)
Signature · 1 line
2.40.1
Re: [PATCH 10/10] kconfig: turn defaults and additional prompt for choice members into error
Quoted 63 lines · Masahiro Yamada
menu_finalize()warns default properties for choice members and prompts outside the choice block. These should be hard errors.While I was here, I moved the checks to slim down
menu_finalize().Signed-off-by Masahiro Yamada <[email protected]>---
scripts/kconfig/menu.c | 10 ---------- scripts/kconfig/parser.y | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 10 deletions(-)scripts/kconfig/menu.c +0
-10@@ -507,16 +507,6 @@ static void _menu_finalize(struct menu *parent, bool inside_choice) menu->sym && !sym_is_choice_value(menu->sym)) { current_entry = menu; menu->sym->flags |=SYMBOL_CHOICEVAL ; -for (prop = menu->sym->prop; prop; prop = prop->next) { -if (prop->type ==P_DEFAULT ) -prop_warn (prop,"defaults for choice " -"values not supported" ); -if (prop->menu == menu) -continue ; -if (prop->type ==P_PROMPT && - prop->menu->parent->sym != sym) -prop_warn (prop,"choice value used outside its choice group" ); - }/* Non-tristate choice values of tristate choices must * depend on the choice being set to Y. The choice * values' dependencies were propagated to their scripts/kconfig/parser.y +21
-0@@ -476,6 +476,37 @@ assign_val: %% +/** + * choice_check_sanity - check sanity of a choice member + * + * @menu: menu of the choice member + * + * Return: -1 if an error is found, 0 otherwise. + */ +static int choice_check_sanity(struct menu *menu) +{ + struct property *prop; + int ret = 0; + + for (prop = menu->sym->prop; prop; prop = prop->next) { + if (prop->type == P_DEFAULT) { + fprintf(stderr, "%s:%d: error: %s", + prop->filename, prop->lineno, + "defaults for choice values not supported\n"); + ret = -1; + } + + if (prop->menu != menu && prop->type == P_PROMPT) {
scripts/kconfig/parser.y assign_val: · line 509
Quoted 10 lines
scripts/kconfig/parser.y +10
-0+ fprintf(stderr, "%s:%d: error: %s", + prop->filename, prop->lineno, + "choice value has a prompt outside its choice group\n"); + ret = -1; + } + } + + return ret; +} +
I observed an error in powerpc.
I will fix up this as follows:
scripts/kconfig/parser.y +2 -1
@@ -496,7 +496,8 @@ static int choice_check_sanity(struct menu *menu) ret = -1; } - if (prop->menu != menu && prop->type == P_PROMPT) { + if (prop->menu != menu && prop->type == P_PROMPT && + prop->menu->parent != menu->parent) { fprintf(stderr, "%s:%d: error: %s", prop->filename, prop->lineno, "choice value has a prompt outside its
choice group\n");
Signature · 2 lines
Best Regards Masahiro Yamada