From f597a718296eef9622ebc1d13f4f8324fa169cef Mon Sep 17 00:00:00 2001 From: Arnaud Lacombe Date: Fri, 1 Jul 2011 17:45:31 -0400 Subject: kconfig/streamline_config.pl: directly access LSMOD from the environment Cc: Steven Rostedt Signed-off-by: Arnaud Lacombe --- scripts/kconfig/Makefile | 12 ++---------- scripts/kconfig/streamline_config.pl | 8 ++++++-- 2 files changed, 8 insertions(+), 12 deletions(-) (limited to 'scripts') diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index 82d2eb285b70..bd41ab29e680 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -33,17 +33,9 @@ silentoldconfig: $(obj)/conf $(Q)mkdir -p include/generated $< --$@ $(Kconfig) -# if no path is given, then use src directory to find file -ifdef LSMOD -LSMOD_F := $(LSMOD) -ifeq ($(findstring /,$(LSMOD)),) - LSMOD_F := $(objtree)/$(LSMOD) -endif -endif - localmodconfig: $(obj)/streamline_config.pl $(obj)/conf $(Q)mkdir -p include/generated - $(Q)perl $< $(srctree) $(Kconfig) $(LSMOD_F) > .tmp.config + $(Q)perl $< $(srctree) $(Kconfig) > .tmp.config $(Q)if [ -f .config ]; then \ cmp -s .tmp.config .config || \ (mv -f .config .config.old.1; \ @@ -58,7 +50,7 @@ localmodconfig: $(obj)/streamline_config.pl $(obj)/conf localyesconfig: $(obj)/streamline_config.pl $(obj)/conf $(Q)mkdir -p include/generated - $(Q)perl $< $(srctree) $(Kconfig) $(LSMOD_F) > .tmp.config + $(Q)perl $< $(srctree) $(Kconfig) > .tmp.config $(Q)sed -i s/=m/=y/ .tmp.config $(Q)if [ -f .config ]; then \ cmp -s .tmp.config .config || \ diff --git a/scripts/kconfig/streamline_config.pl b/scripts/kconfig/streamline_config.pl index a4fe923c0131..ae34d2007f57 100644 --- a/scripts/kconfig/streamline_config.pl +++ b/scripts/kconfig/streamline_config.pl @@ -115,7 +115,7 @@ find_config; # Get the build source and top level Kconfig file (passed in) my $ksource = $ARGV[0]; my $kconfig = $ARGV[1]; -my $lsmod_file = $ARGV[2]; +my $lsmod_file = $ENV{'LSMOD'}; my @makefiles = `find $ksource -name Makefile 2>/dev/null`; chomp @makefiles; @@ -296,7 +296,11 @@ my %modules; if (defined($lsmod_file)) { if ( ! -f $lsmod_file) { - die "$lsmod_file not found"; + if ( -f $ENV{'objtree'}."/".$lsmod_file) { + $lsmod_file = $ENV{'objtree'}."/".$lsmod_file; + } else { + die "$lsmod_file not found"; + } } if ( -x $lsmod_file) { # the file is executable, run it -- cgit v1.2.3 From 22d550ae83603aa8d64d72dd1e2309cd7a96ac89 Mon Sep 17 00:00:00 2001 From: Arnaud Lacombe Date: Wed, 20 Jul 2011 00:40:09 -0400 Subject: kconfig/streamline_config.pl: use options to determine operating mode The options introduced are --localmodconfig (default) and --localyesconfig. They match the Makefile target behavior. Cc: Steven Rostedt Signed-off-by: Arnaud Lacombe --- scripts/kconfig/Makefile | 4 ++-- scripts/kconfig/streamline_config.pl | 14 +++++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) (limited to 'scripts') diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index bd41ab29e680..4de89738827c 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -35,7 +35,7 @@ silentoldconfig: $(obj)/conf localmodconfig: $(obj)/streamline_config.pl $(obj)/conf $(Q)mkdir -p include/generated - $(Q)perl $< $(srctree) $(Kconfig) > .tmp.config + $(Q)perl $< --$@ $(srctree) $(Kconfig) > .tmp.config $(Q)if [ -f .config ]; then \ cmp -s .tmp.config .config || \ (mv -f .config .config.old.1; \ @@ -50,7 +50,7 @@ localmodconfig: $(obj)/streamline_config.pl $(obj)/conf localyesconfig: $(obj)/streamline_config.pl $(obj)/conf $(Q)mkdir -p include/generated - $(Q)perl $< $(srctree) $(Kconfig) > .tmp.config + $(Q)perl $< --$@ $(srctree) $(Kconfig) > .tmp.config $(Q)sed -i s/=m/=y/ .tmp.config $(Q)if [ -f .config ]; then \ cmp -s .tmp.config .config || \ diff --git a/scripts/kconfig/streamline_config.pl b/scripts/kconfig/streamline_config.pl index ae34d2007f57..ec7afce4c88d 100644 --- a/scripts/kconfig/streamline_config.pl +++ b/scripts/kconfig/streamline_config.pl @@ -43,6 +43,7 @@ # make oldconfig # use strict; +use Getopt::Long; my $config = ".config"; @@ -112,6 +113,13 @@ sub find_config { find_config; +# Parse options +my $localmodconfig = 0; +my $localyesconfig = 0; + +GetOptions("localmodconfig" => \$localmodconfig, + "localyesconfig" => \$localyesconfig); + # Get the build source and top level Kconfig file (passed in) my $ksource = $ARGV[0]; my $kconfig = $ARGV[1]; @@ -425,7 +433,11 @@ while() { if (/^(CONFIG.*)=(m|y)/) { if (defined($configs{$1})) { - $setconfigs{$1} = $2; + if ($localyesconfig) { + $setconfigs{$1} = 'y'; + } else { + $setconfigs{$1} = $2; + } } elsif ($2 eq "m") { print "# $1 is not set\n"; next; -- cgit v1.2.3 From 50bce3e80773e06316fcb92796ff26b42348d30b Mon Sep 17 00:00:00 2001 From: Arnaud Lacombe Date: Fri, 1 Jul 2011 18:13:03 -0400 Subject: kconfig/streamline_config.pl: merge local{mod,yes}config The two targets `localmodconfig' and `localyesconfig' only differs from the sed(1) ran on the result of `streamline_config.pl' to convert symbols set to `modules' to `yes'. This conversion can be made directly from the perl script, and thus avoid duplicating the command to generate the configuration. Cc: Steven Rostedt Signed-off-by: Arnaud Lacombe --- scripts/kconfig/Makefile | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) (limited to 'scripts') diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index 4de89738827c..ba573fe7c74d 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -33,7 +33,7 @@ silentoldconfig: $(obj)/conf $(Q)mkdir -p include/generated $< --$@ $(Kconfig) -localmodconfig: $(obj)/streamline_config.pl $(obj)/conf +localyesconfig localmodconfig: $(obj)/streamline_config.pl $(obj)/conf $(Q)mkdir -p include/generated $(Q)perl $< --$@ $(srctree) $(Kconfig) > .tmp.config $(Q)if [ -f .config ]; then \ @@ -48,22 +48,6 @@ localmodconfig: $(obj)/streamline_config.pl $(obj)/conf fi $(Q)rm -f .tmp.config -localyesconfig: $(obj)/streamline_config.pl $(obj)/conf - $(Q)mkdir -p include/generated - $(Q)perl $< --$@ $(srctree) $(Kconfig) > .tmp.config - $(Q)sed -i s/=m/=y/ .tmp.config - $(Q)if [ -f .config ]; then \ - cmp -s .tmp.config .config || \ - (mv -f .config .config.old.1; \ - mv -f .tmp.config .config; \ - $(obj)/conf --silentoldconfig $(Kconfig); \ - mv -f .config.old.1 .config.old) \ - else \ - mv -f .tmp.config .config; \ - $(obj)/conf --silentoldconfig $(Kconfig); \ - fi - $(Q)rm -f .tmp.config - # Create new linux.pot file # Adjust charset to UTF-8 in .po file to accept UTF-8 in Kconfig files # The symlink is used to repair a deficiency in arch/um -- cgit v1.2.3 From 4920e05c79417f9a8d236a044502e10729af91b3 Mon Sep 17 00:00:00 2001 From: Arnaud Lacombe Date: Wed, 3 Aug 2011 21:52:06 -0400 Subject: kconfig/nconf: nuke unreferenced `nohelp_text' After commit 5416857867c9cc94aba641898c567d9707de30f1, nohelp_text' is no longer referenced, nuke it. Signed-off-by: Arnaud Lacombe 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 39ca1f1640ea..b113c50209e3 100644 --- a/scripts/kconfig/nconf.c +++ b/scripts/kconfig/nconf.c @@ -182,8 +182,6 @@ setmod_text[] = N_( "This feature depends on another which\n" "has been configured as a module.\n" "As a result, this feature will be built as a module."), -nohelp_text[] = N_( -"There is no help available for this option.\n"), load_config_text[] = N_( "Enter the name of the configuration file you wish to load.\n" "Accept the name shown to restore the configuration you\n" -- cgit v1.2.3 From 3f198dfee49d2e9c30583c62b0c79286c78c7b44 Mon Sep 17 00:00:00 2001 From: Srinivas Kandagatla Date: Tue, 2 Aug 2011 18:49:52 +0100 Subject: kbuild: Fix help text not displayed in choice option. Help text under choice menu is never displayed because it does not have symbol name associated with it, however many kconfigs have help text under choice, assuming that it will be displayed when user selects help. for example in Kconfig if we have: choice prompt "Choice" ---help--- HELP TEXT ... config A bool "A" config B bool "B" endchoice Without this patch "HELP TEXT" is not displayed when user selects help option when "Choice" is highlighted from menuconfig or xconfig or gconfig. This patch changes the logic in menu_get_ext_help to display help for cases which dont have symbol names like choice. Signed-off-by: Srinivas Kandagatla Reviewed-by: Stuart Menefy Reviewed-by: Arnaud Lacombe Cc: stable@kernel.org Signed-off-by: Michal Marek --- scripts/kconfig/menu.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'scripts') diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index d66008639a43..beeb92e75f8f 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -597,11 +597,10 @@ void menu_get_ext_help(struct menu *menu, struct gstr *help) struct symbol *sym = menu->sym; if (menu_has_help(menu)) { - if (sym->name) { + if (sym->name) str_printf(help, "%s%s:\n\n", CONFIG_, sym->name); - str_append(help, _(menu_get_help(menu))); - str_append(help, "\n"); - } + str_append(help, _(menu_get_help(menu))); + str_append(help, "\n"); } else { str_append(help, nohelp_text); } -- cgit v1.2.3 From 57e6292da67c30acf92f08604f918192a886838a Mon Sep 17 00:00:00 2001 From: Arnaud Lacombe Date: Wed, 3 Aug 2011 21:52:07 -0400 Subject: kconfig: factor code in menu_get_ext_help() Cc: Srinivas Kandagatla Signed-off-by: Arnaud Lacombe Signed-off-by: Michal Marek --- scripts/kconfig/menu.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'scripts') diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index beeb92e75f8f..8c2a97e60faf 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -10,8 +10,7 @@ #include "lkc.h" -static const char nohelp_text[] = N_( - "There is no help available for this option.\n"); +static const char nohelp_text[] = "There is no help available for this option."; struct menu rootmenu; static struct menu **last_entry_ptr; @@ -595,15 +594,14 @@ struct gstr get_relations_str(struct symbol **sym_arr) void menu_get_ext_help(struct menu *menu, struct gstr *help) { struct symbol *sym = menu->sym; + const char *help_text = nohelp_text; if (menu_has_help(menu)) { if (sym->name) str_printf(help, "%s%s:\n\n", CONFIG_, sym->name); - str_append(help, _(menu_get_help(menu))); - str_append(help, "\n"); - } else { - str_append(help, nohelp_text); + help_text = menu_get_help(menu); } + str_printf(help, "%s\n", _(help_text)); if (sym) get_symbol_str(help, sym); } -- cgit v1.2.3 From d2ee52aaf30072e4a761e785c752e305ce10152f Mon Sep 17 00:00:00 2001 From: "K. Y. Srinivasan" Date: Thu, 25 Aug 2011 09:48:30 -0700 Subject: Staging: hv: Add code to parse struct hv_vmbus_device_id table Add code to parse struct hv_vmbus_device_id table. Signed-off-by: K. Y. Srinivasan Signed-off-by: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- scripts/mod/file2alias.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'scripts') diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index e26e2fb462d4..b74d21ab91f7 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c @@ -735,6 +735,27 @@ static int do_virtio_entry(const char *filename, struct virtio_device_id *id, return 1; } +/* + * Looks like: vmbus:guid + * Each byte of the guid will be represented by two hex characters + * in the name. + */ + +static int do_vmbus_entry(const char *filename, struct hv_vmbus_device_id *id, + char *alias) +{ + int i; + char guid_name[((sizeof(struct hv_vmbus_device_id) + 1)) * 2]; + + for (i = 0; i < (sizeof(struct hv_vmbus_device_id) * 2); i += 2) + sprintf(&guid_name[i], "%02x", id->guid[i/2]); + + strcpy(alias, "vmbus:"); + strcat(alias, guid_name); + + return 1; +} + /* Looks like: i2c:S */ static int do_i2c_entry(const char *filename, struct i2c_device_id *id, char *alias) @@ -994,6 +1015,10 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, do_table(symval, sym->st_size, sizeof(struct virtio_device_id), "virtio", do_virtio_entry, mod); + else if (sym_is(symname, "__mod_vmbus_device_table")) + do_table(symval, sym->st_size, + sizeof(struct hv_vmbus_device_id), "vmbus", + do_vmbus_entry, mod); else if (sym_is(symname, "__mod_i2c_device_table")) do_table(symval, sym->st_size, sizeof(struct i2c_device_id), "i2c", -- cgit v1.2.3 From ebf16e38515188b61962ba84b59e898ad64ffff6 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 25 Aug 2011 11:28:11 -0700 Subject: Staging: hv: file2alias: fix up alias creation logic for hv_vmbus_device_id When I added the driver_data field to hv_vmbus_device_id, I forgot to take into the account how the alias was created, so it would append the kernel pointer to the end of the alias, which is not correct. This changes how the hv_vmbus_device_id alias is created to proper account for the driver_data field. As no module yet uses this alias, it is safe to fix this up at this point in the commit stream. Cc: K. Y. Srinivasan Cc: Haiyang Zhang Signed-off-by: Greg Kroah-Hartman --- scripts/mod/file2alias.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index b74d21ab91f7..f936d1fa969d 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c @@ -745,9 +745,9 @@ static int do_vmbus_entry(const char *filename, struct hv_vmbus_device_id *id, char *alias) { int i; - char guid_name[((sizeof(struct hv_vmbus_device_id) + 1)) * 2]; + char guid_name[((sizeof(id->guid) + 1)) * 2]; - for (i = 0; i < (sizeof(struct hv_vmbus_device_id) * 2); i += 2) + for (i = 0; i < (sizeof(id->guid) * 2); i += 2) sprintf(&guid_name[i], "%02x", id->guid[i/2]); strcpy(alias, "vmbus:"); -- cgit v1.2.3 From 953742c8fe8ac45be453fee959d7be40cd89f920 Mon Sep 17 00:00:00 2001 From: Arnaud Lacombe Date: Tue, 16 Aug 2011 01:20:20 -0400 Subject: kconfig: fix __enabled_ macros definition for invisible and un-selected symbols __enabled_ are only generated on visible or selected entries, do not reflect the purpose of its introduction. Fix this by always generating these entries for named symbol. Reported-by: Rabin Vincent Signed-off-by: Arnaud Lacombe --- scripts/kconfig/confdata.c | 49 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 13 deletions(-) (limited to 'scripts') diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 59b667cae5f3..5a58965d8800 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -503,17 +503,6 @@ header_print_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg) fprintf(fp, "#define %s%s%s 1\n", CONFIG_, sym->name, suffix); } - /* - * 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: { @@ -564,6 +553,35 @@ static struct conf_printer header_printer_cb = .print_comment = header_print_comment, }; +/* + * 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. + */ +static void +header_print__enabled_symbol(FILE *fp, struct symbol *sym, const char *value, void *arg) +{ + + switch (sym->type) { + case S_BOOLEAN: + case S_TRISTATE: { + 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; + } + default: + break; + } +} + +static struct conf_printer header__enabled_printer_cb = +{ + .print_symbol = header_print__enabled_symbol, + .print_comment = header_print_comment, +}; + /* * Tristate printer * @@ -945,11 +963,16 @@ int conf_write_autoconf(void) conf_write_heading(out_h, &header_printer_cb, NULL); for_all_symbols(i, sym) { + if (!sym->name) + continue; + sym_calc_value(sym); - if (!(sym->flags & SYMBOL_WRITE) || !sym->name) + + conf_write_symbol(out_h, sym, &header__enabled_printer_cb, NULL); + + if (!(sym->flags & SYMBOL_WRITE)) continue; - /* write symbol to auto.conf, tristate and header files */ conf_write_symbol(out, sym, &kconfig_printer_cb, (void *)1); conf_write_symbol(tristate, sym, &tristate_printer_cb, (void *)1); -- cgit v1.2.3 From 564899f9f0a2df85fa367c8749a1fef323cb3215 Mon Sep 17 00:00:00 2001 From: Davidlohr Bueso Date: Sun, 21 Aug 2011 22:04:09 -0300 Subject: kconfig: handle SIGINT in menuconfig I recently got bitten in the ass when pressing Ctrl-C and lost all my current configuration changes. This patch captures SIGINT and allows the user to save any changes. Some code refactoring was made in order to handle the exit behavior. Signed-off-by: Davidlohr Bueso Signed-off-by: Arnaud Lacombe --- scripts/kconfig/mconf.c | 86 ++++++++++++++++++++++++++++++------------------- 1 file changed, 52 insertions(+), 34 deletions(-) (limited to 'scripts') diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index 820d2b6800fb..19e200d91120 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -272,6 +273,7 @@ static struct menu *current_menu; static int child_count; static int single_menu_mode; static int show_all_options; +static int saved_x, saved_y; static void conf(struct menu *menu); static void conf_choice(struct menu *menu); @@ -792,9 +794,54 @@ static void conf_save(void) } } +static int handle_exit(void) +{ + int res; + + dialog_clear(); + if (conf_get_changed()) + res = dialog_yesno(NULL, + _("Do you wish to save your new configuration ?\n" + " to continue."), + 6, 60); + else + res = -1; + + end_dialog(saved_x, saved_y); + + switch (res) { + case 0: + if (conf_write(filename)) { + fprintf(stderr, _("\n\n" + "Error while writing of the configuration.\n" + "Your configuration changes were NOT saved." + "\n\n")); + return 1; + } + /* fall through */ + case -1: + printf(_("\n\n" + "*** End of the configuration.\n" + "*** Execute 'make' to start the build or try 'make help'." + "\n\n")); + res = 0; + break; + default: + fprintf(stderr, _("\n\n" + "Your configuration changes were NOT saved." + "\n\n")); + } + + return res; +} + +static void sig_handler(int signo) +{ + exit(handle_exit()); +} + int main(int ac, char **av) { - int saved_x, saved_y; char *mode; int res; @@ -802,6 +849,8 @@ int main(int ac, char **av) bindtextdomain(PACKAGE, LOCALEDIR); textdomain(PACKAGE); + signal(SIGINT, sig_handler); + conf_parse(av[1]); conf_read(NULL); @@ -823,40 +872,9 @@ int main(int ac, char **av) set_config_filename(conf_get_configname()); do { conf(&rootmenu); - dialog_clear(); - if (conf_get_changed()) - res = dialog_yesno(NULL, - _("Do you wish to save your " - "new configuration?\n" - " to continue."), - 6, 60); - else - res = -1; + res = handle_exit(); } while (res == KEY_ESC); - end_dialog(saved_x, saved_y); - - switch (res) { - case 0: - if (conf_write(filename)) { - fprintf(stderr, _("\n\n" - "Error while writing of the configuration.\n" - "Your configuration changes were NOT saved." - "\n\n")); - return 1; - } - /* fall through */ - case -1: - printf(_("\n\n" - "*** End of the configuration.\n" - "*** Execute 'make' to start the build or try 'make help'." - "\n\n")); - break; - default: - fprintf(stderr, _("\n\n" - "Your configuration changes were NOT saved." - "\n\n")); - } - return 0; + return res; } -- cgit v1.2.3 From 702a945028fd7cbf7a5e55546b3c47a5c984a1ba Mon Sep 17 00:00:00 2001 From: Lucas De Marchi Date: Sat, 20 Aug 2011 02:28:53 -0300 Subject: kconfig: fix set but not used variables Some variables were being set but never used, which was triggering warnings in GCC >= 4.6. Signed-off-by: Lucas De Marchi Signed-off-by: Arnaud Lacombe --- scripts/kconfig/lxdialog/textbox.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/kconfig/lxdialog/textbox.c b/scripts/kconfig/lxdialog/textbox.c index c704712d0227..154c2dd245b7 100644 --- a/scripts/kconfig/lxdialog/textbox.c +++ b/scripts/kconfig/lxdialog/textbox.c @@ -320,7 +320,6 @@ static void print_page(WINDOW * win, int height, int width) */ static void print_line(WINDOW * win, int row, int width) { - int y, x; char *line; line = get_line(); @@ -329,10 +328,10 @@ static void print_line(WINDOW * win, int row, int width) waddch(win, ' '); waddnstr(win, line, MIN(strlen(line), width - 2)); - getyx(win, y, x); /* Clear 'residue' of previous line */ #if OLD_NCURSES { + int x = getcurx(win); int i; for (i = 0; i < width - x; i++) waddch(win, ' '); -- cgit v1.2.3 From 09d481270d445d98342d8ab872f05491b6d23f8b Mon Sep 17 00:00:00 2001 From: Corentin Chary Date: Tue, 16 Aug 2011 10:46:05 +0200 Subject: scripts: add extract-vmlinux This script can be used to extract vmlinux from a compressed kernel image (bzImage, etc..). It's inspired from (a subset of) extract-ikconfig. It's something a lot of people have been looking for (mainly people with xen < 4 that doesn't support bzImages at all). Signed-off-by: Corentin Chary Signed-off-by: Michal Marek --- scripts/extract-vmlinux | 62 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100755 scripts/extract-vmlinux (limited to 'scripts') diff --git a/scripts/extract-vmlinux b/scripts/extract-vmlinux new file mode 100755 index 000000000000..5061abcc2540 --- /dev/null +++ b/scripts/extract-vmlinux @@ -0,0 +1,62 @@ +#!/bin/sh +# ---------------------------------------------------------------------- +# extract-vmlinux - Extract uncompressed vmlinux from a kernel image +# +# Inspired from extract-ikconfig +# (c) 2009,2010 Dick Streefland +# +# (c) 2011 Corentin Chary +# +# Licensed under the GNU General Public License, version 2 (GPLv2). +# ---------------------------------------------------------------------- + +check_vmlinux() +{ + # Use readelf to check if it's a valid ELF + # TODO: find a better to way to check that it's really vmlinux + # and not just an elf + readelf -h $1 > /dev/null 2>&1 || return 1 + + cat $1 + exit 0 +} + +try_decompress() +{ + # The obscure use of the "tr" filter is to work around older versions of + # "grep" that report the byte offset of the line instead of the pattern. + + # Try to find the header ($1) and decompress from here + for pos in `tr "$1\n$2" "\n$2=" < "$img" | grep -abo "^$2"` + do + pos=${pos%%:*} + tail -c+$pos "$img" | $3 > $tmp 2> /dev/null + check_vmlinux $tmp + done +} + +# Check invocation: +me=${0##*/} +img=$1 +if [ $# -ne 1 -o ! -s "$img" ] +then + echo "Usage: $me " >&2 + exit 2 +fi + +# Prepare temp files: +tmp=$(mktemp /tmp/vmlinux-XXX) +trap "rm -f $tmp" 0 + +# Initial attempt for uncompressed images or objects: +check_vmlinux $img + +# That didn't work, so retry after decompression. +try_decompress '\037\213\010' xy gunzip +try_decompress '\3757zXZ\000' abcde unxz +try_decompress 'BZh' xy bunzip2 +try_decompress '\135\0\0\0' xxx unlzma +try_decompress '\211\114\132' xy 'lzop -d' + +# Bail out: +echo "$me: Cannot find vmlinux." >&2 -- cgit v1.2.3 From 9c65426ad2cce12a2d72cdb42aa08f7ce946065d Mon Sep 17 00:00:00 2001 From: Ian Munsie Date: Tue, 30 Aug 2011 11:47:58 +1000 Subject: tags, powerpc: Update tags.sh to support _GLOBAL symbols On PowerPC we use _GLOBAL throughout the assembly to define symbols, but currently these symbols are missing from the tags generated with ARCH=powerpc make tags. This patch modifies the tags.sh script to recognise _GLOBAL(.*) so that these symbols will be in the tags. This is almost (but not quite) PowerPC specific and this change should not affect anyone else: $ git grep -E '^_GLOBAL\(([^)]*)\).*' |sed 's/^\([^/]*\/[^/]*\)\/.*$/\1/'|uniq -c 627 arch/powerpc 2 arch/um Signed-off-by: Ian Munsie Signed-off-by: Michal Marek --- scripts/tags.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/tags.sh b/scripts/tags.sh index 75c5d24f1993..38f6617a2cb1 100755 --- a/scripts/tags.sh +++ b/scripts/tags.sh @@ -129,7 +129,7 @@ exuberant() -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL \ -I DEFINE_TRACE,EXPORT_TRACEPOINT_SYMBOL,EXPORT_TRACEPOINT_SYMBOL_GPL \ --extra=+f --c-kinds=+px \ - --regex-asm='/^ENTRY\(([^)]*)\).*/\1/' \ + --regex-asm='/^(ENTRY|_GLOBAL)\(([^)]*)\).*/\2/' \ --regex-c='/^SYSCALL_DEFINE[[:digit:]]?\(([^,)]*).*/sys_\1/' \ --regex-c++='/^TRACE_EVENT\(([^,)]*).*/trace_\1/' \ --regex-c++='/^DEFINE_EVENT\([^,)]*, *([^,)]*).*/trace_\1/' @@ -151,7 +151,7 @@ exuberant() emacs() { all_sources | xargs $1 -a \ - --regex='/^ENTRY(\([^)]*\)).*/\1/' \ + --regex='/^(ENTRY|_GLOBAL)(\([^)]*\)).*/\2/' \ --regex='/^SYSCALL_DEFINE[0-9]?(\([^,)]*\).*/sys_\1/' \ --regex='/^TRACE_EVENT(\([^,)]*\).*/trace_\1/' \ --regex='/^DEFINE_EVENT([^,)]*, *\([^,)]*\).*/trace_\1/' -- cgit v1.2.3 From 58238c81443a83922e07b409e54ec93ce909b6ac Mon Sep 17 00:00:00 2001 From: Peter Foley Date: Sun, 31 Jul 2011 14:45:40 -0400 Subject: kbuild: prevent make from deleting _shipped files commit 7373f4f (kbuild: add implicit rules for parser generation) created a implicit rule chain (%.c: %.c_shipped: %.y). Make considers the _shipped files to be intermediate files which causes them to be deleted if they didn't exist before make was run. Mark the _shipped files PRECIOUS to prevent make from deleting them. Signed-off-by: Peter Foley Acked-by: Arnaud Lacombe Signed-off-by: Michal Marek --- scripts/Makefile.lib | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'scripts') diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index aeea84a24836..5d986d9adf1b 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -167,6 +167,7 @@ ifdef REGENERATE_PARSERS quiet_cmd_gperf = GPERF $@ cmd_gperf = gperf -t --output-file $@ -a -C -E -g -k 1,3,$$ -p -t $< +.PRECIOUS: $(src)/%.hash.c_shipped $(src)/%.hash.c_shipped: $(src)/%.gperf $(call cmd,gperf) @@ -177,6 +178,7 @@ LEX_PREFIX = $(if $(LEX_PREFIX_${baseprereq}),$(LEX_PREFIX_${baseprereq}),yy) quiet_cmd_flex = LEX $@ cmd_flex = flex -o$@ -L -P $(LEX_PREFIX) $< +.PRECIOUS: $(src)/%.lex.c_shipped $(src)/%.lex.c_shipped: $(src)/%.l $(call cmd,flex) @@ -187,12 +189,14 @@ YACC_PREFIX = $(if $(YACC_PREFIX_${baseprereq}),$(YACC_PREFIX_${baseprereq}),yy) quiet_cmd_bison = YACC $@ cmd_bison = bison -o$@ -t -l -p $(YACC_PREFIX) $< +.PRECIOUS: $(src)/%.tab.c_shipped $(src)/%.tab.c_shipped: $(src)/%.y $(call cmd,bison) quiet_cmd_bison_h = YACC $@ cmd_bison_h = bison -o/dev/null --defines=$@ -t -l -p $(YACC_PREFIX) $< +.PRECIOUS: $(src)/%.tab.h_shipped $(src)/%.tab.h_shipped: $(src)/%.y $(call cmd,bison_h) -- cgit v1.2.3 From 49c57d254e691a45ade207c754ba09ca7129ed93 Mon Sep 17 00:00:00 2001 From: Arnaud Lacombe Date: Mon, 15 Aug 2011 01:07:13 -0400 Subject: scripts/Makefile.build: do not reference EXTRA_CFLAGS as CFLAGS replacement Usage of these flags has been deprecated for nearly 4 years by: commit f77bf01425b11947eeb3b5b54685212c302741b8 Author: Sam Ravnborg Date: Mon Oct 15 22:25:06 2007 +0200 kbuild: introduce ccflags-y, asflags-y and ldflags-y Moreover, these flags (at least EXTRA_CFLAGS) have been documented for command line use. By default, gmake(1) do not override command line setting, so this is likely to result in build failure or unexpected behavior. Do not advertise for its usage. Cc: Sam Ravnborg Cc: linux-kbuild@vger.kernel.org Signed-off-by: Arnaud Lacombe Signed-off-by: Michal Marek --- scripts/Makefile.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/Makefile.build b/scripts/Makefile.build index a0fd5029cfe7..d2b366c16b64 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -46,7 +46,7 @@ include $(kbuild-file) # If the save-* variables changed error out ifeq ($(KBUILD_NOPEDANTIC),) ifneq ("$(save-cflags)","$(CFLAGS)") - $(error CFLAGS was changed in "$(kbuild-file)". Fix it to use EXTRA_CFLAGS) + $(error CFLAGS was changed in "$(kbuild-file)". Fix it to use ccflags-y) endif endif -- cgit v1.2.3 From c68e58783f20d3eb32b99e1962b26462f2e3195a Mon Sep 17 00:00:00 2001 From: Arnaud Lacombe Date: Mon, 15 Aug 2011 01:07:14 -0400 Subject: script/checkpatch.pl: warn about deprecated use of EXTRA_{A,C,CPP,LD}FLAGS Usage of these flags has been deprecated for nearly 4 years by: commit f77bf01425b11947eeb3b5b54685212c302741b8 Author: Sam Ravnborg Date: Mon Oct 15 22:25:06 2007 +0200 kbuild: introduce ccflags-y, asflags-y and ldflags-y Moreover, these flags (at least EXTRA_CFLAGS) have been documented for command line use. By default, gmake(1) do not override command line setting, so this is likely to result in build failure or unexpected behavior. Warn about their introduction in Makefile or Kbuild files. Cc: Sam Ravnborg Cc: Andy Whitcroft Signed-off-by: Arnaud Lacombe Signed-off-by: Michal Marek --- scripts/checkpatch.pl | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'scripts') diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 9d761c95eca2..955183ada37a 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -1661,6 +1661,20 @@ sub process { #print "is_end<$is_end> length<$length>\n"; } + if (($realfile =~ /Makefile.*/ || $realfile =~ /Kbuild.*/) && + ($line =~ /\+(EXTRA_[A-Z]+FLAGS).*/)) { + my $flag = $1; + my $replacement = { + 'EXTRA_AFLAGS' => 'asflags-y', + 'EXTRA_CFLAGS' => 'ccflags-y', + 'EXTRA_CPPFLAGS' => 'cppflags-y', + 'EXTRA_LDFLAGS' => 'ldflags-y', + }; + + WARN("DEPRECATED_VARIABLE", + "Use of $flag is deprecated, please use \`$replacement->{$flag} instead.\n" . $herecurr) if ($replacement->{$flag}); + } + # check we are in a valid source file if not then ignore this hunk next if ($realfile !~ /\.(h|c|s|S|pl|sh)$/); -- cgit v1.2.3 From 6a5be57f0f00bf5f39b983ec98d58058bc696543 Mon Sep 17 00:00:00 2001 From: Peter Foley Date: Mon, 1 Aug 2011 09:51:24 -0400 Subject: fixdep: fix extraneous dependencies The introduction of include/linux/kconfig.h created 3 extraneous dependencies: include/config/.h include/config/h.h include/config/foo.h Fix this by excluding kconfig.h from fixdep calculations. Signed-off-by: Peter Foley Signed-off-by: Michal Marek --- scripts/basic/fixdep.c | 1 + 1 file changed, 1 insertion(+) (limited to 'scripts') diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c index 291228e25984..cb1f50cf12e3 100644 --- a/scripts/basic/fixdep.c +++ b/scripts/basic/fixdep.c @@ -345,6 +345,7 @@ static void parse_dep_file(void *map, size_t len) memcpy(s, m, p-m); s[p-m] = 0; if (strrcmp(s, "include/generated/autoconf.h") && strrcmp(s, "arch/um/include/uml-config.h") && + strrcmp(s, "include/linux/kconfig.h") && strrcmp(s, ".ver")) { /* * Do not list the source file as dependency, so that -- cgit v1.2.3 From 4e24dbfc26f8b8285c9ed2f92ffddf4eb8ab960a Mon Sep 17 00:00:00 2001 From: Cheng Renquan Date: Thu, 1 Sep 2011 10:52:18 -0700 Subject: scripts/kconfig/nconf: fix typo: unknow => unknown Signed-off-by: Cheng Renquan Acked-by: Arnaud Lacombe --- scripts/kconfig/nconf.gui.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/kconfig/nconf.gui.c b/scripts/kconfig/nconf.gui.c index f8137b3a5382..d3af04e95288 100644 --- a/scripts/kconfig/nconf.gui.c +++ b/scripts/kconfig/nconf.gui.c @@ -461,7 +461,7 @@ int dialog_inputbox(WINDOW *main_window, result[cursor_position] = res; cursor_position++; } else { - mvprintw(0, 0, "unknow key: %d\n", res); + mvprintw(0, 0, "unknown key: %d\n", res); } break; } -- cgit v1.2.3 From cd58a90fa6ff2ec86bcc9e399acfd6dcc97268b3 Mon Sep 17 00:00:00 2001 From: Cheng Renquan Date: Thu, 1 Sep 2011 10:52:19 -0700 Subject: scripts/kconfig/nconf: fix memmove's length arg In case KEY_BACKSPACE / KEY_DC to delete a char, it memmove only (len-cursor_position+1) bytes; the default case is to insert a char, it should also memmove exactly (len-cursor_position+1) bytes; the original use of (len+1) is wrong and may access following memory that doesn't belong to result, may cause SegFault in theory; case KEY_BACKSPACE: if (cursor_position > 0) { memmove(&result[cursor_position-1], &result[cursor_position], len-cursor_position+1); cursor_position--; } break; case KEY_DC: if (cursor_position >= 0 && cursor_position < len) { memmove(&result[cursor_position], &result[cursor_position+1], len-cursor_position+1); } break; default: if ((isgraph(res) || isspace(res)) && len-2 < result_len) { /* insert the char at the proper position */ memmove(&result[cursor_position+1], &result[cursor_position], len-cursor_position+1); result[cursor_position] = res; cursor_position++; } Signed-off-by: Cheng Renquan Acked-by: Nir Tzachar --- scripts/kconfig/nconf.gui.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/kconfig/nconf.gui.c b/scripts/kconfig/nconf.gui.c index d3af04e95288..3ce2a7c0bda6 100644 --- a/scripts/kconfig/nconf.gui.c +++ b/scripts/kconfig/nconf.gui.c @@ -457,7 +457,7 @@ int dialog_inputbox(WINDOW *main_window, /* insert the char at the proper position */ memmove(&result[cursor_position+1], &result[cursor_position], - len+1); + len-cursor_position+1); result[cursor_position] = res; cursor_position++; } else { -- cgit v1.2.3 From 5ea9f64ffc073bf2882f6aa83b0dad3609b1e67a Mon Sep 17 00:00:00 2001 From: Cheng Renquan Date: Thu, 1 Sep 2011 10:52:20 -0700 Subject: scripts/kconfig/nconf: dynamically alloc dialog_input_result To support unlimited length string config items; No check for realloc return value keeps code simple, and to be consistent with other existing unchecked malloc in kconfig. Signed-off-by: Cheng Renquan Signed-off-by: Arnaud Lacombe --- scripts/kconfig/nconf.c | 21 ++++++++++----------- scripts/kconfig/nconf.gui.c | 20 +++++++++++++++----- scripts/kconfig/nconf.h | 2 +- 3 files changed, 26 insertions(+), 17 deletions(-) (limited to 'scripts') diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c index b113c50209e3..73070cb0b6de 100644 --- a/scripts/kconfig/nconf.c +++ b/scripts/kconfig/nconf.c @@ -278,6 +278,9 @@ static int global_exit; /* the currently selected button */ const char *current_instructions = menu_instructions; +static char *dialog_input_result; +static int dialog_input_result_len; + static void conf(struct menu *menu); static void conf_choice(struct menu *menu); static void conf_string(struct menu *menu); @@ -693,7 +696,6 @@ static void search_conf(void) { struct symbol **sym_arr; struct gstr res; - char dialog_input_result[100]; char *dialog_input; int dres; again: @@ -701,7 +703,7 @@ again: _("Search Configuration Parameter"), _("Enter " CONFIG_ " (sub)string to search for " "(with or without \"" CONFIG_ "\")"), - "", dialog_input_result, 99); + "", &dialog_input_result, &dialog_input_result_len); switch (dres) { case 0: break; @@ -1346,7 +1348,6 @@ static void conf_choice(struct menu *menu) static void conf_string(struct menu *menu) { const char *prompt = menu_get_prompt(menu); - char dialog_input_result[256]; while (1) { int res; @@ -1369,8 +1370,8 @@ static void conf_string(struct menu *menu) prompt ? _(prompt) : _("Main Menu"), heading, sym_get_string_value(menu->sym), - dialog_input_result, - sizeof(dialog_input_result)); + &dialog_input_result, + &dialog_input_result_len); switch (res) { case 0: if (sym_set_string_value(menu->sym, @@ -1390,14 +1391,13 @@ static void conf_string(struct menu *menu) static void conf_load(void) { - char dialog_input_result[256]; while (1) { int res; res = dialog_inputbox(main_window, NULL, load_config_text, filename, - dialog_input_result, - sizeof(dialog_input_result)); + &dialog_input_result, + &dialog_input_result_len); switch (res) { case 0: if (!dialog_input_result[0]) @@ -1422,14 +1422,13 @@ static void conf_load(void) static void conf_save(void) { - char dialog_input_result[256]; while (1) { int res; res = dialog_inputbox(main_window, NULL, save_config_text, filename, - dialog_input_result, - sizeof(dialog_input_result)); + &dialog_input_result, + &dialog_input_result_len); switch (res) { case 0: if (!dialog_input_result[0]) diff --git a/scripts/kconfig/nconf.gui.c b/scripts/kconfig/nconf.gui.c index 3ce2a7c0bda6..d64bc1c24c20 100644 --- a/scripts/kconfig/nconf.gui.c +++ b/scripts/kconfig/nconf.gui.c @@ -356,7 +356,7 @@ int btn_dialog(WINDOW *main_window, const char *msg, int btn_num, ...) int dialog_inputbox(WINDOW *main_window, const char *title, const char *prompt, - const char *init, char *result, int result_len) + const char *init, char **resultp, int *result_len) { int prompt_lines = 0; int prompt_width = 0; @@ -367,7 +367,12 @@ int dialog_inputbox(WINDOW *main_window, int i, x, y; int res = -1; int cursor_position = strlen(init); + char *result = *resultp; + if (strlen(init)+1 > *result_len) { + *result_len = strlen(init)+1; + *resultp = result = realloc(result, *result_len); + } /* find the widest line of msg: */ prompt_lines = get_line_no(prompt); @@ -384,7 +389,7 @@ int dialog_inputbox(WINDOW *main_window, y = (LINES-(prompt_lines+4))/2; x = (COLS-(prompt_width+4))/2; - strncpy(result, init, result_len); + strncpy(result, init, *result_len); /* create the windows */ win = newwin(prompt_lines+6, prompt_width+7, y, x); @@ -443,7 +448,7 @@ int dialog_inputbox(WINDOW *main_window, case KEY_UP: case KEY_RIGHT: if (cursor_position < len && - cursor_position < min(result_len, prompt_width)) + cursor_position < min(*result_len, prompt_width)) cursor_position++; break; case KEY_DOWN: @@ -452,8 +457,13 @@ int dialog_inputbox(WINDOW *main_window, cursor_position--; break; default: - if ((isgraph(res) || isspace(res)) && - len-2 < result_len) { + if ((isgraph(res) || isspace(res))) { + /* one for new char, one for '\0' */ + if (len+2 > *result_len) { + *result_len = len+2; + *resultp = result = realloc(result, + *result_len); + } /* insert the char at the proper position */ memmove(&result[cursor_position+1], &result[cursor_position], diff --git a/scripts/kconfig/nconf.h b/scripts/kconfig/nconf.h index 58fbda8fc0dc..0d5261705ef5 100644 --- a/scripts/kconfig/nconf.h +++ b/scripts/kconfig/nconf.h @@ -89,7 +89,7 @@ void fill_window(WINDOW *win, const char *text); int btn_dialog(WINDOW *main_window, const char *msg, int btn_num, ...); int dialog_inputbox(WINDOW *main_window, const char *title, const char *prompt, - const char *init, char *result, int result_len); + const char *init, char **resultp, int *result_len); void refresh_all_windows(WINDOW *main_window); void show_scroll_win(WINDOW *main_window, const char *title, -- cgit v1.2.3 From e631a57a19e103c3bb59495b236634ec62e2a850 Mon Sep 17 00:00:00 2001 From: Cheng Renquan Date: Thu, 1 Sep 2011 10:52:21 -0700 Subject: scripts/kconfig/nconf: fix editing long strings The original dialog_inputbox doesn't work with longer than prompt_width strings, here fixed it in this way: 1) add variable cursor_form_win to record cursor of form_win, keep its value always between [0, prompt_width-1]; reuse the original cursor_position as cursor of the string result, use (cursor_position-cursor_form_win) as begin offset to show part of the string in form_win; Signed-off-by: Cheng Renquan Cc: Arnaud Lacombe Cc: Nir Tzachar --- scripts/kconfig/nconf.gui.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) (limited to 'scripts') diff --git a/scripts/kconfig/nconf.gui.c b/scripts/kconfig/nconf.gui.c index d64bc1c24c20..4b9d8b66087d 100644 --- a/scripts/kconfig/nconf.gui.c +++ b/scripts/kconfig/nconf.gui.c @@ -367,6 +367,7 @@ int dialog_inputbox(WINDOW *main_window, int i, x, y; int res = -1; int cursor_position = strlen(init); + int cursor_form_win; char *result = *resultp; if (strlen(init)+1 > *result_len) { @@ -410,7 +411,9 @@ int dialog_inputbox(WINDOW *main_window, fill_window(prompt_win, prompt); mvwprintw(form_win, 0, 0, "%*s", prompt_width, " "); - mvwprintw(form_win, 0, 0, "%s", result); + cursor_form_win = min(cursor_position, prompt_width-1); + mvwprintw(form_win, 0, 0, "%s", + result + cursor_position-cursor_form_win); /* create panels */ panel = new_panel(win); @@ -436,6 +439,8 @@ int dialog_inputbox(WINDOW *main_window, &result[cursor_position], len-cursor_position+1); cursor_position--; + cursor_form_win--; + len--; } break; case KEY_DC: @@ -443,18 +448,22 @@ int dialog_inputbox(WINDOW *main_window, memmove(&result[cursor_position], &result[cursor_position+1], len-cursor_position+1); + len--; } break; case KEY_UP: case KEY_RIGHT: - if (cursor_position < len && - cursor_position < min(*result_len, prompt_width)) + if (cursor_position < len) { cursor_position++; + cursor_form_win++; + } break; case KEY_DOWN: case KEY_LEFT: - if (cursor_position > 0) + if (cursor_position > 0) { cursor_position--; + cursor_form_win--; + } break; default: if ((isgraph(res) || isspace(res))) { @@ -470,16 +479,24 @@ int dialog_inputbox(WINDOW *main_window, len-cursor_position+1); result[cursor_position] = res; cursor_position++; + cursor_form_win++; + len++; } else { mvprintw(0, 0, "unknown key: %d\n", res); } break; } + if (cursor_form_win < 0) + cursor_form_win = 0; + else if (cursor_form_win > prompt_width-1) + cursor_form_win = prompt_width-1; + wmove(form_win, 0, 0); wclrtoeol(form_win); mvwprintw(form_win, 0, 0, "%*s", prompt_width, " "); - mvwprintw(form_win, 0, 0, "%s", result); - wmove(form_win, 0, cursor_position); + mvwprintw(form_win, 0, 0, "%s", + result + cursor_position-cursor_form_win); + wmove(form_win, 0, cursor_form_win); touchwin(win); refresh_all_windows(main_window); -- cgit v1.2.3 From 93072c3ecafcf188390750cc755185f3150736b9 Mon Sep 17 00:00:00 2001 From: Cheng Renquan Date: Thu, 1 Sep 2011 10:52:22 -0700 Subject: scripts/kconfig/nconf: add KEY_HOME / KEY_END for dialog_inputbox to make it easier to locate begin/end when editing long strings; Signed-off-by: Cheng Renquan Acked By: Nir Tzachar --- scripts/kconfig/nconf.gui.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'scripts') diff --git a/scripts/kconfig/nconf.gui.c b/scripts/kconfig/nconf.gui.c index 4b9d8b66087d..3b18dd839668 100644 --- a/scripts/kconfig/nconf.gui.c +++ b/scripts/kconfig/nconf.gui.c @@ -465,6 +465,14 @@ int dialog_inputbox(WINDOW *main_window, cursor_form_win--; } break; + case KEY_HOME: + cursor_position = 0; + cursor_form_win = 0; + break; + case KEY_END: + cursor_position = len; + cursor_form_win = min(cursor_position, prompt_width-1); + break; default: if ((isgraph(res) || isspace(res))) { /* one for new char, one for '\0' */ -- cgit v1.2.3 From b06fcd6c83c231f51a86448bb33c4cd717fefee8 Mon Sep 17 00:00:00 2001 From: Michal Marek Date: Sat, 8 Oct 2011 00:48:29 +0200 Subject: genksyms: Minor parser cleanup Move the identical logic for recording a struct/union/enum definition to a function. --- scripts/genksyms/parse.y | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) (limited to 'scripts') diff --git a/scripts/genksyms/parse.y b/scripts/genksyms/parse.y index ba5c242866c1..a783ad4e2b51 100644 --- a/scripts/genksyms/parse.y +++ b/scripts/genksyms/parse.y @@ -51,6 +51,18 @@ remove_list(struct string_list **pb, struct string_list **pe) free_list(b, e); } +/* Record definition of a struct/union/enum */ +static void record_compound(struct string_list **keyw, + struct string_list **ident, + struct string_list **body, + enum symbol_type type) +{ + struct string_list *b = *body, *i = *ident, *r; + r = copy_node(i); r->tag = type; + r->next = (*keyw)->next; *body = r; (*keyw)->next = NULL; + add_symbol(i->string, type, b, is_extern); +} + %} %token ASM_KEYW @@ -215,26 +227,11 @@ type_specifier: /* Full definitions of an s/u/e. Record it. */ | STRUCT_KEYW IDENT class_body - { struct string_list *s = *$3, *i = *$2, *r; - r = copy_node(i); r->tag = SYM_STRUCT; - r->next = (*$1)->next; *$3 = r; (*$1)->next = NULL; - add_symbol(i->string, SYM_STRUCT, s, is_extern); - $$ = $3; - } + { record_compound($1, $2, $3, SYM_STRUCT); $$ = $3; } | UNION_KEYW IDENT class_body - { struct string_list *s = *$3, *i = *$2, *r; - r = copy_node(i); r->tag = SYM_UNION; - r->next = (*$1)->next; *$3 = r; (*$1)->next = NULL; - add_symbol(i->string, SYM_UNION, s, is_extern); - $$ = $3; - } + { record_compound($1, $2, $3, SYM_UNION); $$ = $3; } | ENUM_KEYW IDENT enum_body - { struct string_list *s = *$3, *i = *$2, *r; - r = copy_node(i); r->tag = SYM_ENUM; - r->next = (*$1)->next; *$3 = r; (*$1)->next = NULL; - add_symbol(i->string, SYM_ENUM, s, is_extern); - $$ = $3; - } + { record_compound($1, $2, $3, SYM_ENUM); $$ = $3; } /* * Anonymous enum definition. Tell add_symbol() to restart its counter. */ -- cgit v1.2.3 From 2c5925d6b7fedc8f1c325f4f85451f505ec69aca Mon Sep 17 00:00:00 2001 From: Michal Marek Date: Sat, 8 Oct 2011 01:18:35 +0200 Subject: genksyms: Do not expand internal types Consider structures, unions and enums defined in the source file as internal and do not expand them. This way, changes to e.g. struct serial_private in drivers/tty/serial/8250_pci.c will not affect the checksum of the pciserial_* exports. --- scripts/genksyms/genksyms.c | 3 ++- scripts/genksyms/genksyms.h | 4 +++- scripts/genksyms/lex.l | 8 ++++++++ scripts/genksyms/parse.y | 7 +++++++ 4 files changed, 20 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/genksyms/genksyms.c b/scripts/genksyms/genksyms.c index 6d3fda0ce2ae..8a106499ec4f 100644 --- a/scripts/genksyms/genksyms.c +++ b/scripts/genksyms/genksyms.c @@ -40,7 +40,8 @@ static struct symbol *symtab[HASH_BUCKETS]; static FILE *debugfile; int cur_line = 1; -char *cur_filename; +char *cur_filename, *source_file; +int in_source_file; static int flag_debug, flag_dump_defs, flag_reference, flag_dump_types, flag_preserve, flag_warnings; diff --git a/scripts/genksyms/genksyms.h b/scripts/genksyms/genksyms.h index 7ec52ae3846a..3bffdcaaa274 100644 --- a/scripts/genksyms/genksyms.h +++ b/scripts/genksyms/genksyms.h @@ -37,6 +37,7 @@ enum symbol_status { struct string_list { struct string_list *next; enum symbol_type tag; + int in_source_file; char *string; }; @@ -57,7 +58,8 @@ typedef struct string_list **yystype; #define YYSTYPE yystype extern int cur_line; -extern char *cur_filename; +extern char *cur_filename, *source_file; +extern int in_source_file; struct symbol *find_symbol(const char *name, enum symbol_type ns, int exact); struct symbol *add_symbol(const char *name, enum symbol_type type, diff --git a/scripts/genksyms/lex.l b/scripts/genksyms/lex.l index 400ae06a70df..f770071719cb 100644 --- a/scripts/genksyms/lex.l +++ b/scripts/genksyms/lex.l @@ -116,6 +116,7 @@ MC_TOKEN ([~%^&*+=|<>/-]=)|(&&)|("||")|(->)|(<<)|(>>) cur_node->tag = \ find_symbol(cur_node->string, SYM_ENUM_CONST, 1)?\ SYM_ENUM_CONST : SYM_NORMAL ; \ + cur_node->in_source_file = in_source_file; \ } while (0) #define APP _APP(yytext, yyleng) @@ -166,6 +167,13 @@ repeat: cur_filename = memcpy(xmalloc(e-file+1), file, e-file+1); cur_line = atoi(yytext+2); + if (!source_file) { + source_file = xstrdup(cur_filename); + in_source_file = 1; + } else { + in_source_file = (strcmp(cur_filename, source_file) == 0); + } + goto repeat; } diff --git a/scripts/genksyms/parse.y b/scripts/genksyms/parse.y index a783ad4e2b51..23c39998ad86 100644 --- a/scripts/genksyms/parse.y +++ b/scripts/genksyms/parse.y @@ -58,6 +58,13 @@ static void record_compound(struct string_list **keyw, enum symbol_type type) { struct string_list *b = *body, *i = *ident, *r; + + if (i->in_source_file) { + remove_node(keyw); + (*ident)->tag = type; + remove_list(body, ident); + return; + } r = copy_node(i); r->tag = type; r->next = (*keyw)->next; *body = r; (*keyw)->next = NULL; add_symbol(i->string, type, b, is_extern); -- cgit v1.2.3 From 0359de7dd501f694f01b61364c9b633eab41f494 Mon Sep 17 00:00:00 2001 From: Michal Marek Date: Tue, 11 Oct 2011 12:07:05 +0200 Subject: genksyms: Regenerate lexer and parser --- scripts/genksyms/lex.lex.c_shipped | 12 +- scripts/genksyms/parse.tab.c_shipped | 645 +++++++++++++++++++---------------- scripts/genksyms/parse.tab.h_shipped | 7 +- 3 files changed, 358 insertions(+), 306 deletions(-) (limited to 'scripts') diff --git a/scripts/genksyms/lex.lex.c_shipped b/scripts/genksyms/lex.lex.c_shipped index c83cf60410be..0bf4157e6161 100644 --- a/scripts/genksyms/lex.lex.c_shipped +++ b/scripts/genksyms/lex.lex.c_shipped @@ -660,7 +660,7 @@ static int input (void ); /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ -#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0) +#define ECHO fwrite( yytext, yyleng, 1, yyout ) #endif /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, @@ -671,7 +671,7 @@ static int input (void ); if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ - unsigned n; \ + int n; \ for ( n = 0; n < max_size && \ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ @@ -1926,6 +1926,7 @@ void yyfree (void * ptr ) cur_node->tag = \ find_symbol(cur_node->string, SYM_ENUM_CONST, 1)?\ SYM_ENUM_CONST : SYM_NORMAL ; \ + cur_node->in_source_file = in_source_file; \ } while (0) #define APP _APP(yytext, yyleng) @@ -1975,6 +1976,13 @@ repeat: cur_filename = memcpy(xmalloc(e-file+1), file, e-file+1); cur_line = atoi(yytext+2); + if (!source_file) { + source_file = xstrdup(cur_filename); + in_source_file = 1; + } else { + in_source_file = (strcmp(cur_filename, source_file) == 0); + } + goto repeat; } diff --git a/scripts/genksyms/parse.tab.c_shipped b/scripts/genksyms/parse.tab.c_shipped index 61d4a5d09856..ece53c79bb59 100644 --- a/scripts/genksyms/parse.tab.c_shipped +++ b/scripts/genksyms/parse.tab.c_shipped @@ -1,9 +1,8 @@ -/* A Bison parser, made by GNU Bison 2.4.3. */ +/* A Bison parser, made by GNU Bison 2.5. */ -/* Skeleton implementation for Bison's Yacc-like parsers in C +/* Bison implementation for Yacc-like parsers in C - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -45,7 +44,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.4.3" +#define YYBISON_VERSION "2.5" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -96,6 +95,25 @@ remove_list(struct string_list **pb, struct string_list **pe) free_list(b, e); } +/* Record definition of a struct/union/enum */ +static void record_compound(struct string_list **keyw, + struct string_list **ident, + struct string_list **body, + enum symbol_type type) +{ + struct string_list *b = *body, *i = *ident, *r; + + if (i->in_source_file) { + remove_node(keyw); + (*ident)->tag = type; + remove_list(body, ident); + return; + } + r = copy_node(i); r->tag = type; + r->next = (*keyw)->next; *body = r; (*keyw)->next = NULL; + add_symbol(i->string, type, b, is_extern); +} + @@ -283,11 +301,11 @@ YYID (yyi) # define alloca _alloca # else # define YYSTACK_ALLOC alloca -# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ +# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) # include /* INFRINGES ON USER NAME SPACE */ -# ifndef _STDLIB_H -# define _STDLIB_H 1 +# ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 # endif # endif # endif @@ -310,24 +328,24 @@ YYID (yyi) # ifndef YYSTACK_ALLOC_MAXIMUM # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM # endif -# if (defined __cplusplus && ! defined _STDLIB_H \ +# if (defined __cplusplus && ! defined EXIT_SUCCESS \ && ! ((defined YYMALLOC || defined malloc) \ && (defined YYFREE || defined free))) # include /* INFRINGES ON USER NAME SPACE */ -# ifndef _STDLIB_H -# define _STDLIB_H 1 +# ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 # endif # endif # ifndef YYMALLOC # define YYMALLOC malloc -# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ +# if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ # endif # endif # ifndef YYFREE # define YYFREE free -# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ +# if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \ || defined __cplusplus || defined _MSC_VER) void free (void *); /* INFRINGES ON USER NAME SPACE */ # endif @@ -356,23 +374,7 @@ union yyalloc ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + YYSTACK_GAP_MAXIMUM) -/* Copy COUNT objects from FROM to TO. The source and destination do - not overlap. */ -# ifndef YYCOPY -# if defined __GNUC__ && 1 < __GNUC__ -# define YYCOPY(To, From, Count) \ - __builtin_memcpy (To, From, (Count) * sizeof (*(From))) -# else -# define YYCOPY(To, From, Count) \ - do \ - { \ - YYSIZE_T yyi; \ - for (yyi = 0; yyi < (Count); yyi++) \ - (To)[yyi] = (From)[yyi]; \ - } \ - while (YYID (0)) -# endif -# endif +# define YYCOPY_NEEDED 1 /* Relocate STACK from its old location to the new one. The local variables YYSIZE and YYSTACKSIZE give the old and new number of @@ -392,6 +394,26 @@ union yyalloc #endif +#if defined YYCOPY_NEEDED && YYCOPY_NEEDED +/* Copy COUNT objects from FROM to TO. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(To, From, Count) \ + __builtin_memcpy (To, From, (Count) * sizeof (*(From))) +# else +# define YYCOPY(To, From, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (To)[yyi] = (From)[yyi]; \ + } \ + while (YYID (0)) +# endif +# endif +#endif /* !YYCOPY_NEEDED */ + /* YYFINAL -- State number of the termination state. */ #define YYFINAL 4 /* YYLAST -- Last index in YYTABLE. */ @@ -514,20 +536,20 @@ static const yytype_int8 yyrhs[] = /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 104, 104, 105, 109, 109, 115, 115, 117, 117, - 119, 120, 121, 122, 123, 124, 128, 142, 143, 147, - 155, 168, 174, 175, 179, 180, 184, 190, 194, 195, - 196, 197, 198, 202, 203, 204, 205, 209, 211, 213, - 217, 224, 231, 241, 244, 245, 249, 250, 251, 252, - 253, 254, 255, 256, 257, 258, 259, 263, 268, 269, - 273, 274, 278, 278, 278, 279, 287, 288, 292, 301, - 303, 305, 307, 309, 316, 317, 321, 322, 323, 325, - 327, 329, 331, 336, 337, 338, 342, 343, 347, 348, - 353, 358, 360, 364, 365, 373, 377, 379, 381, 383, - 385, 390, 399, 400, 405, 410, 411, 415, 416, 420, - 421, 425, 427, 432, 433, 437, 438, 442, 443, 444, - 448, 452, 453, 457, 458, 462, 463, 466, 471, 479, - 483, 484, 488 + 0, 123, 123, 124, 128, 128, 134, 134, 136, 136, + 138, 139, 140, 141, 142, 143, 147, 161, 162, 166, + 174, 187, 193, 194, 198, 199, 203, 209, 213, 214, + 215, 216, 217, 221, 222, 223, 224, 228, 230, 232, + 236, 238, 240, 245, 248, 249, 253, 254, 255, 256, + 257, 258, 259, 260, 261, 262, 263, 267, 272, 273, + 277, 278, 282, 282, 282, 283, 291, 292, 296, 305, + 307, 309, 311, 313, 320, 321, 325, 326, 327, 329, + 331, 333, 335, 340, 341, 342, 346, 347, 351, 352, + 357, 362, 364, 368, 369, 377, 381, 383, 385, 387, + 389, 394, 403, 404, 409, 414, 415, 419, 420, 424, + 425, 429, 431, 436, 437, 441, 442, 446, 447, 448, + 452, 456, 457, 461, 462, 466, 467, 470, 475, 483, + 487, 488, 492 }; #endif @@ -618,8 +640,8 @@ static const yytype_uint8 yyr2[] = 0, 1, 5 }; -/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state - STATE-NUM when YYTABLE doesn't specify something else to do. Zero +/* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM. + Performed when YYTABLE doesn't specify something else to do. Zero means the default is an error. */ static const yytype_uint8 yydefact[] = { @@ -692,8 +714,7 @@ static const yytype_int16 yypgoto[] = /* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule which - number is the opposite. If zero, do what YYDEFACT says. - If YYTABLE_NINF, syntax error. */ + number is the opposite. If YYTABLE_NINF, syntax error. */ #define YYTABLE_NINF -109 static const yytype_int16 yytable[] = { @@ -753,6 +774,12 @@ static const yytype_int16 yytable[] = 0, 0, 34 }; +#define yypact_value_is_default(yystate) \ + ((yystate) == (-135)) + +#define yytable_value_is_error(yytable_value) \ + YYID (0) + static const yytype_int16 yycheck[] = { 59, 38, 79, 3, 1, 8, 56, 37, 26, 37, @@ -869,7 +896,6 @@ do \ { \ yychar = (Token); \ yylval = (Value); \ - yytoken = YYTRANSLATE (yychar); \ YYPOPSTACK (1); \ goto yybackup; \ } \ @@ -911,19 +937,10 @@ while (YYID (0)) #endif -/* YY_LOCATION_PRINT -- Print the location on the stream. - This macro was not mandated originally: define only if we know - we won't break user code: when these are the locations we know. */ +/* This macro is provided for backward compatibility. */ #ifndef YY_LOCATION_PRINT -# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL -# define YY_LOCATION_PRINT(File, Loc) \ - fprintf (File, "%d.%d-%d.%d", \ - (Loc).first_line, (Loc).first_column, \ - (Loc).last_line, (Loc).last_column) -# else -# define YY_LOCATION_PRINT(File, Loc) ((void) 0) -# endif +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) #endif @@ -1115,7 +1132,6 @@ int yydebug; # define YYMAXDEPTH 10000 #endif - #if YYERROR_VERBOSE @@ -1218,115 +1234,142 @@ yytnamerr (char *yyres, const char *yystr) } # endif -/* Copy into YYRESULT an error message about the unexpected token - YYCHAR while in state YYSTATE. Return the number of bytes copied, - including the terminating null byte. If YYRESULT is null, do not - copy anything; just return the number of bytes that would be - copied. As a special case, return 0 if an ordinary "syntax error" - message will do. Return YYSIZE_MAXIMUM if overflow occurs during - size calculation. */ -static YYSIZE_T -yysyntax_error (char *yyresult, int yystate, int yychar) -{ - int yyn = yypact[yystate]; +/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message + about the unexpected token YYTOKEN for the state stack whose top is + YYSSP. - if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) - return 0; - else + Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is + not large enough to hold the message. In that case, also set + *YYMSG_ALLOC to the required number of bytes. Return 2 if the + required number of bytes is too large to store. */ +static int +yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, + yytype_int16 *yyssp, int yytoken) +{ + YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]); + YYSIZE_T yysize = yysize0; + YYSIZE_T yysize1; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + /* Internationalized format string. */ + const char *yyformat = 0; + /* Arguments of yyformat. */ + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + /* Number of reported tokens (one for the "unexpected", one per + "expected"). */ + int yycount = 0; + + /* There are many possibilities here to consider: + - Assume YYFAIL is not used. It's too flawed to consider. See + + for details. YYERROR is fine as it does not invoke this + function. + - If this state is a consistent state with a default action, then + the only way this function was invoked is if the default action + is an error action. In that case, don't check for expected + tokens because there are none. + - The only way there can be no lookahead present (in yychar) is if + this state is a consistent state with a default action. Thus, + detecting the absence of a lookahead is sufficient to determine + that there is no unexpected or expected token to report. In that + case, just report a simple "syntax error". + - Don't assume there isn't a lookahead just because this state is a + consistent state with a default action. There might have been a + previous inconsistent state, consistent state with a non-default + action, or user semantic action that manipulated yychar. + - Of course, the expected token list depends on states to have + correct lookahead information, and it depends on the parser not + to perform extra reductions after fetching a lookahead from the + scanner and before detecting a syntax error. Thus, state merging + (from LALR or IELR) and default reductions corrupt the expected + token list. However, the list is correct for canonical LR with + one exception: it will still contain any token that will not be + accepted due to an error action in a later state. + */ + if (yytoken != YYEMPTY) { - int yytype = YYTRANSLATE (yychar); - YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); - YYSIZE_T yysize = yysize0; - YYSIZE_T yysize1; - int yysize_overflow = 0; - enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; - char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; - int yyx; - -# if 0 - /* This is so xgettext sees the translatable formats that are - constructed on the fly. */ - YY_("syntax error, unexpected %s"); - YY_("syntax error, unexpected %s, expecting %s"); - YY_("syntax error, unexpected %s, expecting %s or %s"); - YY_("syntax error, unexpected %s, expecting %s or %s or %s"); - YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); -# endif - char *yyfmt; - char const *yyf; - static char const yyunexpected[] = "syntax error, unexpected %s"; - static char const yyexpecting[] = ", expecting %s"; - static char const yyor[] = " or %s"; - char yyformat[sizeof yyunexpected - + sizeof yyexpecting - 1 - + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) - * (sizeof yyor - 1))]; - char const *yyprefix = yyexpecting; - - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. */ - int yyxbegin = yyn < 0 ? -yyn : 0; - - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = YYLAST - yyn + 1; - int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; - int yycount = 1; - - yyarg[0] = yytname[yytype]; - yyfmt = yystpcpy (yyformat, yyunexpected); - - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) - { - if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) - { - yycount = 1; - yysize = yysize0; - yyformat[sizeof yyunexpected - 1] = '\0'; - break; - } - yyarg[yycount++] = yytname[yyx]; - yysize1 = yysize + yytnamerr (0, yytname[yyx]); - yysize_overflow |= (yysize1 < yysize); - yysize = yysize1; - yyfmt = yystpcpy (yyfmt, yyprefix); - yyprefix = yyor; - } + int yyn = yypact[*yyssp]; + yyarg[yycount++] = yytname[yytoken]; + if (!yypact_value_is_default (yyn)) + { + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. In other words, skip the first -YYN actions for + this state because they are default actions. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yyx; + + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR + && !yytable_value_is_error (yytable[yyx + yyn])) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + break; + } + yyarg[yycount++] = yytname[yyx]; + yysize1 = yysize + yytnamerr (0, yytname[yyx]); + if (! (yysize <= yysize1 + && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; + } + } + } - yyf = YY_(yyformat); - yysize1 = yysize + yystrlen (yyf); - yysize_overflow |= (yysize1 < yysize); - yysize = yysize1; + switch (yycount) + { +# define YYCASE_(N, S) \ + case N: \ + yyformat = S; \ + break + YYCASE_(0, YY_("syntax error")); + YYCASE_(1, YY_("syntax error, unexpected %s")); + YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); + YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); + YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); + YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); +# undef YYCASE_ + } - if (yysize_overflow) - return YYSIZE_MAXIMUM; + yysize1 = yysize + yystrlen (yyformat); + if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; - if (yyresult) - { - /* Avoid sprintf, as that infringes on the user's name space. - Don't have undefined behavior even if the translation - produced a string with the wrong number of "%s"s. */ - char *yyp = yyresult; - int yyi = 0; - while ((*yyp = *yyf) != '\0') - { - if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) - { - yyp += yytnamerr (yyp, yyarg[yyi++]); - yyf += 2; - } - else - { - yyp++; - yyf++; - } - } - } - return yysize; + if (*yymsg_alloc < yysize) + { + *yymsg_alloc = 2 * yysize; + if (! (yysize <= *yymsg_alloc + && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) + *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; + return 1; } + + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + { + char *yyp = *yymsg; + int yyi = 0; + while ((*yyp = *yyformat) != '\0') + if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyformat += 2; + } + else + { + yyp++; + yyformat++; + } + } + return 0; } #endif /* YYERROR_VERBOSE */ - /*-----------------------------------------------. | Release the memory associated to this symbol. | @@ -1359,6 +1402,7 @@ yydestruct (yymsg, yytype, yyvaluep) } } + /* Prevent warnings from -Wmissing-prototypes. */ #ifdef YYPARSE_PARAM #if defined __STDC__ || defined __cplusplus @@ -1385,10 +1429,9 @@ YYSTYPE yylval; int yynerrs; - -/*-------------------------. -| yyparse or yypush_parse. | -`-------------------------*/ +/*----------. +| yyparse. | +`----------*/ #ifdef YYPARSE_PARAM #if (defined __STDC__ || defined __C99__FUNC__ \ @@ -1412,8 +1455,6 @@ yyparse () #endif #endif { - - int yystate; /* Number of tokens to shift before error messages enabled. */ int yyerrstatus; @@ -1568,7 +1609,7 @@ yybackup: /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; - if (yyn == YYPACT_NINF) + if (yypact_value_is_default (yyn)) goto yydefault; /* Not known => get a lookahead token if don't already have one. */ @@ -1599,8 +1640,8 @@ yybackup: yyn = yytable[yyn]; if (yyn <= 0) { - if (yyn == 0 || yyn == YYTABLE_NINF) - goto yyerrlab; + if (yytable_value_is_error (yyn)) + goto yyerrlab; yyn = -yyn; goto yyreduce; } @@ -1655,42 +1696,42 @@ yyreduce: { case 4: - { is_typedef = 0; is_extern = 0; current_name = NULL; decl_spec = NULL; ;} + { is_typedef = 0; is_extern = 0; current_name = NULL; decl_spec = NULL; } break; case 5: - { free_list(*(yyvsp[(2) - (2)]), NULL); *(yyvsp[(2) - (2)]) = NULL; ;} + { free_list(*(yyvsp[(2) - (2)]), NULL); *(yyvsp[(2) - (2)]) = NULL; } break; case 6: - { is_typedef = 1; ;} + { is_typedef = 1; } break; case 7: - { (yyval) = (yyvsp[(4) - (4)]); ;} + { (yyval) = (yyvsp[(4) - (4)]); } break; case 8: - { is_typedef = 1; ;} + { is_typedef = 1; } break; case 9: - { (yyval) = (yyvsp[(3) - (3)]); ;} + { (yyval) = (yyvsp[(3) - (3)]); } break; case 14: - { (yyval) = (yyvsp[(2) - (2)]); ;} + { (yyval) = (yyvsp[(2) - (2)]); } break; case 15: - { (yyval) = (yyvsp[(2) - (2)]); ;} + { (yyval) = (yyvsp[(2) - (2)]); } break; case 16: @@ -1704,12 +1745,12 @@ yyreduce: current_name = NULL; } (yyval) = (yyvsp[(3) - (3)]); - ;} + } break; case 17: - { (yyval) = NULL; ;} + { (yyval) = NULL; } break; case 19: @@ -1720,7 +1761,7 @@ yyreduce: is_typedef ? SYM_TYPEDEF : SYM_NORMAL, decl, is_extern); current_name = NULL; (yyval) = (yyvsp[(1) - (1)]); - ;} + } break; case 20: @@ -1733,27 +1774,27 @@ yyreduce: is_typedef ? SYM_TYPEDEF : SYM_NORMAL, decl, is_extern); current_name = NULL; (yyval) = (yyvsp[(3) - (3)]); - ;} + } break; case 21: - { (yyval) = (yyvsp[(4) - (4)]) ? (yyvsp[(4) - (4)]) : (yyvsp[(3) - (4)]) ? (yyvsp[(3) - (4)]) : (yyvsp[(2) - (4)]) ? (yyvsp[(2) - (4)]) : (yyvsp[(1) - (4)]); ;} + { (yyval) = (yyvsp[(4) - (4)]) ? (yyvsp[(4) - (4)]) : (yyvsp[(3) - (4)]) ? (yyvsp[(3) - (4)]) : (yyvsp[(2) - (4)]) ? (yyvsp[(2) - (4)]) : (yyvsp[(1) - (4)]); } break; case 22: - { decl_spec = NULL; ;} + { decl_spec = NULL; } break; case 24: - { decl_spec = *(yyvsp[(1) - (1)]); ;} + { decl_spec = *(yyvsp[(1) - (1)]); } break; case 25: - { decl_spec = *(yyvsp[(2) - (2)]); ;} + { decl_spec = *(yyvsp[(2) - (2)]); } break; case 26: @@ -1762,97 +1803,82 @@ yyreduce: is really irrelevant to the linkage. */ remove_node((yyvsp[(1) - (1)])); (yyval) = (yyvsp[(1) - (1)]); - ;} + } break; case 31: - { is_extern = 1; (yyval) = (yyvsp[(1) - (1)]); ;} + { is_extern = 1; (yyval) = (yyvsp[(1) - (1)]); } break; case 32: - { is_extern = 0; (yyval) = (yyvsp[(1) - (1)]); ;} + { is_extern = 0; (yyval) = (yyvsp[(1) - (1)]); } break; case 37: - { remove_node((yyvsp[(1) - (2)])); (*(yyvsp[(2) - (2)]))->tag = SYM_STRUCT; (yyval) = (yyvsp[(2) - (2)]); ;} + { remove_node((yyvsp[(1) - (2)])); (*(yyvsp[(2) - (2)]))->tag = SYM_STRUCT; (yyval) = (yyvsp[(2) - (2)]); } break; case 38: - { remove_node((yyvsp[(1) - (2)])); (*(yyvsp[(2) - (2)]))->tag = SYM_UNION; (yyval) = (yyvsp[(2) - (2)]); ;} + { remove_node((yyvsp[(1) - (2)])); (*(yyvsp[(2) - (2)]))->tag = SYM_UNION; (yyval) = (yyvsp[(2) - (2)]); } break; case 39: - { remove_node((yyvsp[(1) - (2)])); (*(yyvsp[(2) - (2)]))->tag = SYM_ENUM; (yyval) = (yyvsp[(2) - (2)]); ;} + { remove_node((yyvsp[(1) - (2)])); (*(yyvsp[(2) - (2)]))->tag = SYM_ENUM; (yyval) = (yyvsp[(2) - (2)]); } break; case 40: - { struct string_list *s = *(yyvsp[(3) - (3)]), *i = *(yyvsp[(2) - (3)]), *r; - r = copy_node(i); r->tag = SYM_STRUCT; - r->next = (*(yyvsp[(1) - (3)]))->next; *(yyvsp[(3) - (3)]) = r; (*(yyvsp[(1) - (3)]))->next = NULL; - add_symbol(i->string, SYM_STRUCT, s, is_extern); - (yyval) = (yyvsp[(3) - (3)]); - ;} + { record_compound((yyvsp[(1) - (3)]), (yyvsp[(2) - (3)]), (yyvsp[(3) - (3)]), SYM_STRUCT); (yyval) = (yyvsp[(3) - (3)]); } break; case 41: - { struct string_list *s = *(yyvsp[(3) - (3)]), *i = *(yyvsp[(2) - (3)]), *r; - r = copy_node(i); r->tag = SYM_UNION; - r->next = (*(yyvsp[(1) - (3)]))->next; *(yyvsp[(3) - (3)]) = r; (*(yyvsp[(1) - (3)]))->next = NULL; - add_symbol(i->string, SYM_UNION, s, is_extern); - (yyval) = (yyvsp[(3) - (3)]); - ;} + { record_compound((yyvsp[(1) - (3)]), (yyvsp[(2) - (3)]), (yyvsp[(3) - (3)]), SYM_UNION); (yyval) = (yyvsp[(3) - (3)]); } break; case 42: - { struct string_list *s = *(yyvsp[(3) - (3)]), *i = *(yyvsp[(2) - (3)]), *r; - r = copy_node(i); r->tag = SYM_ENUM; - r->next = (*(yyvsp[(1) - (3)]))->next; *(yyvsp[(3) - (3)]) = r; (*(yyvsp[(1) - (3)]))->next = NULL; - add_symbol(i->string, SYM_ENUM, s, is_extern); - (yyval) = (yyvsp[(3) - (3)]); - ;} + { record_compound((yyvsp[(1) - (3)]), (yyvsp[(2) - (3)]), (yyvsp[(3) - (3)]), SYM_ENUM); (yyval) = (yyvsp[(3) - (3)]); } break; case 43: - { add_symbol(NULL, SYM_ENUM, NULL, 0); (yyval) = (yyvsp[(2) - (2)]); ;} + { add_symbol(NULL, SYM_ENUM, NULL, 0); (yyval) = (yyvsp[(2) - (2)]); } break; case 44: - { (yyval) = (yyvsp[(2) - (2)]); ;} + { (yyval) = (yyvsp[(2) - (2)]); } break; case 45: - { (yyval) = (yyvsp[(2) - (2)]); ;} + { (yyval) = (yyvsp[(2) - (2)]); } break; case 56: - { (*(yyvsp[(1) - (1)]))->tag = SYM_TYPEDEF; (yyval) = (yyvsp[(1) - (1)]); ;} + { (*(yyvsp[(1) - (1)]))->tag = SYM_TYPEDEF; (yyval) = (yyvsp[(1) - (1)]); } break; case 57: - { (yyval) = (yyvsp[(2) - (2)]) ? (yyvsp[(2) - (2)]) : (yyvsp[(1) - (2)]); ;} + { (yyval) = (yyvsp[(2) - (2)]) ? (yyvsp[(2) - (2)]) : (yyvsp[(1) - (2)]); } break; case 58: - { (yyval) = NULL; ;} + { (yyval) = NULL; } break; case 61: - { (yyval) = (yyvsp[(2) - (2)]); ;} + { (yyval) = (yyvsp[(2) - (2)]); } break; case 65: @@ -1860,12 +1886,12 @@ yyreduce: { /* restrict has no effect in prototypes so ignore it */ remove_node((yyvsp[(1) - (1)])); (yyval) = (yyvsp[(1) - (1)]); - ;} + } break; case 66: - { (yyval) = (yyvsp[(2) - (2)]); ;} + { (yyval) = (yyvsp[(2) - (2)]); } break; case 68: @@ -1877,97 +1903,97 @@ yyreduce: current_name = (*(yyvsp[(1) - (1)]))->string; (yyval) = (yyvsp[(1) - (1)]); } - ;} + } break; case 69: - { (yyval) = (yyvsp[(4) - (4)]); ;} + { (yyval) = (yyvsp[(4) - (4)]); } break; case 70: - { (yyval) = (yyvsp[(4) - (4)]); ;} + { (yyval) = (yyvsp[(4) - (4)]); } break; case 71: - { (yyval) = (yyvsp[(2) - (2)]); ;} + { (yyval) = (yyvsp[(2) - (2)]); } break; case 72: - { (yyval) = (yyvsp[(3) - (3)]); ;} + { (yyval) = (yyvsp[(3) - (3)]); } break; case 73: - { (yyval) = (yyvsp[(3) - (3)]); ;} + { (yyval) = (yyvsp[(3) - (3)]); } break; case 74: - { (yyval) = (yyvsp[(2) - (2)]); ;} + { (yyval) = (yyvsp[(2) - (2)]); } break; case 78: - { (yyval) = (yyvsp[(4) - (4)]); ;} + { (yyval) = (yyvsp[(4) - (4)]); } break; case 79: - { (yyval) = (yyvsp[(4) - (4)]); ;} + { (yyval) = (yyvsp[(4) - (4)]); } break; case 80: - { (yyval) = (yyvsp[(2) - (2)]); ;} + { (yyval) = (yyvsp[(2) - (2)]); } break; case 81: - { (yyval) = (yyvsp[(3) - (3)]); ;} + { (yyval) = (yyvsp[(3) - (3)]); } break; case 82: - { (yyval) = (yyvsp[(3) - (3)]); ;} + { (yyval) = (yyvsp[(3) - (3)]); } break; case 83: - { (yyval) = (yyvsp[(2) - (2)]); ;} + { (yyval) = (yyvsp[(2) - (2)]); } break; case 85: - { (yyval) = (yyvsp[(3) - (3)]); ;} + { (yyval) = (yyvsp[(3) - (3)]); } break; case 86: - { (yyval) = NULL; ;} + { (yyval) = NULL; } break; case 89: - { (yyval) = (yyvsp[(3) - (3)]); ;} + { (yyval) = (yyvsp[(3) - (3)]); } break; case 90: - { (yyval) = (yyvsp[(2) - (2)]) ? (yyvsp[(2) - (2)]) : (yyvsp[(1) - (2)]); ;} + { (yyval) = (yyvsp[(2) - (2)]) ? (yyvsp[(2) - (2)]) : (yyvsp[(1) - (2)]); } break; case 91: - { (yyval) = (yyvsp[(2) - (2)]) ? (yyvsp[(2) - (2)]) : (yyvsp[(1) - (2)]); ;} + { (yyval) = (yyvsp[(2) - (2)]) ? (yyvsp[(2) - (2)]) : (yyvsp[(1) - (2)]); } break; case 93: - { (yyval) = NULL; ;} + { (yyval) = NULL; } break; case 94: @@ -1976,39 +2002,39 @@ yyreduce: private parameter names. */ remove_node((yyvsp[(1) - (1)])); (yyval) = (yyvsp[(1) - (1)]); - ;} + } break; case 95: { remove_node((yyvsp[(1) - (1)])); (yyval) = (yyvsp[(1) - (1)]); - ;} + } break; case 96: - { (yyval) = (yyvsp[(4) - (4)]); ;} + { (yyval) = (yyvsp[(4) - (4)]); } break; case 97: - { (yyval) = (yyvsp[(4) - (4)]); ;} + { (yyval) = (yyvsp[(4) - (4)]); } break; case 98: - { (yyval) = (yyvsp[(2) - (2)]); ;} + { (yyval) = (yyvsp[(2) - (2)]); } break; case 99: - { (yyval) = (yyvsp[(3) - (3)]); ;} + { (yyval) = (yyvsp[(3) - (3)]); } break; case 100: - { (yyval) = (yyvsp[(3) - (3)]); ;} + { (yyval) = (yyvsp[(3) - (3)]); } break; case 101: @@ -2017,87 +2043,87 @@ yyreduce: *(yyvsp[(2) - (3)]) = NULL; add_symbol(current_name, SYM_NORMAL, decl, is_extern); (yyval) = (yyvsp[(3) - (3)]); - ;} + } break; case 102: - { (yyval) = NULL; ;} + { (yyval) = NULL; } break; case 104: - { remove_list((yyvsp[(2) - (2)]), &(*(yyvsp[(1) - (2)]))->next); (yyval) = (yyvsp[(2) - (2)]); ;} + { remove_list((yyvsp[(2) - (2)]), &(*(yyvsp[(1) - (2)]))->next); (yyval) = (yyvsp[(2) - (2)]); } break; case 105: - { (yyval) = (yyvsp[(3) - (3)]); ;} + { (yyval) = (yyvsp[(3) - (3)]); } break; case 106: - { (yyval) = (yyvsp[(3) - (3)]); ;} + { (yyval) = (yyvsp[(3) - (3)]); } break; case 107: - { (yyval) = NULL; ;} + { (yyval) = NULL; } break; case 110: - { (yyval) = (yyvsp[(2) - (2)]); ;} + { (yyval) = (yyvsp[(2) - (2)]); } break; case 111: - { (yyval) = (yyvsp[(3) - (3)]); ;} + { (yyval) = (yyvsp[(3) - (3)]); } break; case 112: - { (yyval) = (yyvsp[(2) - (2)]); ;} + { (yyval) = (yyvsp[(2) - (2)]); } break; case 113: - { (yyval) = NULL; ;} + { (yyval) = NULL; } break; case 116: - { (yyval) = (yyvsp[(3) - (3)]); ;} + { (yyval) = (yyvsp[(3) - (3)]); } break; case 117: - { (yyval) = (yyvsp[(2) - (2)]) ? (yyvsp[(2) - (2)]) : (yyvsp[(1) - (2)]); ;} + { (yyval) = (yyvsp[(2) - (2)]) ? (yyvsp[(2) - (2)]) : (yyvsp[(1) - (2)]); } break; case 118: - { (yyval) = (yyvsp[(2) - (2)]); ;} + { (yyval) = (yyvsp[(2) - (2)]); } break; case 120: - { (yyval) = (yyvsp[(2) - (2)]); ;} + { (yyval) = (yyvsp[(2) - (2)]); } break; case 121: - { (yyval) = NULL; ;} + { (yyval) = NULL; } break; case 123: - { (yyval) = (yyvsp[(3) - (3)]); ;} + { (yyval) = (yyvsp[(3) - (3)]); } break; case 124: - { (yyval) = (yyvsp[(4) - (4)]); ;} + { (yyval) = (yyvsp[(4) - (4)]); } break; case 127: @@ -2105,7 +2131,7 @@ yyreduce: { const char *name = strdup((*(yyvsp[(1) - (1)]))->string); add_symbol(name, SYM_ENUM_CONST, NULL, 0); - ;} + } break; case 128: @@ -2114,28 +2140,39 @@ yyreduce: const char *name = strdup((*(yyvsp[(1) - (3)]))->string); struct string_list *expr = copy_list_range(*(yyvsp[(3) - (3)]), *(yyvsp[(2) - (3)])); add_symbol(name, SYM_ENUM_CONST, expr, 0); - ;} + } break; case 129: - { (yyval) = (yyvsp[(2) - (2)]); ;} + { (yyval) = (yyvsp[(2) - (2)]); } break; case 130: - { (yyval) = NULL; ;} + { (yyval) = NULL; } break; case 132: - { export_symbol((*(yyvsp[(3) - (5)]))->string); (yyval) = (yyvsp[(5) - (5)]); ;} + { export_symbol((*(yyvsp[(3) - (5)]))->string); (yyval) = (yyvsp[(5) - (5)]); } break; default: break; } + /* User semantic actions sometimes alter yychar, and that requires + that yytoken be updated with the new translation. We take the + approach of translating immediately before every use of yytoken. + One alternative is translating here after every semantic action, + but that translation would be missed if the semantic action invokes + YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or + if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an + incorrect destructor might then be invoked immediately. In the + case of YYERROR or YYBACKUP, subsequent parser actions might lead + to an incorrect destructor call or verbose syntax error message + before the lookahead is translated. */ YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); YYPOPSTACK (yylen); @@ -2163,6 +2200,10 @@ yyreduce: | yyerrlab -- here on detecting error | `------------------------------------*/ yyerrlab: + /* Make sure we have latest lookahead translation. See comments at + user semantic actions for why this is necessary. */ + yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); + /* If not already recovering from an error, report this error. */ if (!yyerrstatus) { @@ -2170,37 +2211,36 @@ yyerrlab: #if ! YYERROR_VERBOSE yyerror (YY_("syntax error")); #else +# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ + yyssp, yytoken) { - YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); - if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) - { - YYSIZE_T yyalloc = 2 * yysize; - if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) - yyalloc = YYSTACK_ALLOC_MAXIMUM; - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); - yymsg = (char *) YYSTACK_ALLOC (yyalloc); - if (yymsg) - yymsg_alloc = yyalloc; - else - { - yymsg = yymsgbuf; - yymsg_alloc = sizeof yymsgbuf; - } - } - - if (0 < yysize && yysize <= yymsg_alloc) - { - (void) yysyntax_error (yymsg, yystate, yychar); - yyerror (yymsg); - } - else - { - yyerror (YY_("syntax error")); - if (yysize != 0) - goto yyexhaustedlab; - } + char const *yymsgp = YY_("syntax error"); + int yysyntax_error_status; + yysyntax_error_status = YYSYNTAX_ERROR; + if (yysyntax_error_status == 0) + yymsgp = yymsg; + else if (yysyntax_error_status == 1) + { + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); + if (!yymsg) + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + yysyntax_error_status = 2; + } + else + { + yysyntax_error_status = YYSYNTAX_ERROR; + yymsgp = yymsg; + } + } + yyerror (yymsgp); + if (yysyntax_error_status == 2) + goto yyexhaustedlab; } +# undef YYSYNTAX_ERROR #endif } @@ -2259,7 +2299,7 @@ yyerrlab1: for (;;) { yyn = yypact[yystate]; - if (yyn != YYPACT_NINF) + if (!yypact_value_is_default (yyn)) { yyn += YYTERROR; if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) @@ -2318,8 +2358,13 @@ yyexhaustedlab: yyreturn: if (yychar != YYEMPTY) - yydestruct ("Cleanup: discarding lookahead", - yytoken, &yylval); + { + /* Make sure we have latest lookahead translation. See comments at + user semantic actions for why this is necessary. */ + yytoken = YYTRANSLATE (yychar); + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval); + } /* Do not reclaim the symbols of the rule which action triggered this YYABORT or YYACCEPT. */ YYPOPSTACK (yylen); diff --git a/scripts/genksyms/parse.tab.h_shipped b/scripts/genksyms/parse.tab.h_shipped index 350c2b403e21..93240a3cdecc 100644 --- a/scripts/genksyms/parse.tab.h_shipped +++ b/scripts/genksyms/parse.tab.h_shipped @@ -1,9 +1,8 @@ -/* A Bison parser, made by GNU Bison 2.4.3. */ +/* A Bison parser, made by GNU Bison 2.5. */ -/* Skeleton interface for Bison's Yacc-like parsers in C +/* Bison interface for Yacc-like parsers in C - Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006, - 2009, 2010 Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by -- cgit v1.2.3 From 67d0a0754455f89ef3946946159d8ec9e45ce33a Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Mon, 31 Oct 2011 17:13:10 -0700 Subject: kernel.h/checkpatch: mark strict_strto and simple_strto as obsolete Mark obsolete/deprecated strict_strto and simple_strto functions and macros as obsolete. Update checkpatch to warn about their use. Signed-off-by: Joe Perches Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- include/linux/kernel.h | 4 ++++ scripts/checkpatch.pl | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) (limited to 'scripts') diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 4824f26a0dc2..4c0d3b2fd5fc 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -287,6 +287,8 @@ static inline int __must_check kstrtos32_from_user(const char __user *s, size_t return kstrtoint_from_user(s, count, base, res); } +/* Obsolete, do not use. Use kstrto instead */ + extern unsigned long simple_strtoul(const char *,char **,unsigned int); extern long simple_strtol(const char *,char **,unsigned int); extern unsigned long long simple_strtoull(const char *,char **,unsigned int); @@ -296,6 +298,8 @@ extern long long simple_strtoll(const char *,char **,unsigned int); #define strict_strtoull kstrtoull #define strict_strtoll kstrtoll +/* lib/printf utilities */ + extern __printf(2, 3) int sprintf(char *buf, const char * fmt, ...); extern __printf(2, 0) int vsprintf(char *buf, const char *, va_list); extern __printf(3, 4) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 0b3e35c9ef08..5ba679c8cde6 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -3151,10 +3151,10 @@ sub process { "consider using a completion\n" . $herecurr); } -# recommend kstrto* over simple_strto* - if ($line =~ /\bsimple_(strto.*?)\s*\(/) { +# recommend kstrto* over simple_strto* and strict_strto* + if ($line =~ /\b((simple|strict)_(strto(l|ll|ul|ull)))\s*\(/) { WARN("CONSIDER_KSTRTO", - "consider using kstrto* in preference to simple_$1\n" . $herecurr); + "$1 is obsolete, use k$3 instead\n" . $herecurr); } # check for __initcall(), use device_initcall() explicitly please if ($line =~ /^.\s*__initcall\s*\(/) { -- cgit v1.2.3 From 15662b3e8644905032c2e26808401a487d4e90c1 Mon Sep 17 00:00:00 2001 From: Joe Perches Date: Mon, 31 Oct 2011 17:13:12 -0700 Subject: checkpatch: add a --strict check for utf-8 in commit logs Some find using utf-8 in commit logs inappropriate. Some patch commit logs contain unintended utf-8 characters when doing things like copy/pasting compilation output. Look for the start of any commit log by skipping initial lines that look like email headers and "From: " lines. Stop looking for utf-8 at the first signature line. Signed-off-by: Joe Perches Suggested-by: Andrew Morton Cc: Andy Whitcroft Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- scripts/checkpatch.pl | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) (limited to 'scripts') diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 5ba679c8cde6..5e93342d22f9 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -240,9 +240,8 @@ our $NonptrType; our $Type; our $Declare; -our $UTF8 = qr { - [\x09\x0A\x0D\x20-\x7E] # ASCII - | [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte +our $NON_ASCII_UTF8 = qr{ + [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte | \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte | \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates @@ -251,6 +250,11 @@ our $UTF8 = qr { | \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16 }x; +our $UTF8 = qr{ + [\x09\x0A\x0D\x20-\x7E] # ASCII + | $NON_ASCII_UTF8 +}x; + our $typeTypedefs = qr{(?x: (?:__)?(?:u|s|be|le)(?:8|16|32|64)| atomic_t @@ -1330,6 +1334,9 @@ sub process { my $signoff = 0; my $is_patch = 0; + my $in_header_lines = 1; + my $in_commit_log = 0; #Scanning lines before patch + our @report = (); our $cnt_lines = 0; our $cnt_error = 0; @@ -1497,7 +1504,6 @@ sub process { if ($line =~ /^diff --git.*?(\S+)$/) { $realfile = $1; $realfile =~ s@^([^/]*)/@@; - } elsif ($line =~ /^\+\+\+\s+(\S+)/) { $realfile = $1; $realfile =~ s@^([^/]*)/@@; @@ -1536,6 +1542,7 @@ sub process { # Check the patch for a signoff: if ($line =~ /^\s*signed-off-by:/i) { $signoff++; + $in_commit_log = 0; } # Check signature styles @@ -1613,6 +1620,21 @@ sub process { "Invalid UTF-8, patch and commit message should be encoded in UTF-8\n" . $hereptr); } +# Check if it's the start of a commit log +# (not a header line and we haven't seen the patch filename) + if ($in_header_lines && $realfile =~ /^$/ && + $rawline !~ /^(commit\b|from\b|\w+:).+$/i) { + $in_header_lines = 0; + $in_commit_log = 1; + } + +# Still not yet in a patch, check for any UTF-8 + if ($in_commit_log && $realfile =~ /^$/ && + $rawline =~ /$NON_ASCII_UTF8/) { + CHK("UTF8_BEFORE_PATCH", + "8-bit UTF-8 used in possible commit log\n" . $herecurr); + } + # ignore non-hunk lines and lines being removed next if (!$hunk_line || $line =~ /^-/); -- cgit v1.2.3 From 2449b8ba0745327c5fa49a8d9acffe03b2eded69 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Mon, 24 Oct 2011 15:12:28 +0200 Subject: module,bug: Add TAINT_OOT_MODULE flag for modules not built in-tree Use of the GPL or a compatible licence doesn't necessarily make the code any good. We already consider staging modules to be suspect, and this should also be true for out-of-tree modules which may receive very little review. Signed-off-by: Ben Hutchings Reviewed-by: Dave Jones Acked-by: Greg Kroah-Hartman Signed-off-by: Rusty Russell (patched oops-tracing.txt) --- Documentation/oops-tracing.txt | 2 ++ include/linux/kernel.h | 1 + kernel/module.c | 5 +++++ kernel/panic.c | 2 ++ scripts/mod/modpost.c | 7 +++++++ 5 files changed, 17 insertions(+) (limited to 'scripts') diff --git a/Documentation/oops-tracing.txt b/Documentation/oops-tracing.txt index 6fe9001b9263..13032c0140d4 100644 --- a/Documentation/oops-tracing.txt +++ b/Documentation/oops-tracing.txt @@ -263,6 +263,8 @@ characters, each representing a particular tainted value. 12: 'I' if the kernel is working around a severe bug in the platform firmware (BIOS or similar). + 13: 'O' if an externally-built ("out-of-tree") module has been loaded. + The primary reason for the 'Tainted: ' string is to tell kernel debuggers if this is a clean kernel or if anything unusual has occurred. Tainting is permanent: even if an offending module is diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 4c0d3b2fd5fc..e8b1597b5cf2 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -371,6 +371,7 @@ extern enum system_states { #define TAINT_WARN 9 #define TAINT_CRAP 10 #define TAINT_FIRMWARE_WORKAROUND 11 +#define TAINT_OOT_MODULE 12 extern const char hex_asc[]; #define hex_asc_lo(x) hex_asc[((x) & 0x0f)] diff --git a/kernel/module.c b/kernel/module.c index 3c5509642847..ef8cb70c6996 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -2487,6 +2487,9 @@ static int check_modinfo(struct module *mod, struct load_info *info) return -ENOEXEC; } + if (!get_modinfo(info, "intree")) + add_taint_module(mod, TAINT_OOT_MODULE); + if (get_modinfo(info, "staging")) { add_taint_module(mod, TAINT_CRAP); printk(KERN_WARNING "%s: module is from the staging directory," @@ -3255,6 +3258,8 @@ static char *module_flags(struct module *mod, char *buf) buf[bx++] = '('; if (mod->taints & (1 << TAINT_PROPRIETARY_MODULE)) buf[bx++] = 'P'; + else if (mod->taints & (1 << TAINT_OOT_MODULE)) + buf[bx++] = 'O'; if (mod->taints & (1 << TAINT_FORCED_MODULE)) buf[bx++] = 'F'; if (mod->taints & (1 << TAINT_CRAP)) diff --git a/kernel/panic.c b/kernel/panic.c index d7bb6974efb5..b26593604214 100644 --- a/kernel/panic.c +++ b/kernel/panic.c @@ -177,6 +177,7 @@ static const struct tnt tnts[] = { { TAINT_WARN, 'W', ' ' }, { TAINT_CRAP, 'C', ' ' }, { TAINT_FIRMWARE_WORKAROUND, 'I', ' ' }, + { TAINT_OOT_MODULE, 'O', ' ' }, }; /** @@ -194,6 +195,7 @@ static const struct tnt tnts[] = { * 'W' - Taint on warning. * 'C' - modules from drivers/staging are loaded. * 'I' - Working around severe firmware bug. + * 'O' - Out-of-tree module has been loaded. * * The string is overwritten by the next call to print_tainted(). */ diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index a509ff8f32fa..2bd594e6d1b4 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -1849,6 +1849,12 @@ static void add_header(struct buffer *b, struct module *mod) buf_printf(b, "};\n"); } +static void add_intree_flag(struct buffer *b, int is_intree) +{ + if (is_intree) + buf_printf(b, "\nMODULE_INFO(intree, \"Y\");\n"); +} + static void add_staging_flag(struct buffer *b, const char *name) { static const char *staging_dir = "drivers/staging"; @@ -2169,6 +2175,7 @@ int main(int argc, char **argv) buf.pos = 0; add_header(&buf, mod); + add_intree_flag(&buf, !external_module); add_staging_flag(&buf, mod->name); err |= add_versions(&buf, mod); add_depends(&buf, mod, modules); -- cgit v1.2.3