* [PATCH 1/6] menuconfig: Fix memory leak introduced by jump keys feature
2013-04-22 21:31 [pull request] Pull request for branch yem-kconfig-for-next Yann E. MORIN
@ 2013-04-22 21:31 ` Yann E. MORIN
2013-04-22 21:31 ` [PATCH 2/6] menuconfig: Add "breadcrumbs" navigation aid Yann E. MORIN
` (5 subsequent siblings)
6 siblings, 0 replies; 14+ messages in thread
From: Yann E. MORIN @ 2013-04-22 21:31 UTC (permalink / raw)
To: linux-kbuild; +Cc: Michal Marek, Benjamin Poirier, Yann E. MORIN, stable
From: Benjamin Poirier <bpoirier@suse.de>
Fixes the memory leak of struct jump_key allocated in get_prompt_str()
Signed-off-by: Benjamin Poirier <bpoirier@suse.de>
Tested-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Reviewed-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: stable@vger.kernel.org
---
scripts/kconfig/list.h | 13 +++++++++++++
scripts/kconfig/mconf.c | 3 +++
2 files changed, 16 insertions(+)
diff --git a/scripts/kconfig/list.h b/scripts/kconfig/list.h
index 0ae730b..b87206c 100644
--- a/scripts/kconfig/list.h
+++ b/scripts/kconfig/list.h
@@ -51,6 +51,19 @@ struct list_head {
pos = list_entry(pos->member.next, typeof(*pos), member))
/**
+ * list_for_each_entry_safe - iterate over list of given type safe against removal of list entry
+ * @pos: the type * to use as a loop cursor.
+ * @n: another type * to use as temporary storage
+ * @head: the head for your list.
+ * @member: the name of the list_struct within the struct.
+ */
+#define list_for_each_entry_safe(pos, n, head, member) \
+ for (pos = list_entry((head)->next, typeof(*pos), member), \
+ n = list_entry(pos->member.next, typeof(*pos), member); \
+ &pos->member != (head); \
+ pos = n, n = list_entry(n->member.next, typeof(*n), member))
+
+/**
* list_empty - tests whether a list is empty
* @head: the list to test.
*/
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c
index 566288a..c5418d6 100644
--- a/scripts/kconfig/mconf.c
+++ b/scripts/kconfig/mconf.c
@@ -389,6 +389,7 @@ again:
.targets = targets,
.keys = keys,
};
+ struct jump_key *pos, *tmp;
res = get_relations_str(sym_arr, &head);
dres = show_textbox_ext(_("Search Results"), (char *)
@@ -402,6 +403,8 @@ again:
again = true;
}
str_free(&res);
+ list_for_each_entry_safe(pos, tmp, &head, entries)
+ free(pos);
} while (again);
free(sym_arr);
str_free(&title);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 14+ messages in thread* [PATCH 2/6] menuconfig: Add "breadcrumbs" navigation aid
2013-04-22 21:31 [pull request] Pull request for branch yem-kconfig-for-next Yann E. MORIN
2013-04-22 21:31 ` [PATCH 1/6] menuconfig: Fix memory leak introduced by jump keys feature Yann E. MORIN
@ 2013-04-22 21:31 ` Yann E. MORIN
2013-04-22 21:31 ` [PATCH 3/6] kconfig/lxdialog: rationalise the include paths where to find {.n}curses{,w}.h Yann E. MORIN
` (4 subsequent siblings)
6 siblings, 0 replies; 14+ messages in thread
From: Yann E. MORIN @ 2013-04-22 21:31 UTC (permalink / raw)
To: linux-kbuild; +Cc: Michal Marek, Benjamin Poirier, Yann E. MORIN
From: Benjamin Poirier <bpoirier@suse.de>
Displays a trail of the menu entries used to get to the current menu.
Signed-off-by: Benjamin Poirier <bpoirier@suse.de>
Tested-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
[yann.morin.1998@free.fr: small, trivial code re-ordering]
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
---
scripts/kconfig/list.h | 27 ++++++++++++++
scripts/kconfig/lxdialog/dialog.h | 7 ++++
scripts/kconfig/lxdialog/util.c | 45 +++++++++++++++++++++--
scripts/kconfig/mconf.c | 71 ++++++++++++++++++++++++++++++++++++-
4 files changed, 147 insertions(+), 3 deletions(-)
diff --git a/scripts/kconfig/list.h b/scripts/kconfig/list.h
index b87206c..ea1d581 100644
--- a/scripts/kconfig/list.h
+++ b/scripts/kconfig/list.h
@@ -101,4 +101,31 @@ static inline void list_add_tail(struct list_head *_new, struct list_head *head)
__list_add(_new, head->prev, head);
}
+/*
+ * Delete a list entry by making the prev/next entries
+ * point to each other.
+ *
+ * This is only for internal list manipulation where we know
+ * the prev/next entries already!
+ */
+static inline void __list_del(struct list_head *prev, struct list_head *next)
+{
+ next->prev = prev;
+ prev->next = next;
+}
+
+#define LIST_POISON1 ((void *) 0x00100100)
+#define LIST_POISON2 ((void *) 0x00200200)
+/**
+ * list_del - deletes entry from list.
+ * @entry: the element to delete from the list.
+ * Note: list_empty() on entry does not return true after this, the entry is
+ * in an undefined state.
+ */
+static inline void list_del(struct list_head *entry)
+{
+ __list_del(entry->prev, entry->next);
+ entry->next = LIST_POISON1;
+ entry->prev = LIST_POISON2;
+}
#endif
diff --git a/scripts/kconfig/lxdialog/dialog.h b/scripts/kconfig/lxdialog/dialog.h
index 307022a..10993370 100644
--- a/scripts/kconfig/lxdialog/dialog.h
+++ b/scripts/kconfig/lxdialog/dialog.h
@@ -106,8 +106,14 @@ struct dialog_color {
int hl; /* highlight this item */
};
+struct subtitle_list {
+ struct subtitle_list *next;
+ const char *text;
+};
+
struct dialog_info {
const char *backtitle;
+ struct subtitle_list *subtitles;
struct dialog_color screen;
struct dialog_color shadow;
struct dialog_color dialog;
@@ -196,6 +202,7 @@ int on_key_resize(void);
int init_dialog(const char *backtitle);
void set_dialog_backtitle(const char *backtitle);
+void set_dialog_subtitles(struct subtitle_list *subtitles);
void end_dialog(int x, int y);
void attr_clear(WINDOW * win, int height, int width, chtype attr);
void dialog_clear(void);
diff --git a/scripts/kconfig/lxdialog/util.c b/scripts/kconfig/lxdialog/util.c
index 109d531..a0e97c2 100644
--- a/scripts/kconfig/lxdialog/util.c
+++ b/scripts/kconfig/lxdialog/util.c
@@ -257,12 +257,48 @@ void dialog_clear(void)
attr_clear(stdscr, LINES, COLS, dlg.screen.atr);
/* Display background title if it exists ... - SLH */
if (dlg.backtitle != NULL) {
- int i;
+ int i, len = 0, skip = 0;
+ struct subtitle_list *pos;
wattrset(stdscr, dlg.screen.atr);
mvwaddstr(stdscr, 0, 1, (char *)dlg.backtitle);
+
+ for (pos = dlg.subtitles; pos != NULL; pos = pos->next) {
+ /* 3 is for the arrow and spaces */
+ len += strlen(pos->text) + 3;
+ }
+
wmove(stdscr, 1, 1);
- for (i = 1; i < COLS - 1; i++)
+ if (len > COLS - 2) {
+ const char *ellipsis = "[...] ";
+ waddstr(stdscr, ellipsis);
+ skip = len - (COLS - 2 - strlen(ellipsis));
+ }
+
+ for (pos = dlg.subtitles; pos != NULL; pos = pos->next) {
+ if (skip == 0)
+ waddch(stdscr, ACS_RARROW);
+ else
+ skip--;
+
+ if (skip == 0)
+ waddch(stdscr, ' ');
+ else
+ skip--;
+
+ if (skip < strlen(pos->text)) {
+ waddstr(stdscr, pos->text + skip);
+ skip = 0;
+ } else
+ skip -= strlen(pos->text);
+
+ if (skip == 0)
+ waddch(stdscr, ' ');
+ else
+ skip--;
+ }
+
+ for (i = len + 1; i < COLS - 1; i++)
waddch(stdscr, ACS_HLINE);
}
wnoutrefresh(stdscr);
@@ -302,6 +338,11 @@ void set_dialog_backtitle(const char *backtitle)
dlg.backtitle = backtitle;
}
+void set_dialog_subtitles(struct subtitle_list *subtitles)
+{
+ dlg.subtitles = subtitles;
+}
+
/*
* End using dialog functions.
*/
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c
index c5418d6..387dc8d 100644
--- a/scripts/kconfig/mconf.c
+++ b/scripts/kconfig/mconf.c
@@ -311,6 +311,50 @@ static void set_config_filename(const char *config_filename)
filename[sizeof(filename)-1] = '\0';
}
+struct subtitle_part {
+ struct list_head entries;
+ const char *text;
+};
+static LIST_HEAD(trail);
+
+static struct subtitle_list *subtitles;
+static void set_subtitle(void)
+{
+ struct subtitle_part *sp;
+ struct subtitle_list *pos, *tmp;
+
+ for (pos = subtitles; pos != NULL; pos = tmp) {
+ tmp = pos->next;
+ free(pos);
+ }
+
+ subtitles = NULL;
+ list_for_each_entry(sp, &trail, entries) {
+ if (sp->text) {
+ if (pos) {
+ pos->next = xcalloc(sizeof(*pos), 1);
+ pos = pos->next;
+ } else {
+ subtitles = pos = xcalloc(sizeof(*pos), 1);
+ }
+ pos->text = sp->text;
+ }
+ }
+
+ set_dialog_subtitles(subtitles);
+}
+
+static void reset_subtitle(void)
+{
+ struct subtitle_list *pos, *tmp;
+
+ for (pos = subtitles; pos != NULL; pos = tmp) {
+ tmp = pos->next;
+ free(pos);
+ }
+ subtitles = NULL;
+ set_dialog_subtitles(subtitles);
+}
struct search_data {
struct list_head *head;
@@ -353,6 +397,8 @@ static void search_conf(void)
char *dialog_input;
int dres, vscroll = 0, hscroll = 0;
bool again;
+ struct gstr sttext;
+ struct subtitle_part stpart;
title = str_new();
str_printf( &title, _("Enter %s (sub)string to search for "
@@ -379,6 +425,11 @@ again:
if (strncasecmp(dialog_input_result, CONFIG_, strlen(CONFIG_)) == 0)
dialog_input += strlen(CONFIG_);
+ sttext = str_new();
+ str_printf(&sttext, "Search (%s)", dialog_input_result);
+ stpart.text = str_get(&sttext);
+ list_add_tail(&stpart.entries, &trail);
+
sym_arr = sym_re_search(dialog_input);
do {
LIST_HEAD(head);
@@ -392,6 +443,7 @@ again:
struct jump_key *pos, *tmp;
res = get_relations_str(sym_arr, &head);
+ set_subtitle();
dres = show_textbox_ext(_("Search Results"), (char *)
str_get(&res), 0, 0, keys, &vscroll,
&hscroll, &update_text, (void *)
@@ -408,6 +460,8 @@ again:
} while (again);
free(sym_arr);
str_free(&title);
+ list_del(trail.prev);
+ str_free(&sttext);
}
static void build_conf(struct menu *menu)
@@ -592,16 +646,24 @@ static void conf(struct menu *menu, struct menu *active_menu)
{
struct menu *submenu;
const char *prompt = menu_get_prompt(menu);
+ struct subtitle_part stpart;
struct symbol *sym;
int res;
int s_scroll = 0;
+ if (menu != &rootmenu)
+ stpart.text = menu_get_prompt(menu);
+ else
+ stpart.text = NULL;
+ list_add_tail(&stpart.entries, &trail);
+
while (1) {
item_reset();
current_menu = menu;
build_conf(menu);
if (!child_count)
break;
+ set_subtitle();
dialog_clear();
res = dialog_menu(prompt ? _(prompt) : _("Main Menu"),
_(menu_instructions),
@@ -643,13 +705,17 @@ static void conf(struct menu *menu, struct menu *active_menu)
case 2:
if (sym)
show_help(submenu);
- else
+ else {
+ reset_subtitle();
show_helptext(_("README"), _(mconf_readme));
+ }
break;
case 3:
+ reset_subtitle();
conf_save();
break;
case 4:
+ reset_subtitle();
conf_load();
break;
case 5:
@@ -682,6 +748,8 @@ static void conf(struct menu *menu, struct menu *active_menu)
break;
}
}
+
+ list_del(trail.prev);
}
static int show_textbox_ext(const char *title, char *text, int r, int c, int
@@ -884,6 +952,7 @@ static int handle_exit(void)
int res;
save_and_exit = 1;
+ reset_subtitle();
dialog_clear();
if (conf_get_changed())
res = dialog_yesno(NULL,
--
1.7.10.4
^ permalink raw reply related [flat|nested] 14+ messages in thread* [PATCH 3/6] kconfig/lxdialog: rationalise the include paths where to find {.n}curses{,w}.h
2013-04-22 21:31 [pull request] Pull request for branch yem-kconfig-for-next Yann E. MORIN
2013-04-22 21:31 ` [PATCH 1/6] menuconfig: Fix memory leak introduced by jump keys feature Yann E. MORIN
2013-04-22 21:31 ` [PATCH 2/6] menuconfig: Add "breadcrumbs" navigation aid Yann E. MORIN
@ 2013-04-22 21:31 ` Yann E. MORIN
2013-04-22 21:31 ` [PATCH 4/6] kconfig: allow specifying the seed for randconfig Yann E. MORIN
` (3 subsequent siblings)
6 siblings, 0 replies; 14+ messages in thread
From: Yann E. MORIN @ 2013-04-22 21:31 UTC (permalink / raw)
To: linux-kbuild; +Cc: Michal Marek, Yann E. MORIN
From: "Yann E. MORIN" <yann.morin.1998@free.fr>
The current code does this:
if [ -f /usr/include/ncursesw/curses.h ]; then
echo '-I/usr/include/ncursesw -DCURSES_LOC="<ncursesw/curses.h>"'
elif [ -f /usr/include/ncurses/ncurses.h ]; then
echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"'
elif [ -f /usr/include/ncurses/curses.h ]; then
echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses/curses.h>"'
[...]
This is merely inconsistent:
- adding the full path to the directory in the -I directive,
- especially since that path is already a sub-path of the system
include path,
- and then repeating the sub-path in the #include directive.
Rationalise each include directive:
- only use the filename in the #include directive,
- keep the -I directives: they are always searched for before the
system include path; this ensures the correct header is used.
Using the -I directives and the filename-only in #include is more in
line with how pkg-config behaves, eg.:
$ pkg-config --cflags ncursesw
-I/usr/include/ncursesw
This paves the way for using pkg-config for CFLAGS, too, now we use it
to find the libraries.
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
---
scripts/kconfig/lxdialog/check-lxdialog.sh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/kconfig/lxdialog/check-lxdialog.sh b/scripts/kconfig/lxdialog/check-lxdialog.sh
index 782d200..9d2a4c5 100644
--- a/scripts/kconfig/lxdialog/check-lxdialog.sh
+++ b/scripts/kconfig/lxdialog/check-lxdialog.sh
@@ -22,12 +22,12 @@ ldflags()
ccflags()
{
if [ -f /usr/include/ncursesw/curses.h ]; then
- echo '-I/usr/include/ncursesw -DCURSES_LOC="<ncursesw/curses.h>"'
+ echo '-I/usr/include/ncursesw -DCURSES_LOC="<curses.h>"'
echo ' -DNCURSES_WIDECHAR=1'
elif [ -f /usr/include/ncurses/ncurses.h ]; then
echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses.h>"'
elif [ -f /usr/include/ncurses/curses.h ]; then
- echo '-I/usr/include/ncurses -DCURSES_LOC="<ncurses/curses.h>"'
+ echo '-I/usr/include/ncurses -DCURSES_LOC="<curses.h>"'
elif [ -f /usr/include/ncurses.h ]; then
echo '-DCURSES_LOC="<ncurses.h>"'
else
--
1.7.10.4
^ permalink raw reply related [flat|nested] 14+ messages in thread* [PATCH 4/6] kconfig: allow specifying the seed for randconfig
2013-04-22 21:31 [pull request] Pull request for branch yem-kconfig-for-next Yann E. MORIN
` (2 preceding siblings ...)
2013-04-22 21:31 ` [PATCH 3/6] kconfig/lxdialog: rationalise the include paths where to find {.n}curses{,w}.h Yann E. MORIN
@ 2013-04-22 21:31 ` Yann E. MORIN
2013-04-22 21:31 ` [PATCH 5/6] kconfig: implement KCONFIG_PROBABILITY " Yann E. MORIN
` (2 subsequent siblings)
6 siblings, 0 replies; 14+ messages in thread
From: Yann E. MORIN @ 2013-04-22 21:31 UTC (permalink / raw)
To: linux-kbuild; +Cc: Michal Marek, Yann E. MORIN
From: "Yann E. MORIN" <yann.morin.1998@free.fr>
For reproducibility, it can be useful to be able to specify the
seed to use to seed the RNG.
Add a new KCONFIG_SEED environment variable which can be set to
the seed to use:
$ make KCONFIG_SEED=42 randconfig
$ sha1sum .config
70a128c8dcc61303069e1be352cce64114dfcbca .config
$ make KCONFIG_SEED=42 randconfig
$ sha1sum .config
70a128c8dcc61303069e1be352cce64114dfcbca .config
It's very usefull for eg. debugging the kconfig parser.
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
---
Documentation/kbuild/kconfig.txt | 9 +++++++++
scripts/kconfig/conf.c | 12 +++++++++++-
2 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/Documentation/kbuild/kconfig.txt b/Documentation/kbuild/kconfig.txt
index b8b77bb..dbf746b 100644
--- a/Documentation/kbuild/kconfig.txt
+++ b/Documentation/kbuild/kconfig.txt
@@ -90,6 +90,15 @@ disable the options that are explicitly listed in the specified
mini-config files.
______________________________________________________________________
+Environment variables for 'randconfig'
+
+KCONFIG_SEED
+--------------------------------------------------
+You can set this to the integer value used to seed the RNG, if you want
+to somehow debug the behaviour of the kconfig parser/frontends.
+If not set, the current time will be used.
+
+______________________________________________________________________
Environment variables for 'silentoldconfig'
KCONFIG_NOSILENTUPDATE
diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
index e39fcd8..bde5b95 100644
--- a/scripts/kconfig/conf.c
+++ b/scripts/kconfig/conf.c
@@ -13,6 +13,7 @@
#include <getopt.h>
#include <sys/stat.h>
#include <sys/time.h>
+#include <errno.h>
#include "lkc.h"
@@ -514,14 +515,23 @@ int main(int ac, char **av)
{
struct timeval now;
unsigned int seed;
+ char *seed_env;
/*
* Use microseconds derived seed,
* compensate for systems where it may be zero
*/
gettimeofday(&now, NULL);
-
seed = (unsigned int)((now.tv_sec + 1) * (now.tv_usec + 1));
+
+ seed_env = getenv("KCONFIG_SEED");
+ if( seed_env && *seed_env ) {
+ char *endp;
+ int tmp = (int)strtol(seed_env, &endp, 10);
+ if (*endp == '\0') {
+ seed = tmp;
+ }
+ }
srand(seed);
break;
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 14+ messages in thread* [PATCH 5/6] kconfig: implement KCONFIG_PROBABILITY for randconfig
2013-04-22 21:31 [pull request] Pull request for branch yem-kconfig-for-next Yann E. MORIN
` (3 preceding siblings ...)
2013-04-22 21:31 ` [PATCH 4/6] kconfig: allow specifying the seed for randconfig Yann E. MORIN
@ 2013-04-22 21:31 ` Yann E. MORIN
2013-04-23 8:44 ` Michal Marek
2013-04-23 21:50 ` Yann E. MORIN
2013-04-22 21:31 ` [PATCH 6/6] kconfig: do randomise choice entries in presence of KCONFIG_ALLCONFIG Yann E. MORIN
2013-04-23 7:07 ` [pull request] Pull request for branch yem-kconfig-for-next Yann E. MORIN
6 siblings, 2 replies; 14+ messages in thread
From: Yann E. MORIN @ 2013-04-22 21:31 UTC (permalink / raw)
To: linux-kbuild; +Cc: Michal Marek, Yann E. MORIN, Peter Korsgaard
From: "Yann E. MORIN" <yann.morin.1998@free.fr>
Introduce a KCONFIG_PROBABILITY environment variable to tweak the
probability between 0 (all options off) and 100 (all options on).
[Patch originally written by Peter for Buildroot, see: ]
[http://git.buildroot.org/buildroot/commit/?id=3435c1afb5 ]
Signed-off-by: Peter Korsgaard <jacmet@uclibc.org>
[yann.morin.1998@free.fr: add to Documentation/]
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
---
Documentation/kbuild/kconfig.txt | 17 +++++++++++++++++
scripts/kconfig/confdata.c | 22 +++++++++++++++++++---
2 files changed, 36 insertions(+), 3 deletions(-)
diff --git a/Documentation/kbuild/kconfig.txt b/Documentation/kbuild/kconfig.txt
index dbf746b..1817128 100644
--- a/Documentation/kbuild/kconfig.txt
+++ b/Documentation/kbuild/kconfig.txt
@@ -98,6 +98,23 @@ You can set this to the integer value used to seed the RNG, if you want
to somehow debug the behaviour of the kconfig parser/frontends.
If not set, the current time will be used.
+KCONFIG_PROBABILITY
+--------------------------------------------------
+If this variable is set and contains an integer in the range [0,100],
+then its value is used as a probability each variable is set. If the
+variable is a tristate, there is then a further 50% chance it is set
+to either 'M' or 'Y'. If KCONFIG_PROBABILITY is not set, then the
+default is 50. Examples (rounded figures):
+ KCONFIG_PROBABILITY=33
+ boolean : no : 67% yes: 33%
+ tristrate : no : 67% mod: 16% yes: 16%
+ KCONFIG_PROBABILITY=50
+ boolean : no : 50% yes: 50%
+ tristate : no : 50% mod: 25% yes: 25%
+ KCONFIG_PROBABILITY=67
+ boolean : no : 33% yes: 67%
+ tristrate : no : 33% mod: 33% yes: 33%
+
______________________________________________________________________
Environment variables for 'silentoldconfig'
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index 13ddf11..8d8d853 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -1106,7 +1106,16 @@ static void set_all_choice_values(struct symbol *csym)
void conf_set_all_new_symbols(enum conf_def_mode mode)
{
struct symbol *sym, *csym;
- int i, cnt;
+ int i, cnt, prob = 50;
+
+ if (mode == def_random) {
+ char *endp, *env = getenv("KCONFIG_PROBABILITY");
+ if (env && *env) {
+ int tmp = (int)strtol(env, &endp, 10);
+ if (*endp == '\0' && tmp >= 0 && tmp <= 100)
+ prob = tmp;
+ }
+ }
for_all_symbols(i, sym) {
if (sym_has_value(sym))
@@ -1125,8 +1134,15 @@ void conf_set_all_new_symbols(enum conf_def_mode mode)
sym->def[S_DEF_USER].tri = no;
break;
case def_random:
- cnt = sym_get_type(sym) == S_TRISTATE ? 3 : 2;
- sym->def[S_DEF_USER].tri = (tristate)(rand() % cnt);
+ cnt = (rand() % 100) - (100 - prob);
+ if (cnt < 0)
+ sym->def[S_DEF_USER].tri = no;
+ else
+ if ((sym_get_type(sym) == S_TRISTATE)
+ && (cnt > prob/2))
+ sym->def[S_DEF_USER].tri = mod;
+ else
+ sym->def[S_DEF_USER].tri = yes;
break;
default:
continue;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [PATCH 5/6] kconfig: implement KCONFIG_PROBABILITY for randconfig
2013-04-22 21:31 ` [PATCH 5/6] kconfig: implement KCONFIG_PROBABILITY " Yann E. MORIN
@ 2013-04-23 8:44 ` Michal Marek
2013-04-23 16:34 ` Yann E. MORIN
2013-04-23 21:50 ` Yann E. MORIN
1 sibling, 1 reply; 14+ messages in thread
From: Michal Marek @ 2013-04-23 8:44 UTC (permalink / raw)
To: Yann E. MORIN; +Cc: linux-kbuild, Peter Korsgaard
On 22.4.2013 23:31, Yann E. MORIN wrote:
> diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
> index 13ddf11..8d8d853 100644
> --- a/scripts/kconfig/confdata.c
> +++ b/scripts/kconfig/confdata.c
> @@ -1106,7 +1106,16 @@ static void set_all_choice_values(struct symbol *csym)
> void conf_set_all_new_symbols(enum conf_def_mode mode)
> {
> struct symbol *sym, *csym;
> - int i, cnt;
> + int i, cnt, prob = 50;
> +
[...]
> case def_random:
> - cnt = sym_get_type(sym) == S_TRISTATE ? 3 : 2;
> - sym->def[S_DEF_USER].tri = (tristate)(rand() % cnt);
> + cnt = (rand() % 100) - (100 - prob);
> + if (cnt < 0)
> + sym->def[S_DEF_USER].tri = no;
> + else
> + if ((sym_get_type(sym) == S_TRISTATE)
> + && (cnt > prob/2))
> + sym->def[S_DEF_USER].tri = mod;
> + else
> + sym->def[S_DEF_USER].tri = yes;
Previously, the distribution was 50%-50% for boolean options and
33%-33%-33% for tristate options. Now the default for tristate options
changed to 50%-25%-25% (no-mod-yes). Wouldn't it make more sense to have
a special case for KCONFIG_PROBABILITY not set, that would use the same
distribution as before. I.e.
if (prob == -1) {
cnt = sym_get_type(sym) == S_TRISTATE ? 3 : 2;
sym->def[S_DEF_USER].tri = (tristate)(rand() % cnt);
} else {
/* new math */
}
Not building half of all drivers is rather boring :)
Thanks,
Michal
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH 5/6] kconfig: implement KCONFIG_PROBABILITY for randconfig
2013-04-23 8:44 ` Michal Marek
@ 2013-04-23 16:34 ` Yann E. MORIN
2013-04-23 20:05 ` Michal Marek
0 siblings, 1 reply; 14+ messages in thread
From: Yann E. MORIN @ 2013-04-23 16:34 UTC (permalink / raw)
To: Michal Marek; +Cc: linux-kbuild, Peter Korsgaard
Michal, All,
On Tue, Apr 23, 2013 at 10:44:58AM +0200, Michal Marek wrote:
> On 22.4.2013 23:31, Yann E. MORIN wrote:
> > diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
> > index 13ddf11..8d8d853 100644
> > --- a/scripts/kconfig/confdata.c
> > +++ b/scripts/kconfig/confdata.c
> > @@ -1106,7 +1106,16 @@ static void set_all_choice_values(struct symbol *csym)
> > void conf_set_all_new_symbols(enum conf_def_mode mode)
> > {
> > struct symbol *sym, *csym;
> > - int i, cnt;
> > + int i, cnt, prob = 50;
> > +
> [...]
> > case def_random:
> > - cnt = sym_get_type(sym) == S_TRISTATE ? 3 : 2;
> > - sym->def[S_DEF_USER].tri = (tristate)(rand() % cnt);
> > + cnt = (rand() % 100) - (100 - prob);
> > + if (cnt < 0)
> > + sym->def[S_DEF_USER].tri = no;
> > + else
> > + if ((sym_get_type(sym) == S_TRISTATE)
> > + && (cnt > prob/2))
> > + sym->def[S_DEF_USER].tri = mod;
> > + else
> > + sym->def[S_DEF_USER].tri = yes;
>
> Previously, the distribution was 50%-50% for boolean options and
> 33%-33%-33% for tristate options. Now the default for tristate options
> changed to 50%-25%-25% (no-mod-yes). Wouldn't it make more sense to have
> a special case for KCONFIG_PROBABILITY not set, that would use the same
> distribution as before. I.e.
>
> if (prob == -1) {
> cnt = sym_get_type(sym) == S_TRISTATE ? 3 : 2;
> sym->def[S_DEF_USER].tri = (tristate)(rand() % cnt);
> } else {
> /* new math */
> }
OK, what about this proposal, instead:
KCONFIG_PROBABILITY y:n split y:m:n split Notes
-------------------------------------------------------------------------
unset or empty 50 : 50 33 : 33 : 34 [1]
N N : 100-N N/2 : N/2 : 100-N [2]
N:M N+M : 100-(N+M) N : M : 100-(N+M) [3]
N:M:L N : 100-N M : L : 100-(M+L) [4]
[1] current behaviour
[2] the curent patch's behaviour
[3] boolean's Y probability is tristate's Y plus tristate's M probabilities
[4] all probabilities explicitly stated
I have a prototype for this I need to clean up. If that's OK for you, I'll
submit that; if not, I'll use your suggestion.
> Not building half of all drivers is rather boring :)
Oh! No! All that idle CPU time that could be put to better use... ;-]
Regards,
Yann E. MORIN.
--
.-----------------.--------------------.------------------.--------------------.
| 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. |
'------------------------------^-------^------------------^--------------------'
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH 5/6] kconfig: implement KCONFIG_PROBABILITY for randconfig
2013-04-23 16:34 ` Yann E. MORIN
@ 2013-04-23 20:05 ` Michal Marek
0 siblings, 0 replies; 14+ messages in thread
From: Michal Marek @ 2013-04-23 20:05 UTC (permalink / raw)
To: Yann E. MORIN; +Cc: linux-kbuild, Peter Korsgaard
Dne 23.4.2013 18:34, Yann E. MORIN napsal(a):
> Michal, All,
>
> On Tue, Apr 23, 2013 at 10:44:58AM +0200, Michal Marek wrote:
>> On 22.4.2013 23:31, Yann E. MORIN wrote:
>>> diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
>>> index 13ddf11..8d8d853 100644
>>> --- a/scripts/kconfig/confdata.c
>>> +++ b/scripts/kconfig/confdata.c
>>> @@ -1106,7 +1106,16 @@ static void set_all_choice_values(struct symbol *csym)
>>> void conf_set_all_new_symbols(enum conf_def_mode mode)
>>> {
>>> struct symbol *sym, *csym;
>>> - int i, cnt;
>>> + int i, cnt, prob = 50;
>>> +
>> [...]
>>> case def_random:
>>> - cnt = sym_get_type(sym) == S_TRISTATE ? 3 : 2;
>>> - sym->def[S_DEF_USER].tri = (tristate)(rand() % cnt);
>>> + cnt = (rand() % 100) - (100 - prob);
>>> + if (cnt < 0)
>>> + sym->def[S_DEF_USER].tri = no;
>>> + else
>>> + if ((sym_get_type(sym) == S_TRISTATE)
>>> + && (cnt > prob/2))
>>> + sym->def[S_DEF_USER].tri = mod;
>>> + else
>>> + sym->def[S_DEF_USER].tri = yes;
>>
>> Previously, the distribution was 50%-50% for boolean options and
>> 33%-33%-33% for tristate options. Now the default for tristate options
>> changed to 50%-25%-25% (no-mod-yes). Wouldn't it make more sense to have
>> a special case for KCONFIG_PROBABILITY not set, that would use the same
>> distribution as before. I.e.
>>
>> if (prob == -1) {
>> cnt = sym_get_type(sym) == S_TRISTATE ? 3 : 2;
>> sym->def[S_DEF_USER].tri = (tristate)(rand() % cnt);
>> } else {
>> /* new math */
>> }
>
> OK, what about this proposal, instead:
> KCONFIG_PROBABILITY y:n split y:m:n split Notes
> -------------------------------------------------------------------------
> unset or empty 50 : 50 33 : 33 : 34 [1]
> N N : 100-N N/2 : N/2 : 100-N [2]
> N:M N+M : 100-(N+M) N : M : 100-(N+M) [3]
> N:M:L N : 100-N M : L : 100-(M+L) [4]
>
> [1] current behaviour
> [2] the curent patch's behaviour
> [3] boolean's Y probability is tristate's Y plus tristate's M probabilities
> [4] all probabilities explicitly stated
>
> I have a prototype for this I need to clean up. If that's OK for you, I'll
> submit that; if not, I'll use your suggestion.
As long as the default behavior does not change (1/3 vs. 34% is fine
:)), then I am fine with any semantics of $KCONFIG_PROBABILITY.
Michal
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 5/6] kconfig: implement KCONFIG_PROBABILITY for randconfig
2013-04-22 21:31 ` [PATCH 5/6] kconfig: implement KCONFIG_PROBABILITY " Yann E. MORIN
2013-04-23 8:44 ` Michal Marek
@ 2013-04-23 21:50 ` Yann E. MORIN
2013-04-24 17:56 ` Yann E. MORIN
1 sibling, 1 reply; 14+ messages in thread
From: Yann E. MORIN @ 2013-04-23 21:50 UTC (permalink / raw)
To: linux-kbuild; +Cc: Michal Marek, Peter Korsgaard
Michal, All,
On Mon, Apr 22, 2013 at 11:31:24PM +0200, Yann E. MORIN wrote:
> From: "Yann E. MORIN" <yann.morin.1998@free.fr>
> Introduce a KCONFIG_PROBABILITY environment variable to tweak the
> probability between 0 (all options off) and 100 (all options on).
Please, drop this patch: randconfig is utterly broken is a very subtle
way (even without this patch applied), which I still have to track down,
and I'm not confident I can find and properly fis it before the end of
the week.
The core of the problem is the following code (as seen in current master
from Linus' tree):
scripts/kconfig/confdata.c:
[--SNIP--]
1106 void conf_set_all_new_symbols(enum conf_def_mode mode)
1107 {
1108 struct symbol *sym, *csym;
1109 int i, cnt;
1110
1111 for_all_symbols(i, sym) {
1112 if (sym_has_value(sym))
1113 continue;
1114 switch (sym_get_type(sym)) {
1115 case S_BOOLEAN:
1116 case S_TRISTATE:
1117 switch (mode) {
1118 case def_yes:
1119 sym->def[S_DEF_USER].tri = yes;
1120 break;
1121 case def_mod:
1122 sym->def[S_DEF_USER].tri = mod;
1123 break;
1124 case def_no:
1125 sym->def[S_DEF_USER].tri = no;
1126 break;
1127 case def_random:
1128 cnt = sym_get_type(sym) == S_TRISTATE ? 3 : 2;
1129 sym->def[S_DEF_USER].tri = (tristate)(rand() % cnt);
1130 break;
1131 default:
1132 continue;
1133 }
1134 if (!(sym_is_choice(sym) && mode == def_random))
1135 sym->flags |= SYMBOL_DEF_USER;
1136 break;
1137 default:
1138 break;
1139 }
1140
1141 }
1142
1143 sym_clear_all_valid();
[--SNIP--]
Fact is, sym_get_type(sym) is never ever equal to S_TRISTATE when we
test it on line 1128.
I'm currently investigating, but I suspect that's because CONFIG_MODULES
is not yet set, which only happens after we call to sym_clear_all_valid()
later on line 1143, which is too late.
I'll be testing this solution (pseudo-code):
find symbol defining MODULES
randomly set it to y or no
sym_clear_all_valid();
for_all_symbols(i, sym) {
current code
}
sym_clear_all_valid();
More on this later. For now, just drop this probability patch. The other
patches are still good for 3.10.
Regards,
Yann E. MORIN.
--
.-----------------.--------------------.------------------.--------------------.
| 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. |
'------------------------------^-------^------------------^--------------------'
^ permalink raw reply [flat|nested] 14+ messages in thread* Re: [PATCH 5/6] kconfig: implement KCONFIG_PROBABILITY for randconfig
2013-04-23 21:50 ` Yann E. MORIN
@ 2013-04-24 17:56 ` Yann E. MORIN
2013-04-24 22:28 ` Michal Marek
0 siblings, 1 reply; 14+ messages in thread
From: Yann E. MORIN @ 2013-04-24 17:56 UTC (permalink / raw)
To: linux-kbuild; +Cc: Michal Marek, Peter Korsgaard
Michal, All,
On Tue, Apr 23, 2013 at 11:50:44PM +0200, Yann E. MORIN wrote:
> On Mon, Apr 22, 2013 at 11:31:24PM +0200, Yann E. MORIN wrote:
> > From: "Yann E. MORIN" <yann.morin.1998@free.fr>
> > Introduce a KCONFIG_PROBABILITY environment variable to tweak the
> > probability between 0 (all options off) and 100 (all options on).
>
> Please, drop this patch: randconfig is utterly broken is a very subtle
> way (even without this patch applied), which I still have to track down,
> and I'm not confident I can find and properly fis it before the end of
[--SNIP--]
> More on this later. For now, just drop this probability patch. The other
> patches are still good for 3.10.
Michal, I have something interesting now that I'm testing. If you did
not already apply the rest of the series, just hold-on just a bit more,
I'll re-spin a new version of the series later tonight.
Regards,
Yann E. MORIN.
--
.-----------------.--------------------.------------------.--------------------.
| 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. |
'------------------------------^-------^------------------^--------------------'
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH 5/6] kconfig: implement KCONFIG_PROBABILITY for randconfig
2013-04-24 17:56 ` Yann E. MORIN
@ 2013-04-24 22:28 ` Michal Marek
0 siblings, 0 replies; 14+ messages in thread
From: Michal Marek @ 2013-04-24 22:28 UTC (permalink / raw)
To: Yann E. MORIN; +Cc: linux-kbuild, Peter Korsgaard
Dne 24.4.2013 19:56, Yann E. MORIN napsal(a):
> Michal, All,
>
> On Tue, Apr 23, 2013 at 11:50:44PM +0200, Yann E. MORIN wrote:
>> On Mon, Apr 22, 2013 at 11:31:24PM +0200, Yann E. MORIN wrote:
>>> From: "Yann E. MORIN" <yann.morin.1998@free.fr>
>>> Introduce a KCONFIG_PROBABILITY environment variable to tweak the
>>> probability between 0 (all options off) and 100 (all options on).
>>
>> Please, drop this patch: randconfig is utterly broken is a very subtle
>> way (even without this patch applied), which I still have to track down,
>> and I'm not confident I can find and properly fis it before the end of
> [--SNIP--]
>> More on this later. For now, just drop this probability patch. The other
>> patches are still good for 3.10.
>
> Michal, I have something interesting now that I'm testing. If you did
> not already apply the rest of the series, just hold-on just a bit more,
> I'll re-spin a new version of the series later tonight.
OK, I'll wait.
Michal
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH 6/6] kconfig: do randomise choice entries in presence of KCONFIG_ALLCONFIG
2013-04-22 21:31 [pull request] Pull request for branch yem-kconfig-for-next Yann E. MORIN
` (4 preceding siblings ...)
2013-04-22 21:31 ` [PATCH 5/6] kconfig: implement KCONFIG_PROBABILITY " Yann E. MORIN
@ 2013-04-22 21:31 ` Yann E. MORIN
2013-04-23 7:07 ` [pull request] Pull request for branch yem-kconfig-for-next Yann E. MORIN
6 siblings, 0 replies; 14+ messages in thread
From: Yann E. MORIN @ 2013-04-22 21:31 UTC (permalink / raw)
To: linux-kbuild
Cc: Michal Marek, Yann E. MORIN, Thomas Petazzoni, Sam Ravnborg,
Arnaud Lacombe
From: "Yann E. MORIN" <yann.morin.1998@free.fr>
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.in
does *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.
Also, as a side-efect, this patch fixes the following case:
---8<---
choice
config OPTION_A
bool "Option A"
config OPTION_B
bool "Option B"
config OPTION_C
bool "Option C"
endchoice
---8<---
which could previously generate such .config files:
---8<--- ---8<---
CONFIG_OPTION_A=y CONFIG_OPTION_A=y
CONFIG_OPTION_B=y # CONFIG_OPTION_B is not set
# CONFIG_OPTION_C is not set CONFIG_OPTION_C=y
---8<--- ---8<---
Ie., the first entry in a choice is always set, plus zero or one of
the other options may be set.
This patch ensures that only one option may be set for a choice.
Reported-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: Michal Marek <mmarek@suse.cz>
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Arnaud Lacombe <lacombar@gmail.com>
---
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 | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index 8d8d853..5487279 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -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);
@@ -1077,6 +1077,7 @@ static void randomize_choice_values(struct symbol *csym)
else {
sym->def[S_DEF_USER].tri = no;
}
+ sym->flags &= ~(SYMBOL_VALID);
}
csym->flags |= SYMBOL_DEF_USER;
/* clear VALID to get value calculated */
--
1.7.10.4
^ permalink raw reply related [flat|nested] 14+ messages in thread* Re: [pull request] Pull request for branch yem-kconfig-for-next
2013-04-22 21:31 [pull request] Pull request for branch yem-kconfig-for-next Yann E. MORIN
` (5 preceding siblings ...)
2013-04-22 21:31 ` [PATCH 6/6] kconfig: do randomise choice entries in presence of KCONFIG_ALLCONFIG Yann E. MORIN
@ 2013-04-23 7:07 ` Yann E. MORIN
6 siblings, 0 replies; 14+ messages in thread
From: Yann E. MORIN @ 2013-04-23 7:07 UTC (permalink / raw)
To: linux-kbuild; +Cc: Michal Marek, Benjamin Poirier
Michal, All,
On Monday 22 April 2013 23:31:19 Yann E. MORIN wrote:
> Here is the official pull-request for the kconfig-related changes I've
> gathered from the list and accumulated for inclusin in 3.9:
3.10! I meant: for 3.10! :-)
Sorry for the confusion...
Regards,
Yann E. MORIN.
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +0/33 662376056 | Software Designer | \ / CAMPAIGN | ^ |
| --==< O_o >==-- '------------.-------: X AGAINST | /e\ There is no |
| http://ymorin.is-a-geek.org/ | (*_*) | / \ HTML MAIL | """ conspiracy. |
'------------------------------'-------'------------------'--------------------'
^ permalink raw reply [flat|nested] 14+ messages in thread