Pull request for branch yem-kconfig-for-next
From: "Yann E. MORIN" <[email protected]>
Hello Michal, All!
These are the patches against kconfig that I have accumulated for 3.11, and for which I plan to later send a proper pull-request.
Note-whorthy this time:
- fix values of tristates that are selected by boolean choices (Arve)
- fix choice randomisation in presence of KCONFIG_ALLCONFIG (me)
- fix choice randomisation selecting more than one value in
a choice (but only if it is conditional) (me)
- fix choice-in-a-choice randomisation not selecting any value
for the inner-most choice (me)
Also, some code-cleanups and eye-candy:
- mconf and nconf code cleanups (Dirk, Sedat) - mconf and nconf eye-candy (Dirk) - scripts/config script-name in help text (Clément) - heuristic to sort found symbols by relevance (me) - more randconfig debugging help (me)
Note: this series is for review before I send an official pull-request. I want to avoid the debacle [0] [1] of the last kconfig breakage I caused with my previous kconfig "fix" to randomising choices in presence of KCONFIG_ALLCONFIG.
I would like to send an official pull-request early next week, so all of these can land early in -next, so they get some real-life t4esting before the next merge windows open. So please, please, test this carefully. ;-)
[0] http://marc.info/?t=136684274600002&r=1&w=2
[1] http://marc.info/?t=136696367200003&r=1&w=2
Regards,
Yann E. MORIN.
The following changes since commit f722406faae2d073cc1d01063d1123c35425939e:
Linux 3.10-rc1 (2013-05-11 17:14:08 -0700)
are available in the git repository at:
git://gitorious.org/linux-kconfig/linux-kconfig.git yem-kconfig-for-next
for you to fetch changes up to b4e0ac8385fecde0363a2499323f81b4a91e8430:
kconfig: fix randomising choice entries in presence of KCONFIG_ALLCONFIG (2013-06-18 23:59:02 +0200)
----------------------------------------------------------------
Arve Hjønnevåg (1):
kconfig: Fix defconfig when one choice menu selects options that another choice menu depends on
Clement Chauplannaz (1):
scripts/config: replace hard-coded script name by a dynamic value
Dirk Gouders (4):
kconfig/lxdialog: handle newline characters in print_autowrap()
mconf: use function calls instead of ncurses' variables LINES and COLS
nconf: use function calls instead of ncurses' variables LINES and COLS mconf/nconf: mark empty menus/menuconfigs different from non-empty ones
Sedat Dilek (2):
kconfig/lxdialog: Add definitions for mininimum (re)size values kconfig/lxdialog: Use new mininimum resize definitions in conf_choice()
Yann E. MORIN (6):
kconfig/conf: fix randconfig setting multiple symbols in a choice kconfig/conf: accept a base-16 seed for randconfig kconfig/conf: print the seed used to initialise the RNG for randconfig
kconfig: sort found symbols by relevance
kconfig: loop as long as we changed some symbols in randconfig
kconfig: fix randomising choice entries in presence of KCONFIG_ALLCONFIG
scripts/config | 12 ++-- scripts/kconfig/conf.c | 6 +- scripts/kconfig/confdata.c | 39 +++++++++---- scripts/kconfig/expr.h | 3 + scripts/kconfig/lkc.h | 3 +- scripts/kconfig/lkc_proto.h | 1 + scripts/kconfig/lxdialog/checklist.c | 8 +-- scripts/kconfig/lxdialog/dialog.h | 14 +++++ scripts/kconfig/lxdialog/inputbox.c | 8 +-- scripts/kconfig/lxdialog/menubox.c | 6 +- scripts/kconfig/lxdialog/textbox.c | 6 +- scripts/kconfig/lxdialog/util.c | 46 ++++++++------- scripts/kconfig/lxdialog/yesno.c | 8 +-- scripts/kconfig/mconf.c | 19 ++++--- scripts/kconfig/menu.c | 16 ++++++ scripts/kconfig/nconf.c | 37 +++++++----- scripts/kconfig/nconf.gui.c | 20 ++++--- scripts/kconfig/symbol.c | 107 ++++++++++++++++++++++++++++++++--- 18 files changed, 263 insertions(+), 96 deletions(-)
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'
PATCH 1/14 kconfig: Fix defconfig when one choice menu selects options that another choice menu depends on
From: Arve Hjønnevåg <[email protected]>
The defconfig and Kconfig combination below, which is based on 3.10-rc4 Kconfigs, resulted in several options getting set to "m" instead of "y".
defconfig.choice:
---8<---CONFIG_MODULES=yCONFIG_USB_ZERO=y
---8<---
Kconfig.choice:
---8<---
menuconfig MODULES
bool "Enable loadable module support"
config CONFIGFS_FS
tristate "Userspace-driven configuration filesystem"
config OCFS2_FS
tristate "OCFS2 file system support"
depends on CONFIGFS_FS
select CRC32
config USB_LIBCOMPOSITE
tristate
select CONFIGFS_FS
choice
tristate "USB Gadget Drivers"
default USB_ETH
config USB_ZERO
tristate "Gadget Zero (DEVELOPMENT)"
select USB_LIBCOMPOSITE
config USB_ETH
tristate "Ethernet Gadget (with CDC Ethernet support)" select USB_LIBCOMPOSITE
endchoice
config CRC32
tristate "CRC32/CRC32c functions"
default y
choice
prompt "CRC32 implementation"
depends on CRC32
default CRC32_SLICEBY8
config CRC32_SLICEBY8
bool "Slice by 8 bytes"
endchoice
---8<---
$ scripts/kconfig/conf --defconfig=defconfig.choice Kconfig.choice
would result in:
.config:
---8<---CONFIG_MODULES=yCONFIG_CONFIGFS_FS=mCONFIG_USB_LIBCOMPOSITE=mCONFIG_USB_ZERO=mCONFIG_CRC32=yCONFIG_CRC32_SLICEBY8=y
---8<---
when the expected result would be:
.config:
---8<---CONFIG_MODULES=yCONFIG_CONFIGFS_FS=yCONFIG_USB_LIBCOMPOSITE=yCONFIG_USB_ZERO=yCONFIG_CRC32=yCONFIG_CRC32_SLICEBY8=y
---8<---
[[email protected]: add the resulting .config to commit log,
remove unneeded USB_GADGET from the defconfig]
--- scripts/kconfig/confdata.c | 14 ++++++++++---- scripts/kconfig/expr.h | 3 +++ scripts/kconfig/lkc.h | 1 + scripts/kconfig/symbol.c | 11 +++++++++++ 4 files changed, 25 insertions(+), 4 deletions(-)
scripts/kconfig/confdata.c +10 -4
@@ -1083,7 +1083,7 @@ static void randomize_choice_values(struct symbol *csym) csym->flags &= ~(SYMBOL_VALID ); } -static void set_all_choice_values (struct symbol *csym) +void set_all_choice_values (struct symbol *csym) {struct property *prop;struct symbol *sym;
@@ -1100,7 +1100,7 @@ static void set_all_choice_values(struct symbol *csym) } csym->flags |=SYMBOL_DEF_USER ;/* clear VALID to get value calculated */ - csym->flags &= ~(SYMBOL_VALID ); + csym->flags &= ~(SYMBOL_VALID |SYMBOL_NEED_SET_CHOICE_VALUES ); }void conf_set_all_new_symbols (enum conf_def_mode mode)
@@ -1202,6 +1202,14 @@ void conf_set_all_new_symbols(enum conf_def_mode mode)* selected in a choice block and we set it to yes, * and the rest to no. */ +if (mode != def_random) { + for_all_symbols(i, csym) { +if ((sym_is_choice (csym) && !sym_has_value (csym)) || +sym_is_choice_value (csym)) + csym->flags |=SYMBOL_NEED_SET_CHOICE_VALUES ; + } + } + for_all_symbols(i, csym) {if (sym_has_value (csym) || !sym_is_choice (csym))continue ;
@@ -1209,7 +1217,5 @@ void conf_set_all_new_symbols(enum conf_def_mode mode)sym_calc_value (csym);if (mode == def_random)randomize_choice_values (csym); -else -set_all_choice_values (csym); } }
scripts/kconfig/expr.h +3 -0
@@ -106,6 +106,9 @@ struct symbol {#define SYMBOL_DEF3 0x40000/* symbol.def[S_DEF_3] is valid */ #define SYMBOL_DEF4 0x80000/* symbol.def[S_DEF_4] is valid */ +/* choice values need to be set before calculating this symbol value */ +#define SYMBOL_NEED_SET_CHOICE_VALUES 0x100000 +#define SYMBOL_MAXLENGTH 256#define SYMBOL_HASHSIZE 9973
scripts/kconfig/lkc.h +1 -0
@@ -87,6 +87,7 @@ char *conf_get_default_confname(void);void sym_set_change_count (int count);void sym_add_change_count (int count);void conf_set_all_new_symbols (enum conf_def_mode mode); +void set_all_choice_values (struct symbol *csym);struct conf_printer {void (*print_symbol)(FILE *,struct symbol *,const char *,void *);
scripts/kconfig/symbol.c +11 -0
@@ -300,6 +300,14 @@ void sym_calc_value(struct symbol *sym)if (sym->flags &SYMBOL_VALID )return ; + +if (sym_is_choice_value (sym) && + sym->flags &SYMBOL_NEED_SET_CHOICE_VALUES ) { + sym->flags &= ~SYMBOL_NEED_SET_CHOICE_VALUES ; + prop =sym_get_choice_prop (sym); +sym_calc_value (prop_get_symbol (prop)); + } + sym->flags |=SYMBOL_VALID ; oldval = sym->curr;
@@ -425,6 +433,9 @@ void sym_calc_value(struct symbol *sym)if (sym->flags &SYMBOL_AUTO ) sym->flags &= ~SYMBOL_WRITE ; + +if (sym->flags &SYMBOL_NEED_SET_CHOICE_VALUES ) +set_all_choice_values (sym); }void sym_clear_all_valid (void )
Signature · 1 line
1.8.1.2
PATCH 2/14 kconfig/lxdialog: Add definitions for mininimum (re)size values
In reply to Yann E. MORINFrom: Sedat Dilek <[email protected]>
Commit c8dc68ad0fbd ("kconfig/lxdialog: support resize") added support for resizing, but forgot to collect all hardcoded values at one single place.
Also add a definition for the check for a minimum screen/window size of 80x19.
[ ChangeLog v3:
* Rename MENU_{HEIGTH,WIDTH}_MIN -> MENUBOX_{HEIGTH,WIDTH}_MIN ChangeLog v2:
* Rename WIN_{HEIGTH,WIDTH}_MIN -> WINDOW_{HEIGTH,WIDTH}_MIN
* Mention the check for a minimum screen/window size in the changelog
* Add a comment above the block of new definitions ]
--- scripts/kconfig/lxdialog/checklist.c | 4 ++-- scripts/kconfig/lxdialog/dialog.h | 14 ++++++++++++++ scripts/kconfig/lxdialog/inputbox.c | 4 ++-- scripts/kconfig/lxdialog/menubox.c | 2 +- scripts/kconfig/lxdialog/textbox.c | 2 +- scripts/kconfig/lxdialog/util.c | 2 +- scripts/kconfig/lxdialog/yesno.c | 4 ++-- 7 files changed, 23 insertions(+), 9 deletions(-)
scripts/kconfig/lxdialog/checklist.c +2 -2
@@ -132,9 +132,9 @@ int dialog_checklist(const char *title, const char *prompt, int height, } do_resize: -if (getmaxy (stdscr) < (height +6 )) +if (getmaxy (stdscr) < (height +CHECKLIST_HEIGTH_MIN ))return -ERRDISPLAYTOOSMALL ; -if (getmaxx (stdscr) < (width +6 )) +if (getmaxx (stdscr) < (width +CHECKLIST_WIDTH_MIN ))return -ERRDISPLAYTOOSMALL ; max_choice =MIN (list_height,item_count ());
scripts/kconfig/lxdialog/dialog.h +14 -0
@@ -200,6 +200,20 @@ int item_is_tag(char tag);int on_key_esc (WINDOW *win);int on_key_resize (void ); +/* minimum (re)size values */ +#define CHECKLIST_HEIGTH_MIN 6/* For dialog_checklist() */ +#define CHECKLIST_WIDTH_MIN 6 +#define INPUTBOX_HEIGTH_MIN 2/* For dialog_inputbox() */ +#define INPUTBOX_WIDTH_MIN 2 +#define MENUBOX_HEIGTH_MIN 15/* For dialog_menu() */ +#define MENUBOX_WIDTH_MIN 65 +#define TEXTBOX_HEIGTH_MIN 8/* For dialog_textbox() */ +#define TEXTBOX_WIDTH_MIN 8 +#define YESNO_HEIGTH_MIN 4/* For dialog_yesno() */ +#define YESNO_WIDTH_MIN 4 +#define WINDOW_HEIGTH_MIN 19/* For init_dialog() */ +#define WINDOW_WIDTH_MIN 80 +int init_dialog (const char *backtitle);void set_dialog_backtitle (const char *backtitle);void set_dialog_subtitles (struct subtitle_list *subtitles);
scripts/kconfig/lxdialog/inputbox.c +2 -2
@@ -56,9 +56,9 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int widthstrcpy (instr, init); do_resize: -if (getmaxy (stdscr) <= (height -2 )) +if (getmaxy (stdscr) <= (height -INPUTBOX_HEIGTH_MIN ))return -ERRDISPLAYTOOSMALL ; -if (getmaxx (stdscr) <= (width -2 )) +if (getmaxx (stdscr) <= (width -INPUTBOX_WIDTH_MIN ))return -ERRDISPLAYTOOSMALL ;/* center dialog box on screen */
scripts/kconfig/lxdialog/menubox.c +1 -1
@@ -193,7 +193,7 @@ int dialog_menu(const char *title, const char *prompt, do_resize: height =getmaxy (stdscr); width =getmaxx (stdscr); -if (height <15 || width <65 ) +if (height <MENUBOX_HEIGTH_MIN || width <MENUBOX_WIDTH_MIN )return -ERRDISPLAYTOOSMALL ; height -=4 ;
scripts/kconfig/lxdialog/textbox.c +1 -1
@@ -80,7 +80,7 @@ int dialog_textbox(const char *title, char *tbuf, int initial_height, do_resize:getmaxyx (stdscr, height, width); -if (height <8 || width <8 ) +if (height <TEXTBOX_HEIGTH_MIN || width <TEXTBOX_WIDTH_MIN )return -ERRDISPLAYTOOSMALL ;if (initial_height !=0 ) height = initial_height;
scripts/kconfig/lxdialog/util.c +1 -1
@@ -317,7 +317,7 @@ int init_dialog(const char *backtitle)getyx (stdscr, saved_y, saved_x);getmaxyx (stdscr, height, width); -if (height <19 || width <80 ) { +if (height <WINDOW_HEIGTH_MIN || width <WINDOW_WIDTH_MIN ) {endwin ();return -ERRDISPLAYTOOSMALL ; }
scripts/kconfig/lxdialog/yesno.c +2 -2
@@ -45,9 +45,9 @@ int dialog_yesno(const char *title, const char *prompt, int height, int width)WINDOW *dialog; do_resize: -if (getmaxy (stdscr) < (height +4 )) +if (getmaxy (stdscr) < (height +YESNO_HEIGTH_MIN ))return -ERRDISPLAYTOOSMALL ; -if (getmaxx (stdscr) < (width +4 )) +if (getmaxx (stdscr) < (width +YESNO_WIDTH_MIN ))return -ERRDISPLAYTOOSMALL ;/* center dialog box on screen */
Signature · 1 line
1.8.1.2
PATCH 3/14 kconfig/lxdialog: Use new mininimum resize definitions in conf_choice()
In reply to Yann E. MORINFrom: Sedat Dilek <[email protected]>
This is a cleanup which uses the proper (new) definitions and does not change current behaviour.
---
Yann had some more ideas on improvements:
"What would be nice is an improvement that scales the choice window to the number of entries in the choice. If there are a lot of choice entries, then the choice popup grows in height (but does not overflow the screen of course). So, instead of seeing only 6 entries, we'd see as much as possible in the current screen.
Ditto for the width: the popup adapts to the longest prompt (but does not overflow the screen either, of course), so prompts are not truncated."
NOTE: This patch requires [1].
[1] http://marc.info/?l=linux-kbuild&m=137128726917166&w=2
--- scripts/kconfig/mconf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
scripts/kconfig/mconf.c +3 -1
@@ -825,7 +825,9 @@ static void conf_choice(struct menu *menu)dialog_clear (); res =dialog_checklist (prompt ?_ (prompt) :_ ("Main Menu" ),_ (radiolist_instructions), -15 ,70 ,6 ); +MENUBOX_HEIGTH_MIN , +MENUBOX_WIDTH_MIN , +CHECKLIST_HEIGTH_MIN ); selected =item_activate_selected ();switch (res) {case 0 :
Signature · 1 line
1.8.1.2
PATCH 4/14 kconfig/lxdialog: handle newline characters in print_autowrap()
In reply to Yann E. MORINFrom: Dirk Gouders <[email protected]>
When exiting menuconfig with unsaved changes, a dialog like the following is shown:
Do you wish to save your new configuration ? <ESC><ESC> to continue.
The author of the dialog text specified a newline after the '?', and probably expected it to be processed, so let print_autowrap() handle newlines propperly.
Also, reword that dialog's second phrase with a real sentence.
--- scripts/kconfig/lxdialog/util.c | 31 +++++++++++++++++-------------- scripts/kconfig/mconf.c | 4 ++-- 2 files changed, 19 insertions(+), 16 deletions(-)
scripts/kconfig/lxdialog/util.c +17 -14
@@ -371,27 +371,19 @@ void print_title(WINDOW *dialog, const char *title, int width)/* * Print a string of text in a window, automatically wrap around to the * next line if the string is too long to fit on one line. Newline -* characters '\n' are replaced by spaces. We start on a new line +* characters '\n' are propperly processed. We start on a new line * if there is no room for at least 4 nonblanks following a double-space. */ void print_autowrap (WINDOW * win,const char *prompt,int width,int y,int x) {int newl, cur_x, cur_y; -int i, prompt_len, room, wlen; -char tempstr[MAX_LEN +1 ], *word, *sp, *sp2; +int prompt_len, room, wlen; +char tempstr[MAX_LEN +1 ], *word, *sp, *sp2, *newline_separator =0 ;strcpy (tempstr, prompt); prompt_len =strlen (tempstr); -/* -* Remove newlines -*/ -for (i =0 ; i < prompt_len; i++) { -if (tempstr[i] =='\n' ) - tempstr[i] =' ' ; - } -if (prompt_len <= width - x *2 ) {/* If prompt is short */ wmove (win, y, (width - prompt_len) /2 );waddstr (win, tempstr);
@@ -401,7 +393,10 @@ void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x) newl =1 ; word = tempstr;while (word && *word) { - sp =strchr (word,' ' ); + sp =strpbrk (word,"\n " ); +if (sp && *sp =='\n' ) + newline_separator = sp; +if (sp) *sp++ =0 ;
@@ -413,7 +408,7 @@ void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x)if (wlen > room || (newl && wlen <4 && sp && wlen +1 +strlen (sp) > room - && (!(sp2 =strchr (sp,' ' )) + && (!(sp2 =strpbrk (sp,"\n " )) || wlen +1 + (sp2 - sp) > room))) { cur_y++; cur_x = x;
@@ -421,7 +416,15 @@ void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x)wmove (win, cur_y, cur_x);waddstr (win, word);getyx (win, cur_y, cur_x); - cur_x++; + +/* Move to the next line if the word separator was a newline */ +if (newline_separator) { + cur_y++; + cur_x = x; + newline_separator =0 ; + }else + cur_x++; +if (sp && *sp ==' ' ) { cur_x++;/* double space */ while (*++sp ==' ' ) ;
scripts/kconfig/mconf.c +2 -2
@@ -958,8 +958,8 @@ static int handle_exit(void)dialog_clear ();if (conf_get_changed ()) res =dialog_yesno (NULL , -_ ("Do you wish to save your new configuration ?\n" -"<ESC><ESC> to continue." ), +_ ("Do you wish to save your new configuration?\n" +"(Press <ESC><ESC> to continue kernel configuration.)" ),6 ,60 );else res =-1 ;
Signature · 1 line
1.8.1.2
PATCH 5/14 mconf: use function calls instead of ncurses' variables LINES and COLS
In reply to Yann E. MORINFrom: Dirk Gouders <[email protected]>
According to the documentation [1], LINES and COLS are initialized by initscr(); it does not say anything about the behavior when windows are resized.
Do not rely on the current implementation of ncurses that updates these variables on resize, but use the propper function calls to get window dimensions.
init_dialog() could make use of the variables, but for the sake of consistency we do not change it's current use of the macro getmaxyx().
[1] ncurses(3X)
--- scripts/kconfig/lxdialog/checklist.c | 4 ++-- scripts/kconfig/lxdialog/inputbox.c | 4 ++-- scripts/kconfig/lxdialog/menubox.c | 4 ++-- scripts/kconfig/lxdialog/textbox.c | 4 ++-- scripts/kconfig/lxdialog/util.c | 13 +++++++++---- scripts/kconfig/lxdialog/yesno.c | 4 ++-- 6 files changed, 19 insertions(+), 14 deletions(-)
scripts/kconfig/lxdialog/checklist.c +2 -2
@@ -140,8 +140,8 @@ do_resize: max_choice =MIN (list_height,item_count ());/* center dialog box on screen */ - x = (COLS - width) /2 ; - y = (LINES - height) /2 ; + x = (getmaxx (stdscr) - width) /2 ; + y = (getmaxy (stdscr) - height) /2 ;draw_shadow (stdscr, y, x, height, width);
scripts/kconfig/lxdialog/inputbox.c +2 -2
@@ -62,8 +62,8 @@ do_resize:return -ERRDISPLAYTOOSMALL ;/* center dialog box on screen */ - x = (COLS - width) /2 ; - y = (LINES - height) /2 ; + x = (getmaxx (stdscr) - width) /2 ; + y = (getmaxy (stdscr) - height) /2 ;draw_shadow (stdscr, y, x, height, width);
scripts/kconfig/lxdialog/menubox.c +2 -2
@@ -203,8 +203,8 @@ do_resize: max_choice =MIN (menu_height,item_count ());/* center dialog box on screen */ - x = (COLS - width) /2 ; - y = (LINES - height) /2 ; + x = (getmaxx (stdscr) - width) /2 ; + y = (getmaxy (stdscr) - height) /2 ;draw_shadow (stdscr, y, x, height, width);
scripts/kconfig/lxdialog/textbox.c +2 -2
@@ -98,8 +98,8 @@ do_resize: width =0 ;/* center dialog box on screen */ - x = (COLS - width) /2 ; - y = (LINES - height) /2 ; + x = (getmaxx (stdscr) - width) /2 ; + y = (getmaxy (stdscr) - height) /2 ;draw_shadow (stdscr, y, x, height, width);
scripts/kconfig/lxdialog/util.c +9 -4
@@ -254,7 +254,12 @@ void attr_clear(WINDOW * win, int height, int width, chtype attr)void dialog_clear (void ) { -attr_clear (stdscr,LINES ,COLS , dlg.screen.atr); +int lines, columns; + + lines =getmaxy (stdscr); + columns =getmaxx (stdscr); + +attr_clear (stdscr, lines, columns, dlg.screen.atr);/* Display background title if it exists ... - SLH */ if (dlg.backtitle !=NULL ) {int i, len =0 , skip =0 ;
@@ -269,10 +274,10 @@ void dialog_clear(void) }wmove (stdscr,1 ,1 ); -if (len >COLS -2 ) { +if (len > columns -2 ) {const char *ellipsis ="[...] " ;waddstr (stdscr, ellipsis); - skip = len - (COLS -2 -strlen (ellipsis)); + skip = len - (columns -2 -strlen (ellipsis)); }for (pos = dlg.subtitles; pos !=NULL ; pos = pos->next) {
@@ -298,7 +303,7 @@ void dialog_clear(void) skip--; } -for (i = len +1 ; i <COLS -1 ; i++) +for (i = len +1 ; i < columns -1 ; i++)waddch (stdscr,ACS_HLINE ); }wnoutrefresh (stdscr);
scripts/kconfig/lxdialog/yesno.c +2 -2
@@ -51,8 +51,8 @@ do_resize:return -ERRDISPLAYTOOSMALL ;/* center dialog box on screen */ - x = (COLS - width) /2 ; - y = (LINES - height) /2 ; + x = (getmaxx (stdscr) - width) /2 ; + y = (getmaxy (stdscr) - height) /2 ;draw_shadow (stdscr, y, x, height, width);
Signature · 1 line
1.8.1.2
PATCH 6/14 nconf: use function calls instead of ncurses' variables LINES and COLS
In reply to Yann E. MORINFrom: Dirk Gouders <[email protected]>
According to the documentation [1], LINES and COLS are initialized by initscr(); it does not say anything about the behavior when windows are resized.
Do not rely on the current implementation of ncurses that updates these variables on resize, but use the propper function calls or macros to get window dimensions.
The use of the variables in main() was OK, but for the sake of consistency it was modified to use the macro getmaxyx().
[1] ncurses(3X)
--- scripts/kconfig/nconf.c | 21 ++++++++++++++------- scripts/kconfig/nconf.gui.c | 20 +++++++++++--------- 2 files changed, 25 insertions(+), 16 deletions(-)
scripts/kconfig/nconf.c +14 -7
@@ -365,15 +365,16 @@ static void print_function_line(void)int i;int offset =1 ;const int skip =1 ; +int lines =getmaxy (stdscr);for (i =0 ; i < function_keys_num; i++) { (void )wattrset (main_window, attributes[FUNCTION_HIGHLIGHT ]); -mvwprintw (main_window,LINES -3 , offset, +mvwprintw (main_window, lines-3 , offset,"%s" , function_keys[i].key_str); (void )wattrset (main_window, attributes[FUNCTION_TEXT ]); offset +=strlen (function_keys[i].key_str); -mvwprintw (main_window,LINES -3 , +mvwprintw (main_window, lines-3 , offset,"%s" , function_keys[i].func); offset +=strlen (function_keys[i].func) + skip;
@@ -954,7 +955,7 @@ static void show_menu(const char *prompt, const char *instructions,clear (); (void )wattrset (main_window, attributes[NORMAL ]); -print_in_middle (stdscr,1 ,0 ,COLS , +print_in_middle (stdscr,1 ,0 ,getmaxx (stdscr), menu_backtitle, attributes[MAIN_HEADING ]);
@@ -1455,14 +1456,18 @@ static void conf_save(void)void setup_windows (void ) { +int lines, columns; + +getmaxyx (stdscr, lines, columns); +if (main_window !=NULL )delwin (main_window);/* set up the menu and menu window */ - main_window =newwin (LINES -2 ,COLS -2 ,2 ,1 ); + main_window =newwin (lines-2 , columns-2 ,2 ,1 );keypad (main_window, TRUE); - mwin_max_lines =LINES -7 ; - mwin_max_cols =COLS -6 ; + mwin_max_lines = lines-7 ; + mwin_max_cols = columns-6 ;/* panels order is from bottom to top */ new_panel (main_window);
@@ -1470,6 +1475,7 @@ void setup_windows(void)int main (int ac,char **av) { +int lines, columns;char *mode;setlocale (LC_ALL ,"" );
@@ -1495,7 +1501,8 @@ int main(int ac, char **av)keypad (stdscr, TRUE);curs_set (0 ); -if (COLS <75 ||LINES <20 ) { +getmaxyx (stdscr, lines, columns); +if (columns <75 || lines <20 ) {endwin ();printf ("Your terminal should have at " "least 20 lines and 75 columns\n" );
scripts/kconfig/nconf.gui.c +11 -9
@@ -276,8 +276,8 @@ int btn_dialog(WINDOW *main_window, const char *msg, int btn_num, ...) total_width =max (msg_width, btns_width);/* place dialog in middle of screen */ - y = (LINES -(msg_lines+4 ))/2 ; - x = (COLS -(total_width+4 ))/2 ; + y = (getmaxy (stdscr)-(msg_lines+4 ))/2 ; + x = (getmaxx (stdscr)-(total_width+4 ))/2 ;/* create the windows */
@@ -387,8 +387,8 @@ int dialog_inputbox(WINDOW *main_window, prompt_width =max (prompt_width,strlen (title));/* place dialog in middle of screen */ - y = (LINES -(prompt_lines+4 ))/2 ; - x = (COLS -(prompt_width+4 ))/2 ; + y = (getmaxy (stdscr)-(prompt_lines+4 ))/2 ; + x = (getmaxx (stdscr)-(prompt_width+4 ))/2 ;strncpy (result, init, *result_len);
@@ -545,7 +545,7 @@ void show_scroll_win(WINDOW *main_window, {int res;int total_lines =get_line_no (text); -int x, y; +int x, y, lines, columns;int start_x =0 , start_y =0 ;int text_lines =0 , text_cols =0 ;int total_cols =0 ;
@@ -556,6 +556,8 @@ void show_scroll_win(WINDOW *main_window,WINDOW *pad;PANEL *panel; +getmaxyx (stdscr, lines, columns); +/* find the widest line of msg: */ total_lines =get_line_no (text);for (i =0 ; i < total_lines; i++) {
@@ -569,14 +571,14 @@ void show_scroll_win(WINDOW *main_window, (void )wattrset (pad, attributes[SCROLLWIN_TEXT ]);fill_window (pad, text); - win_lines =min (total_lines+4 ,LINES -2 ); - win_cols =min (total_cols+2 ,COLS -2 ); + win_lines =min (total_lines+4 , lines-2 ); + win_cols =min (total_cols+2 , columns-2 ); text_lines =max (win_lines-4 ,0 ); text_cols =max (win_cols-2 ,0 );/* place window in middle of screen */ - y = (LINES -win_lines)/2 ; - x = (COLS -win_cols)/2 ; + y = (lines-win_lines)/2 ; + x = (columns-win_cols)/2 ; win =newwin (win_lines, win_cols, y, x);keypad (win, TRUE);
Signature · 1 line
1.8.1.2
PATCH 7/14 mconf/nconf: mark empty menus/menuconfigs different from non-empty ones
In reply to Yann E. MORINFrom: Dirk Gouders <[email protected]>
Submenus are sometimes empty and it would be nice if there is something that notifies us that we should not expect any content _before_ we enter a submenu.
A new function menu_is_empty() was introduced and empty menus and menuconfigs are now marked by "----" as opposed to non-empty ones that are marked by "--->".
This scheme was suggested by "Yann E. MORIN" <[email protected]>.
--- scripts/kconfig/lkc_proto.h | 1 + scripts/kconfig/mconf.c | 11 ++++++----- scripts/kconfig/menu.c | 16 ++++++++++++++++ scripts/kconfig/nconf.c | 16 ++++++++-------- 4 files changed, 31 insertions(+), 13 deletions(-)
scripts/kconfig/lkc_proto.h +1 -0
@@ -14,6 +14,7 @@ P(conf_set_message_callback, void,(void (*fn)(const char *fmt, va_list ap)));/* menu.c */ P(rootmenu,struct menu,); +P(menu_is_empty, bool, (struct menu *menu)); P(menu_is_visible, bool, (struct menu *menu)); P(menu_has_prompt, bool, (struct menu *menu)); P(menu_get_prompt,const char *,(struct menu *menu));
scripts/kconfig/mconf.c +6 -5
@@ -48,7 +48,7 @@ static const char mconf_readme[] = N_("----------\n" "o Use the Up/Down arrow keys (cursor keys) to highlight the item\n" " you wish to change or submenu wish to select and press <Enter>.\n" -" Submenus are designated by \"--->\".\n" +" Submenus are designated by \"--->\", empty ones by \"----\".\n" "\n" " Shortcut: Press the option's highlighted letter (hotkey).\n" " Pressing a hotkey more than once will sequence\n"
@@ -176,7 +176,7 @@ static const char mconf_readme[] = N_( "\n"), menu_instructions[] = N_("Arrow keys navigate the menu. " -"<Enter> selects submenus --->. " +"<Enter> selects submenus ---> (or empty submenus ----). " "Highlighted letters are hotkeys. " "Pressing <Y> includes, <N> excludes, <M> modularizes features. " "Press <Esc><Esc> to exit, <?> for Help, </> for Search. "
@@ -498,8 +498,9 @@ static void build_conf(struct menu *menu) menu->data ?"-->" :"++>" , indent + 1, ' ', prompt); }else -item_make (" %*c%s --->" , indent +1 ,' ' , prompt); - +item_make (" %*c%s %s" , + indent +1 ,' ' , prompt, +menu_is_empty (menu) ?"----" :"--->" );item_set_tag ('m' );item_set_data (menu);if (single_menu_mode && menu->data)
@@ -630,7 +631,7 @@ static void build_conf(struct menu *menu) (sym_has_value (sym) || !sym_is_changable (sym)) ? "" : _(" (NEW)"));if (menu->prompt->type ==P_MENU ) { -item_add_str (" --->" ); +item_add_str (" %s" ,menu_is_empty (menu) ?"----" :"--->" );return ; } }
scripts/kconfig/menu.c +16 -0
@@ -430,6 +430,22 @@ bool menu_has_prompt(struct menu *menu)return true; } +/* +* Determine if a menu is empty. +* A menu is considered empty if it contains no or only +* invisible entries. +*/ +bool menu_is_empty (struct menu *menu) +{ +struct menu *child; + +for (child = menu->list; child; child = child->next) { +if (menu_is_visible (child)) +return (false); + } +return (true); +} +bool menu_is_visible (struct menu *menu) {struct menu *child;
scripts/kconfig/nconf.c +8 -8
@@ -45,8 +45,8 @@ static const char nconf_global_help[] = N_("<n> to remove it. You may press the <Space> key to cycle through the\n" "available options.\n" "\n" -"A trailing \"--->\" designates a submenu.\n" -"\n" +"A trailing \"--->\" designates a submenu, a trailing \"----\" an\n" +"empty submenu.\n" "\n" "Menu navigation keys\n" "----------------------------------------------------------------------\n"
@@ -131,7 +131,7 @@ static const char nconf_global_help[] = N_( "\n"), menu_no_f_instructions[] = N_("Legend: [*] built-in [ ] excluded <M> module < > module capable.\n" -"Submenus are designated by a trailing \"--->\".\n" +"Submenus are designated by a trailing \"--->\", empty ones by \"----\".\n" "\n" "Use the following keys to navigate the menus:\n" "Move up or down with <Up> and <Down>.\n"
@@ -148,7 +148,7 @@ menu_no_f_instructions[] = N_( "For help related to the current menu entry press <?> or <h>.\n"), menu_instructions[] = N_("Legend: [*] built-in [ ] excluded <M> module < > module capable.\n" -"Submenus are designated by a trailing \"--->\".\n" +"Submenus are designated by a trailing \"--->\", empty ones by \"----\".\n" "\n" "Use the following keys to navigate the menus:\n" "Move up or down with <Up> or <Down>.\n"
@@ -760,9 +760,9 @@ static void build_conf(struct menu *menu) indent + 1, ' ', prompt); }else item_make (menu,'m' , -" %*c%s --->" , - indent +1 , -' ' , prompt); +" %*c%s %s" , + indent +1 ,' ' , prompt, +menu_is_empty (menu) ?"----" :"--->" );if (single_menu_mode && menu->data) goto conf_childs;
@@ -904,7 +904,7 @@ static void build_conf(struct menu *menu) (sym_has_value (sym) || !sym_is_changable (sym)) ? "" : _(" (NEW)"));if (menu->prompt && menu->prompt->type ==P_MENU ) { -item_add_str (" --->" ); +item_add_str (" %s" ,menu_is_empty (menu) ?"----" :"--->" );return ; } }
Signature · 1 line
1.8.1.2
PATCH 8/14 scripts/config: replace hard-coded script name by a dynamic value
In reply to Yann E. MORINFrom: Clement Chauplannaz <[email protected]>
The script config' prints its name in usage() function. It is currently hard-coded to value config'. However, the script may be reused under a different name in contexts other than the Linux Kernel.
Replace the hard-coded value `config' by the name of the script at runtime.
--- scripts/config | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
scripts/config +7 -5
@@ -1,6 +1,8 @@ #!/bin/bash # Manipulate options in a .config file from the command line +myname=${0##*/} + # If no prefix forced, use the default CONFIG_ CONFIG_="${CONFIG_-CONFIG_}"
@@ -8,7 +10,7 @@ usage() { cat >&2 <<EOL Manipulate options in a .config file from the command line. Usage: -config options command ... +$myname options command ... commands: --enable|-e option Enable option --disable|-d option Disable option
@@ -33,14 +35,14 @@ options: --file config-file .config file to change (default .config) --keep-case|-k Keep next symbols' case (dont' upper-case it) -config doesn't check the validity of the .config file. This is done at next +$myname doesn't check the validity of the .config file. This is done at next make time. -By default, config will upper-case the given symbol. Use --keep-case to keep +By default, $myname will upper-case the given symbol. Use --keep-case to keep the case of all following symbols unchanged. -config uses 'CONFIG_' as the default symbol prefix. Set the environment -variable CONFIG_ to the prefix to use. Eg.: CONFIG_="FOO_" config ... +$myname uses 'CONFIG_' as the default symbol prefix. Set the environment +variable CONFIG_ to the prefix to use. Eg.: CONFIG_="FOO_" $myname ... EOL exit 1 }
Signature · 1 line
1.8.1.2
PATCH 9/14 kconfig/conf: fix randconfig setting multiple symbols in a choice
In reply to Yann E. MORINFrom: "Yann E. MORIN" <[email protected]>
Currently, randconfig may set more than one symbol in a given choice. Given this config file:
config A
bool "A"
if A
choice
bool "B/C/D"
config B
bool "B"
config C
bool "C"
config D
bool "D"
endchoice
endif # A
Then randconfig generates such .config files (case where A is not set is not shown below for brevity), and where only the right-most .config is valid:
CONFIG_A=y CONFIG_A=y CONFIG_A=y CONFIG_B=y CONFIG_B=y CONFIG_B=y CONFIG_C=y # CONFIG_C is not set # CONFIG_C is not set # CONFIG_D is not set CONFIG_D=y # CONFIG_D is not set
That is, in a randomised choice, the first symbol is always selected, and at most one other symbol may be selected.
This is due to symbol randomised in a choice not being properly flagged as having a value.
Fix that by flagging those symbols adequately: have a user-defined value, and be not valid (to force recalculation of the symbol).
Note: if the choice is not conditional, then the randomisation is properly done.
[[email protected]: independently re-done the same patch as Matthieu,
as pointed out by Sedat]
--- scripts/kconfig/confdata.c | 3 +++ 1 file changed, 3 insertions(+)
scripts/kconfig/confdata.c +3 -0
@@ -1077,6 +1077,9 @@ static void randomize_choice_values(struct symbol *csym)else { sym->def[S_DEF_USER ].tri = no; } + sym->flags |=SYMBOL_DEF_USER ; +/* clear VALID to get value calculated */ + sym->flags &= ~SYMBOL_VALID ; } csym->flags |=SYMBOL_DEF_USER ;/* clear VALID to get value calculated */
Signature · 1 line
1.8.1.2
PATCH 10/14 kconfig/conf: accept a base-16 seed for randconfig
In reply to Yann E. MORINFrom: "Yann E. MORIN" <[email protected]>
--- scripts/kconfig/conf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/kconfig/conf.c +1 -1
@@ -527,7 +527,7 @@ int main(int ac, char **av) seed_env =getenv ("KCONFIG_SEED" );if ( seed_env && *seed_env ) {char *endp; -int tmp = (int )strtol (seed_env, &endp,10 ); +int tmp = (int )strtol (seed_env, &endp,0 );if (*endp =='\0' ) { seed = tmp; }
Signature · 1 line
1.8.1.2
PATCH 11/14 kconfig/conf: print the seed used to initialise the RNG for randconfig
In reply to Yann E. MORINFrom: "Yann E. MORIN" <[email protected]>
... so the user has a chance to reproduce a test-case.
--- scripts/kconfig/conf.c | 1 + 1 file changed, 1 insertion(+)
scripts/kconfig/conf.c +1 -0
@@ -532,6 +532,7 @@ int main(int ac, char **av) seed = tmp; } } +fprintf ( stderr,"KCONFIG_SEED=0x%X\n" , seed );srand (seed);break ; }
Signature · 1 line
1.8.1.2
PATCH 12/14 kconfig: sort found symbols by relevance
In reply to Yann E. MORINFrom: "Yann E. MORIN" <[email protected]>
When searching for symbols, return the symbols sorted by relevance.
Sorting is done as thus:
- first, symbols with a prompt, [1] - then, smallest offset, [2] - then, shortest match, [3] - then, highest relative match, [4] - finally, alphabetical sort [5]
So, searching (eg.) for 'P.*CI' :
[1] Symbols of interest are probably those with a prompt, as they can be changed, while symbols with no prompt are only for info. Thus:
PCIEASPM comes before PCI_ATS
[2] Symbols that match earlier in the name are to be preferred over symbols which match later. Thus:
PCI_MSI comes before WDTPCI
[3] The shortest match is (IMHO) more interesting than a longer one. Thus:
PCI comes before PCMCIA
[4] The relative match is the ratio of the length of the match against the length of the symbol. The more of a symbol name we match, the more instersting that symbol is. Thus:
PCIEAER comes before PCIEASPM
[5] As fallback, sort symbols alphabetically
This heuristic tries hard to get interesting symbols first in the list.
In any case, exact match can (as previously) be requested by using start-of-line and end-of-line in the search regexp: ^PCI$
--- scripts/kconfig/symbol.c | 96 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 87 insertions(+), 9 deletions(-)
scripts/kconfig/symbol.c +87 -9
@@ -954,38 +954,116 @@ const char *sym_escape_string_value(const char *in)return res; } +struct sym_match { +struct symbol *sym; +off_t so, eo; +}; + +/* Compare matched symbols as thus: +* - first, symbols with a prompt, +* - then, smallest offset, +* - then, shortest match, +* - then, highest relative match, +* - finally, alphabetical sort +*/ +static int sym_rel_comp (const void *sym1,const void *sym2 ) +{ +struct sym_match *s1 = *(struct sym_match **)sym1; +struct sym_match *s2 = *(struct sym_match **)sym2; +struct property *p; +bool p1 = false, p2 = false; +int l1, l2, r1, r2; + + for_all_prompts(s1->sym, p) { + p1 = true; + } + for_all_prompts(s2->sym, p) { + p2 = true; + } +if (p1 && !p2) +return -1 ; +if (!p1 && p2) +return 1 ; + +if (s1->so < s2->so) +return -1 ; +if (s1->so > s2->so) +return 1 ; + + l1 = s1->eo - s1->so; + l2 = s2->eo - s2->so; +if (l1>l2) +return 1 ; +if (l1<l2) +return -1 ; + + r1 =100 *l1 /strlen (s1->sym->name); + r2 =100 *l2 /strlen (s2->sym->name); +if (r1 > r2) +return -1 ; +if (r1 < r2) +return 1 ; + +return strcmp (s1->sym->name, s2->sym->name); +} +struct symbol **sym_re_search (const char *pattern) {struct symbol *sym, **sym_arr =NULL ; +struct sym_match **sym_match_arr =NULL ;int i, cnt, size;regex_t re; +regmatch_t match[1 ]; cnt = size =0 ;/* Skip if empty */ if (strlen (pattern) ==0 )return NULL ; -if (regcomp (&re, pattern,REG_EXTENDED |REG_NOSUB |REG_ICASE )) +if (regcomp (&re, pattern,REG_EXTENDED |REG_ICASE ))return NULL ; for_all_symbols(i, sym) { +struct sym_match *tmp_sym_match;if (sym->flags &SYMBOL_CONST || !sym->name)continue ; -if (regexec (&re, sym->name,0 ,NULL ,0 )) +if (regexec (&re, sym->name,1 , match,0 ))continue ;if (cnt +1 >= size) { -void *tmp = sym_arr; +void *tmp; size +=16 ; - sym_arr =realloc (sym_arr, size *sizeof (struct symbol *)); -if (!sym_arr) { -free (tmp); -return NULL ; + tmp =realloc (sym_match_arr, size *sizeof (struct sym_match *)); +if (!tmp) { + goto sym_re_search_free; } + sym_match_arr = tmp; }sym_calc_value (sym); - sym_arr[cnt++] = sym; + tmp_sym_match = (struct sym_match *)malloc (sizeof (struct sym_match )); +if (!tmp_sym_match) + goto sym_re_search_free; + tmp_sym_match->sym = sym; +/* As regexec return 0, we know we have a match, so +* we can use match[0].rm_[se]o without further checks +*/ + tmp_sym_match->so = match[0 ].rm_so; + tmp_sym_match->eo = match[0 ].rm_eo; + sym_match_arr[cnt++] = tmp_sym_match; } -if (sym_arr) +if (sym_match_arr) { +qsort (sym_match_arr, cnt,sizeof (struct sym_match *), sym_rel_comp); + sym_arr =malloc ((cnt+1 ) *sizeof (struct symbol )); +if (!sym_arr) + goto sym_re_search_free; +for (i =0 ; i < cnt; i++) + sym_arr[i] = sym_match_arr[i]->sym; sym_arr[cnt] =NULL ; + } +sym_re_search_free: +if (sym_match_arr) { +for (i =0 ; i < cnt; i++) +free (sym_match_arr[i]); +free (sym_match_arr); + }regfree (&re);return sym_arr;
Signature · 1 line
1.8.1.2
PATCH 13/14 kconfig: loop as long as we changed some symbols in randconfig
In reply to Yann E. MORINFrom: "Yann E. MORIN" <[email protected]>
Because of choice-in-a-choice constructs, it can happen that not all symbols are assigned a value during randconfig, leading in rare cases to this situation:
---8<--- choice-in-choice.in
choice
bool "A/B/C"
config A
bool "A"
config B
bool "B"
if B
choice
bool "E/F"
config E
bool "E"
config F
bool "F"
endchoice
endif # B
config C
bool "C"
endchoice
---8<---
$ ./scripts/kconfig/conf --randconfig choice-in-choice.in
[--SNIP--]
$ ./scripts/kconfig/conf --silentoldconfig choice-in-choice.in </dev/null
[--SNIP--]
A/B/C
1. A (A)
> 2. B (B)
3. C (C)
choice[1-3]: 2
E/F
> 1. E (E) (NEW)
2. F (F) (NEW)
choice[1-2]: aborted!
Console input/output is redirected. Run 'make oldconfig' to update
configuration.Fix this by looping in randconfig for as long as some symbol gets assigned a value.
Note: this was spotted with the USB EHCI Debug Device Gadget (USB_G_DBGP), which uses this choice-in-a-choice construct, and exhibits this problem. The example above is just a stripped-down minimalist test-case.
--- scripts/kconfig/conf.c | 3 ++- scripts/kconfig/confdata.c | 18 ++++++++++++++---- scripts/kconfig/lkc.h | 2 +- 3 files changed, 17 insertions(+), 6 deletions(-)
scripts/kconfig/conf.c +2 -1
@@ -654,7 +654,8 @@ int main(int ac, char **av)conf_set_all_new_symbols (def_default);break ;case randconfig: -conf_set_all_new_symbols (def_random); +/* Really nothing to do in this loop */ +while (conf_set_all_new_symbols (def_random)) ;break ;case defconfig:conf_set_all_new_symbols (def_default);
scripts/kconfig/confdata.c +14 -4
@@ -1040,7 +1040,7 @@ void conf_set_changed_callback(void (*fn)(void)) conf_changed_callback = fn; } -static void randomize_choice_values (struct symbol *csym) +static bool randomize_choice_values (struct symbol *csym) {struct property *prop;struct symbol *sym;
@@ -1053,7 +1053,7 @@ static void randomize_choice_values(struct symbol *csym)* In both cases stop. */ if (csym->curr.tri != yes) -return ; +return false; prop =sym_get_choice_prop (csym);
@@ -1084,6 +1084,8 @@ static void randomize_choice_values(struct symbol *csym) csym->flags |=SYMBOL_DEF_USER ;/* clear VALID to get value calculated */ csym->flags &= ~(SYMBOL_VALID ); + +return true; }void set_all_choice_values (struct symbol *csym)
@@ -1106,7 +1108,7 @@ void set_all_choice_values(struct symbol *csym) csym->flags &= ~(SYMBOL_VALID |SYMBOL_NEED_SET_CHOICE_VALUES ); } -void conf_set_all_new_symbols (enum conf_def_mode mode) +bool conf_set_all_new_symbols (enum conf_def_mode mode) {struct symbol *sym, *csym;int i, cnt, pby, pty, ptm;/* pby: probability of boolean = y
@@ -1154,6 +1156,7 @@ void conf_set_all_new_symbols(enum conf_def_mode mode)exit (1 ); } } +bool has_changed = false; for_all_symbols(i, sym) {if (sym_has_value (sym) || (sym->flags &SYMBOL_VALID ))
@@ -1161,6 +1164,7 @@ void conf_set_all_new_symbols(enum conf_def_mode mode)switch (sym_get_type (sym)) {case S_BOOLEAN :case S_TRISTATE : + has_changed = true;switch (mode) {case def_yes: sym->def[S_DEF_USER ].tri = yes;
@@ -1219,6 +1223,12 @@ void conf_set_all_new_symbols(enum conf_def_mode mode)sym_calc_value (csym);if (mode == def_random) -randomize_choice_values (csym); + has_changed =randomize_choice_values (csym); +else { +set_all_choice_values (csym); + has_changed = true; + } } + +return has_changed; }
scripts/kconfig/lkc.h +1 -1
@@ -86,7 +86,7 @@ const char *conf_get_autoconfig_name(void);char *conf_get_default_confname (void );void sym_set_change_count (int count);void sym_add_change_count (int count); -void conf_set_all_new_symbols (enum conf_def_mode mode); +bool conf_set_all_new_symbols (enum conf_def_mode mode);void set_all_choice_values (struct symbol *csym);struct conf_printer {
Signature · 1 line
1.8.1.2
PATCH 14/14 kconfig: fix randomising choice entries in presence of KCONFIG_ALLCONFIG
In reply to Yann E. MORINFrom: "Yann E. MORIN" <[email protected]>
Currently, randconfig does randomise choice entries, unless KCONFIG_ALLCONFIG is specified.
For example, given those two files (Thomas' test-case):
---8<--- Config.test.in
config OPTIONA
bool "Option A"
choice
prompt "This is a choice"
config CHOICE_OPTIONA
bool "Choice Option A"
config CHOICE_OPTIONB
bool "Choice Option B"
endchoice
config OPTIONB
bool "Option B"
---8<--- Config.test.in
---8<--- config.defaults
CONFIG_OPTIONA=y
---8<--- config.defaults
And running:
./scripts/kconfig/conf --randconfig Config.test.in
does properly randomise the two choice symbols (and the two booleans).
However, running:
KCONFIG_ALLCONFIG=config.defaults \
./scripts/kconfig/conf --randconfig Config.test.indoes *not* reandomise the two choice entries, and only CHOICE_OPTIONA will ever be selected. (OPTIONA will always be set (expected), and OPTIONB will be be properly randomised (expected).)
This patch defers setting that a choice has a value until a symbol for that choice is indeed set, so that choices are properly randomised when KCONFIG_ALLCONFIG is set, but not if a symbol for that choice is set.
---
Changes v3 -> v4
- fix previous issue where some choices would not be set, which would cause silentoldconfig to ask for them and was then breaking this workflow (as reported by Arnd and Sedat):
KCONFIG_ALLCONFIG=foo.defconfig make randconfig
make silentoldconfig </dev/nullo
which I have tested (3h28min!) with:
touch defconfig
for(( i=0; i<10000; i++ )); do
KCONFIG_ALLCONFIG=$(pwd)/defconfig make randconfig >/dev/null 2>&1 make silentoldconfig </dev/null >/dev/null 2>&1 || break
done
which did not break at all.
- change done in v3 (below) is already fixed by a previous patch
Changes v2 -> v3
- ensure only one symbol is set in a choice
Changes v1 -> v2:
- further postpone setting that a choice has a value until one is indeed set
- do not print symbols that are part of an invisible choice
--- scripts/kconfig/confdata.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
scripts/kconfig/confdata.c +3 -3
@@ -288,8 +288,6 @@ load: for_all_symbols(i, sym) { sym->flags |=SYMBOL_CHANGED ; sym->flags &= ~(def_flags|SYMBOL_VALID ); -if (sym_is_choice (sym)) - sym->flags |= def_flags;switch (sym->type) {case S_INT :case S_HEX :
@@ -379,13 +377,13 @@ setsym:case mod:if (cs->def[def].tri == yes) {conf_warning ("%s creates inconsistent choice state" , sym->name); - cs->flags &= ~def_flags; }break ;case yes:if (cs->def[def].tri != no)conf_warning ("override: %s changes choice state" , sym->name); cs->def[def].val = sym; + cs->flags |= def_flags;break ; } cs->def[def].tri =EXPR_OR (cs->def[def].tri, sym->def[def].tri);
@@ -791,6 +789,8 @@ int conf_write(const char *name)sym_calc_value (sym);if (!(sym->flags &SYMBOL_WRITE )) goto next; +if (sym_is_choice_value (sym) && !menu_is_visible (menu->parent)) + goto next; sym->flags &= ~SYMBOL_WRITE ;conf_write_symbol (out, sym, &kconfig_printer_cb,NULL );
Signature · 1 line
1.8.1.2
Dne 19.6.2013 00:44, Yann E. MORIN napsal(a):
Quoted 22 lines
From: "Yann E. MORIN" <[email protected]>
Hello Michal, All!
These are the patches against kconfig that I have accumulated for 3.11, and for which I plan to later send a proper pull-request.
Note-whorthy this time:
- fix values of tristates that are selected by boolean choices (Arve)
- fix choice randomisation in presence ofKCONFIG_ALLCONFIG(me)
- fix choice randomisation selecting more than one value in
a choice (but only if it is conditional) (me)
- fix choice-in-a-choice randomisation not selecting any value
for the inner-most choice (me)Also, some code-cleanups and eye-candy:
- mconf and nconf code cleanups (Dirk, Sedat) - mconf and nconf eye-candy (Dirk) - scripts/config script-name in help text (Clément) - heuristic to sort found symbols by relevance (me) - more randconfig debugging help (me)
Quoted 8 lines
Note: this series is for review before I send an official pull-request. I want to avoid the debacle [0] [1] of the last kconfig breakage I caused with my previous kconfig "fix" to randomising choices in presence of
KCONFIG_ALLCONFIG.I would like to send an official pull-request early next week, so all of these can land early in -next, so they get some real-life t4esting before the next merge windows open. So please, please, test this carefully. ;-)
I tested this a bit, it works fine. Unless somebody else finds issues, I'll merge it.
Thanks,
Michal
Michal, All,
On 2013-06-19 22:40 +0200, Michal Marek spake thusly:
Quoted 28 lines
Dne 19.6.2013 00:44, Yann E. MORIN napsal(a):
Quoted 27 lines
From: "Yann E. MORIN" <[email protected]>
Hello Michal, All!
These are the patches against kconfig that I have accumulated for 3.11, and for which I plan to later send a proper pull-request.
Note-whorthy this time:
- fix values of tristates that are selected by boolean choices (Arve)
- fix choice randomisation in presence ofKCONFIG_ALLCONFIG(me)
- fix choice randomisation selecting more than one value in
a choice (but only if it is conditional) (me)
- fix choice-in-a-choice randomisation not selecting any value
for the inner-most choice (me)Also, some code-cleanups and eye-candy:
- mconf and nconf code cleanups (Dirk, Sedat) - mconf and nconf eye-candy (Dirk) - scripts/config script-name in help text (Clément) - heuristic to sort found symbols by relevance (me) - more randconfig debugging help (me)Note: this series is for review before I send an official pull-request. I want to avoid the debacle [0] [1] of the last kconfig breakage I caused with my previous kconfig "fix" to randomising choices in presence of
KCONFIG_ALLCONFIG.
Quoted 6 lines
Quoted 3 lines
I would like to send an official pull-request early next week, so all of these can land early in -next, so they get some real-life t4esting before the next merge windows open. So please, please, test this carefully. ;-)
I tested this a bit, it works fine. Unless somebody else finds issues, I'll merge it.
Could you please wait a few days (say friday, or monday), I know someone whose supposed to do some testing on his use-case (Hello Thomas! ;-) ).
Thank you!
Regards,
Yann E. MORIN.
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'
Re: [PATCH 12/14] kconfig: sort found symbols by relevance
In reply to Yann E. MORINHi Yann,
Sorry for the late reply...
Quoted 4 lines · Yann E. MORIN
From: "Yann E. MORIN" <[email protected]>
When searching for symbols, return the symbols sorted by relevance.
Quoted 8 lines
Sorting is done as thus:
- first, symbols with a prompt, [1] - then, smallest offset, [2] - then, shortest match, [3] - then, highest relative match, [4] - finally, alphabetical sort [5]So, searching (eg.) for 'P.*CI' :
Nobody would actually search for that, so that's not a particularly good example to determine whether your sort order is sane or not.
Quoted 4 lines
[1] Symbols of interest are probably those with a prompt, as they can be changed, while symbols with no prompt are only for info. Thus:
PCIEASPM comes beforePCI_ATS
This is not necessarily true. I often look for symbols which have no prompt, and the information I am looking for is exactly "does this symbol have a prompt or is its value determined automatically"?
Quoted 3 lines
[2] Symbols that match earlier in the name are to be preferred over symbols which match later. Thus:
PCI_MSIcomes before WDTPCI
This makes some sense, although it could have some unexpected side effects (e.g. FOO_BAR_PCI would be listed before SOMETHING_PCI_BAZBAZ, right?)
Quoted 3 lines
[3] The shortest match is (IMHO) more interesting than a longer one. Thus:
PCI comes before PCMCIA
This makes sense too, but I'm sure there are cases where it will be confusing too, and alphabetical order would do it in part too.
Quoted 4 lines
[4] The relative match is the ratio of the length of the match against the length of the symbol. The more of a symbol name we match, the more instersting that symbol is. Thus:
PCIEAER comes before PCIEASPM
This is an obscure sort rule and I'm sure it will add more confusion than it will help. Alphabetical order should really be good enough at this point.
Quoted 4 lines
[5] As fallback, sort symbols alphabetically
This heuristic tries hard to get interesting symbols first in the list.
I know I am the one whose question triggered this work from you, but in the end the "response" seems disproportionate. Having 5 different ordering rules is a lot, and that's quite a bit of code, which while not the most complex in the world, is still far from trivial and may require maintenance work in the future.
The result of the search will be read by a human. As such, the order of the results should be immediately obvious. Returning what the user is most probably looking for first in the list is not as important as making it possible for the user to search the results for what he/she is looking for, and this can only be the case if the user understands the sort order instinctively. The 5 rules you used aren't exactly that IMHO. This situation is completely different from a web search for example, where the search engine has to select the most relevant pages because listing them all is out of the question.
The original order was random and that's the worse possible order, so I am all for improving it. But I think the sort order should be driven by simple and instinctive rules. This means 1 or 2 ordering rules, not 5. As I recall, my original proposal was "exact match first, then alphabetical order." 2 rules, instinctive and easy to document.
Quoted 2 lines
In any case, exact match can (as previously) be requested by using start-of-line and end-of-line in the search regexp: ^PCI$
Actually this solved my original problem just fine. As a matter of fact, I stopped replying to the original thread shortly after learning this, because I kind of lost interest in the following discussion.
So I think it is more important to make it clearer that regular expressions are allowed, than to come up with a brilliant sort order. I know the help page says it, but the prompt itself only asks for a "(sub)string" and it is not immediately obvious (to me at least) that regular expressions are considered substrings.
BTW, if you really decide to commit your proposal despite my concerns, you will have to document the sorting rules in the help page.
Thanks,
Signature · 2 lines
Jean Delvare Suse L3
Re: [PATCH 12/14] kconfig: sort found symbols by relevance
Quoted 38 lines · Jean Delvare
Hi Yann,
Sorry for the late reply...
Quoted 4 lines · Yann E. MORIN
From: "Yann E. MORIN" <[email protected]>
When searching for symbols, return the symbols sorted by relevance.
Quoted 8 lines
Sorting is done as thus:
- first, symbols with a prompt, [1] - then, smallest offset, [2] - then, shortest match, [3] - then, highest relative match, [4] - finally, alphabetical sort [5]So, searching (eg.) for 'P.*CI' :
Nobody would actually search for that, so that's not a particularly good example to determine whether your sort order is sane or not.
Quoted 4 lines
[1] Symbols of interest are probably those with a prompt, as they can be changed, while symbols with no prompt are only for info. Thus:
PCIEASPM comes beforePCI_ATSThis is not necessarily true. I often look for symbols which have no prompt, and the information I am looking for is exactly "does this symbol have a prompt or is its value determined automatically"?
Quoted 3 lines
[2] Symbols that match earlier in the name are to be preferred over symbols which match later. Thus:
PCI_MSIcomes before WDTPCIThis makes some sense, although it could have some unexpected side effects (e.g.
FOO_BAR_PCIwould be listed beforeSOMETHING_PCI_BAZBAZ, right?)
Quoted 6 lines
Quoted 3 lines
[3] The shortest match is (IMHO) more interesting than a longer one. Thus:
PCI comes before PCMCIAThis makes sense too, but I'm sure there are cases where it will be confusing too, and alphabetical order would do it in part too.
PCI does sort before PCMCIA alphabetically ;). Also, the match lenght will only be different when using regular expressions, so this rule will not matter in the usual case.
Quoted 8 lines
Quoted 4 lines
[4] The relative match is the ratio of the length of the match against the length of the symbol. The more of a symbol name we match, the more instersting that symbol is. Thus:
PCIEAER comes before PCIEASPMThis is an obscure sort rule and I'm sure it will add more confusion than it will help. Alphabetical order should really be good enough at this point.
When the prefix matches, then I agree that most people will expect the matches be alphabetically sorted. Maybe only do this comparison only if s1->so != 0, otherwise fallback to the strcmp() directly?
Thanks,
Michal
Re: [PATCH 12/14] kconfig: sort found symbols by relevance
In reply to Jean DelvareJean, Michal, All,
On 2013-06-24 09:57 +0200, Jean Delvare spake thusly:
Quoted 10 lines · Yann E. MORIN
Quoted 9 lines
When searching for symbols, return the symbols sorted by relevance.
Sorting is done as thus:
- first, symbols with a prompt, [1] - then, smallest offset, [2] - then, shortest match, [3] - then, highest relative match, [4] - finally, alphabetical sort [5]
Quoted 4 lines
Quoted 1 line
So, searching (eg.) for 'P.*CI' :
Nobody would actually search for that, so that's not a particularly good example to determine whether your sort order is sane or not.
Yes, this was just to explain the sorting algorithm with a simple example.
[--SNIP--]
Quoted 7 lines
Quoted 1 line
This heuristic tries hard to get interesting symbols first in the list.
I know I am the one whose question triggered this work from you, but in the end the "response" seems disproportionate. Having 5 different ordering rules is a lot, and that's quite a bit of code, which while not the most complex in the world, is still far from trivial and may require maintenance work in the future.
OK, I understand you concerns.
Michal, please do not apply this patch: I'll rewrite it with a simpler heuristic as Jean suggested, and will re-submit a complete pull-request later tonight.
Quoted 5 lines
So I think it is more important to make it clearer that regular expressions are allowed, than to come up with a brilliant sort order. I know the help page says it, but the prompt itself only asks for a "(sub)string" and it is not immediately obvious (to me at least) that regular expressions are considered substrings.
OK, Ill see to rewite the title of the dialog box.
Thanks for the review!
Regards,
Yann E. MORIN.
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------. | Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: | | +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ | | +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no | | http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. | '------------------------------^-------^------------------^--------------------'