From de125187dc17e3715ba983adf60faecfdc3a64c4 Mon Sep 17 00:00:00 2001 From: Jean-Christophe PLAGNIOL-VILLARD Date: Fri, 6 May 2011 07:03:49 +0200 Subject: kconfig: autogenerated config_is_xxx macro this will allow to use to use if(config_is_xxx()) if(config_is_xxx_module()) in the code instead of #ifdef CONFIG_xxx #ifdef CONFIG_xxx_MODULE and now let the compiler remove the non usefull code and not the pre-processor as done in the mach-types for arm as exmaple Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD Acked-by: Andi Kleen Signed-off-by: Michal Marek --- scripts/kconfig/confdata.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'scripts') diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 834eecb010ba..db06af0321b3 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -778,6 +778,29 @@ out: return res; } +static void conf_write_function_autoconf(FILE *out, char* conf, char* name, + int val) +{ + char c; + char *tmp, *d; + + d = strdup(conf); + tmp = d; + while ((c = *conf++)) + *d++ = tolower(c); + + fprintf(out, "#define %sis_", tmp); + free(tmp); + + d = strdup(name); + tmp = d; + while ((c = *name++)) + *d++ = tolower(c); + fprintf(out, "%s%s() %d\n", tmp, (val > 1) ? "_module" : "", + val ? 1 : 0); + free(tmp); +} + int conf_write_autoconf(void) { struct symbol *sym; @@ -785,6 +808,7 @@ int conf_write_autoconf(void) const char *name; FILE *out, *tristate, *out_h; int i; + int fct_val; sym_clear_all_valid(); @@ -825,6 +849,7 @@ int conf_write_autoconf(void) rootmenu.prompt->text); for_all_symbols(i, sym) { + fct_val = 1; sym_calc_value(sym); if (!(sym->flags & SYMBOL_WRITE) || !sym->name) continue; @@ -838,12 +863,14 @@ int conf_write_autoconf(void) case S_TRISTATE: switch (sym_get_tristate_value(sym)) { case no: + fct_val = 0; break; case mod: fprintf(tristate, "%s%s=M\n", CONFIG_, sym->name); fprintf(out_h, "#define %s%s_MODULE 1\n", CONFIG_, sym->name); + fct_val = 2; break; case yes: if (sym->type == S_TRISTATE) @@ -870,8 +897,10 @@ int conf_write_autoconf(void) CONFIG_, sym->name, str); break; default: + fct_val = 0; break; } + conf_write_function_autoconf(out_h, CONFIG_, sym->name, fct_val); } fclose(out); fclose(tristate); -- cgit v1.2.3-59-g8ed1b From 4c54f0f846102b05efcc99114ada2b913baab161 Mon Sep 17 00:00:00 2001 From: Michal Marek Date: Tue, 17 May 2011 17:31:53 +0200 Subject: kconfig: Only generate config_is_xxx for bool and tristate options For strings and integers, the config_is_xxx macros are useless and sometimes misleading: #define CONFIG_INITRAMFS_SOURCE "" #define config_is_initramfs_source() 1 Cc: Jean-Christophe PLAGNIOL-VILLARD Signed-off-by: Michal Marek --- scripts/kconfig/confdata.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'scripts') diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index a1a9872e4a2d..d01f962e879f 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -798,7 +798,6 @@ int conf_write_autoconf(void) const char *name; FILE *out, *tristate, *out_h; int i; - int fct_val; sym_clear_all_valid(); @@ -839,7 +838,7 @@ int conf_write_autoconf(void) rootmenu.prompt->text); for_all_symbols(i, sym) { - fct_val = 1; + int fct_val = 0; sym_calc_value(sym); if (!(sym->flags & SYMBOL_WRITE) || !sym->name) continue; @@ -853,7 +852,6 @@ int conf_write_autoconf(void) case S_TRISTATE: switch (sym_get_tristate_value(sym)) { case no: - fct_val = 0; break; case mod: fprintf(tristate, "%s%s=M\n", @@ -868,8 +866,10 @@ int conf_write_autoconf(void) CONFIG_, sym->name); fprintf(out_h, "#define %s%s 1\n", CONFIG_, sym->name); + fct_val = 1; break; } + conf_write_function_autoconf(out_h, CONFIG_, sym->name, fct_val); break; case S_STRING: conf_write_string(true, sym->name, sym_get_string_value(sym), out_h); @@ -887,10 +887,8 @@ int conf_write_autoconf(void) CONFIG_, sym->name, str); break; default: - fct_val = 0; break; } - conf_write_function_autoconf(out_h, CONFIG_, sym->name, fct_val); } fclose(out); fclose(tristate); -- cgit v1.2.3-59-g8ed1b From d8fc320079b46cf462897148f48d4a63f37f56ce Mon Sep 17 00:00:00 2001 From: Arnaud Lacombe Date: Tue, 31 May 2011 12:30:26 -0400 Subject: kconfig: annotate non-trivial fall-trough Signed-off-by: Arnaud Lacombe --- scripts/kconfig/conf.c | 4 ++++ scripts/kconfig/confdata.c | 5 +++++ scripts/kconfig/gconf.c | 1 + scripts/kconfig/mconf.c | 1 + 4 files changed, 11 insertions(+) (limited to 'scripts') diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index 006ad817cd5f..6d2e936f3b67 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c @@ -106,6 +106,7 @@ static int conf_askvalue(struct symbol *sym, const char *def) return 0; } check_stdin(); + /* fall through */ case oldaskconfig: fflush(stdout); xfgets(line, 128, stdin); @@ -150,6 +151,7 @@ static int conf_string(struct menu *menu) def = NULL; break; } + /* fall through */ default: line[strlen(line)-1] = 0; def = line; @@ -304,6 +306,7 @@ static int conf_choice(struct menu *menu) break; } check_stdin(); + /* fall through */ case oldaskconfig: fflush(stdout); xfgets(line, 128, stdin); @@ -369,6 +372,7 @@ static void conf(struct menu *menu) check_conf(menu); return; } + /* fall through */ case P_COMMENT: prompt = menu_get_prompt(menu); if (prompt) diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 2bafd9a7c8da..0a1ccc397b86 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -128,6 +128,7 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p) sym->flags |= def_flags; break; } + /* fall through */ case S_BOOLEAN: if (p[0] == 'y') { sym->def[def].tri = yes; @@ -148,6 +149,7 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p) sym->type = S_STRING; goto done; } + /* fall through */ case S_STRING: if (*p++ != '"') break; @@ -162,6 +164,7 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p) conf_warning("invalid string found"); return 1; } + /* fall through */ case S_INT: case S_HEX: done: @@ -237,6 +240,7 @@ load: case S_STRING: if (sym->def[def].val) free(sym->def[def].val); + /* fall through */ default: sym->def[def].val = NULL; sym->def[def].tri = no; @@ -363,6 +367,7 @@ int conf_read(const char *name) break; if (!sym_is_choice(sym)) goto sym_ok; + /* fall through */ default: if (!strcmp(sym->curr.val, sym->def[S_DEF_USER].val)) goto sym_ok; diff --git a/scripts/kconfig/gconf.c b/scripts/kconfig/gconf.c index a11d5f7b9eeb..c406bde28dbe 100644 --- a/scripts/kconfig/gconf.c +++ b/scripts/kconfig/gconf.c @@ -1172,6 +1172,7 @@ static gchar **fill_row(struct menu *menu) row[COL_BTNVIS] = GINT_TO_POINTER(TRUE); if (sym_is_choice(sym)) break; + /* fall through */ case S_TRISTATE: val = sym_get_tristate_value(sym); switch (val) { diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index d433c7a24745..87001e62cefd 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c @@ -845,6 +845,7 @@ int main(int ac, char **av) "\n\n")); return 1; } + /* fall through */ case -1: printf(_("\n\n" "*** End of the configuration.\n" -- cgit v1.2.3-59-g8ed1b From 75f1468beaeca690e139b4e1bcd19aa20973fca9 Mon Sep 17 00:00:00 2001 From: Arnaud Lacombe Date: Tue, 31 May 2011 12:31:57 -0400 Subject: kconfig: fix return code for invalid boolean symbol in conf_set_sym_val() Cc: Sam Ravnborg Signed-off-by: Arnaud Lacombe --- scripts/kconfig/confdata.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 0a1ccc397b86..4e878dda1add 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -141,7 +141,7 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p) break; } conf_warning("symbol value '%s' invalid for %s", p, sym->name); - break; + return 1; case S_OTHER: if (*p != '"') { for (p2 = p; *p2 && !isspace(*p2); p2++) -- cgit v1.2.3-59-g8ed1b From 10a4b2772e7643247ddb5316c644f1fe7c4dccca Mon Sep 17 00:00:00 2001 From: Arnaud Lacombe Date: Wed, 1 Jun 2011 16:00:46 -0400 Subject: kconfig: add missing inclusion This header is needed when using va_{start,end,copy}(3) functions family. Signed-off-by: Arnaud Lacombe --- scripts/kconfig/confdata.c | 1 + scripts/kconfig/menu.c | 1 + scripts/kconfig/util.c | 1 + 3 files changed, 3 insertions(+) (limited to 'scripts') diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 4e878dda1add..ca16ab4367dd 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index 5fdf10dc1d8a..d64108bc0cf9 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -3,6 +3,7 @@ * Released under the terms of the GNU GPL v2.0. */ +#include #include #include diff --git a/scripts/kconfig/util.c b/scripts/kconfig/util.c index 6330cc871a47..e07d557bb3a9 100644 --- a/scripts/kconfig/util.c +++ b/scripts/kconfig/util.c @@ -5,6 +5,7 @@ * Released under the terms of the GNU GPL v2.0. */ +#include #include #include "lkc.h" -- cgit v1.2.3-59-g8ed1b From dd003306a4fae241e1f9cac5bef2c8f2afeb0446 Mon Sep 17 00:00:00 2001 From: Arnaud Lacombe Date: Wed, 1 Jun 2011 16:06:22 -0400 Subject: kconfig: add missing inclusion This header is needed when using isspace(3) function family. Signed-off-by: Arnaud Lacombe --- scripts/kconfig/menu.c | 1 + 1 file changed, 1 insertion(+) (limited to 'scripts') diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index d64108bc0cf9..24547fe0fe9e 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -3,6 +3,7 @@ * Released under the terms of the GNU GPL v2.0. */ +#include #include #include #include -- cgit v1.2.3-59-g8ed1b From 02d95c96c3d29df0a1d3bb515692ad4894030729 Mon Sep 17 00:00:00 2001 From: Arnaud Lacombe Date: Wed, 1 Jun 2011 16:08:14 -0400 Subject: kconfig: add missing inclusion This header is needed when using {m,re}alloc(3) and free(3) function family. Signed-off-by: Arnaud Lacombe --- scripts/kconfig/util.c | 1 + 1 file changed, 1 insertion(+) (limited to 'scripts') diff --git a/scripts/kconfig/util.c b/scripts/kconfig/util.c index e07d557bb3a9..d0b8b2318e48 100644 --- a/scripts/kconfig/util.c +++ b/scripts/kconfig/util.c @@ -6,6 +6,7 @@ */ #include +#include #include #include "lkc.h" -- cgit v1.2.3-59-g8ed1b From 84250386efa581fdf5578b68b9dd6b79998ac48d Mon Sep 17 00:00:00 2001 From: Arnaud Lacombe Date: Wed, 1 Jun 2011 16:15:52 -0400 Subject: kconfig: nuke reference to SWIG SWIG is not used (yet?) to create kconfig binding, so there is no point referencing it. Signed-off-by: Arnaud Lacombe --- scripts/kconfig/expr.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'scripts') diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index 16bfae2d3217..80fce57080cc 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h @@ -172,8 +172,6 @@ struct menu { #define MENU_CHANGED 0x0001 #define MENU_ROOT 0x0002 -#ifndef SWIG - extern struct file *file_list; extern struct file *current_file; struct file *lookup_file(const char *name); @@ -218,7 +216,6 @@ static inline int expr_is_no(struct expr *e) { return e && (e->type == E_SYMBOL && e->left.sym == &symbol_no); } -#endif #ifdef __cplusplus } -- cgit v1.2.3-59-g8ed1b From 5a6f8d2bd9e3392569ed6f29ea4d7210652f929b Mon Sep 17 00:00:00 2001 From: Arnaud Lacombe Date: Wed, 1 Jun 2011 16:14:47 -0400 Subject: kconfig: nuke LKC_DIRECT_LINK cruft This interface is not (and has never been ?) used by any frontend, just get rid of it. Signed-off-by: Arnaud Lacombe --- scripts/kconfig/Makefile | 24 ++++++++---------------- scripts/kconfig/conf.c | 1 - scripts/kconfig/confdata.c | 1 - scripts/kconfig/expr.c | 1 - scripts/kconfig/gconf.c | 4 ---- scripts/kconfig/kconfig_load.c | 35 ----------------------------------- scripts/kconfig/kxgettext.c | 1 - scripts/kconfig/lex.zconf.c_shipped | 1 - scripts/kconfig/lkc.h | 5 ----- scripts/kconfig/mconf.c | 1 - scripts/kconfig/menu.c | 1 - scripts/kconfig/nconf.c | 2 +- scripts/kconfig/qconf.cc | 4 ---- scripts/kconfig/symbol.c | 1 - scripts/kconfig/zconf.l | 1 - scripts/kconfig/zconf.tab.c_shipped | 1 - scripts/kconfig/zconf.y | 1 - 17 files changed, 9 insertions(+), 76 deletions(-) delete mode 100644 scripts/kconfig/kconfig_load.c (limited to 'scripts') diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index faa9a4701b6f..0460ac3b3588 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -170,8 +170,8 @@ mconf-objs := mconf.o zconf.tab.o $(lxdialog) nconf-objs := nconf.o zconf.tab.o nconf.gui.o kxgettext-objs := kxgettext.o zconf.tab.o qconf-cxxobjs := qconf.o -qconf-objs := kconfig_load.o zconf.tab.o -gconf-objs := gconf.o kconfig_load.o zconf.tab.o +qconf-objs := zconf.tab.o +gconf-objs := gconf.o zconf.tab.o hostprogs-y := conf @@ -203,7 +203,7 @@ ifeq ($(gconf-target),1) hostprogs-y += gconf endif -clean-files := lkc_defs.h qconf.moc .tmp_qtcheck .tmp_gtkcheck +clean-files := qconf.moc .tmp_qtcheck .tmp_gtkcheck clean-files += zconf.tab.c lex.zconf.c zconf.hash.c gconf.glade.h clean-files += mconf qconf gconf nconf clean-files += config.pot linux.pot @@ -223,12 +223,11 @@ HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(srctree)/$(src)/check.sh $(HOSTCC) HOSTCFLAGS_lex.zconf.o := -I$(src) HOSTCFLAGS_zconf.tab.o := -I$(src) -HOSTLOADLIBES_qconf = $(KC_QT_LIBS) -ldl -HOSTCXXFLAGS_qconf.o = $(KC_QT_CFLAGS) -D LKC_DIRECT_LINK +HOSTLOADLIBES_qconf = $(KC_QT_LIBS) +HOSTCXXFLAGS_qconf.o = $(KC_QT_CFLAGS) -HOSTLOADLIBES_gconf = `pkg-config --libs gtk+-2.0 gmodule-2.0 libglade-2.0` -ldl -HOSTCFLAGS_gconf.o = `pkg-config --cflags gtk+-2.0 gmodule-2.0 libglade-2.0` \ - -D LKC_DIRECT_LINK +HOSTLOADLIBES_gconf = `pkg-config --libs gtk+-2.0 gmodule-2.0 libglade-2.0` +HOSTCFLAGS_gconf.o = `pkg-config --cflags gtk+-2.0 gmodule-2.0 libglade-2.0` HOSTLOADLIBES_mconf = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC)) @@ -318,18 +317,11 @@ endif $(obj)/zconf.tab.o: $(obj)/lex.zconf.c $(obj)/zconf.hash.c -$(obj)/kconfig_load.o: $(obj)/lkc_defs.h - -$(obj)/qconf.o: $(obj)/qconf.moc $(obj)/lkc_defs.h - -$(obj)/gconf.o: $(obj)/lkc_defs.h +$(obj)/qconf.o: $(obj)/qconf.moc $(obj)/%.moc: $(src)/%.h $(KC_QT_MOC) -i $< -o $@ -$(obj)/lkc_defs.h: $(src)/lkc_proto.h - $(Q)sed < $< > $@ 's/P(\([^,]*\),.*/#define \1 (\*\1_p)/' - # Extract gconf menu items for I18N support $(obj)/gconf.glade.h: $(obj)/gconf.glade $(Q)intltool-extract --type=gettext/glade --srcdir=$(srctree) \ diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index 6d2e936f3b67..08c05bcc82c9 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c @@ -14,7 +14,6 @@ #include #include -#define LKC_DIRECT_LINK #include "lkc.h" static void conf(struct menu *menu); diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index ca16ab4367dd..c257bb0bf90a 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -14,7 +14,6 @@ #include #include -#define LKC_DIRECT_LINK #include "lkc.h" static void conf_warning(const char *fmt, ...) diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c index 001003452f68..792c62ed9d63 100644 --- a/scripts/kconfig/expr.c +++ b/scripts/kconfig/expr.c @@ -7,7 +7,6 @@ #include #include -#define LKC_DIRECT_LINK #include "lkc.h" #define DEBUG_EXPR 0 diff --git a/scripts/kconfig/gconf.c b/scripts/kconfig/gconf.c index c406bde28dbe..9258957a0913 100644 --- a/scripts/kconfig/gconf.c +++ b/scripts/kconfig/gconf.c @@ -1507,10 +1507,6 @@ int main(int ac, char *av[]) char *env; gchar *glade_file; -#ifndef LKC_DIRECT_LINK - kconfig_load(); -#endif - bindtextdomain(PACKAGE, LOCALEDIR); bind_textdomain_codeset(PACKAGE, "UTF-8"); textdomain(PACKAGE); diff --git a/scripts/kconfig/kconfig_load.c b/scripts/kconfig/kconfig_load.c deleted file mode 100644 index dbdcaad82325..000000000000 --- a/scripts/kconfig/kconfig_load.c +++ /dev/null @@ -1,35 +0,0 @@ -#include -#include -#include - -#include "lkc.h" - -#define P(name,type,arg) type (*name ## _p) arg -#include "lkc_proto.h" -#undef P - -void kconfig_load(void) -{ - void *handle; - char *error; - - handle = dlopen("./libkconfig.so", RTLD_LAZY); - if (!handle) { - handle = dlopen("./scripts/kconfig/libkconfig.so", RTLD_LAZY); - if (!handle) { - fprintf(stderr, "%s\n", dlerror()); - exit(1); - } - } - -#define P(name,type,arg) \ -{ \ - name ## _p = dlsym(handle, #name); \ - if ((error = dlerror())) { \ - fprintf(stderr, "%s\n", error); \ - exit(1); \ - } \ -} -#include "lkc_proto.h" -#undef P -} diff --git a/scripts/kconfig/kxgettext.c b/scripts/kconfig/kxgettext.c index e9d8e791bf0d..2858738b22d5 100644 --- a/scripts/kconfig/kxgettext.c +++ b/scripts/kconfig/kxgettext.c @@ -7,7 +7,6 @@ #include #include -#define LKC_DIRECT_LINK #include "lkc.h" static char *escape(const char* text, char *bf, int len) diff --git a/scripts/kconfig/lex.zconf.c_shipped b/scripts/kconfig/lex.zconf.c_shipped index d9182916f724..dcea7a744317 100644 --- a/scripts/kconfig/lex.zconf.c_shipped +++ b/scripts/kconfig/lex.zconf.c_shipped @@ -785,7 +785,6 @@ char *zconftext; #include #include -#define LKC_DIRECT_LINK #include "lkc.h" #define START_STRSIZE 16 diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index febf0c94d558..625ec69ebeee 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h @@ -21,12 +21,7 @@ static inline char *bind_textdomain_codeset(const char *dn, char *c) { return c; extern "C" { #endif -#ifdef LKC_DIRECT_LINK #define P(name,type,arg) extern type name arg -#else -#include "lkc_defs.h" -#define P(name,type,arg) extern type (*name ## _p) arg -#endif #include "lkc_proto.h" #undef P diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index 87001e62cefd..820d2b6800fb 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c @@ -18,7 +18,6 @@ #include #include -#define LKC_DIRECT_LINK #include "lkc.h" #include "lxdialog/dialog.h" diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index 24547fe0fe9e..aab5a1fee5a8 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -8,7 +8,6 @@ #include #include -#define LKC_DIRECT_LINK #include "lkc.h" static const char nohelp_text[] = N_( diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c index 488dd7410787..da9f5c49d886 100644 --- a/scripts/kconfig/nconf.c +++ b/scripts/kconfig/nconf.c @@ -7,7 +7,7 @@ */ #define _GNU_SOURCE #include -#define LKC_DIRECT_LINK + #include "lkc.h" #include "nconf.h" #include diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc index c2796b866f8f..31e01cdbfc6e 100644 --- a/scripts/kconfig/qconf.cc +++ b/scripts/kconfig/qconf.cc @@ -1745,10 +1745,6 @@ int main(int ac, char** av) bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); -#ifndef LKC_DIRECT_LINK - kconfig_load(); -#endif - progname = av[0]; configApp = new QApplication(ac, av); if (ac > 1 && av[1][0] == '-') { diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index a796c95fe8a0..cf8edf4fc429 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c @@ -9,7 +9,6 @@ #include #include -#define LKC_DIRECT_LINK #include "lkc.h" struct symbol symbol_yes = { diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l index b22f884f9022..29b79f4c34c2 100644 --- a/scripts/kconfig/zconf.l +++ b/scripts/kconfig/zconf.l @@ -14,7 +14,6 @@ #include #include -#define LKC_DIRECT_LINK #include "lkc.h" #define START_STRSIZE 16 diff --git a/scripts/kconfig/zconf.tab.c_shipped b/scripts/kconfig/zconf.tab.c_shipped index 4c5495ea205e..c1579e6e79a6 100644 --- a/scripts/kconfig/zconf.tab.c_shipped +++ b/scripts/kconfig/zconf.tab.c_shipped @@ -88,7 +88,6 @@ #include #include -#define LKC_DIRECT_LINK #include "lkc.h" #define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt) diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y index 49fb4ab664c3..29c391f51606 100644 --- a/scripts/kconfig/zconf.y +++ b/scripts/kconfig/zconf.y @@ -11,7 +11,6 @@ #include #include -#define LKC_DIRECT_LINK #include "lkc.h" #define printd(mask, fmt...) if (cdebug & (mask)) printf(fmt) -- cgit v1.2.3-59-g8ed1b From f8aea775c1d852c09adee1d0d62a9cab8764e6ea Mon Sep 17 00:00:00 2001 From: Arnaud Lacombe Date: Sun, 5 Jun 2011 23:32:07 -0400 Subject: kconfig/gconf: kill deadcode The only call site of renderer_toggled() has been commented out since Apr. 2003, as per Linus' Linux history repository: commit e7f67eb3c0570aa50c1cc0707b478a6d93bdc255 Author: Roman Zippel Date: Fri Apr 4 04:18:05 2003 -0800 [PATCH] gconf update A gconf update by Romain Livin - fixed bug when double-clicking for changing value. - expand row when enabling a row with a submenu. - various bug fixes As this result in a warning: scripts/kconfig/gconf.c:891:13: warning: 'renderer_toggled' defined but not used just nuke that code. Signed-off-by: Arnaud Lacombe --- scripts/kconfig/gconf.c | 33 --------------------------------- 1 file changed, 33 deletions(-) (limited to 'scripts') diff --git a/scripts/kconfig/gconf.c b/scripts/kconfig/gconf.c index 9258957a0913..9f4438027df4 100644 --- a/scripts/kconfig/gconf.c +++ b/scripts/kconfig/gconf.c @@ -285,8 +285,6 @@ void init_left_tree(void) static void renderer_edited(GtkCellRendererText * cell, const gchar * path_string, const gchar * new_text, gpointer user_data); -static void renderer_toggled(GtkCellRendererToggle * cellrenderertoggle, - gchar * arg1, gpointer user_data); void init_right_tree(void) { @@ -320,8 +318,6 @@ void init_right_tree(void) "inconsistent", COL_BTNINC, "visible", COL_BTNVIS, "radio", COL_BTNRAD, NULL); - /*g_signal_connect(G_OBJECT(renderer), "toggled", - G_CALLBACK(renderer_toggled), NULL); */ renderer = gtk_cell_renderer_text_new(); gtk_tree_view_column_pack_start(GTK_TREE_VIEW_COLUMN(column), renderer, FALSE); @@ -888,35 +884,6 @@ static void toggle_sym_value(struct menu *menu) display_tree_part(); //fixme: keep exp/coll } -static void renderer_toggled(GtkCellRendererToggle * cell, - gchar * path_string, gpointer user_data) -{ - GtkTreePath *path, *sel_path = NULL; - GtkTreeIter iter, sel_iter; - GtkTreeSelection *sel; - struct menu *menu; - - path = gtk_tree_path_new_from_string(path_string); - if (!gtk_tree_model_get_iter(model2, &iter, path)) - return; - - sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree2_w)); - if (gtk_tree_selection_get_selected(sel, NULL, &sel_iter)) - sel_path = gtk_tree_model_get_path(model2, &sel_iter); - if (!sel_path) - goto out1; - if (gtk_tree_path_compare(path, sel_path)) - goto out2; - - gtk_tree_model_get(model2, &iter, COL_MENU, &menu, -1); - toggle_sym_value(menu); - - out2: - gtk_tree_path_free(sel_path); - out1: - gtk_tree_path_free(path); -} - static gint column2index(GtkTreeViewColumn * column) { gint i; -- cgit v1.2.3-59-g8ed1b From 1ea3ad4e93222faf1d138ceb10291376d2da7cc6 Mon Sep 17 00:00:00 2001 From: Arnaud Lacombe Date: Sun, 5 Jun 2011 23:36:05 -0400 Subject: kconfig/gconf: silent missing prototype warnings As the `gconf' frontend is un-maintained, go the easy way by silencing the "warning: no previous prototype for ''" warnings. Signed-off-by: Arnaud Lacombe --- scripts/kconfig/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index 0460ac3b3588..84abb2fc61d1 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -227,7 +227,8 @@ HOSTLOADLIBES_qconf = $(KC_QT_LIBS) HOSTCXXFLAGS_qconf.o = $(KC_QT_CFLAGS) HOSTLOADLIBES_gconf = `pkg-config --libs gtk+-2.0 gmodule-2.0 libglade-2.0` -HOSTCFLAGS_gconf.o = `pkg-config --cflags gtk+-2.0 gmodule-2.0 libglade-2.0` +HOSTCFLAGS_gconf.o = `pkg-config --cflags gtk+-2.0 gmodule-2.0 libglade-2.0` \ + -Wno-missing-prototypes HOSTLOADLIBES_mconf = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC)) -- cgit v1.2.3-59-g8ed1b From ec6452a5ec68498221a0ced3443cefd65b08be36 Mon Sep 17 00:00:00 2001 From: Arnaud Lacombe Date: Wed, 8 Jun 2011 01:42:11 -0400 Subject: kconfig: do not overwrite symbol direct dependency in assignment Considering the following configuration: config F bool "F" choice AB bool "AB" config A bool "A" config B bool "B" endchoice if A config D bool default y if F select E config E bool "E" endif if B config D bool default y if F select E config E bool "E" endif The following configuration: CONFIG_F=y CONFIG_A=y # CONFIG_B is not set CONFIG_D=y CONFIG_E=y emits a spurious warning: (D) selects E which has unmet direct dependencies (B) If a symbol appears in two different branch of the tree, it should inherit the dependency of both parent, not just the last one. Reported-by: Yann E. Morin Tested-by: Yann E. Morin Signed-off-by: Arnaud Lacombe Signed-off-by: Michal Marek --- scripts/kconfig/menu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index aab5a1fee5a8..d66008639a43 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -351,7 +351,7 @@ void menu_finalize(struct menu *parent) last_menu->next = NULL; } - sym->dir_dep.expr = parent->dep; + sym->dir_dep.expr = expr_alloc_or(sym->dir_dep.expr, parent->dep); } for (menu = parent->list; menu; menu = menu->next) { if (sym && sym_is_choice(sym) && -- cgit v1.2.3-59-g8ed1b From e54e692ba613c2170c66ce36a3791c009680af08 Mon Sep 17 00:00:00 2001 From: Arnaud Lacombe Date: Sun, 15 May 2011 23:42:09 -0400 Subject: kconfig: introduce specialized printer Make conf_write_symbol() grammar agnostic to be able to use it from different code path. These path pass a printer callback which will print a symbol's name and its value in different format. conf_write_symbol()'s job become mostly only to prepare a string for the printer. This avoid to have to pass specialized flag to generic functions Signed-off-by: Arnaud Lacombe [mmarek: rebased on top of de12518 (kconfig: autogenerated config_is_xxx macro)] Signed-off-by: Michal Marek --- scripts/kconfig/confdata.c | 342 ++++++++++++++++++++++++++++---------------- scripts/kconfig/lkc.h | 5 + scripts/kconfig/lkc_proto.h | 1 + scripts/kconfig/symbol.c | 46 +++++- 4 files changed, 266 insertions(+), 128 deletions(-) (limited to 'scripts') diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index a49cf4f7dca5..be6952c7fb29 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -422,64 +422,228 @@ int conf_read(const char *name) return 0; } -/* Write a S_STRING */ -static void conf_write_string(bool headerfile, const char *name, - const char *str, FILE *out) +/* + * Kconfig configuration printer + * + * This printer is used when generating the resulting configuration after + * kconfig invocation and `defconfig' files. Unset symbol might be omitted by + * passing a non-NULL argument to the printer. + * + */ +static void +kconfig_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg) +{ + + switch (sym->type) { + case S_BOOLEAN: + case S_TRISTATE: + if (*value == 'n') { + bool skip_unset = (arg != NULL); + + if (!skip_unset) + fprintf(fp, "# %s%s is not set\n", + CONFIG_, sym->name); + return; + } + break; + default: + break; + } + + fprintf(fp, "%s%s=%s\n", CONFIG_, sym->name, value); +} + +static void +kconfig_print_comment(FILE *fp, const char *value, void *arg) { - int l; - if (headerfile) - fprintf(out, "#define %s%s \"", CONFIG_, name); - else - fprintf(out, "%s%s=\"", CONFIG_, name); - - while (1) { - l = strcspn(str, "\"\\"); + const char *p = value; + size_t l; + + for (;;) { + l = strcspn(p, "\n"); + fprintf(fp, "#"); if (l) { - xfwrite(str, l, 1, out); - str += l; + fprintf(fp, " "); + fwrite(p, l, 1, fp); + p += l; } - if (!*str) + fprintf(fp, "\n"); + if (*p++ == '\0') break; - fprintf(out, "\\%c", *str++); } - fputs("\"\n", out); } -static void conf_write_symbol(struct symbol *sym, FILE *out, bool write_no) +static struct conf_printer kconfig_printer_cb = { - const char *str; + .print_symbol = kconfig_print_symbol, + .print_comment = kconfig_print_comment, +}; + +/* + * Header printer + * + * This printer is used when generating the `include/generated/autoconf.h' file. + */ +static void +header_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg) +{ + const char *suffix = ""; switch (sym->type) { case S_BOOLEAN: case S_TRISTATE: - switch (sym_get_tristate_value(sym)) { - case no: - if (write_no) - fprintf(out, "# %s%s is not set\n", - CONFIG_, sym->name); - break; - case mod: - fprintf(out, "%s%s=m\n", CONFIG_, sym->name); - break; - case yes: - fprintf(out, "%s%s=y\n", CONFIG_, sym->name); - break; + switch (*value) { + case 'n': + return; + case 'm': + suffix = "_MODULE"; + /* FALLTHROUGH */ + default: + value = "1"; } break; - case S_STRING: - conf_write_string(false, sym->name, sym_get_string_value(sym), out); + default: break; - case S_HEX: - case S_INT: - str = sym_get_string_value(sym); - fprintf(out, "%s%s=%s\n", CONFIG_, sym->name, str); + } + + fprintf(fp, "#define %s%s%s %s\n", + CONFIG_, sym->name, suffix, value); +} + +static void +header_print_comment(FILE *fp, const char *value, void *arg) +{ + const char *p = value; + size_t l; + + fprintf(fp, "/*\n"); + for (;;) { + l = strcspn(p, "\n"); + fprintf(fp, " *"); + if (l) { + fprintf(fp, " "); + fwrite(p, l, 1, fp); + p += l; + } + fprintf(fp, "\n"); + if (*p++ == '\0') + break; + } + fprintf(fp, " */\n"); +} + +static struct conf_printer header_printer_cb = +{ + .print_symbol = header_print_symbol, + .print_comment = header_print_comment, +}; + +/* + * Function-style header printer + * + * This printer is used to generate the config_is_xxx() function-style macros + * in `include/generated/autoconf.h' + */ +static void +header_function_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg) +{ + int val = 0; + char c; + char *tmp, *d; + + switch (sym->type) { + case S_BOOLEAN: + case S_TRISTATE: break; + default: + return; + } + if (*value == 'm') + val = 2; + else if (*value == 'y') + val = 1; + + d = strdup(CONFIG_); + tmp = d; + while ((c = *d)) { + *d = tolower(c); + d++; + } + + fprintf(fp, "#define %sis_", tmp); + free(tmp); + + d = strdup(sym->name); + tmp = d; + while ((c = *d)) { + *d = tolower(c); + d++; + } + fprintf(fp, "%s%s() %d\n", tmp, (val > 1) ? "_module" : "", + val ? 1 : 0); + free(tmp); +} + +static struct conf_printer header_function_printer_cb = +{ + .print_symbol = header_function_print_symbol, +}; + + +/* + * Tristate printer + * + * This printer is used when generating the `include/config/tristate.conf' file. + */ +static void +tristate_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg) +{ + + if (sym->type == S_TRISTATE && *value != 'n') + fprintf(fp, "%s%s=%c\n", CONFIG_, sym->name, (char)toupper(*value)); +} + +static struct conf_printer tristate_printer_cb = +{ + .print_symbol = tristate_print_symbol, + .print_comment = kconfig_print_comment, +}; + +static void conf_write_symbol(FILE *fp, struct symbol *sym, + struct conf_printer *printer, void *printer_arg) +{ + const char *str; + + switch (sym->type) { case S_OTHER: case S_UNKNOWN: break; + case S_STRING: + str = sym_get_string_value(sym); + str = sym_escape_string_value(str); + printer->print_symbol(fp, sym, str, printer_arg); + free((void *)str); + break; + default: + str = sym_get_string_value(sym); + printer->print_symbol(fp, sym, str, printer_arg); } } +static void +conf_write_heading(FILE *fp, struct conf_printer *printer, void *printer_arg) +{ + char buf[256]; + + snprintf(buf, sizeof(buf), + "\n" + "Automatically generated file; DO NOT EDIT.\n" + "%s\n", + rootmenu.prompt->text); + + printer->print_comment(fp, buf, printer_arg); +} + /* * Write out a minimal config. * All values that has default values are skipped as this is redundant. @@ -536,7 +700,7 @@ int conf_write_defconfig(const char *filename) goto next_menu; } } - conf_write_symbol(sym, out, true); + conf_write_symbol(out, sym, &kconfig_printer_cb, NULL); } next_menu: if (menu->list != NULL) { @@ -601,11 +765,7 @@ int conf_write(const char *name) if (!out) return 1; - fprintf(out, _("#\n" - "# Automatically generated make config: don't edit\n" - "# %s\n" - "#\n"), - rootmenu.prompt->text); + conf_write_heading(out, &kconfig_printer_cb, NULL); if (!conf_get_changed()) sym_clear_all_valid(); @@ -626,8 +786,8 @@ int conf_write(const char *name) if (!(sym->flags & SYMBOL_WRITE)) goto next; sym->flags &= ~SYMBOL_WRITE; - /* Write config symbol to file */ - conf_write_symbol(sym, out, true); + + conf_write_symbol(out, sym, &kconfig_printer_cb, NULL); } next: @@ -773,33 +933,9 @@ out: return res; } -static void conf_write_function_autoconf(FILE *out, char* conf, char* name, - int val) -{ - char c; - char *tmp, *d; - - d = strdup(conf); - tmp = d; - while ((c = *conf++)) - *d++ = tolower(c); - - fprintf(out, "#define %sis_", tmp); - free(tmp); - - d = strdup(name); - tmp = d; - while ((c = *name++)) - *d++ = tolower(c); - fprintf(out, "%s%s() %d\n", tmp, (val > 1) ? "_module" : "", - val ? 1 : 0); - free(tmp); -} - int conf_write_autoconf(void) { struct symbol *sym; - const char *str; const char *name; FILE *out, *tristate, *out_h; int i; @@ -828,72 +964,24 @@ int conf_write_autoconf(void) return 1; } - fprintf(out, "#\n" - "# Automatically generated make config: don't edit\n" - "# %s\n" - "#\n", - rootmenu.prompt->text); - fprintf(tristate, "#\n" - "# Automatically generated - do not edit\n" - "\n"); - fprintf(out_h, "/*\n" - " * Automatically generated C config: don't edit\n" - " * %s\n" - " */\n", - rootmenu.prompt->text); + conf_write_heading(out, &kconfig_printer_cb, NULL); + + conf_write_heading(tristate, &tristate_printer_cb, NULL); + + conf_write_heading(out_h, &header_printer_cb, NULL); for_all_symbols(i, sym) { - int fct_val = 0; sym_calc_value(sym); if (!(sym->flags & SYMBOL_WRITE) || !sym->name) continue; - /* write symbol to config file */ - conf_write_symbol(sym, out, false); + /* write symbol to auto.conf, tristate and header files */ + conf_write_symbol(out, sym, &kconfig_printer_cb, (void *)1); - /* update autoconf and tristate files */ - switch (sym->type) { - case S_BOOLEAN: - case S_TRISTATE: - switch (sym_get_tristate_value(sym)) { - case no: - break; - case mod: - fprintf(tristate, "%s%s=M\n", - CONFIG_, sym->name); - fprintf(out_h, "#define %s%s_MODULE 1\n", - CONFIG_, sym->name); - fct_val = 2; - break; - case yes: - if (sym->type == S_TRISTATE) - fprintf(tristate,"%s%s=Y\n", - CONFIG_, sym->name); - fprintf(out_h, "#define %s%s 1\n", - CONFIG_, sym->name); - fct_val = 1; - break; - } - conf_write_function_autoconf(out_h, CONFIG_, sym->name, fct_val); - break; - case S_STRING: - conf_write_string(true, sym->name, sym_get_string_value(sym), out_h); - break; - case S_HEX: - str = sym_get_string_value(sym); - if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) { - fprintf(out_h, "#define %s%s 0x%s\n", - CONFIG_, sym->name, str); - break; - } - case S_INT: - str = sym_get_string_value(sym); - fprintf(out_h, "#define %s%s %s\n", - CONFIG_, sym->name, str); - break; - default: - break; - } + conf_write_symbol(tristate, sym, &tristate_printer_cb, (void *)1); + + conf_write_symbol(out_h, sym, &header_printer_cb, NULL); + conf_write_symbol(out_h, sym, &header_function_printer_cb, NULL); } fclose(out); fclose(tristate); diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index 625ec69ebeee..306c5a59efc2 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h @@ -87,6 +87,11 @@ 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); +struct conf_printer { + void (*print_symbol)(FILE *, struct symbol *, const char *, void *); + void (*print_comment)(FILE *, const char *, void *); +}; + /* confdata.c and expr.c */ static inline void xfwrite(const void *str, size_t len, size_t count, FILE *out) { diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h index 17342fef38b9..47fe9c340f9a 100644 --- a/scripts/kconfig/lkc_proto.h +++ b/scripts/kconfig/lkc_proto.h @@ -31,6 +31,7 @@ P(symbol_hash,struct symbol *,[SYMBOL_HASHSIZE]); P(sym_lookup,struct symbol *,(const char *name, int flags)); P(sym_find,struct symbol *,(const char *name)); P(sym_expand_string_value,const char *,(const char *in)); +P(sym_escape_string_value, const char *,(const char *in)); P(sym_re_search,struct symbol **,(const char *pattern)); P(sym_type_name,const char *,(enum symbol_type type)); P(sym_calc_value,void,(struct symbol *sym)); diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index cf8edf4fc429..071f00c3046e 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c @@ -750,7 +750,8 @@ const char *sym_get_string_value(struct symbol *sym) case no: return "n"; case mod: - return "m"; + sym_calc_value(modules_sym); + return (modules_sym->curr.tri == no) ? "n" : "m"; case yes: return "y"; } @@ -892,6 +893,49 @@ const char *sym_expand_string_value(const char *in) return res; } +const char *sym_escape_string_value(const char *in) +{ + const char *p; + size_t reslen; + char *res; + size_t l; + + reslen = strlen(in) + strlen("\"\"") + 1; + + p = in; + for (;;) { + l = strcspn(p, "\"\\"); + p += l; + + if (p[0] == '\0') + break; + + reslen++; + p++; + } + + res = malloc(reslen); + res[0] = '\0'; + + strcat(res, "\""); + + p = in; + for (;;) { + l = strcspn(p, "\"\\"); + strncat(res, p, l); + p += l; + + if (p[0] == '\0') + break; + + strcat(res, "\\"); + strncat(res, p++, 1); + } + + strcat(res, "\""); + return res; +} + struct symbol **sym_re_search(const char *pattern) { struct symbol *sym, **sym_arr = NULL; -- cgit v1.2.3-59-g8ed1b From 8494453ad50599b0c9d099a230e423a89222ad08 Mon Sep 17 00:00:00 2001 From: Arnaud Lacombe Date: Sun, 19 Sep 2010 22:45:00 -0400 Subject: kconfig: use calloc() for expr allocation Signed-off-by: Arnaud Lacombe --- scripts/kconfig/expr.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'scripts') diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c index 792c62ed9d63..290ce41f8ba4 100644 --- a/scripts/kconfig/expr.c +++ b/scripts/kconfig/expr.c @@ -13,8 +13,7 @@ struct expr *expr_alloc_symbol(struct symbol *sym) { - struct expr *e = malloc(sizeof(*e)); - memset(e, 0, sizeof(*e)); + struct expr *e = calloc(1, sizeof(*e)); e->type = E_SYMBOL; e->left.sym = sym; return e; @@ -22,8 +21,7 @@ struct expr *expr_alloc_symbol(struct symbol *sym) struct expr *expr_alloc_one(enum expr_type type, struct expr *ce) { - struct expr *e = malloc(sizeof(*e)); - memset(e, 0, sizeof(*e)); + struct expr *e = calloc(1, sizeof(*e)); e->type = type; e->left.expr = ce; return e; @@ -31,8 +29,7 @@ struct expr *expr_alloc_one(enum expr_type type, struct expr *ce) struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e2) { - struct expr *e = malloc(sizeof(*e)); - memset(e, 0, sizeof(*e)); + struct expr *e = calloc(1, sizeof(*e)); e->type = type; e->left.expr = e1; e->right.expr = e2; @@ -41,8 +38,7 @@ struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e struct expr *expr_alloc_comp(enum expr_type type, struct symbol *s1, struct symbol *s2) { - struct expr *e = malloc(sizeof(*e)); - memset(e, 0, sizeof(*e)); + struct expr *e = calloc(1, sizeof(*e)); e->type = type; e->left.sym = s1; e->right.sym = s2; -- cgit v1.2.3-59-g8ed1b From 275744cc8da0fd006e8f8fc1090f01dc0296810d Mon Sep 17 00:00:00 2001 From: Arnaud Lacombe Date: Wed, 13 Oct 2010 20:43:28 -0400 Subject: kconfig/conf: reduce the scope of `defconfig_file' This variable is not used outside of main() so there is not much reason keeping it global. Ensure it is initialized as gcc has no way to know that normal execution path expect only one option switch to be given on the command line (except when we request help). As a result, we always initialize `defconfig_file' before using it. Signed-off-by: Arnaud Lacombe --- scripts/kconfig/conf.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'scripts') diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index 08c05bcc82c9..6431f5c004d9 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c @@ -34,8 +34,6 @@ enum input_mode { oldnoconfig, } input_mode = oldaskconfig; -char *defconfig_file; - static int indent = 1; static int valid_stdin = 1; static int sync_kconfig; @@ -462,7 +460,7 @@ static struct option long_opts[] = { int main(int ac, char **av) { int opt; - const char *name; + const char *name, *defconfig_file = NULL /* gcc uninit */; struct stat tmpstat; setlocale(LC_ALL, ""); -- cgit v1.2.3-59-g8ed1b From 32543999f31e8e3a25325cc7c25d98db0c111118 Mon Sep 17 00:00:00 2001 From: Arnaud Lacombe Date: Tue, 2 Nov 2010 00:26:33 -0400 Subject: kconfig/conf: add command line options' description Signed-off-by: Arnaud Lacombe --- scripts/kconfig/conf.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index 6431f5c004d9..819ab18961fe 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c @@ -457,8 +457,28 @@ static struct option long_opts[] = { {NULL, 0, NULL, 0} }; +static void conf_usage(const char *progname) +{ + + printf("Usage: %s [option] \n", progname); + printf("[option] is _one_ of the following:\n"); + printf(" --listnewconfig List new options\n"); + printf(" --oldaskconfig Start a new configuration using a line-oriented program\n"); + printf(" --oldconfig Update a configuration using a provided .config as base\n"); + printf(" --silentoldconfig Same as oldconfig, but quietly, additionally update deps\n"); + printf(" --oldnoconfig Same as silentoldconfig but set new symbols to no\n"); + printf(" --defconfig New config with default defined in \n"); + printf(" --savedefconfig Save the minimal current configuration to \n"); + printf(" --allnoconfig New config where all options are answered with no\n"); + printf(" --allyesconfig New config where all options are answered with yes\n"); + printf(" --allmodconfig New config where all options are answered with mod\n"); + printf(" --alldefconfig New config with all symbols set to default\n"); + printf(" --randconfig New config with random answer to all options\n"); +} + int main(int ac, char **av) { + const char *progname = av[0]; int opt; const char *name, *defconfig_file = NULL /* gcc uninit */; struct stat tmpstat; @@ -492,14 +512,24 @@ int main(int ac, char **av) srand(seed); break; } + case oldaskconfig: + case oldconfig: + case allnoconfig: + case allyesconfig: + case allmodconfig: + case alldefconfig: + case listnewconfig: + case oldnoconfig: + break; case '?': - fprintf(stderr, _("See README for usage info\n")); + conf_usage(progname); exit(1); break; } } if (ac == optind) { printf(_("%s: Kconfig file missing\n"), av[0]); + conf_usage(progname); exit(1); } name = av[optind]; -- cgit v1.2.3-59-g8ed1b From 131c60a95e15e7d32b6f10881368e1ffe7296695 Mon Sep 17 00:00:00 2001 From: Arnaud Lacombe Date: Sat, 2 Jul 2011 00:25:49 -0400 Subject: kconfig: remove pending prototypes for kconfig_load() Commit 5a6f8d2bd9e3392569ed6f29ea4d7210652f929b removed `kconfig_load()', however, it missed an hidden prototypes in `lkc.h'. Fix this. Signed-off-by: Arnaud Lacombe --- scripts/kconfig/lkc.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'scripts') diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index 625ec69ebeee..60ffe8cc83f1 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h @@ -94,9 +94,6 @@ static inline void xfwrite(const void *str, size_t len, size_t count, FILE *out) fprintf(stderr, "\nError in writing or end of file.\n"); } -/* kconfig_load.c */ -void kconfig_load(void); - /* menu.c */ void _menu_init(void); void menu_warn(struct menu *menu, const char *fmt, ...); -- cgit v1.2.3-59-g8ed1b From ab63f58f253c3eca620347f5180ca3d6a1b6aa38 Mon Sep 17 00:00:00 2001 From: Arnaud Lacombe Date: Sat, 2 Jul 2011 00:59:41 -0400 Subject: kconfig/conf: mark xfgets() private This function has not much reason to be public. In the mean time, convert declaration from K&R C to ISO C. Signed-off-by: Arnaud Lacombe --- scripts/kconfig/conf.c | 7 +++---- scripts/kconfig/lkc.h | 3 --- 2 files changed, 3 insertions(+), 7 deletions(-) (limited to 'scripts') diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index 819ab18961fe..f208f900ed3a 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c @@ -18,6 +18,7 @@ static void conf(struct menu *menu); static void check_conf(struct menu *menu); +static void xfgets(char *str, int size, FILE *in); enum input_mode { oldaskconfig, @@ -672,13 +673,11 @@ int main(int ac, char **av) } return 0; } + /* * Helper function to facilitate fgets() by Jean Sacren. */ -void xfgets(str, size, in) - char *str; - int size; - FILE *in; +void xfgets(char *str, int size, FILE *in) { if (fgets(str, size, in) == NULL) fprintf(stderr, "\nError in reading or end of file.\n"); diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index 60ffe8cc83f1..eed22491f13f 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h @@ -76,9 +76,6 @@ void zconf_nextfile(const char *name); int zconf_lineno(void); const char *zconf_curname(void); -/* conf.c */ -void xfgets(char *str, int size, FILE *in); - /* confdata.c */ const char *conf_get_configname(void); const char *conf_get_autoconfig_name(void); -- cgit v1.2.3-59-g8ed1b From e9882ac0e53332f6d7ab776e7a214a9cfbf3e4b4 Mon Sep 17 00:00:00 2001 From: Raghavendra D Prabhu Date: Sat, 9 Jul 2011 21:54:49 +0530 Subject: nconfig: Avoid Wunused-but-set warning I am seeing Wunused-but-set warning while make nconfig. Looks like active_menu is not used. Removing it fixes the warning. Signed-off-by: Raghavendra D Prabhu Acked-by: WANG Cong Signed-off-by: Michal Marek --- scripts/kconfig/nconf.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'scripts') diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c index da9f5c49d886..ce47e26cbed2 100644 --- a/scripts/kconfig/nconf.c +++ b/scripts/kconfig/nconf.c @@ -1067,7 +1067,6 @@ static void conf(struct menu *menu) struct menu *submenu = 0; const char *prompt = menu_get_prompt(menu); struct symbol *sym; - struct menu *active_menu = NULL; int res; int current_index = 0; int last_top_row = 0; @@ -1152,7 +1151,6 @@ static void conf(struct menu *menu) continue; submenu = (struct menu *) item_data(); - active_menu = (struct menu *)item_data(); if (!submenu || !menu_is_visible(submenu)) continue; if (submenu) -- cgit v1.2.3-59-g8ed1b From 5416857867c9cc94aba641898c567d9707de30f1 Mon Sep 17 00:00:00 2001 From: Arnaud Lacombe Date: Sun, 10 Jul 2011 03:27:04 -0400 Subject: kconfig/nconf: use the generic menu_get_ext_help() nconf is the only front-end which does not use this helper, but prefer to copy/paste the code. The test wrt. menu validity added in this version of the code is bogus anyway as an invalid menu will get dereferenced a few line below by calling menu_get_prompt(). For now, convert nconf to use menu_get_ext_help(), as do every other front-end. We will deals with menu validity checks properly in a separate commit. Cc: Nir Tzachar Cc: Andrej Gelenberg Signed-off-by: Arnaud Lacombe Signed-off-by: Michal Marek --- scripts/kconfig/nconf.c | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) (limited to 'scripts') diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c index ce47e26cbed2..d55666d2dd85 100644 --- a/scripts/kconfig/nconf.c +++ b/scripts/kconfig/nconf.c @@ -1221,19 +1221,7 @@ static void conf_message_callback(const char *fmt, va_list ap) static void show_help(struct menu *menu) { struct gstr help = str_new(); - - if (menu && menu->sym && menu_has_help(menu)) { - if (menu->sym->name) { - str_printf(&help, "%s%s:\n\n", CONFIG_, menu->sym->name); - str_append(&help, _(menu_get_help(menu))); - str_append(&help, "\n"); - get_symbol_str(&help, menu->sym); - } else { - str_append(&help, _(menu_get_help(menu))); - } - } else { - str_append(&help, nohelp_text); - } + menu_get_ext_help(menu, &help); show_scroll_win(main_window, _(menu_get_prompt(menu)), str_get(&help)); str_free(&help); } -- cgit v1.2.3-59-g8ed1b From f98ee76955f883abf2ea2a5e5b43deab01734f47 Mon Sep 17 00:00:00 2001 From: Arnaud Lacombe Date: Sun, 10 Jul 2011 03:27:05 -0400 Subject: kconfig/nconf: prevent segfault on empty menu nconf does not check the validity of the current menu when help is requested (with either , '?' or 'h'). This leads to a NULL pointer dereference when an empty menu is encountered. The following reduced testcase exposes the problem: config DEP bool menu "FOO" config BAR bool "BAR" depends on DEP endmenu Issue will happen when entering menu "FOO" and requesting help. nconf is the only front-end which do not filter the validity of the current menu. Such filter can not really happen beforehand as other key which does not deals with the current menu might be entered by the user, so just bails out earlier if we encounter an invalid menu. Cc: Nir Tzachar Cc: Andrej Gelenberg Reported-by: Andrej Gelenberg Signed-off-by: Arnaud Lacombe Signed-off-by: Michal Marek --- scripts/kconfig/nconf.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c index d55666d2dd85..d6345df1ce12 100644 --- a/scripts/kconfig/nconf.c +++ b/scripts/kconfig/nconf.c @@ -1220,7 +1220,12 @@ static void conf_message_callback(const char *fmt, va_list ap) static void show_help(struct menu *menu) { - struct gstr help = str_new(); + struct gstr help; + + if (!menu) + return; + + help = str_new(); menu_get_ext_help(menu, &help); show_scroll_win(main_window, _(menu_get_prompt(menu)), str_get(&help)); str_free(&help); -- cgit v1.2.3-59-g8ed1b From a1e806550e566e987e06561873ab8276ee54d130 Mon Sep 17 00:00:00 2001 From: Arnaud Lacombe Date: Sun, 10 Jul 2011 03:27:33 -0400 Subject: kconfig/nconf: remove useless conditionnal After the test if (!submenu || ...) continue; the variable `submenu' can _not_ be NULL, so do not test for this situation. Cc: Nir Tzachar Signed-off-by: Arnaud Lacombe Signed-off-by: Michal Marek --- scripts/kconfig/nconf.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'scripts') diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c index d6345df1ce12..39ca1f1640ea 100644 --- a/scripts/kconfig/nconf.c +++ b/scripts/kconfig/nconf.c @@ -1153,10 +1153,7 @@ static void conf(struct menu *menu) submenu = (struct menu *) item_data(); if (!submenu || !menu_is_visible(submenu)) continue; - if (submenu) - sym = submenu->sym; - else - sym = NULL; + sym = submenu->sym; switch (res) { case ' ': -- cgit v1.2.3-59-g8ed1b From eb4cf5a642f6430cffff7ba5d8d9bd46ea409281 Mon Sep 17 00:00:00 2001 From: Arnaud Lacombe Date: Thu, 14 Jul 2011 15:31:07 -0400 Subject: kconfig: fix missing "0x" prefix from S_HEX symbol in autoconf.h The specialized printer for headers (espectially autoconf.h) is missing fixup code for S_HEX symbol's "0x" prefix. As long as kconfig does not warn for such missing prefix, this code is needed. Fix this. In the same time, fix some nits in `header_print_symbol()'. Cc: Randy Dunlap Cc: Mauro Carvalho Chehab Broken-by: Arnaud Lacombe Reported-by: Randy Dunlap Reported-by: Mauro Carvalho Chehab Acked-by: Mauro Carvalho Chehab Acked-by: Randy Dunlap Signed-off-by: Arnaud Lacombe Signed-off-by: Michal Marek --- scripts/kconfig/confdata.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'scripts') diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index be6952c7fb29..df629ecb4fdf 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -487,27 +487,43 @@ static struct conf_printer kconfig_printer_cb = static void header_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg) { - const char *suffix = ""; switch (sym->type) { case S_BOOLEAN: - case S_TRISTATE: + case S_TRISTATE: { + const char *suffix = ""; + switch (*value) { case 'n': return; case 'm': suffix = "_MODULE"; - /* FALLTHROUGH */ + /* fall through */ default: value = "1"; } + fprintf(fp, "#define %s%s%s %s\n", + CONFIG_, sym->name, suffix, value); + break; + } + case S_HEX: { + const char *prefix = ""; + + if (value[0] != '0' || (value[1] != 'x' && value[1] != 'X')) + prefix = "0x"; + fprintf(fp, "#define %s%s %s%s\n", + CONFIG_, sym->name, prefix, value); + break; + } + case S_STRING: + case S_INT: + fprintf(fp, "#define %s%s %s\n", + CONFIG_, sym->name, value); break; default: break; } - fprintf(fp, "#define %s%s%s %s\n", - CONFIG_, sym->name, suffix, value); } static void -- cgit v1.2.3-59-g8ed1b From bac6aa865b3dc98e9fbc17f11d4d513d6b0bc435 Mon Sep 17 00:00:00 2001 From: Michal Marek Date: Wed, 25 May 2011 15:10:25 +0200 Subject: xconfig: Abort close if configuration cannot be saved Give the user an opportunity to fix the error or save the configuration under a different path. Reported-by: Hiromu Yakura Signed-off-by: Michal Marek --- scripts/kconfig/qconf.cc | 13 ++++++++++--- scripts/kconfig/qconf.h | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'scripts') diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc index 31e01cdbfc6e..df274febb3e5 100644 --- a/scripts/kconfig/qconf.cc +++ b/scripts/kconfig/qconf.cc @@ -1478,10 +1478,13 @@ void ConfigMainWindow::loadConfig(void) ConfigView::updateListAll(); } -void ConfigMainWindow::saveConfig(void) +bool ConfigMainWindow::saveConfig(void) { - if (conf_write(NULL)) + if (conf_write(NULL)) { QMessageBox::information(this, "qconf", _("Unable to save configuration!")); + return false; + } + return true; } void ConfigMainWindow::saveConfigAs(void) @@ -1642,7 +1645,11 @@ void ConfigMainWindow::closeEvent(QCloseEvent* e) mb.setButtonText(QMessageBox::Cancel, _("Cancel Exit")); switch (mb.exec()) { case QMessageBox::Yes: - saveConfig(); + if (saveConfig()) + e->accept(); + else + e->ignore(); + break; case QMessageBox::No: e->accept(); break; diff --git a/scripts/kconfig/qconf.h b/scripts/kconfig/qconf.h index 91677d900dbd..3715b3e7212c 100644 --- a/scripts/kconfig/qconf.h +++ b/scripts/kconfig/qconf.h @@ -311,7 +311,7 @@ public slots: void listFocusChanged(void); void goBack(void); void loadConfig(void); - void saveConfig(void); + bool saveConfig(void); void saveConfigAs(void); void searchConfig(void); void showSingleView(void); -- cgit v1.2.3-59-g8ed1b From 2a11c8ea20bf850b3a2c60db8c2e7497d28aba99 Mon Sep 17 00:00:00 2001 From: Michal Marek Date: Wed, 20 Jul 2011 17:38:57 +0200 Subject: kconfig: Introduce IS_ENABLED(), IS_BUILTIN() and IS_MODULE() Replace the config_is_*() macros with a variant that allows for grepping for usage of CONFIG_* options in the code. Usage: if (IS_ENABLED(CONFIG_NUMA)) or #if IS_ENABLED(CONFIG_NUMA) The IS_ENABLED() macro evaluates to 1 if the argument is set (to either 'y' or 'm'), IS_BUILTIN() tests if the option is 'y' and IS_MODULE() test if the option is 'm'. Only boolean and tristate options are supported. Reviewed-by: Arnaud Lacombe Acked-by: Randy Dunlap Signed-off-by: Michal Marek --- Makefile | 2 +- include/linux/kconfig.h | 32 +++++++++++++++++++++ scripts/kconfig/confdata.c | 71 +++++++++------------------------------------- 3 files changed, 47 insertions(+), 58 deletions(-) create mode 100644 include/linux/kconfig.h (limited to 'scripts') diff --git a/Makefile b/Makefile index afb8e0d26f2c..bd7629bb93da 100644 --- a/Makefile +++ b/Makefile @@ -360,7 +360,7 @@ CFLAGS_GCOV = -fprofile-arcs -ftest-coverage LINUXINCLUDE := -I$(srctree)/arch/$(hdr-arch)/include \ -Iarch/$(hdr-arch)/include/generated -Iinclude \ $(if $(KBUILD_SRC), -I$(srctree)/include) \ - -include include/generated/autoconf.h + -include $(srctree)/include/linux/kconfig.h KBUILD_CPPFLAGS := -D__KERNEL__ diff --git a/include/linux/kconfig.h b/include/linux/kconfig.h new file mode 100644 index 000000000000..067eda0e4b32 --- /dev/null +++ b/include/linux/kconfig.h @@ -0,0 +1,32 @@ +#ifndef __LINUX_KCONFIG_H +#define __LINUX_KCONFIG_H + +#include + +/* + * Helper macros to use CONFIG_ options in C expressions. Note that + * these only work with boolean and tristate options. + */ + +/* + * IS_ENABLED(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y' or 'm', + * 0 otherwise. + * + */ +#define IS_ENABLED(option) \ + (__enabled_ ## option || __enabled_ ## option ## _MODULE) + +/* + * IS_BUILTIN(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'y', 0 + * otherwise. For boolean options, this is equivalent to + * IS_ENABLED(CONFIG_FOO). + */ +#define IS_BUILTIN(option) __enabled_ ## option + +/* + * IS_MODULE(CONFIG_FOO) evaluates to 1 if CONFIG_FOO is set to 'm', 0 + * otherwise. + */ +#define IS_MODULE(option) __enabled_ ## option ## _MODULE + +#endif /* __LINUX_KCONFIG_H */ diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index df629ecb4fdf..59b667cae5f3 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -495,15 +495,25 @@ header_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg) switch (*value) { case 'n': - return; + break; case 'm': suffix = "_MODULE"; /* fall through */ default: - value = "1"; + fprintf(fp, "#define %s%s%s 1\n", + CONFIG_, sym->name, suffix); } - fprintf(fp, "#define %s%s%s %s\n", - CONFIG_, sym->name, suffix, value); + /* + * Generate the __enabled_CONFIG_* and + * __enabled_CONFIG_*_MODULE macros for use by the + * IS_{ENABLED,BUILTIN,MODULE} macros. The _MODULE variant is + * generated even for booleans so that the IS_ENABLED() macro + * works. + */ + fprintf(fp, "#define __enabled_" CONFIG_ "%s %d\n", + sym->name, (*value == 'y')); + fprintf(fp, "#define __enabled_" CONFIG_ "%s_MODULE %d\n", + sym->name, (*value == 'm')); break; } case S_HEX: { @@ -554,58 +564,6 @@ static struct conf_printer header_printer_cb = .print_comment = header_print_comment, }; -/* - * Function-style header printer - * - * This printer is used to generate the config_is_xxx() function-style macros - * in `include/generated/autoconf.h' - */ -static void -header_function_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg) -{ - int val = 0; - char c; - char *tmp, *d; - - switch (sym->type) { - case S_BOOLEAN: - case S_TRISTATE: - break; - default: - return; - } - if (*value == 'm') - val = 2; - else if (*value == 'y') - val = 1; - - d = strdup(CONFIG_); - tmp = d; - while ((c = *d)) { - *d = tolower(c); - d++; - } - - fprintf(fp, "#define %sis_", tmp); - free(tmp); - - d = strdup(sym->name); - tmp = d; - while ((c = *d)) { - *d = tolower(c); - d++; - } - fprintf(fp, "%s%s() %d\n", tmp, (val > 1) ? "_module" : "", - val ? 1 : 0); - free(tmp); -} - -static struct conf_printer header_function_printer_cb = -{ - .print_symbol = header_function_print_symbol, -}; - - /* * Tristate printer * @@ -997,7 +955,6 @@ int conf_write_autoconf(void) conf_write_symbol(tristate, sym, &tristate_printer_cb, (void *)1); conf_write_symbol(out_h, sym, &header_printer_cb, NULL); - conf_write_symbol(out_h, sym, &header_function_printer_cb, NULL); } fclose(out); fclose(tristate); -- cgit v1.2.3-59-g8ed1b