aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2013-11-14 20:38:05 -0500
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2013-11-14 20:38:05 -0500
commit42249094f79422fbf5ed4b54eeb48ff096809b8f (patch)
tree91e6850c8c7e8cc284cf8bb6363f8662f84011f4 /scripts
parent936816161978ca716a56c5e553c68f25972b1e3a (diff)
parent2c027b7c48a888ab173ba45babb4525e278375d9 (diff)
Merge branch 'next' into for-linus
Merge first round of changes for 3.13 merge window.
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Makefile.headersinst20
-rw-r--r--scripts/Makefile.lib17
-rwxr-xr-xscripts/checkkconfigsymbols.sh4
-rwxr-xr-xscripts/checkpatch.pl929
-rwxr-xr-xscripts/coccicheck76
-rw-r--r--scripts/coccinelle/api/alloc/drop_kmalloc_cast.cocci2
-rw-r--r--scripts/coccinelle/api/alloc/kzalloc-simple.cocci2
-rw-r--r--scripts/coccinelle/api/d_find_alias.cocci2
-rw-r--r--scripts/coccinelle/api/devm_request_and_ioremap.cocci2
-rw-r--r--scripts/coccinelle/api/kstrdup.cocci2
-rw-r--r--scripts/coccinelle/api/memdup.cocci2
-rw-r--r--scripts/coccinelle/api/memdup_user.cocci2
-rw-r--r--scripts/coccinelle/api/ptr_ret.cocci12
-rw-r--r--scripts/coccinelle/api/simple_open.cocci2
-rw-r--r--scripts/coccinelle/free/devm_free.cocci2
-rw-r--r--scripts/coccinelle/free/kfree.cocci2
-rw-r--r--scripts/coccinelle/free/kfreeaddr.cocci32
-rw-r--r--scripts/coccinelle/free/pci_free_consistent.cocci52
-rw-r--r--scripts/coccinelle/iterators/fen.cocci2
-rw-r--r--scripts/coccinelle/iterators/itnull.cocci2
-rw-r--r--scripts/coccinelle/iterators/list_entry_update.cocci2
-rw-r--r--scripts/coccinelle/iterators/use_after_iter.cocci2
-rw-r--r--scripts/coccinelle/locks/call_kern.cocci2
-rw-r--r--scripts/coccinelle/locks/double_lock.cocci2
-rw-r--r--scripts/coccinelle/locks/flags.cocci2
-rw-r--r--scripts/coccinelle/locks/mini_lock.cocci2
-rw-r--r--scripts/coccinelle/misc/boolinit.cocci2
-rw-r--r--scripts/coccinelle/misc/boolreturn.cocci58
-rw-r--r--scripts/coccinelle/misc/cstptr.cocci2
-rw-r--r--scripts/coccinelle/misc/doubleinit.cocci2
-rw-r--r--scripts/coccinelle/misc/ifaddr.cocci2
-rw-r--r--scripts/coccinelle/misc/ifcol.cocci2
-rw-r--r--scripts/coccinelle/misc/noderef.cocci2
-rw-r--r--scripts/coccinelle/misc/orplus.cocci2
-rw-r--r--scripts/coccinelle/misc/warn.cocci2
-rw-r--r--scripts/coccinelle/null/eno.cocci2
-rw-r--r--scripts/coccinelle/null/kmerr.cocci2
-rw-r--r--scripts/coccinelle/tests/doublebitand.cocci2
-rw-r--r--scripts/coccinelle/tests/doubletest.cocci2
-rw-r--r--scripts/coccinelle/tests/odd_ptr_err.cocci2
-rwxr-xr-xscripts/config56
-rwxr-xr-xscripts/diffconfig33
-rw-r--r--scripts/dtc/dtc-lexer.l2
-rw-r--r--scripts/dtc/dtc-lexer.lex.c_shipped232
-rw-r--r--scripts/dtc/dtc-parser.tab.c_shipped715
-rw-r--r--scripts/dtc/dtc-parser.tab.h_shipped14
-rw-r--r--scripts/headers_install.sh7
-rw-r--r--scripts/kconfig/conf.c6
-rw-r--r--scripts/kconfig/confdata.c44
-rw-r--r--scripts/kconfig/expr.h3
-rw-r--r--scripts/kconfig/lkc.h3
-rw-r--r--scripts/kconfig/lkc_proto.h1
-rw-r--r--scripts/kconfig/lxdialog/checklist.c8
-rw-r--r--scripts/kconfig/lxdialog/dialog.h14
-rw-r--r--scripts/kconfig/lxdialog/inputbox.c8
-rw-r--r--scripts/kconfig/lxdialog/menubox.c6
-rw-r--r--scripts/kconfig/lxdialog/textbox.c6
-rw-r--r--scripts/kconfig/lxdialog/util.c46
-rw-r--r--scripts/kconfig/lxdialog/yesno.c8
-rw-r--r--scripts/kconfig/mconf.c23
-rw-r--r--scripts/kconfig/menu.c27
-rw-r--r--scripts/kconfig/nconf.c41
-rw-r--r--scripts/kconfig/nconf.gui.c20
-rw-r--r--scripts/kconfig/symbol.c103
-rw-r--r--scripts/kconfig/zconf.tab.c_shipped562
-rw-r--r--scripts/kconfig/zconf.y11
-rw-r--r--scripts/mod/Makefile15
-rw-r--r--scripts/mod/devicetable-offsets.c6
-rw-r--r--scripts/mod/file2alias.c30
-rw-r--r--scripts/mod/modpost.c55
-rw-r--r--scripts/package/builddeb94
-rw-r--r--scripts/package/buildtar21
-rwxr-xr-xscripts/package/mkspec47
-rwxr-xr-xscripts/recordmcount.pl4
-rwxr-xr-xscripts/setlocalversion3
-rw-r--r--scripts/sortextable.c13
76 files changed, 2359 insertions, 1190 deletions
diff --git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst
index 182084d728c8..8ccf83056a7a 100644
--- a/scripts/Makefile.headersinst
+++ b/scripts/Makefile.headersinst
@@ -47,18 +47,24 @@ header-y := $(filter-out $(generic-y), $(header-y))
47all-files := $(header-y) $(genhdr-y) $(wrapper-files) 47all-files := $(header-y) $(genhdr-y) $(wrapper-files)
48output-files := $(addprefix $(installdir)/, $(all-files)) 48output-files := $(addprefix $(installdir)/, $(all-files))
49 49
50input-files := $(foreach hdr, $(header-y), \ 50input-files1 := $(foreach hdr, $(header-y), \
51 $(if $(wildcard $(srcdir)/$(hdr)), \ 51 $(if $(wildcard $(srcdir)/$(hdr)), \
52 $(wildcard $(srcdir)/$(hdr)), \ 52 $(wildcard $(srcdir)/$(hdr))) \
53 )
54input-files1-name := $(notdir $(input-files1))
55input-files2 := $(foreach hdr, $(header-y), \
56 $(if $(wildcard $(srcdir)/$(hdr)),, \
53 $(if $(wildcard $(oldsrcdir)/$(hdr)), \ 57 $(if $(wildcard $(oldsrcdir)/$(hdr)), \
54 $(wildcard $(oldsrcdir)/$(hdr)), \ 58 $(wildcard $(oldsrcdir)/$(hdr)), \
55 $(error Missing UAPI file $(srcdir)/$(hdr))) \ 59 $(error Missing UAPI file $(srcdir)/$(hdr))) \
56 )) \ 60 ))
57 $(foreach hdr, $(genhdr-y), \ 61input-files2-name := $(notdir $(input-files2))
62input-files3 := $(foreach hdr, $(genhdr-y), \
58 $(if $(wildcard $(gendir)/$(hdr)), \ 63 $(if $(wildcard $(gendir)/$(hdr)), \
59 $(wildcard $(gendir)/$(hdr)), \ 64 $(wildcard $(gendir)/$(hdr)), \
60 $(error Missing generated UAPI file $(gendir)/$(hdr)) \ 65 $(error Missing generated UAPI file $(gendir)/$(hdr)) \
61 )) 66 ))
67input-files3-name := $(notdir $(input-files3))
62 68
63# Work out what needs to be removed 69# Work out what needs to be removed
64oldheaders := $(patsubst $(installdir)/%,%,$(wildcard $(installdir)/*.h)) 70oldheaders := $(patsubst $(installdir)/%,%,$(wildcard $(installdir)/*.h))
@@ -72,7 +78,9 @@ printdir = $(patsubst $(INSTALL_HDR_PATH)/%/,%,$(dir $@))
72quiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\ 78quiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\
73 file$(if $(word 2, $(all-files)),s)) 79 file$(if $(word 2, $(all-files)),s))
74 cmd_install = \ 80 cmd_install = \
75 $(CONFIG_SHELL) $< $(installdir) $(input-files); \ 81 $(CONFIG_SHELL) $< $(installdir) $(srcdir) $(input-files1-name); \
82 $(CONFIG_SHELL) $< $(installdir) $(oldsrcdir) $(input-files2-name); \
83 $(CONFIG_SHELL) $< $(installdir) $(gendir) $(input-files3-name); \
76 for F in $(wrapper-files); do \ 84 for F in $(wrapper-files); do \
77 echo "\#include <asm-generic/$$F>" > $(installdir)/$$F; \ 85 echo "\#include <asm-generic/$$F>" > $(installdir)/$$F; \
78 done; \ 86 done; \
@@ -98,7 +106,7 @@ __headersinst: $(subdirs) $(install-file)
98 @: 106 @:
99 107
100targets += $(install-file) 108targets += $(install-file)
101$(install-file): scripts/headers_install.sh $(input-files) FORCE 109$(install-file): scripts/headers_install.sh $(input-files1) $(input-files2) $(input-files3) FORCE
102 $(if $(unwanted),$(call cmd,remove),) 110 $(if $(unwanted),$(call cmd,remove),)
103 $(if $(wildcard $(dir $@)),,$(shell mkdir -p $(dir $@))) 111 $(if $(wildcard $(dir $@)),,$(shell mkdir -p $(dir $@)))
104 $(call if_changed,install) 112 $(call if_changed,install)
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 8337663aa298..49392ecbef17 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -63,7 +63,7 @@ multi-objs := $(multi-objs-y) $(multi-objs-m)
63subdir-obj-y := $(filter %/built-in.o, $(obj-y)) 63subdir-obj-y := $(filter %/built-in.o, $(obj-y))
64 64
65# $(obj-dirs) is a list of directories that contain object files 65# $(obj-dirs) is a list of directories that contain object files
66obj-dirs := $(dir $(multi-objs) $(subdir-obj-y)) 66obj-dirs := $(dir $(multi-objs) $(obj-y))
67 67
68# Replace multi-part objects by their individual parts, look at local dir only 68# Replace multi-part objects by their individual parts, look at local dir only
69real-objs-y := $(foreach m, $(filter-out $(subdir-obj-y), $(obj-y)), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m))) $(extra-y) 69real-objs-y := $(foreach m, $(filter-out $(subdir-obj-y), $(obj-y)), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m))) $(extra-y)
@@ -149,7 +149,7 @@ cpp_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \
149 149
150ld_flags = $(LDFLAGS) $(ldflags-y) 150ld_flags = $(LDFLAGS) $(ldflags-y)
151 151
152dtc_cpp_flags = -Wp,-MD,$(depfile).pre -nostdinc \ 152dtc_cpp_flags = -Wp,-MD,$(depfile).pre.tmp -nostdinc \
153 -I$(srctree)/arch/$(SRCARCH)/boot/dts \ 153 -I$(srctree)/arch/$(SRCARCH)/boot/dts \
154 -I$(srctree)/arch/$(SRCARCH)/boot/dts/include \ 154 -I$(srctree)/arch/$(SRCARCH)/boot/dts/include \
155 -undef -D__DTS__ 155 -undef -D__DTS__
@@ -244,7 +244,7 @@ cmd_gzip = (cat $(filter-out FORCE,$^) | gzip -n -f -9 > $@) || \
244# --------------------------------------------------------------------------- 244# ---------------------------------------------------------------------------
245 245
246# Generate an assembly file to wrap the output of the device tree compiler 246# Generate an assembly file to wrap the output of the device tree compiler
247quiet_cmd_dt_S_dtb= DTB $@ 247quiet_cmd_dt_S_dtb= DTB $@
248cmd_dt_S_dtb= \ 248cmd_dt_S_dtb= \
249( \ 249( \
250 echo '\#include <asm-generic/vmlinux.lds.h>'; \ 250 echo '\#include <asm-generic/vmlinux.lds.h>'; \
@@ -265,13 +265,13 @@ quiet_cmd_dtc = DTC $@
265cmd_dtc = $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \ 265cmd_dtc = $(CPP) $(dtc_cpp_flags) -x assembler-with-cpp -o $(dtc-tmp) $< ; \
266 $(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 \ 266 $(objtree)/scripts/dtc/dtc -O dtb -o $@ -b 0 \
267 -i $(dir $<) $(DTC_FLAGS) \ 267 -i $(dir $<) $(DTC_FLAGS) \
268 -d $(depfile).dtc $(dtc-tmp) ; \ 268 -d $(depfile).dtc.tmp $(dtc-tmp) ; \
269 cat $(depfile).pre $(depfile).dtc > $(depfile) 269 cat $(depfile).pre.tmp $(depfile).dtc.tmp > $(depfile)
270 270
271$(obj)/%.dtb: $(src)/%.dts FORCE 271$(obj)/%.dtb: $(src)/%.dts FORCE
272 $(call if_changed_dep,dtc) 272 $(call if_changed_dep,dtc)
273 273
274dtc-tmp = $(subst $(comma),_,$(dot-target).dts) 274dtc-tmp = $(subst $(comma),_,$(dot-target).dts.tmp)
275 275
276# Bzip2 276# Bzip2
277# --------------------------------------------------------------------------- 277# ---------------------------------------------------------------------------
@@ -311,6 +311,11 @@ cmd_lzo = (cat $(filter-out FORCE,$^) | \
311 lzop -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \ 311 lzop -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \
312 (rm -f $@ ; false) 312 (rm -f $@ ; false)
313 313
314quiet_cmd_lz4 = LZ4 $@
315cmd_lz4 = (cat $(filter-out FORCE,$^) | \
316 lz4c -l -c1 stdin stdout && $(call size_append, $(filter-out FORCE,$^))) > $@ || \
317 (rm -f $@ ; false)
318
314# U-Boot mkimage 319# U-Boot mkimage
315# --------------------------------------------------------------------------- 320# ---------------------------------------------------------------------------
316 321
diff --git a/scripts/checkkconfigsymbols.sh b/scripts/checkkconfigsymbols.sh
index 2ca49bb31efc..ccb3391882d1 100755
--- a/scripts/checkkconfigsymbols.sh
+++ b/scripts/checkkconfigsymbols.sh
@@ -9,7 +9,7 @@ paths="$@"
9# Doing this once at the beginning saves a lot of time, on a cache-hot tree. 9# Doing this once at the beginning saves a lot of time, on a cache-hot tree.
10Kconfigs="`find . -name 'Kconfig' -o -name 'Kconfig*[^~]'`" 10Kconfigs="`find . -name 'Kconfig' -o -name 'Kconfig*[^~]'`"
11 11
12/bin/echo -e "File list \tundefined symbol used" 12printf "File list \tundefined symbol used\n"
13find $paths -name '*.[chS]' -o -name 'Makefile' -o -name 'Makefile*[^~]'| while read i 13find $paths -name '*.[chS]' -o -name 'Makefile' -o -name 'Makefile*[^~]'| while read i
14do 14do
15 # Output the bare Kconfig variable and the filename; the _MODULE part at 15 # Output the bare Kconfig variable and the filename; the _MODULE part at
@@ -54,6 +54,6 @@ while read symb files; do
54 # beyond the purpose of this script. 54 # beyond the purpose of this script.
55 symb_bare=`echo $symb | sed -e 's/_MODULE//'` 55 symb_bare=`echo $symb | sed -e 's/_MODULE//'`
56 if ! grep -q "\<$symb_bare\>" $Kconfigs; then 56 if ! grep -q "\<$symb_bare\>" $Kconfigs; then
57 /bin/echo -e "$files: \t$symb" 57 printf "$files: \t$symb\n"
58 fi 58 fi
59done|sort 59done|sort
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index b954de58304f..66cad506b8a2 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -6,6 +6,7 @@
6# Licensed under the terms of the GNU GPL License version 2 6# Licensed under the terms of the GNU GPL License version 2
7 7
8use strict; 8use strict;
9use POSIX;
9 10
10my $P = $0; 11my $P = $0;
11$P =~ s@.*/@@g; 12$P =~ s@.*/@@g;
@@ -27,13 +28,19 @@ my $summary = 1;
27my $mailback = 0; 28my $mailback = 0;
28my $summary_file = 0; 29my $summary_file = 0;
29my $show_types = 0; 30my $show_types = 0;
31my $fix = 0;
30my $root; 32my $root;
31my %debug; 33my %debug;
34my %camelcase = ();
35my %use_type = ();
36my @use = ();
32my %ignore_type = (); 37my %ignore_type = ();
33my @ignore = (); 38my @ignore = ();
34my $help = 0; 39my $help = 0;
35my $configuration_file = ".checkpatch.conf"; 40my $configuration_file = ".checkpatch.conf";
36my $max_line_length = 80; 41my $max_line_length = 80;
42my $ignore_perl_version = 0;
43my $minimum_perl_version = 5.10.0;
37 44
38sub help { 45sub help {
39 my ($exitcode) = @_; 46 my ($exitcode) = @_;
@@ -51,6 +58,7 @@ Options:
51 --terse one line per report 58 --terse one line per report
52 -f, --file treat FILE as regular source file 59 -f, --file treat FILE as regular source file
53 --subjective, --strict enable more subjective tests 60 --subjective, --strict enable more subjective tests
61 --types TYPE(,TYPE2...) show only these comma separated message types
54 --ignore TYPE(,TYPE2...) ignore various comma separated message types 62 --ignore TYPE(,TYPE2...) ignore various comma separated message types
55 --max-line-length=n set the maximum line length, if exceeded, warn 63 --max-line-length=n set the maximum line length, if exceeded, warn
56 --show-types show the message "types" in the output 64 --show-types show the message "types" in the output
@@ -63,6 +71,13 @@ Options:
63 is all off) 71 is all off)
64 --test-only=WORD report only warnings/errors containing WORD 72 --test-only=WORD report only warnings/errors containing WORD
65 literally 73 literally
74 --fix EXPERIMENTAL - may create horrible results
75 If correctable single-line errors exist, create
76 "<inputfile>.EXPERIMENTAL-checkpatch-fixes"
77 with potential errors corrected to the preferred
78 checkpatch style
79 --ignore-perl-version override checking of perl version. expect
80 runtime errors.
66 -h, --help, --version display this help and exit 81 -h, --help, --version display this help and exit
67 82
68When FILE is - read standard input. 83When FILE is - read standard input.
@@ -108,13 +123,15 @@ GetOptions(
108 'subjective!' => \$check, 123 'subjective!' => \$check,
109 'strict!' => \$check, 124 'strict!' => \$check,
110 'ignore=s' => \@ignore, 125 'ignore=s' => \@ignore,
126 'types=s' => \@use,
111 'show-types!' => \$show_types, 127 'show-types!' => \$show_types,
112 'max-line-length=i' => \$max_line_length, 128 'max-line-length=i' => \$max_line_length,
113 'root=s' => \$root, 129 'root=s' => \$root,
114 'summary!' => \$summary, 130 'summary!' => \$summary,
115 'mailback!' => \$mailback, 131 'mailback!' => \$mailback,
116 'summary-file!' => \$summary_file, 132 'summary-file!' => \$summary_file,
117 133 'fix!' => \$fix,
134 'ignore-perl-version!' => \$ignore_perl_version,
118 'debug=s' => \%debug, 135 'debug=s' => \%debug,
119 'test-only=s' => \$tst_only, 136 'test-only=s' => \$tst_only,
120 'h|help' => \$help, 137 'h|help' => \$help,
@@ -125,24 +142,50 @@ help(0) if ($help);
125 142
126my $exit = 0; 143my $exit = 0;
127 144
145if ($^V && $^V lt $minimum_perl_version) {
146 printf "$P: requires at least perl version %vd\n", $minimum_perl_version;
147 if (!$ignore_perl_version) {
148 exit(1);
149 }
150}
151
128if ($#ARGV < 0) { 152if ($#ARGV < 0) {
129 print "$P: no input files\n"; 153 print "$P: no input files\n";
130 exit(1); 154 exit(1);
131} 155}
132 156
133@ignore = split(/,/, join(',',@ignore)); 157sub hash_save_array_words {
134foreach my $word (@ignore) { 158 my ($hashRef, $arrayRef) = @_;
135 $word =~ s/\s*\n?$//g; 159
136 $word =~ s/^\s*//g; 160 my @array = split(/,/, join(',', @$arrayRef));
137 $word =~ s/\s+/ /g; 161 foreach my $word (@array) {
138 $word =~ tr/[a-z]/[A-Z]/; 162 $word =~ s/\s*\n?$//g;
163 $word =~ s/^\s*//g;
164 $word =~ s/\s+/ /g;
165 $word =~ tr/[a-z]/[A-Z]/;
166
167 next if ($word =~ m/^\s*#/);
168 next if ($word =~ m/^\s*$/);
169
170 $hashRef->{$word}++;
171 }
172}
139 173
140 next if ($word =~ m/^\s*#/); 174sub hash_show_words {
141 next if ($word =~ m/^\s*$/); 175 my ($hashRef, $prefix) = @_;
142 176
143 $ignore_type{$word}++; 177 if ($quiet == 0 && keys %$hashRef) {
178 print "NOTE: $prefix message types:";
179 foreach my $word (sort keys %$hashRef) {
180 print " $word";
181 }
182 print "\n\n";
183 }
144} 184}
145 185
186hash_save_array_words(\%ignore_type, \@ignore);
187hash_save_array_words(\%use_type, \@use);
188
146my $dbg_values = 0; 189my $dbg_values = 0;
147my $dbg_possible = 0; 190my $dbg_possible = 0;
148my $dbg_type = 0; 191my $dbg_type = 0;
@@ -199,6 +242,8 @@ our $Sparse = qr{
199 __rcu 242 __rcu
200 }x; 243 }x;
201 244
245our $InitAttribute = qr{__(?:mem|cpu|dev|net_|)(?:initdata|initconst|init\b)};
246
202# Notes to $Attribute: 247# Notes to $Attribute:
203# We need \b after 'init' otherwise 'initconst' will cause a false positive in a check 248# We need \b after 'init' otherwise 'initconst' will cause a false positive in a check
204our $Attribute = qr{ 249our $Attribute = qr{
@@ -219,7 +264,7 @@ our $Attribute = qr{
219 __deprecated| 264 __deprecated|
220 __read_mostly| 265 __read_mostly|
221 __kprobes| 266 __kprobes|
222 __(?:mem|cpu|dev|)(?:initdata|initconst|init\b)| 267 $InitAttribute|
223 ____cacheline_aligned| 268 ____cacheline_aligned|
224 ____cacheline_aligned_in_smp| 269 ____cacheline_aligned_in_smp|
225 ____cacheline_internodealigned_in_smp| 270 ____cacheline_internodealigned_in_smp|
@@ -230,20 +275,26 @@ our $Inline = qr{inline|__always_inline|noinline};
230our $Member = qr{->$Ident|\.$Ident|\[[^]]*\]}; 275our $Member = qr{->$Ident|\.$Ident|\[[^]]*\]};
231our $Lval = qr{$Ident(?:$Member)*}; 276our $Lval = qr{$Ident(?:$Member)*};
232 277
278our $Int_type = qr{(?i)llu|ull|ll|lu|ul|l|u};
279our $Binary = qr{(?i)0b[01]+$Int_type?};
280our $Hex = qr{(?i)0x[0-9a-f]+$Int_type?};
281our $Int = qr{[0-9]+$Int_type?};
233our $Float_hex = qr{(?i)0x[0-9a-f]+p-?[0-9]+[fl]?}; 282our $Float_hex = qr{(?i)0x[0-9a-f]+p-?[0-9]+[fl]?};
234our $Float_dec = qr{(?i)(?:[0-9]+\.[0-9]*|[0-9]*\.[0-9]+)(?:e-?[0-9]+)?[fl]?}; 283our $Float_dec = qr{(?i)(?:[0-9]+\.[0-9]*|[0-9]*\.[0-9]+)(?:e-?[0-9]+)?[fl]?};
235our $Float_int = qr{(?i)[0-9]+e-?[0-9]+[fl]?}; 284our $Float_int = qr{(?i)[0-9]+e-?[0-9]+[fl]?};
236our $Float = qr{$Float_hex|$Float_dec|$Float_int}; 285our $Float = qr{$Float_hex|$Float_dec|$Float_int};
237our $Constant = qr{$Float|(?i)(?:0x[0-9a-f]+|[0-9]+)[ul]*}; 286our $Constant = qr{$Float|$Binary|$Hex|$Int};
238our $Assignment = qr{\*\=|/=|%=|\+=|-=|<<=|>>=|&=|\^=|\|=|=}; 287our $Assignment = qr{\*\=|/=|%=|\+=|-=|<<=|>>=|&=|\^=|\|=|=};
239our $Compare = qr{<=|>=|==|!=|<|>}; 288our $Compare = qr{<=|>=|==|!=|<|>};
289our $Arithmetic = qr{\+|-|\*|\/|%};
240our $Operators = qr{ 290our $Operators = qr{
241 <=|>=|==|!=| 291 <=|>=|==|!=|
242 =>|->|<<|>>|<|>|!|~| 292 =>|->|<<|>>|<|>|!|~|
243 &&|\|\||,|\^|\+\+|--|&|\||\+|-|\*|\/|% 293 &&|\|\||,|\^|\+\+|--|&|\||$Arithmetic
244 }x; 294 }x;
245 295
246our $NonptrType; 296our $NonptrType;
297our $NonptrTypeWithAttr;
247our $Type; 298our $Type;
248our $Declare; 299our $Declare;
249 300
@@ -269,7 +320,7 @@ our $typeTypedefs = qr{(?x:
269 320
270our $logFunctions = qr{(?x: 321our $logFunctions = qr{(?x:
271 printk(?:_ratelimited|_once|)| 322 printk(?:_ratelimited|_once|)|
272 [a-z0-9]+_(?:printk|emerg|alert|crit|err|warning|warn|notice|info|debug|dbg|vdbg|devel|cont|WARN)(?:_ratelimited|_once|)| 323 (?:[a-z0-9]+_){1,2}(?:printk|emerg|alert|crit|err|warning|warn|notice|info|debug|dbg|vdbg|devel|cont|WARN)(?:_ratelimited|_once|)|
273 WARN(?:_RATELIMIT|_ONCE|)| 324 WARN(?:_RATELIMIT|_ONCE|)|
274 panic| 325 panic|
275 MODULE_[A-Z_]+ 326 MODULE_[A-Z_]+
@@ -306,6 +357,12 @@ our @typeList = (
306 qr{${Ident}_handler}, 357 qr{${Ident}_handler},
307 qr{${Ident}_handler_fn}, 358 qr{${Ident}_handler_fn},
308); 359);
360our @typeListWithAttr = (
361 @typeList,
362 qr{struct\s+$InitAttribute\s+$Ident},
363 qr{union\s+$InitAttribute\s+$Ident},
364);
365
309our @modifierList = ( 366our @modifierList = (
310 qr{fastcall}, 367 qr{fastcall},
311); 368);
@@ -319,6 +376,7 @@ our $allowed_asm_includes = qr{(?x:
319sub build_types { 376sub build_types {
320 my $mods = "(?x: \n" . join("|\n ", @modifierList) . "\n)"; 377 my $mods = "(?x: \n" . join("|\n ", @modifierList) . "\n)";
321 my $all = "(?x: \n" . join("|\n ", @typeList) . "\n)"; 378 my $all = "(?x: \n" . join("|\n ", @typeList) . "\n)";
379 my $allWithAttr = "(?x: \n" . join("|\n ", @typeListWithAttr) . "\n)";
322 $Modifier = qr{(?:$Attribute|$Sparse|$mods)}; 380 $Modifier = qr{(?:$Attribute|$Sparse|$mods)};
323 $NonptrType = qr{ 381 $NonptrType = qr{
324 (?:$Modifier\s+|const\s+)* 382 (?:$Modifier\s+|const\s+)*
@@ -329,6 +387,15 @@ sub build_types {
329 ) 387 )
330 (?:\s+$Modifier|\s+const)* 388 (?:\s+$Modifier|\s+const)*
331 }x; 389 }x;
390 $NonptrTypeWithAttr = qr{
391 (?:$Modifier\s+|const\s+)*
392 (?:
393 (?:typeof|__typeof__)\s*\([^\)]*\)|
394 (?:$typeTypedefs\b)|
395 (?:${allWithAttr}\b)
396 )
397 (?:\s+$Modifier|\s+const)*
398 }x;
332 $Type = qr{ 399 $Type = qr{
333 $NonptrType 400 $NonptrType
334 (?:(?:\s|\*|\[\])+\s*const|(?:\s|\*|\[\])+|(?:\s*\[\s*\])+)? 401 (?:(?:\s|\*|\[\])+\s*const|(?:\s|\*|\[\])+|(?:\s*\[\s*\])+)?
@@ -338,7 +405,6 @@ sub build_types {
338} 405}
339build_types(); 406build_types();
340 407
341
342our $Typecast = qr{\s*(\(\s*$NonptrType\s*\)){0,1}\s*}; 408our $Typecast = qr{\s*(\(\s*$NonptrType\s*\)){0,1}\s*};
343 409
344# Using $balanced_parens, $LvalOrFunc, or $FuncArg 410# Using $balanced_parens, $LvalOrFunc, or $FuncArg
@@ -358,10 +424,94 @@ sub deparenthesize {
358 return $string; 424 return $string;
359} 425}
360 426
427sub seed_camelcase_file {
428 my ($file) = @_;
429
430 return if (!(-f $file));
431
432 local $/;
433
434 open(my $include_file, '<', "$file")
435 or warn "$P: Can't read '$file' $!\n";
436 my $text = <$include_file>;
437 close($include_file);
438
439 my @lines = split('\n', $text);
440
441 foreach my $line (@lines) {
442 next if ($line !~ /(?:[A-Z][a-z]|[a-z][A-Z])/);
443 if ($line =~ /^[ \t]*(?:#[ \t]*define|typedef\s+$Type)\s+(\w*(?:[A-Z][a-z]|[a-z][A-Z])\w*)/) {
444 $camelcase{$1} = 1;
445 }
446 elsif ($line =~ /^\s*$Declare\s+(\w*(?:[A-Z][a-z]|[a-z][A-Z])\w*)\s*\(/) {
447 $camelcase{$1} = 1;
448 }
449 }
450}
451
452my $camelcase_seeded = 0;
453sub seed_camelcase_includes {
454 return if ($camelcase_seeded);
455
456 my $files;
457 my $camelcase_cache = "";
458 my @include_files = ();
459
460 $camelcase_seeded = 1;
461
462 if (-d ".git") {
463 my $git_last_include_commit = `git log --no-merges --pretty=format:"%h%n" -1 -- include`;
464 chomp $git_last_include_commit;
465 $camelcase_cache = ".checkpatch-camelcase.git.$git_last_include_commit";
466 } else {
467 my $last_mod_date = 0;
468 $files = `find $root/include -name "*.h"`;
469 @include_files = split('\n', $files);
470 foreach my $file (@include_files) {
471 my $date = POSIX::strftime("%Y%m%d%H%M",
472 localtime((stat $file)[9]));
473 $last_mod_date = $date if ($last_mod_date < $date);
474 }
475 $camelcase_cache = ".checkpatch-camelcase.date.$last_mod_date";
476 }
477
478 if ($camelcase_cache ne "" && -f $camelcase_cache) {
479 open(my $camelcase_file, '<', "$camelcase_cache")
480 or warn "$P: Can't read '$camelcase_cache' $!\n";
481 while (<$camelcase_file>) {
482 chomp;
483 $camelcase{$_} = 1;
484 }
485 close($camelcase_file);
486
487 return;
488 }
489
490 if (-d ".git") {
491 $files = `git ls-files "include/*.h"`;
492 @include_files = split('\n', $files);
493 }
494
495 foreach my $file (@include_files) {
496 seed_camelcase_file($file);
497 }
498
499 if ($camelcase_cache ne "") {
500 unlink glob ".checkpatch-camelcase.*";
501 open(my $camelcase_file, '>', "$camelcase_cache")
502 or warn "$P: Can't write '$camelcase_cache' $!\n";
503 foreach (sort { lc($a) cmp lc($b) } keys(%camelcase)) {
504 print $camelcase_file ("$_\n");
505 }
506 close($camelcase_file);
507 }
508}
509
361$chk_signoff = 0 if ($file); 510$chk_signoff = 0 if ($file);
362 511
363my @rawlines = (); 512my @rawlines = ();
364my @lines = (); 513my @lines = ();
514my @fixed = ();
365my $vname; 515my $vname;
366for my $filename (@ARGV) { 516for my $filename (@ARGV) {
367 my $FILE; 517 my $FILE;
@@ -389,6 +539,7 @@ for my $filename (@ARGV) {
389 } 539 }
390 @rawlines = (); 540 @rawlines = ();
391 @lines = (); 541 @lines = ();
542 @fixed = ();
392} 543}
393 544
394exit($exit); 545exit($exit);
@@ -429,7 +580,7 @@ sub parse_email {
429 $comment = $2 if defined $2; 580 $comment = $2 if defined $2;
430 $formatted_email =~ s/$address.*$//; 581 $formatted_email =~ s/$address.*$//;
431 $name = $formatted_email; 582 $name = $formatted_email;
432 $name =~ s/^\s+|\s+$//g; 583 $name = trim($name);
433 $name =~ s/^\"|\"$//g; 584 $name =~ s/^\"|\"$//g;
434 # If there's a name left after stripping spaces and 585 # If there's a name left after stripping spaces and
435 # leading quotes, and the address doesn't have both 586 # leading quotes, and the address doesn't have both
@@ -444,9 +595,9 @@ sub parse_email {
444 } 595 }
445 } 596 }
446 597
447 $name =~ s/^\s+|\s+$//g; 598 $name = trim($name);
448 $name =~ s/^\"|\"$//g; 599 $name =~ s/^\"|\"$//g;
449 $address =~ s/^\s+|\s+$//g; 600 $address = trim($address);
450 $address =~ s/^\<|\>$//g; 601 $address =~ s/^\<|\>$//g;
451 602
452 if ($name =~ /[^\w \-]/i) { ##has "must quote" chars 603 if ($name =~ /[^\w \-]/i) { ##has "must quote" chars
@@ -462,9 +613,9 @@ sub format_email {
462 613
463 my $formatted_email; 614 my $formatted_email;
464 615
465 $name =~ s/^\s+|\s+$//g; 616 $name = trim($name);
466 $name =~ s/^\"|\"$//g; 617 $name =~ s/^\"|\"$//g;
467 $address =~ s/^\s+|\s+$//g; 618 $address = trim($address);
468 619
469 if ($name =~ /[^\w \-]/i) { ##has "must quote" chars 620 if ($name =~ /[^\w \-]/i) { ##has "must quote" chars
470 $name =~ s/(?<!\\)"/\\"/g; ##escape quotes 621 $name =~ s/(?<!\\)"/\\"/g; ##escape quotes
@@ -1258,7 +1409,9 @@ sub possible {
1258my $prefix = ''; 1409my $prefix = '';
1259 1410
1260sub show_type { 1411sub show_type {
1261 return !defined $ignore_type{$_[0]}; 1412 return defined $use_type{$_[0]} if (scalar keys %use_type > 0);
1413
1414 return !defined $ignore_type{$_[0]};
1262} 1415}
1263 1416
1264sub report { 1417sub report {
@@ -1286,19 +1439,25 @@ sub ERROR {
1286 if (report("ERROR", $_[0], $_[1])) { 1439 if (report("ERROR", $_[0], $_[1])) {
1287 our $clean = 0; 1440 our $clean = 0;
1288 our $cnt_error++; 1441 our $cnt_error++;
1442 return 1;
1289 } 1443 }
1444 return 0;
1290} 1445}
1291sub WARN { 1446sub WARN {
1292 if (report("WARNING", $_[0], $_[1])) { 1447 if (report("WARNING", $_[0], $_[1])) {
1293 our $clean = 0; 1448 our $clean = 0;
1294 our $cnt_warn++; 1449 our $cnt_warn++;
1450 return 1;
1295 } 1451 }
1452 return 0;
1296} 1453}
1297sub CHK { 1454sub CHK {
1298 if ($check && report("CHECK", $_[0], $_[1])) { 1455 if ($check && report("CHECK", $_[0], $_[1])) {
1299 our $clean = 0; 1456 our $clean = 0;
1300 our $cnt_chk++; 1457 our $cnt_chk++;
1458 return 1;
1301 } 1459 }
1460 return 0;
1302} 1461}
1303 1462
1304sub check_absolute_file { 1463sub check_absolute_file {
@@ -1329,6 +1488,45 @@ sub check_absolute_file {
1329 } 1488 }
1330} 1489}
1331 1490
1491sub trim {
1492 my ($string) = @_;
1493
1494 $string =~ s/^\s+|\s+$//g;
1495
1496 return $string;
1497}
1498
1499sub ltrim {
1500 my ($string) = @_;
1501
1502 $string =~ s/^\s+//;
1503
1504 return $string;
1505}
1506
1507sub rtrim {
1508 my ($string) = @_;
1509
1510 $string =~ s/\s+$//;
1511
1512 return $string;
1513}
1514
1515sub tabify {
1516 my ($leading) = @_;
1517
1518 my $source_indent = 8;
1519 my $max_spaces_before_tab = $source_indent - 1;
1520 my $spaces_to_tab = " " x $source_indent;
1521
1522 #convert leading spaces to tabs
1523 1 while $leading =~ s@^([\t]*)$spaces_to_tab@$1\t@g;
1524 #Remove spaces before a tab
1525 1 while $leading =~ s@^([\t]*)( {1,$max_spaces_before_tab})\t@$1\t@g;
1526
1527 return "$leading";
1528}
1529
1332sub pos_last_openparen { 1530sub pos_last_openparen {
1333 my ($line) = @_; 1531 my ($line) = @_;
1334 1532
@@ -1406,7 +1604,7 @@ sub process {
1406 my %suppress_export; 1604 my %suppress_export;
1407 my $suppress_statement = 0; 1605 my $suppress_statement = 0;
1408 1606
1409 my %camelcase = (); 1607 my %signatures = ();
1410 1608
1411 # Pre-scan the patch sanitizing the lines. 1609 # Pre-scan the patch sanitizing the lines.
1412 # Pre-scan the patch looking for any __setup documentation. 1610 # Pre-scan the patch looking for any __setup documentation.
@@ -1420,6 +1618,8 @@ sub process {
1420 $linenr++; 1618 $linenr++;
1421 $line = $rawline; 1619 $line = $rawline;
1422 1620
1621 push(@fixed, $rawline) if ($fix);
1622
1423 if ($rawline=~/^\+\+\+\s+(\S+)/) { 1623 if ($rawline=~/^\+\+\+\s+(\S+)/) {
1424 $setup_docs = 0; 1624 $setup_docs = 0;
1425 if ($1 =~ m@Documentation/kernel-parameters.txt$@) { 1625 if ($1 =~ m@Documentation/kernel-parameters.txt$@) {
@@ -1497,6 +1697,8 @@ sub process {
1497 $linenr = 0; 1697 $linenr = 0;
1498 foreach my $line (@lines) { 1698 foreach my $line (@lines) {
1499 $linenr++; 1699 $linenr++;
1700 my $sline = $line; #copy of $line
1701 $sline =~ s/$;/ /g; #with comments as spaces
1500 1702
1501 my $rawline = $rawlines[$linenr - 1]; 1703 my $rawline = $rawlines[$linenr - 1];
1502 1704
@@ -1611,16 +1813,29 @@ sub process {
1611 "Non-standard signature: $sign_off\n" . $herecurr); 1813 "Non-standard signature: $sign_off\n" . $herecurr);
1612 } 1814 }
1613 if (defined $space_before && $space_before ne "") { 1815 if (defined $space_before && $space_before ne "") {
1614 WARN("BAD_SIGN_OFF", 1816 if (WARN("BAD_SIGN_OFF",
1615 "Do not use whitespace before $ucfirst_sign_off\n" . $herecurr); 1817 "Do not use whitespace before $ucfirst_sign_off\n" . $herecurr) &&
1818 $fix) {
1819 $fixed[$linenr - 1] =
1820 "$ucfirst_sign_off $email";
1821 }
1616 } 1822 }
1617 if ($sign_off =~ /-by:$/i && $sign_off ne $ucfirst_sign_off) { 1823 if ($sign_off =~ /-by:$/i && $sign_off ne $ucfirst_sign_off) {
1618 WARN("BAD_SIGN_OFF", 1824 if (WARN("BAD_SIGN_OFF",
1619 "'$ucfirst_sign_off' is the preferred signature form\n" . $herecurr); 1825 "'$ucfirst_sign_off' is the preferred signature form\n" . $herecurr) &&
1826 $fix) {
1827 $fixed[$linenr - 1] =
1828 "$ucfirst_sign_off $email";
1829 }
1830
1620 } 1831 }
1621 if (!defined $space_after || $space_after ne " ") { 1832 if (!defined $space_after || $space_after ne " ") {
1622 WARN("BAD_SIGN_OFF", 1833 if (WARN("BAD_SIGN_OFF",
1623 "Use a single space after $ucfirst_sign_off\n" . $herecurr); 1834 "Use a single space after $ucfirst_sign_off\n" . $herecurr) &&
1835 $fix) {
1836 $fixed[$linenr - 1] =
1837 "$ucfirst_sign_off $email";
1838 }
1624 } 1839 }
1625 1840
1626 my ($email_name, $email_address, $comment) = parse_email($email); 1841 my ($email_name, $email_address, $comment) = parse_email($email);
@@ -1641,6 +1856,17 @@ sub process {
1641 "email address '$email' might be better as '$suggested_email$comment'\n" . $herecurr); 1856 "email address '$email' might be better as '$suggested_email$comment'\n" . $herecurr);
1642 } 1857 }
1643 } 1858 }
1859
1860# Check for duplicate signatures
1861 my $sig_nospace = $line;
1862 $sig_nospace =~ s/\s//g;
1863 $sig_nospace = lc($sig_nospace);
1864 if (defined $signatures{$sig_nospace}) {
1865 WARN("BAD_SIGN_OFF",
1866 "Duplicate signature\n" . $herecurr);
1867 } else {
1868 $signatures{$sig_nospace} = 1;
1869 }
1644 } 1870 }
1645 1871
1646# Check for wrappage within a valid hunk of the file 1872# Check for wrappage within a valid hunk of the file
@@ -1705,13 +1931,19 @@ sub process {
1705#trailing whitespace 1931#trailing whitespace
1706 if ($line =~ /^\+.*\015/) { 1932 if ($line =~ /^\+.*\015/) {
1707 my $herevet = "$here\n" . cat_vet($rawline) . "\n"; 1933 my $herevet = "$here\n" . cat_vet($rawline) . "\n";
1708 ERROR("DOS_LINE_ENDINGS", 1934 if (ERROR("DOS_LINE_ENDINGS",
1709 "DOS line endings\n" . $herevet); 1935 "DOS line endings\n" . $herevet) &&
1710 1936 $fix) {
1937 $fixed[$linenr - 1] =~ s/[\s\015]+$//;
1938 }
1711 } elsif ($rawline =~ /^\+.*\S\s+$/ || $rawline =~ /^\+\s+$/) { 1939 } elsif ($rawline =~ /^\+.*\S\s+$/ || $rawline =~ /^\+\s+$/) {
1712 my $herevet = "$here\n" . cat_vet($rawline) . "\n"; 1940 my $herevet = "$here\n" . cat_vet($rawline) . "\n";
1713 ERROR("TRAILING_WHITESPACE", 1941 if (ERROR("TRAILING_WHITESPACE",
1714 "trailing whitespace\n" . $herevet); 1942 "trailing whitespace\n" . $herevet) &&
1943 $fix) {
1944 $fixed[$linenr - 1] =~ s/\s+$//;
1945 }
1946
1715 $rpt_cleaners = 1; 1947 $rpt_cleaners = 1;
1716 } 1948 }
1717 1949
@@ -1806,8 +2038,12 @@ sub process {
1806 2038
1807# check for spaces before a quoted newline 2039# check for spaces before a quoted newline
1808 if ($rawline =~ /^.*\".*\s\\n/) { 2040 if ($rawline =~ /^.*\".*\s\\n/) {
1809 WARN("QUOTED_WHITESPACE_BEFORE_NEWLINE", 2041 if (WARN("QUOTED_WHITESPACE_BEFORE_NEWLINE",
1810 "unnecessary whitespace before a quoted newline\n" . $herecurr); 2042 "unnecessary whitespace before a quoted newline\n" . $herecurr) &&
2043 $fix) {
2044 $fixed[$linenr - 1] =~ s/^(\+.*\".*)\s+\\n/$1\\n/;
2045 }
2046
1811 } 2047 }
1812 2048
1813# check for adding lines without a newline. 2049# check for adding lines without a newline.
@@ -1838,16 +2074,23 @@ sub process {
1838 if ($rawline =~ /^\+\s* \t\s*\S/ || 2074 if ($rawline =~ /^\+\s* \t\s*\S/ ||
1839 $rawline =~ /^\+\s* \s*/) { 2075 $rawline =~ /^\+\s* \s*/) {
1840 my $herevet = "$here\n" . cat_vet($rawline) . "\n"; 2076 my $herevet = "$here\n" . cat_vet($rawline) . "\n";
1841 ERROR("CODE_INDENT",
1842 "code indent should use tabs where possible\n" . $herevet);
1843 $rpt_cleaners = 1; 2077 $rpt_cleaners = 1;
2078 if (ERROR("CODE_INDENT",
2079 "code indent should use tabs where possible\n" . $herevet) &&
2080 $fix) {
2081 $fixed[$linenr - 1] =~ s/^\+([ \t]+)/"\+" . tabify($1)/e;
2082 }
1844 } 2083 }
1845 2084
1846# check for space before tabs. 2085# check for space before tabs.
1847 if ($rawline =~ /^\+/ && $rawline =~ / \t/) { 2086 if ($rawline =~ /^\+/ && $rawline =~ / \t/) {
1848 my $herevet = "$here\n" . cat_vet($rawline) . "\n"; 2087 my $herevet = "$here\n" . cat_vet($rawline) . "\n";
1849 WARN("SPACE_BEFORE_TAB", 2088 if (WARN("SPACE_BEFORE_TAB",
1850 "please, no space before tabs\n" . $herevet); 2089 "please, no space before tabs\n" . $herevet) &&
2090 $fix) {
2091 $fixed[$linenr - 1] =~
2092 s/(^\+.*) +\t/$1\t/;
2093 }
1851 } 2094 }
1852 2095
1853# check for && or || at the start of a line 2096# check for && or || at the start of a line
@@ -1875,25 +2118,43 @@ sub process {
1875 2118
1876 if ($newindent ne $goodtabindent && 2119 if ($newindent ne $goodtabindent &&
1877 $newindent ne $goodspaceindent) { 2120 $newindent ne $goodspaceindent) {
1878 CHK("PARENTHESIS_ALIGNMENT", 2121
1879 "Alignment should match open parenthesis\n" . $hereprev); 2122 if (CHK("PARENTHESIS_ALIGNMENT",
2123 "Alignment should match open parenthesis\n" . $hereprev) &&
2124 $fix && $line =~ /^\+/) {
2125 $fixed[$linenr - 1] =~
2126 s/^\+[ \t]*/\+$goodtabindent/;
2127 }
1880 } 2128 }
1881 } 2129 }
1882 } 2130 }
1883 2131
1884 if ($line =~ /^\+.*\*[ \t]*\)[ \t]+/) { 2132 if ($line =~ /^\+.*\*[ \t]*\)[ \t]+(?!$Assignment|$Arithmetic)/) {
1885 CHK("SPACING", 2133 if (CHK("SPACING",
1886 "No space is necessary after a cast\n" . $hereprev); 2134 "No space is necessary after a cast\n" . $hereprev) &&
2135 $fix) {
2136 $fixed[$linenr - 1] =~
2137 s/^(\+.*\*[ \t]*\))[ \t]+/$1/;
2138 }
1887 } 2139 }
1888 2140
1889 if ($realfile =~ m@^(drivers/net/|net/)@ && 2141 if ($realfile =~ m@^(drivers/net/|net/)@ &&
1890 $rawline =~ /^\+[ \t]*\/\*[ \t]*$/ && 2142 $prevrawline =~ /^\+[ \t]*\/\*[ \t]*$/ &&
1891 $prevrawline =~ /^\+[ \t]*$/) { 2143 $rawline =~ /^\+[ \t]*\*/) {
1892 WARN("NETWORKING_BLOCK_COMMENT_STYLE", 2144 WARN("NETWORKING_BLOCK_COMMENT_STYLE",
1893 "networking block comments don't use an empty /* line, use /* Comment...\n" . $hereprev); 2145 "networking block comments don't use an empty /* line, use /* Comment...\n" . $hereprev);
1894 } 2146 }
1895 2147
1896 if ($realfile =~ m@^(drivers/net/|net/)@ && 2148 if ($realfile =~ m@^(drivers/net/|net/)@ &&
2149 $prevrawline =~ /^\+[ \t]*\/\*/ && #starting /*
2150 $prevrawline !~ /\*\/[ \t]*$/ && #no trailing */
2151 $rawline =~ /^\+/ && #line is new
2152 $rawline !~ /^\+[ \t]*\*/) { #no leading *
2153 WARN("NETWORKING_BLOCK_COMMENT_STYLE",
2154 "networking block comments start with * on subsequent lines\n" . $hereprev);
2155 }
2156
2157 if ($realfile =~ m@^(drivers/net/|net/)@ &&
1897 $rawline !~ m@^\+[ \t]*\*/[ \t]*$@ && #trailing */ 2158 $rawline !~ m@^\+[ \t]*\*/[ \t]*$@ && #trailing */
1898 $rawline !~ m@^\+.*/\*.*\*/[ \t]*$@ && #inline /*...*/ 2159 $rawline !~ m@^\+.*/\*.*\*/[ \t]*$@ && #inline /*...*/
1899 $rawline !~ m@^\+.*\*{2,}/[ \t]*$@ && #trailing **/ 2160 $rawline !~ m@^\+.*\*{2,}/[ \t]*$@ && #trailing **/
@@ -1907,10 +2168,13 @@ sub process {
1907# 1) within comments 2168# 1) within comments
1908# 2) indented preprocessor commands 2169# 2) indented preprocessor commands
1909# 3) hanging labels 2170# 3) hanging labels
1910 if ($rawline =~ /^\+ / && $line !~ /\+ *(?:$;|#|$Ident:)/) { 2171 if ($rawline =~ /^\+ / && $line !~ /^\+ *(?:$;|#|$Ident:)/) {
1911 my $herevet = "$here\n" . cat_vet($rawline) . "\n"; 2172 my $herevet = "$here\n" . cat_vet($rawline) . "\n";
1912 WARN("LEADING_SPACE", 2173 if (WARN("LEADING_SPACE",
1913 "please, no spaces at the start of a line\n" . $herevet); 2174 "please, no spaces at the start of a line\n" . $herevet) &&
2175 $fix) {
2176 $fixed[$linenr - 1] =~ s/^\+([ \t]+)/"\+" . tabify($1)/e;
2177 }
1914 } 2178 }
1915 2179
1916# check we are in a valid C source file if not then ignore this hunk 2180# check we are in a valid C source file if not then ignore this hunk
@@ -1951,7 +2215,7 @@ sub process {
1951 $realline_next); 2215 $realline_next);
1952#print "LINE<$line>\n"; 2216#print "LINE<$line>\n";
1953 if ($linenr >= $suppress_statement && 2217 if ($linenr >= $suppress_statement &&
1954 $realcnt && $line =~ /.\s*\S/) { 2218 $realcnt && $sline =~ /.\s*\S/) {
1955 ($stat, $cond, $line_nr_next, $remain_next, $off_next) = 2219 ($stat, $cond, $line_nr_next, $remain_next, $off_next) =
1956 ctx_statement_block($linenr, $realcnt, 0); 2220 ctx_statement_block($linenr, $realcnt, 0);
1957 $stat =~ s/\n./\n /g; 2221 $stat =~ s/\n./\n /g;
@@ -2200,7 +2464,7 @@ sub process {
2200 $prev_values = substr($curr_values, -1); 2464 $prev_values = substr($curr_values, -1);
2201 2465
2202#ignore lines not being added 2466#ignore lines not being added
2203 if ($line=~/^[^\+]/) {next;} 2467 next if ($line =~ /^[^\+]/);
2204 2468
2205# TEST: allow direct testing of the type matcher. 2469# TEST: allow direct testing of the type matcher.
2206 if ($dbg_type) { 2470 if ($dbg_type) {
@@ -2251,8 +2515,15 @@ sub process {
2251 2515
2252# no C99 // comments 2516# no C99 // comments
2253 if ($line =~ m{//}) { 2517 if ($line =~ m{//}) {
2254 ERROR("C99_COMMENTS", 2518 if (ERROR("C99_COMMENTS",
2255 "do not use C99 // comments\n" . $herecurr); 2519 "do not use C99 // comments\n" . $herecurr) &&
2520 $fix) {
2521 my $line = $fixed[$linenr - 1];
2522 if ($line =~ /\/\/(.*)$/) {
2523 my $comment = trim($1);
2524 $fixed[$linenr - 1] =~ s@\/\/(.*)$@/\* $comment \*/@;
2525 }
2526 }
2256 } 2527 }
2257 # Remove C99 comments. 2528 # Remove C99 comments.
2258 $line =~ s@//.*@@; 2529 $line =~ s@//.*@@;
@@ -2304,16 +2575,22 @@ sub process {
2304 } 2575 }
2305 2576
2306# check for global initialisers. 2577# check for global initialisers.
2307 if ($line =~ /^.$Type\s*$Ident\s*(?:\s+$Modifier)*\s*=\s*(0|NULL|false)\s*;/) { 2578 if ($line =~ /^\+(\s*$Type\s*$Ident\s*(?:\s+$Modifier))*\s*=\s*(0|NULL|false)\s*;/) {
2308 ERROR("GLOBAL_INITIALISERS", 2579 if (ERROR("GLOBAL_INITIALISERS",
2309 "do not initialise globals to 0 or NULL\n" . 2580 "do not initialise globals to 0 or NULL\n" .
2310 $herecurr); 2581 $herecurr) &&
2582 $fix) {
2583 $fixed[$linenr - 1] =~ s/($Type\s*$Ident\s*(?:\s+$Modifier))*\s*=\s*(0|NULL|false)\s*;/$1;/;
2584 }
2311 } 2585 }
2312# check for static initialisers. 2586# check for static initialisers.
2313 if ($line =~ /\bstatic\s.*=\s*(0|NULL|false)\s*;/) { 2587 if ($line =~ /^\+.*\bstatic\s.*=\s*(0|NULL|false)\s*;/) {
2314 ERROR("INITIALISED_STATIC", 2588 if (ERROR("INITIALISED_STATIC",
2315 "do not initialise statics to 0 or NULL\n" . 2589 "do not initialise statics to 0 or NULL\n" .
2316 $herecurr); 2590 $herecurr) &&
2591 $fix) {
2592 $fixed[$linenr - 1] =~ s/(\bstatic\s.*?)\s*=\s*(0|NULL|false)\s*;/$1;/;
2593 }
2317 } 2594 }
2318 2595
2319# check for static const char * arrays. 2596# check for static const char * arrays.
@@ -2351,7 +2628,7 @@ sub process {
2351 # (char*[ const]) 2628 # (char*[ const])
2352 while ($line =~ m{(\($NonptrType(\s*(?:$Modifier\b\s*|\*\s*)+)\))}g) { 2629 while ($line =~ m{(\($NonptrType(\s*(?:$Modifier\b\s*|\*\s*)+)\))}g) {
2353 #print "AA<$1>\n"; 2630 #print "AA<$1>\n";
2354 my ($from, $to) = ($2, $2); 2631 my ($ident, $from, $to) = ($1, $2, $2);
2355 2632
2356 # Should start with a space. 2633 # Should start with a space.
2357 $to =~ s/^(\S)/ $1/; 2634 $to =~ s/^(\S)/ $1/;
@@ -2361,15 +2638,22 @@ sub process {
2361 while ($to =~ s/\*\s+\*/\*\*/) { 2638 while ($to =~ s/\*\s+\*/\*\*/) {
2362 } 2639 }
2363 2640
2364 #print "from<$from> to<$to>\n"; 2641## print "1: from<$from> to<$to> ident<$ident>\n";
2365 if ($from ne $to) { 2642 if ($from ne $to) {
2366 ERROR("POINTER_LOCATION", 2643 if (ERROR("POINTER_LOCATION",
2367 "\"(foo$from)\" should be \"(foo$to)\"\n" . $herecurr); 2644 "\"(foo$from)\" should be \"(foo$to)\"\n" . $herecurr) &&
2645 $fix) {
2646 my $sub_from = $ident;
2647 my $sub_to = $ident;
2648 $sub_to =~ s/\Q$from\E/$to/;
2649 $fixed[$linenr - 1] =~
2650 s@\Q$sub_from\E@$sub_to@;
2651 }
2368 } 2652 }
2369 } 2653 }
2370 while ($line =~ m{(\b$NonptrType(\s*(?:$Modifier\b\s*|\*\s*)+)($Ident))}g) { 2654 while ($line =~ m{(\b$NonptrType(\s*(?:$Modifier\b\s*|\*\s*)+)($Ident))}g) {
2371 #print "BB<$1>\n"; 2655 #print "BB<$1>\n";
2372 my ($from, $to, $ident) = ($2, $2, $3); 2656 my ($match, $from, $to, $ident) = ($1, $2, $2, $3);
2373 2657
2374 # Should start with a space. 2658 # Should start with a space.
2375 $to =~ s/^(\S)/ $1/; 2659 $to =~ s/^(\S)/ $1/;
@@ -2381,10 +2665,18 @@ sub process {
2381 # Modifiers should have spaces. 2665 # Modifiers should have spaces.
2382 $to =~ s/(\b$Modifier$)/$1 /; 2666 $to =~ s/(\b$Modifier$)/$1 /;
2383 2667
2384 #print "from<$from> to<$to> ident<$ident>\n"; 2668## print "2: from<$from> to<$to> ident<$ident>\n";
2385 if ($from ne $to && $ident !~ /^$Modifier$/) { 2669 if ($from ne $to && $ident !~ /^$Modifier$/) {
2386 ERROR("POINTER_LOCATION", 2670 if (ERROR("POINTER_LOCATION",
2387 "\"foo${from}bar\" should be \"foo${to}bar\"\n" . $herecurr); 2671 "\"foo${from}bar\" should be \"foo${to}bar\"\n" . $herecurr) &&
2672 $fix) {
2673
2674 my $sub_from = $match;
2675 my $sub_to = $match;
2676 $sub_to =~ s/\Q$from\E/$to/;
2677 $fixed[$linenr - 1] =~
2678 s@\Q$sub_from\E@$sub_to@;
2679 }
2388 } 2680 }
2389 } 2681 }
2390 2682
@@ -2441,8 +2733,12 @@ sub process {
2441 } 2733 }
2442 2734
2443 if ($line =~ /\bpr_warning\s*\(/) { 2735 if ($line =~ /\bpr_warning\s*\(/) {
2444 WARN("PREFER_PR_LEVEL", 2736 if (WARN("PREFER_PR_LEVEL",
2445 "Prefer pr_warn(... to pr_warning(...\n" . $herecurr); 2737 "Prefer pr_warn(... to pr_warning(...\n" . $herecurr) &&
2738 $fix) {
2739 $fixed[$linenr - 1] =~
2740 s/\bpr_warning\b/pr_warn/;
2741 }
2446 } 2742 }
2447 2743
2448 if ($line =~ /\bdev_printk\s*\(\s*KERN_([A-Z]+)/) { 2744 if ($line =~ /\bdev_printk\s*\(\s*KERN_([A-Z]+)/) {
@@ -2470,9 +2766,13 @@ sub process {
2470 } 2766 }
2471 2767
2472# missing space after union, struct or enum definition 2768# missing space after union, struct or enum definition
2473 if ($line =~ /^.\s*(?:typedef\s+)?(enum|union|struct)(?:\s+$Ident)?(?:\s+$Ident)?[=\{]/) { 2769 if ($line =~ /^.\s*(?:typedef\s+)?(enum|union|struct)(?:\s+$Ident){1,2}[=\{]/) {
2474 WARN("SPACING", 2770 if (WARN("SPACING",
2475 "missing space after $1 definition\n" . $herecurr); 2771 "missing space after $1 definition\n" . $herecurr) &&
2772 $fix) {
2773 $fixed[$linenr - 1] =~
2774 s/^(.\s*(?:typedef\s+)?(?:enum|union|struct)(?:\s+$Ident){1,2})([=\{])/$1 $2/;
2775 }
2476 } 2776 }
2477 2777
2478# check for spacing round square brackets; allowed: 2778# check for spacing round square brackets; allowed:
@@ -2484,8 +2784,12 @@ sub process {
2484 if ($prefix !~ /$Type\s+$/ && 2784 if ($prefix !~ /$Type\s+$/ &&
2485 ($where != 0 || $prefix !~ /^.\s+$/) && 2785 ($where != 0 || $prefix !~ /^.\s+$/) &&
2486 $prefix !~ /[{,]\s+$/) { 2786 $prefix !~ /[{,]\s+$/) {
2487 ERROR("BRACKET_SPACE", 2787 if (ERROR("BRACKET_SPACE",
2488 "space prohibited before open square bracket '['\n" . $herecurr); 2788 "space prohibited before open square bracket '['\n" . $herecurr) &&
2789 $fix) {
2790 $fixed[$linenr - 1] =~
2791 s/^(\+.*?)\s+\[/$1\[/;
2792 }
2489 } 2793 }
2490 } 2794 }
2491 2795
@@ -2502,7 +2806,6 @@ sub process {
2502 __attribute__|format|__extension__| 2806 __attribute__|format|__extension__|
2503 asm|__asm__)$/x) 2807 asm|__asm__)$/x)
2504 { 2808 {
2505
2506 # cpp #define statements have non-optional spaces, ie 2809 # cpp #define statements have non-optional spaces, ie
2507 # if there is a space between the name and the open 2810 # if there is a space between the name and the open
2508 # parenthesis it is simply not a parameter group. 2811 # parenthesis it is simply not a parameter group.
@@ -2516,19 +2819,20 @@ sub process {
2516 } elsif ($ctx =~ /$Type$/) { 2819 } elsif ($ctx =~ /$Type$/) {
2517 2820
2518 } else { 2821 } else {
2519 WARN("SPACING", 2822 if (WARN("SPACING",
2520 "space prohibited between function name and open parenthesis '('\n" . $herecurr); 2823 "space prohibited between function name and open parenthesis '('\n" . $herecurr) &&
2824 $fix) {
2825 $fixed[$linenr - 1] =~
2826 s/\b$name\s+\(/$name\(/;
2827 }
2521 } 2828 }
2522 } 2829 }
2523 2830
2524# check for whitespace before a non-naked semicolon
2525 if ($line =~ /^\+.*\S\s+;/) {
2526 WARN("SPACING",
2527 "space prohibited before semicolon\n" . $herecurr);
2528 }
2529
2530# Check operator spacing. 2831# Check operator spacing.
2531 if (!($line=~/\#\s*include/)) { 2832 if (!($line=~/\#\s*include/)) {
2833 my $fixed_line = "";
2834 my $line_fixed = 0;
2835
2532 my $ops = qr{ 2836 my $ops = qr{
2533 <<=|>>=|<=|>=|==|!=| 2837 <<=|>>=|<=|>=|==|!=|
2534 \+=|-=|\*=|\/=|%=|\^=|\|=|&=| 2838 \+=|-=|\*=|\/=|%=|\^=|\|=|&=|
@@ -2537,11 +2841,31 @@ sub process {
2537 \?|: 2841 \?|:
2538 }x; 2842 }x;
2539 my @elements = split(/($ops|;)/, $opline); 2843 my @elements = split(/($ops|;)/, $opline);
2844
2845## print("element count: <" . $#elements . ">\n");
2846## foreach my $el (@elements) {
2847## print("el: <$el>\n");
2848## }
2849
2850 my @fix_elements = ();
2540 my $off = 0; 2851 my $off = 0;
2541 2852
2853 foreach my $el (@elements) {
2854 push(@fix_elements, substr($rawline, $off, length($el)));
2855 $off += length($el);
2856 }
2857
2858 $off = 0;
2859
2542 my $blank = copy_spacing($opline); 2860 my $blank = copy_spacing($opline);
2861 my $last_after = -1;
2543 2862
2544 for (my $n = 0; $n < $#elements; $n += 2) { 2863 for (my $n = 0; $n < $#elements; $n += 2) {
2864
2865 my $good = $fix_elements[$n] . $fix_elements[$n + 1];
2866
2867## print("n: <$n> good: <$good>\n");
2868
2545 $off += length($elements[$n]); 2869 $off += length($elements[$n]);
2546 2870
2547 # Pick up the preceding and succeeding characters. 2871 # Pick up the preceding and succeeding characters.
@@ -2598,8 +2922,11 @@ sub process {
2598 } elsif ($op eq ';') { 2922 } elsif ($op eq ';') {
2599 if ($ctx !~ /.x[WEBC]/ && 2923 if ($ctx !~ /.x[WEBC]/ &&
2600 $cc !~ /^\\/ && $cc !~ /^;/) { 2924 $cc !~ /^\\/ && $cc !~ /^;/) {
2601 ERROR("SPACING", 2925 if (ERROR("SPACING",
2602 "space required after that '$op' $at\n" . $hereptr); 2926 "space required after that '$op' $at\n" . $hereptr)) {
2927 $good = $fix_elements[$n] . trim($fix_elements[$n + 1]) . " ";
2928 $line_fixed = 1;
2929 }
2603 } 2930 }
2604 2931
2605 # // is a comment 2932 # // is a comment
@@ -2610,15 +2937,25 @@ sub process {
2610 # : when part of a bitfield 2937 # : when part of a bitfield
2611 } elsif ($op eq '->' || $opv eq ':B') { 2938 } elsif ($op eq '->' || $opv eq ':B') {
2612 if ($ctx =~ /Wx.|.xW/) { 2939 if ($ctx =~ /Wx.|.xW/) {
2613 ERROR("SPACING", 2940 if (ERROR("SPACING",
2614 "spaces prohibited around that '$op' $at\n" . $hereptr); 2941 "spaces prohibited around that '$op' $at\n" . $hereptr)) {
2942 $good = rtrim($fix_elements[$n]) . trim($fix_elements[$n + 1]);
2943 if (defined $fix_elements[$n + 2]) {
2944 $fix_elements[$n + 2] =~ s/^\s+//;
2945 }
2946 $line_fixed = 1;
2947 }
2615 } 2948 }
2616 2949
2617 # , must have a space on the right. 2950 # , must have a space on the right.
2618 } elsif ($op eq ',') { 2951 } elsif ($op eq ',') {
2619 if ($ctx !~ /.x[WEC]/ && $cc !~ /^}/) { 2952 if ($ctx !~ /.x[WEC]/ && $cc !~ /^}/) {
2620 ERROR("SPACING", 2953 if (ERROR("SPACING",
2621 "space required after that '$op' $at\n" . $hereptr); 2954 "space required after that '$op' $at\n" . $hereptr)) {
2955 $good = $fix_elements[$n] . trim($fix_elements[$n + 1]) . " ";
2956 $line_fixed = 1;
2957 $last_after = $n;
2958 }
2622 } 2959 }
2623 2960
2624 # '*' as part of a type definition -- reported already. 2961 # '*' as part of a type definition -- reported already.
@@ -2632,34 +2969,56 @@ sub process {
2632 $opv eq '*U' || $opv eq '-U' || 2969 $opv eq '*U' || $opv eq '-U' ||
2633 $opv eq '&U' || $opv eq '&&U') { 2970 $opv eq '&U' || $opv eq '&&U') {
2634 if ($ctx !~ /[WEBC]x./ && $ca !~ /(?:\)|!|~|\*|-|\&|\||\+\+|\-\-|\{)$/) { 2971 if ($ctx !~ /[WEBC]x./ && $ca !~ /(?:\)|!|~|\*|-|\&|\||\+\+|\-\-|\{)$/) {
2635 ERROR("SPACING", 2972 if (ERROR("SPACING",
2636 "space required before that '$op' $at\n" . $hereptr); 2973 "space required before that '$op' $at\n" . $hereptr)) {
2974 if ($n != $last_after + 2) {
2975 $good = $fix_elements[$n] . " " . ltrim($fix_elements[$n + 1]);
2976 $line_fixed = 1;
2977 }
2978 }
2637 } 2979 }
2638 if ($op eq '*' && $cc =~/\s*$Modifier\b/) { 2980 if ($op eq '*' && $cc =~/\s*$Modifier\b/) {
2639 # A unary '*' may be const 2981 # A unary '*' may be const
2640 2982
2641 } elsif ($ctx =~ /.xW/) { 2983 } elsif ($ctx =~ /.xW/) {
2642 ERROR("SPACING", 2984 if (ERROR("SPACING",
2643 "space prohibited after that '$op' $at\n" . $hereptr); 2985 "space prohibited after that '$op' $at\n" . $hereptr)) {
2986 $good = $fix_elements[$n] . rtrim($fix_elements[$n + 1]);
2987 if (defined $fix_elements[$n + 2]) {
2988 $fix_elements[$n + 2] =~ s/^\s+//;
2989 }
2990 $line_fixed = 1;
2991 }
2644 } 2992 }
2645 2993
2646 # unary ++ and unary -- are allowed no space on one side. 2994 # unary ++ and unary -- are allowed no space on one side.
2647 } elsif ($op eq '++' or $op eq '--') { 2995 } elsif ($op eq '++' or $op eq '--') {
2648 if ($ctx !~ /[WEOBC]x[^W]/ && $ctx !~ /[^W]x[WOBEC]/) { 2996 if ($ctx !~ /[WEOBC]x[^W]/ && $ctx !~ /[^W]x[WOBEC]/) {
2649 ERROR("SPACING", 2997 if (ERROR("SPACING",
2650 "space required one side of that '$op' $at\n" . $hereptr); 2998 "space required one side of that '$op' $at\n" . $hereptr)) {
2999 $good = $fix_elements[$n] . trim($fix_elements[$n + 1]) . " ";
3000 $line_fixed = 1;
3001 }
2651 } 3002 }
2652 if ($ctx =~ /Wx[BE]/ || 3003 if ($ctx =~ /Wx[BE]/ ||
2653 ($ctx =~ /Wx./ && $cc =~ /^;/)) { 3004 ($ctx =~ /Wx./ && $cc =~ /^;/)) {
2654 ERROR("SPACING", 3005 if (ERROR("SPACING",
2655 "space prohibited before that '$op' $at\n" . $hereptr); 3006 "space prohibited before that '$op' $at\n" . $hereptr)) {
3007 $good = rtrim($fix_elements[$n]) . trim($fix_elements[$n + 1]);
3008 $line_fixed = 1;
3009 }
2656 } 3010 }
2657 if ($ctx =~ /ExW/) { 3011 if ($ctx =~ /ExW/) {
2658 ERROR("SPACING", 3012 if (ERROR("SPACING",
2659 "space prohibited after that '$op' $at\n" . $hereptr); 3013 "space prohibited after that '$op' $at\n" . $hereptr)) {
3014 $good = $fix_elements[$n] . trim($fix_elements[$n + 1]);
3015 if (defined $fix_elements[$n + 2]) {
3016 $fix_elements[$n + 2] =~ s/^\s+//;
3017 }
3018 $line_fixed = 1;
3019 }
2660 } 3020 }
2661 3021
2662
2663 # << and >> may either have or not have spaces both sides 3022 # << and >> may either have or not have spaces both sides
2664 } elsif ($op eq '<<' or $op eq '>>' or 3023 } elsif ($op eq '<<' or $op eq '>>' or
2665 $op eq '&' or $op eq '^' or $op eq '|' or 3024 $op eq '&' or $op eq '^' or $op eq '|' or
@@ -2668,17 +3027,25 @@ sub process {
2668 $op eq '%') 3027 $op eq '%')
2669 { 3028 {
2670 if ($ctx =~ /Wx[^WCE]|[^WCE]xW/) { 3029 if ($ctx =~ /Wx[^WCE]|[^WCE]xW/) {
2671 ERROR("SPACING", 3030 if (ERROR("SPACING",
2672 "need consistent spacing around '$op' $at\n" . 3031 "need consistent spacing around '$op' $at\n" . $hereptr)) {
2673 $hereptr); 3032 $good = rtrim($fix_elements[$n]) . " " . trim($fix_elements[$n + 1]) . " ";
3033 if (defined $fix_elements[$n + 2]) {
3034 $fix_elements[$n + 2] =~ s/^\s+//;
3035 }
3036 $line_fixed = 1;
3037 }
2674 } 3038 }
2675 3039
2676 # A colon needs no spaces before when it is 3040 # A colon needs no spaces before when it is
2677 # terminating a case value or a label. 3041 # terminating a case value or a label.
2678 } elsif ($opv eq ':C' || $opv eq ':L') { 3042 } elsif ($opv eq ':C' || $opv eq ':L') {
2679 if ($ctx =~ /Wx./) { 3043 if ($ctx =~ /Wx./) {
2680 ERROR("SPACING", 3044 if (ERROR("SPACING",
2681 "space prohibited before that '$op' $at\n" . $hereptr); 3045 "space prohibited before that '$op' $at\n" . $hereptr)) {
3046 $good = rtrim($fix_elements[$n]) . trim($fix_elements[$n + 1]);
3047 $line_fixed = 1;
3048 }
2682 } 3049 }
2683 3050
2684 # All the others need spaces both sides. 3051 # All the others need spaces both sides.
@@ -2701,11 +3068,41 @@ sub process {
2701 } 3068 }
2702 3069
2703 if ($ok == 0) { 3070 if ($ok == 0) {
2704 ERROR("SPACING", 3071 if (ERROR("SPACING",
2705 "spaces required around that '$op' $at\n" . $hereptr); 3072 "spaces required around that '$op' $at\n" . $hereptr)) {
3073 $good = rtrim($fix_elements[$n]) . " " . trim($fix_elements[$n + 1]) . " ";
3074 if (defined $fix_elements[$n + 2]) {
3075 $fix_elements[$n + 2] =~ s/^\s+//;
3076 }
3077 $line_fixed = 1;
3078 }
2706 } 3079 }
2707 } 3080 }
2708 $off += length($elements[$n + 1]); 3081 $off += length($elements[$n + 1]);
3082
3083## print("n: <$n> GOOD: <$good>\n");
3084
3085 $fixed_line = $fixed_line . $good;
3086 }
3087
3088 if (($#elements % 2) == 0) {
3089 $fixed_line = $fixed_line . $fix_elements[$#elements];
3090 }
3091
3092 if ($fix && $line_fixed && $fixed_line ne $fixed[$linenr - 1]) {
3093 $fixed[$linenr - 1] = $fixed_line;
3094 }
3095
3096
3097 }
3098
3099# check for whitespace before a non-naked semicolon
3100 if ($line =~ /^\+.*\S\s+;/) {
3101 if (WARN("SPACING",
3102 "space prohibited before semicolon\n" . $herecurr) &&
3103 $fix) {
3104 1 while $fixed[$linenr - 1] =~
3105 s/^(\+.*\S)\s+;/$1;/;
2709 } 3106 }
2710 } 3107 }
2711 3108
@@ -2734,45 +3131,80 @@ sub process {
2734#need space before brace following if, while, etc 3131#need space before brace following if, while, etc
2735 if (($line =~ /\(.*\){/ && $line !~ /\($Type\){/) || 3132 if (($line =~ /\(.*\){/ && $line !~ /\($Type\){/) ||
2736 $line =~ /do{/) { 3133 $line =~ /do{/) {
2737 ERROR("SPACING", 3134 if (ERROR("SPACING",
2738 "space required before the open brace '{'\n" . $herecurr); 3135 "space required before the open brace '{'\n" . $herecurr) &&
3136 $fix) {
3137 $fixed[$linenr - 1] =~ s/^(\+.*(?:do|\))){/$1 {/;
3138 }
2739 } 3139 }
2740 3140
3141## # check for blank lines before declarations
3142## if ($line =~ /^.\t+$Type\s+$Ident(?:\s*=.*)?;/ &&
3143## $prevrawline =~ /^.\s*$/) {
3144## WARN("SPACING",
3145## "No blank lines before declarations\n" . $hereprev);
3146## }
3147##
3148
2741# closing brace should have a space following it when it has anything 3149# closing brace should have a space following it when it has anything
2742# on the line 3150# on the line
2743 if ($line =~ /}(?!(?:,|;|\)))\S/) { 3151 if ($line =~ /}(?!(?:,|;|\)))\S/) {
2744 ERROR("SPACING", 3152 if (ERROR("SPACING",
2745 "space required after that close brace '}'\n" . $herecurr); 3153 "space required after that close brace '}'\n" . $herecurr) &&
3154 $fix) {
3155 $fixed[$linenr - 1] =~
3156 s/}((?!(?:,|;|\)))\S)/} $1/;
3157 }
2746 } 3158 }
2747 3159
2748# check spacing on square brackets 3160# check spacing on square brackets
2749 if ($line =~ /\[\s/ && $line !~ /\[\s*$/) { 3161 if ($line =~ /\[\s/ && $line !~ /\[\s*$/) {
2750 ERROR("SPACING", 3162 if (ERROR("SPACING",
2751 "space prohibited after that open square bracket '['\n" . $herecurr); 3163 "space prohibited after that open square bracket '['\n" . $herecurr) &&
3164 $fix) {
3165 $fixed[$linenr - 1] =~
3166 s/\[\s+/\[/;
3167 }
2752 } 3168 }
2753 if ($line =~ /\s\]/) { 3169 if ($line =~ /\s\]/) {
2754 ERROR("SPACING", 3170 if (ERROR("SPACING",
2755 "space prohibited before that close square bracket ']'\n" . $herecurr); 3171 "space prohibited before that close square bracket ']'\n" . $herecurr) &&
3172 $fix) {
3173 $fixed[$linenr - 1] =~
3174 s/\s+\]/\]/;
3175 }
2756 } 3176 }
2757 3177
2758# check spacing on parentheses 3178# check spacing on parentheses
2759 if ($line =~ /\(\s/ && $line !~ /\(\s*(?:\\)?$/ && 3179 if ($line =~ /\(\s/ && $line !~ /\(\s*(?:\\)?$/ &&
2760 $line !~ /for\s*\(\s+;/) { 3180 $line !~ /for\s*\(\s+;/) {
2761 ERROR("SPACING", 3181 if (ERROR("SPACING",
2762 "space prohibited after that open parenthesis '('\n" . $herecurr); 3182 "space prohibited after that open parenthesis '('\n" . $herecurr) &&
3183 $fix) {
3184 $fixed[$linenr - 1] =~
3185 s/\(\s+/\(/;
3186 }
2763 } 3187 }
2764 if ($line =~ /(\s+)\)/ && $line !~ /^.\s*\)/ && 3188 if ($line =~ /(\s+)\)/ && $line !~ /^.\s*\)/ &&
2765 $line !~ /for\s*\(.*;\s+\)/ && 3189 $line !~ /for\s*\(.*;\s+\)/ &&
2766 $line !~ /:\s+\)/) { 3190 $line !~ /:\s+\)/) {
2767 ERROR("SPACING", 3191 if (ERROR("SPACING",
2768 "space prohibited before that close parenthesis ')'\n" . $herecurr); 3192 "space prohibited before that close parenthesis ')'\n" . $herecurr) &&
3193 $fix) {
3194 $fixed[$linenr - 1] =~
3195 s/\s+\)/\)/;
3196 }
2769 } 3197 }
2770 3198
2771#goto labels aren't indented, allow a single space however 3199#goto labels aren't indented, allow a single space however
2772 if ($line=~/^.\s+[A-Za-z\d_]+:(?![0-9]+)/ and 3200 if ($line=~/^.\s+[A-Za-z\d_]+:(?![0-9]+)/ and
2773 !($line=~/^. [A-Za-z\d_]+:/) and !($line=~/^.\s+default:/)) { 3201 !($line=~/^. [A-Za-z\d_]+:/) and !($line=~/^.\s+default:/)) {
2774 WARN("INDENTED_LABEL", 3202 if (WARN("INDENTED_LABEL",
2775 "labels should not be indented\n" . $herecurr); 3203 "labels should not be indented\n" . $herecurr) &&
3204 $fix) {
3205 $fixed[$linenr - 1] =~
3206 s/^(.)\s+/$1/;
3207 }
2776 } 3208 }
2777 3209
2778# Return is not a function. 3210# Return is not a function.
@@ -2809,8 +3241,13 @@ sub process {
2809 } 3241 }
2810 3242
2811# Need a space before open parenthesis after if, while etc 3243# Need a space before open parenthesis after if, while etc
2812 if ($line=~/\b(if|while|for|switch)\(/) { 3244 if ($line =~ /\b(if|while|for|switch)\(/) {
2813 ERROR("SPACING", "space required before the open parenthesis '('\n" . $herecurr); 3245 if (ERROR("SPACING",
3246 "space required before the open parenthesis '('\n" . $herecurr) &&
3247 $fix) {
3248 $fixed[$linenr - 1] =~
3249 s/\b(if|while|for|switch)\(/$1 \(/;
3250 }
2814 } 3251 }
2815 3252
2816# Check for illegal assignment in if conditional -- and check for trailing 3253# Check for illegal assignment in if conditional -- and check for trailing
@@ -2934,23 +3371,48 @@ sub process {
2934 } 3371 }
2935 } 3372 }
2936 3373
2937#CamelCase 3374#Specific variable tests
2938 while ($line =~ m{($Constant|$Lval)}g) { 3375 while ($line =~ m{($Constant|$Lval)}g) {
2939 my $var = $1; 3376 my $var = $1;
2940 if ($var !~ /$Constant/ && 3377
2941 $var =~ /[A-Z]\w*[a-z]|[a-z]\w*[A-Z]/ && 3378#gcc binary extension
2942 $var !~ /"^(?:Clear|Set|TestClear|TestSet|)Page[A-Z]/ && 3379 if ($var =~ /^$Binary$/) {
2943 !defined $camelcase{$var}) { 3380 if (WARN("GCC_BINARY_CONSTANT",
2944 $camelcase{$var} = 1; 3381 "Avoid gcc v4.3+ binary constant extension: <$var>\n" . $herecurr) &&
2945 WARN("CAMELCASE", 3382 $fix) {
2946 "Avoid CamelCase: <$var>\n" . $herecurr); 3383 my $hexval = sprintf("0x%x", oct($var));
3384 $fixed[$linenr - 1] =~
3385 s/\b$var\b/$hexval/;
3386 }
3387 }
3388
3389#CamelCase
3390 if ($var !~ /^$Constant$/ &&
3391 $var =~ /[A-Z][a-z]|[a-z][A-Z]/ &&
3392#Ignore Page<foo> variants
3393 $var !~ /^(?:Clear|Set|TestClear|TestSet|)Page[A-Z]/ &&
3394#Ignore SI style variants like nS, mV and dB (ie: max_uV, regulator_min_uA_show)
3395 $var !~ /^(?:[a-z_]*?)_?[a-z][A-Z](?:_[a-z_]+)?$/) {
3396 while ($var =~ m{($Ident)}g) {
3397 my $word = $1;
3398 next if ($word !~ /[A-Z][a-z]|[a-z][A-Z]/);
3399 seed_camelcase_includes() if ($check);
3400 if (!defined $camelcase{$word}) {
3401 $camelcase{$word} = 1;
3402 CHK("CAMELCASE",
3403 "Avoid CamelCase: <$word>\n" . $herecurr);
3404 }
3405 }
2947 } 3406 }
2948 } 3407 }
2949 3408
2950#no spaces allowed after \ in define 3409#no spaces allowed after \ in define
2951 if ($line=~/\#\s*define.*\\\s$/) { 3410 if ($line =~ /\#\s*define.*\\\s+$/) {
2952 WARN("WHITESPACE_AFTER_LINE_CONTINUATION", 3411 if (WARN("WHITESPACE_AFTER_LINE_CONTINUATION",
2953 "Whitepspace after \\ makes next lines useless\n" . $herecurr); 3412 "Whitespace after \\ makes next lines useless\n" . $herecurr) &&
3413 $fix) {
3414 $fixed[$linenr - 1] =~ s/\s+$//;
3415 }
2954 } 3416 }
2955 3417
2956#warn if <asm/foo.h> is #included and <linux/foo.h> is available (uses RAW line) 3418#warn if <asm/foo.h> is #included and <linux/foo.h> is available (uses RAW line)
@@ -3021,7 +3483,7 @@ sub process {
3021 if ($dstat ne '' && 3483 if ($dstat ne '' &&
3022 $dstat !~ /^(?:$Ident|-?$Constant),$/ && # 10, // foo(), 3484 $dstat !~ /^(?:$Ident|-?$Constant),$/ && # 10, // foo(),
3023 $dstat !~ /^(?:$Ident|-?$Constant);$/ && # foo(); 3485 $dstat !~ /^(?:$Ident|-?$Constant);$/ && # foo();
3024 $dstat !~ /^[!~-]?(?:$Ident|$Constant)$/ && # 10 // foo() // !foo // ~foo // -foo 3486 $dstat !~ /^[!~-]?(?:$Lval|$Constant)$/ && # 10 // foo() // !foo // ~foo // -foo // foo->bar // foo.bar->baz
3025 $dstat !~ /^'X'$/ && # character constants 3487 $dstat !~ /^'X'$/ && # character constants
3026 $dstat !~ /$exceptions/ && 3488 $dstat !~ /$exceptions/ &&
3027 $dstat !~ /^\.$Ident\s*=/ && # .foo = 3489 $dstat !~ /^\.$Ident\s*=/ && # .foo =
@@ -3030,7 +3492,8 @@ sub process {
3030 $dstat !~ /^for\s*$Constant$/ && # for (...) 3492 $dstat !~ /^for\s*$Constant$/ && # for (...)
3031 $dstat !~ /^for\s*$Constant\s+(?:$Ident|-?$Constant)$/ && # for (...) bar() 3493 $dstat !~ /^for\s*$Constant\s+(?:$Ident|-?$Constant)$/ && # for (...) bar()
3032 $dstat !~ /^do\s*{/ && # do {... 3494 $dstat !~ /^do\s*{/ && # do {...
3033 $dstat !~ /^\({/) # ({... 3495 $dstat !~ /^\({/ && # ({...
3496 $ctx !~ /^.\s*#\s*define\s+TRACE_(?:SYSTEM|INCLUDE_FILE|INCLUDE_PATH)\b/)
3034 { 3497 {
3035 $ctx =~ s/\n*$//; 3498 $ctx =~ s/\n*$//;
3036 my $herectx = $here . "\n"; 3499 my $herectx = $here . "\n";
@@ -3230,11 +3693,11 @@ sub process {
3230 } 3693 }
3231 3694
3232# check for unnecessary blank lines around braces 3695# check for unnecessary blank lines around braces
3233 if (($line =~ /^.\s*}\s*$/ && $prevline =~ /^.\s*$/)) { 3696 if (($line =~ /^.\s*}\s*$/ && $prevrawline =~ /^.\s*$/)) {
3234 CHK("BRACES", 3697 CHK("BRACES",
3235 "Blank lines aren't necessary before a close brace '}'\n" . $hereprev); 3698 "Blank lines aren't necessary before a close brace '}'\n" . $hereprev);
3236 } 3699 }
3237 if (($line =~ /^.\s*$/ && $prevline =~ /^..*{\s*$/)) { 3700 if (($rawline =~ /^.\s*$/ && $prevline =~ /^..*{\s*$/)) {
3238 CHK("BRACES", 3701 CHK("BRACES",
3239 "Blank lines aren't necessary after an open brace '{'\n" . $hereprev); 3702 "Blank lines aren't necessary after an open brace '{'\n" . $hereprev);
3240 } 3703 }
@@ -3262,6 +3725,32 @@ sub process {
3262 } 3725 }
3263 } 3726 }
3264 3727
3728sub string_find_replace {
3729 my ($string, $find, $replace) = @_;
3730
3731 $string =~ s/$find/$replace/g;
3732
3733 return $string;
3734}
3735
3736# check for bad placement of section $InitAttribute (e.g.: __initdata)
3737 if ($line =~ /(\b$InitAttribute\b)/) {
3738 my $attr = $1;
3739 if ($line =~ /^\+\s*static\s+(?:const\s+)?(?:$attr\s+)?($NonptrTypeWithAttr)\s+(?:$attr\s+)?($Ident(?:\[[^]]*\])?)\s*[=;]/) {
3740 my $ptr = $1;
3741 my $var = $2;
3742 if ((($ptr =~ /\b(union|struct)\s+$attr\b/ &&
3743 ERROR("MISPLACED_INIT",
3744 "$attr should be placed after $var\n" . $herecurr)) ||
3745 ($ptr !~ /\b(union|struct)\s+$attr\b/ &&
3746 WARN("MISPLACED_INIT",
3747 "$attr should be placed after $var\n" . $herecurr))) &&
3748 $fix) {
3749 $fixed[$linenr - 1] =~ s/(\bstatic\s+(?:const\s+)?)(?:$attr\s+)?($NonptrTypeWithAttr)\s+(?:$attr\s+)?($Ident(?:\[[^]]*\])?)\s*([=;])\s*/"$1" . trim(string_find_replace($2, "\\s*$attr\\s*", " ")) . " " . trim(string_find_replace($3, "\\s*$attr\\s*", "")) . " $attr" . ("$4" eq ";" ? ";" : " = ")/e;
3750 }
3751 }
3752 }
3753
3265# prefer usleep_range over udelay 3754# prefer usleep_range over udelay
3266 if ($line =~ /\budelay\s*\(\s*(\d+)\s*\)/) { 3755 if ($line =~ /\budelay\s*\(\s*(\d+)\s*\)/) {
3267 # ignore udelay's < 10, however 3756 # ignore udelay's < 10, however
@@ -3279,6 +3768,18 @@ sub process {
3279 } 3768 }
3280 } 3769 }
3281 3770
3771# check for comparisons of jiffies
3772 if ($line =~ /\bjiffies\s*$Compare|$Compare\s*jiffies\b/) {
3773 WARN("JIFFIES_COMPARISON",
3774 "Comparing jiffies is almost always wrong; prefer time_after, time_before and friends\n" . $herecurr);
3775 }
3776
3777# check for comparisons of get_jiffies_64()
3778 if ($line =~ /\bget_jiffies_64\s*\(\s*\)\s*$Compare|$Compare\s*get_jiffies_64\s*\(\s*\)/) {
3779 WARN("JIFFIES_COMPARISON",
3780 "Comparing get_jiffies_64() is almost always wrong; prefer time_after64, time_before64 and friends\n" . $herecurr);
3781 }
3782
3282# warn about #ifdefs in C files 3783# warn about #ifdefs in C files
3283# if ($line =~ /^.\s*\#\s*if(|n)def/ && ($realfile =~ /\.c$/)) { 3784# if ($line =~ /^.\s*\#\s*if(|n)def/ && ($realfile =~ /\.c$/)) {
3284# print "#ifdef in C files should be avoided\n"; 3785# print "#ifdef in C files should be avoided\n";
@@ -3288,8 +3789,13 @@ sub process {
3288 3789
3289# warn about spacing in #ifdefs 3790# warn about spacing in #ifdefs
3290 if ($line =~ /^.\s*\#\s*(ifdef|ifndef|elif)\s\s+/) { 3791 if ($line =~ /^.\s*\#\s*(ifdef|ifndef|elif)\s\s+/) {
3291 ERROR("SPACING", 3792 if (ERROR("SPACING",
3292 "exactly one space required after that #$1\n" . $herecurr); 3793 "exactly one space required after that #$1\n" . $herecurr) &&
3794 $fix) {
3795 $fixed[$linenr - 1] =~
3796 s/^(.\s*\#\s*(ifdef|ifndef|elif))\s{2,}/$1 /;
3797 }
3798
3293 } 3799 }
3294 3800
3295# check for spinlock_t definitions without a comment. 3801# check for spinlock_t definitions without a comment.
@@ -3330,8 +3836,12 @@ sub process {
3330 3836
3331# Check for __inline__ and __inline, prefer inline 3837# Check for __inline__ and __inline, prefer inline
3332 if ($line =~ /\b(__inline__|__inline)\b/) { 3838 if ($line =~ /\b(__inline__|__inline)\b/) {
3333 WARN("INLINE", 3839 if (WARN("INLINE",
3334 "plain inline is preferred over $1\n" . $herecurr); 3840 "plain inline is preferred over $1\n" . $herecurr) &&
3841 $fix) {
3842 $fixed[$linenr - 1] =~ s/\b(__inline__|__inline)\b/inline/;
3843
3844 }
3335 } 3845 }
3336 3846
3337# Check for __attribute__ packed, prefer __packed 3847# Check for __attribute__ packed, prefer __packed
@@ -3348,14 +3858,21 @@ sub process {
3348 3858
3349# Check for __attribute__ format(printf, prefer __printf 3859# Check for __attribute__ format(printf, prefer __printf
3350 if ($line =~ /\b__attribute__\s*\(\s*\(\s*format\s*\(\s*printf/) { 3860 if ($line =~ /\b__attribute__\s*\(\s*\(\s*format\s*\(\s*printf/) {
3351 WARN("PREFER_PRINTF", 3861 if (WARN("PREFER_PRINTF",
3352 "__printf(string-index, first-to-check) is preferred over __attribute__((format(printf, string-index, first-to-check)))\n" . $herecurr); 3862 "__printf(string-index, first-to-check) is preferred over __attribute__((format(printf, string-index, first-to-check)))\n" . $herecurr) &&
3863 $fix) {
3864 $fixed[$linenr - 1] =~ s/\b__attribute__\s*\(\s*\(\s*format\s*\(\s*printf\s*,\s*(.*)\)\s*\)\s*\)/"__printf(" . trim($1) . ")"/ex;
3865
3866 }
3353 } 3867 }
3354 3868
3355# Check for __attribute__ format(scanf, prefer __scanf 3869# Check for __attribute__ format(scanf, prefer __scanf
3356 if ($line =~ /\b__attribute__\s*\(\s*\(\s*format\s*\(\s*scanf\b/) { 3870 if ($line =~ /\b__attribute__\s*\(\s*\(\s*format\s*\(\s*scanf\b/) {
3357 WARN("PREFER_SCANF", 3871 if (WARN("PREFER_SCANF",
3358 "__scanf(string-index, first-to-check) is preferred over __attribute__((format(scanf, string-index, first-to-check)))\n" . $herecurr); 3872 "__scanf(string-index, first-to-check) is preferred over __attribute__((format(scanf, string-index, first-to-check)))\n" . $herecurr) &&
3873 $fix) {
3874 $fixed[$linenr - 1] =~ s/\b__attribute__\s*\(\s*\(\s*format\s*\(\s*scanf\s*,\s*(.*)\)\s*\)\s*\)/"__scanf(" . trim($1) . ")"/ex;
3875 }
3359 } 3876 }
3360 3877
3361# check for sizeof(&) 3878# check for sizeof(&)
@@ -3366,8 +3883,11 @@ sub process {
3366 3883
3367# check for sizeof without parenthesis 3884# check for sizeof without parenthesis
3368 if ($line =~ /\bsizeof\s+((?:\*\s*|)$Lval|$Type(?:\s+$Lval|))/) { 3885 if ($line =~ /\bsizeof\s+((?:\*\s*|)$Lval|$Type(?:\s+$Lval|))/) {
3369 WARN("SIZEOF_PARENTHESIS", 3886 if (WARN("SIZEOF_PARENTHESIS",
3370 "sizeof $1 should be sizeof($1)\n" . $herecurr); 3887 "sizeof $1 should be sizeof($1)\n" . $herecurr) &&
3888 $fix) {
3889 $fixed[$linenr - 1] =~ s/\bsizeof\s+((?:\*\s*|)$Lval|$Type(?:\s+$Lval|))/"sizeof(" . trim($1) . ")"/ex;
3890 }
3371 } 3891 }
3372 3892
3373# check for line continuations in quoted strings with odd counts of " 3893# check for line continuations in quoted strings with odd counts of "
@@ -3386,8 +3906,11 @@ sub process {
3386 if ($line =~ /\bseq_printf\s*\(/) { 3906 if ($line =~ /\bseq_printf\s*\(/) {
3387 my $fmt = get_quoted_string($line, $rawline); 3907 my $fmt = get_quoted_string($line, $rawline);
3388 if ($fmt !~ /[^\\]\%/) { 3908 if ($fmt !~ /[^\\]\%/) {
3389 WARN("PREFER_SEQ_PUTS", 3909 if (WARN("PREFER_SEQ_PUTS",
3390 "Prefer seq_puts to seq_printf\n" . $herecurr); 3910 "Prefer seq_puts to seq_printf\n" . $herecurr) &&
3911 $fix) {
3912 $fixed[$linenr - 1] =~ s/\bseq_printf\b/seq_puts/;
3913 }
3391 } 3914 }
3392 } 3915 }
3393 3916
@@ -3449,6 +3972,16 @@ sub process {
3449 } 3972 }
3450 } 3973 }
3451 3974
3975# check for new externs in .h files.
3976 if ($realfile =~ /\.h$/ &&
3977 $line =~ /^\+\s*(extern\s+)$Type\s*$Ident\s*\(/s) {
3978 if (CHK("AVOID_EXTERNS",
3979 "extern prototypes should be avoided in .h files\n" . $herecurr) &&
3980 $fix) {
3981 $fixed[$linenr - 1] =~ s/(.*)\bextern\b\s*(.*)/$1$2/;
3982 }
3983 }
3984
3452# check for new externs in .c files. 3985# check for new externs in .c files.
3453 if ($realfile =~ /\.c$/ && defined $stat && 3986 if ($realfile =~ /\.c$/ && defined $stat &&
3454 $stat =~ /^.\s*(?:extern\s+)?$Type\s+($Ident)(\s*)\(/s) 3987 $stat =~ /^.\s*(?:extern\s+)?$Type\s+($Ident)(\s*)\(/s)
@@ -3495,6 +4028,14 @@ sub process {
3495 "unnecessary cast may hide bugs, see http://c-faq.com/malloc/mallocnocast.html\n" . $herecurr); 4028 "unnecessary cast may hide bugs, see http://c-faq.com/malloc/mallocnocast.html\n" . $herecurr);
3496 } 4029 }
3497 4030
4031# alloc style
4032# p = alloc(sizeof(struct foo), ...) should be p = alloc(sizeof(*p), ...)
4033 if ($^V && $^V ge 5.10.0 &&
4034 $line =~ /\b($Lval)\s*\=\s*(?:$balanced_parens)?\s*([kv][mz]alloc(?:_node)?)\s*\(\s*(sizeof\s*\(\s*struct\s+$Lval\s*\))/) {
4035 CHK("ALLOC_SIZEOF_STRUCT",
4036 "Prefer $3(sizeof(*$1)...) over $3($4...)\n" . $herecurr);
4037 }
4038
3498# check for krealloc arg reuse 4039# check for krealloc arg reuse
3499 if ($^V && $^V ge 5.10.0 && 4040 if ($^V && $^V ge 5.10.0 &&
3500 $line =~ /\b($Lval)\s*\=\s*(?:$balanced_parens)?\s*krealloc\s*\(\s*\1\s*,/) { 4041 $line =~ /\b($Lval)\s*\=\s*(?:$balanced_parens)?\s*krealloc\s*\(\s*\1\s*,/) {
@@ -3510,8 +4051,11 @@ sub process {
3510 4051
3511# check for multiple semicolons 4052# check for multiple semicolons
3512 if ($line =~ /;\s*;\s*$/) { 4053 if ($line =~ /;\s*;\s*$/) {
3513 WARN("ONE_SEMICOLON", 4054 if (WARN("ONE_SEMICOLON",
3514 "Statements terminations use 1 semicolon\n" . $herecurr); 4055 "Statements terminations use 1 semicolon\n" . $herecurr) &&
4056 $fix) {
4057 $fixed[$linenr - 1] =~ s/(\s*;\s*){2,}$/;/g;
4058 }
3515 } 4059 }
3516 4060
3517# check for switch/default statements without a break; 4061# check for switch/default statements without a break;
@@ -3529,9 +4073,12 @@ sub process {
3529 } 4073 }
3530 4074
3531# check for gcc specific __FUNCTION__ 4075# check for gcc specific __FUNCTION__
3532 if ($line =~ /__FUNCTION__/) { 4076 if ($line =~ /\b__FUNCTION__\b/) {
3533 WARN("USE_FUNC", 4077 if (WARN("USE_FUNC",
3534 "__func__ should be used instead of gcc specific __FUNCTION__\n" . $herecurr); 4078 "__func__ should be used instead of gcc specific __FUNCTION__\n" . $herecurr) &&
4079 $fix) {
4080 $fixed[$linenr - 1] =~ s/\b__FUNCTION__\b/__func__/g;
4081 }
3535 } 4082 }
3536 4083
3537# check for use of yield() 4084# check for use of yield()
@@ -3540,6 +4087,33 @@ sub process {
3540 "Using yield() is generally wrong. See yield() kernel-doc (sched/core.c)\n" . $herecurr); 4087 "Using yield() is generally wrong. See yield() kernel-doc (sched/core.c)\n" . $herecurr);
3541 } 4088 }
3542 4089
4090# check for comparisons against true and false
4091 if ($line =~ /\+\s*(.*?)\b(true|false|$Lval)\s*(==|\!=)\s*(true|false|$Lval)\b(.*)$/i) {
4092 my $lead = $1;
4093 my $arg = $2;
4094 my $test = $3;
4095 my $otype = $4;
4096 my $trail = $5;
4097 my $op = "!";
4098
4099 ($arg, $otype) = ($otype, $arg) if ($arg =~ /^(?:true|false)$/i);
4100
4101 my $type = lc($otype);
4102 if ($type =~ /^(?:true|false)$/) {
4103 if (("$test" eq "==" && "$type" eq "true") ||
4104 ("$test" eq "!=" && "$type" eq "false")) {
4105 $op = "";
4106 }
4107
4108 CHK("BOOL_COMPARISON",
4109 "Using comparison to $otype is error prone\n" . $herecurr);
4110
4111## maybe suggesting a correct construct would better
4112## "Using comparison to $otype is error prone. Perhaps use '${lead}${op}${arg}${trail}'\n" . $herecurr);
4113
4114 }
4115 }
4116
3543# check for semaphores initialized locked 4117# check for semaphores initialized locked
3544 if ($line =~ /^.\s*sema_init.+,\W?0\W?\)/) { 4118 if ($line =~ /^.\s*sema_init.+,\W?0\W?\)/) {
3545 WARN("CONSIDER_COMPLETION", 4119 WARN("CONSIDER_COMPLETION",
@@ -3709,12 +4283,41 @@ sub process {
3709 } 4283 }
3710 } 4284 }
3711 4285
3712 if ($quiet == 0 && keys %ignore_type) { 4286 hash_show_words(\%use_type, "Used");
3713 print "NOTE: Ignored message types:"; 4287 hash_show_words(\%ignore_type, "Ignored");
3714 foreach my $ignore (sort keys %ignore_type) { 4288
3715 print " $ignore"; 4289 if ($clean == 0 && $fix && "@rawlines" ne "@fixed") {
3716 } 4290 my $newfile = $filename . ".EXPERIMENTAL-checkpatch-fixes";
3717 print "\n\n"; 4291 my $linecount = 0;
4292 my $f;
4293
4294 open($f, '>', $newfile)
4295 or die "$P: Can't open $newfile for write\n";
4296 foreach my $fixed_line (@fixed) {
4297 $linecount++;
4298 if ($file) {
4299 if ($linecount > 3) {
4300 $fixed_line =~ s/^\+//;
4301 print $f $fixed_line. "\n";
4302 }
4303 } else {
4304 print $f $fixed_line . "\n";
4305 }
4306 }
4307 close($f);
4308
4309 if (!$quiet) {
4310 print << "EOM";
4311Wrote EXPERIMENTAL --fix correction(s) to '$newfile'
4312
4313Do _NOT_ trust the results written to this file.
4314Do _NOT_ submit these changes without inspecting them for correctness.
4315
4316This EXPERIMENTAL file is simply a convenience to help rewrite patches.
4317No warranties, expressed or implied...
4318
4319EOM
4320 }
3718 } 4321 }
3719 4322
3720 if ($clean == 1 && $quiet == 0) { 4323 if ($clean == 1 && $quiet == 0) {
diff --git a/scripts/coccicheck b/scripts/coccicheck
index 06fcb3333247..bbf901afb606 100755
--- a/scripts/coccicheck
+++ b/scripts/coccicheck
@@ -1,17 +1,31 @@
1#!/bin/bash 1#!/bin/bash
2 2
3#
4# This script requires at least spatch
5# version 1.0.0-rc11.
6#
7
3SPATCH="`which ${SPATCH:=spatch}`" 8SPATCH="`which ${SPATCH:=spatch}`"
4 9
10trap kill_running SIGTERM SIGINT
11declare -a SPATCH_PID
12
5# The verbosity may be set by the environmental parameter V= 13# The verbosity may be set by the environmental parameter V=
6# as for example with 'make V=1 coccicheck' 14# as for example with 'make V=1 coccicheck'
7 15
8if [ -n "$V" -a "$V" != "0" ]; then 16if [ -n "$V" -a "$V" != "0" ]; then
9 VERBOSE=1 17 VERBOSE="$V"
10else 18else
11 VERBOSE=0 19 VERBOSE=0
12fi 20fi
13 21
14FLAGS="$SPFLAGS -very_quiet" 22if [ -z "$J" ]; then
23 NPROC=$(getconf _NPROCESSORS_ONLN)
24else
25 NPROC="$J"
26fi
27
28FLAGS="$SPFLAGS --very-quiet"
15 29
16# spatch only allows include directories with the syntax "-I include" 30# spatch only allows include directories with the syntax "-I include"
17# while gcc also allows "-Iinclude" and "-include include" 31# while gcc also allows "-Iinclude" and "-include include"
@@ -27,14 +41,14 @@ if [ "$C" = "1" -o "$C" = "2" ]; then
27else 41else
28 ONLINE=0 42 ONLINE=0
29 if [ "$KBUILD_EXTMOD" = "" ] ; then 43 if [ "$KBUILD_EXTMOD" = "" ] ; then
30 OPTIONS="-dir $srctree $COCCIINCLUDE" 44 OPTIONS="--dir $srctree $COCCIINCLUDE"
31 else 45 else
32 OPTIONS="-dir $KBUILD_EXTMOD $COCCIINCLUDE" 46 OPTIONS="--dir $KBUILD_EXTMOD $COCCIINCLUDE"
33 fi 47 fi
34fi 48fi
35 49
36if [ "$KBUILD_EXTMOD" != "" ] ; then 50if [ "$KBUILD_EXTMOD" != "" ] ; then
37 OPTIONS="-patch $srctree $OPTIONS" 51 OPTIONS="--patch $srctree $OPTIONS"
38fi 52fi
39 53
40if [ ! -x "$SPATCH" ]; then 54if [ ! -x "$SPATCH" ]; then
@@ -44,13 +58,21 @@ fi
44 58
45if [ "$MODE" = "" ] ; then 59if [ "$MODE" = "" ] ; then
46 if [ "$ONLINE" = "0" ] ; then 60 if [ "$ONLINE" = "0" ] ; then
47 echo 'You have not explicitly specified the mode to use. Using default "chain" mode.' 61 echo 'You have not explicitly specified the mode to use. Using default "report" mode.'
48 echo 'All available modes will be tried (in that order): patch, report, context, org' 62 echo 'Available modes are the following: patch, report, context, org'
49 echo 'You can specify the mode with "make coccicheck MODE=<mode>"' 63 echo 'You can specify the mode with "make coccicheck MODE=<mode>"'
64 echo 'Note however that some modes are not implemented by some semantic patches.'
65 fi
66 MODE="report"
67fi
68
69if [ "$MODE" = "chain" ] ; then
70 if [ "$ONLINE" = "0" ] ; then
71 echo 'You have selected the "chain" mode.'
72 echo 'All available modes will be tried (in that order): patch, report, context, org'
50 fi 73 fi
51 MODE="chain"
52elif [ "$MODE" = "report" -o "$MODE" = "org" ] ; then 74elif [ "$MODE" = "report" -o "$MODE" = "org" ] ; then
53 FLAGS="$FLAGS -no_show_diff" 75 FLAGS="$FLAGS --no-show-diff"
54fi 76fi
55 77
56if [ "$ONLINE" = "0" ] ; then 78if [ "$ONLINE" = "0" ] ; then
@@ -61,19 +83,35 @@ if [ "$ONLINE" = "0" ] ; then
61fi 83fi
62 84
63run_cmd() { 85run_cmd() {
86 local i
64 if [ $VERBOSE -ne 0 ] ; then 87 if [ $VERBOSE -ne 0 ] ; then
65 echo "Running: $@" 88 echo "Running ($NPROC in parallel): $@"
66 fi 89 fi
67 eval $@ 90 for i in $(seq 0 $(( NPROC - 1)) ); do
91 eval "$@ --max $NPROC --index $i &"
92 SPATCH_PID[$i]=$!
93 if [ $VERBOSE -eq 2 ] ; then
94 echo "${SPATCH_PID[$i]} running"
95 fi
96 done
97 wait
68} 98}
69 99
100kill_running() {
101 for i in $(seq $(( NPROC - 1 )) ); do
102 if [ $VERBOSE -eq 2 ] ; then
103 echo "Killing ${SPATCH_PID[$i]}"
104 fi
105 kill ${SPATCH_PID[$i]} 2>/dev/null
106 done
107}
70 108
71coccinelle () { 109coccinelle () {
72 COCCI="$1" 110 COCCI="$1"
73 111
74 OPT=`grep "Option" $COCCI | cut -d':' -f2` 112 OPT=`grep "Option" $COCCI | cut -d':' -f2`
75 113
76# The option '-parse_cocci' can be used to syntactically check the SmPL files. 114# The option '--parse-cocci' can be used to syntactically check the SmPL files.
77# 115#
78# $SPATCH -D $MODE $FLAGS -parse_cocci $COCCI $OPT > /dev/null 116# $SPATCH -D $MODE $FLAGS -parse_cocci $COCCI $OPT > /dev/null
79 117
@@ -114,20 +152,20 @@ coccinelle () {
114 152
115 if [ "$MODE" = "chain" ] ; then 153 if [ "$MODE" = "chain" ] ; then
116 run_cmd $SPATCH -D patch \ 154 run_cmd $SPATCH -D patch \
117 $FLAGS -sp_file $COCCI $OPT $OPTIONS || \ 155 $FLAGS --cocci-file $COCCI $OPT $OPTIONS || \
118 run_cmd $SPATCH -D report \ 156 run_cmd $SPATCH -D report \
119 $FLAGS -sp_file $COCCI $OPT $OPTIONS -no_show_diff || \ 157 $FLAGS --cocci-file $COCCI $OPT $OPTIONS --no-show-diff || \
120 run_cmd $SPATCH -D context \ 158 run_cmd $SPATCH -D context \
121 $FLAGS -sp_file $COCCI $OPT $OPTIONS || \ 159 $FLAGS --cocci-file $COCCI $OPT $OPTIONS || \
122 run_cmd $SPATCH -D org \ 160 run_cmd $SPATCH -D org \
123 $FLAGS -sp_file $COCCI $OPT $OPTIONS -no_show_diff || exit 1 161 $FLAGS --cocci-file $COCCI $OPT $OPTIONS --no-show-diff || exit 1
124 elif [ "$MODE" = "rep+ctxt" ] ; then 162 elif [ "$MODE" = "rep+ctxt" ] ; then
125 run_cmd $SPATCH -D report \ 163 run_cmd $SPATCH -D report \
126 $FLAGS -sp_file $COCCI $OPT $OPTIONS -no_show_diff && \ 164 $FLAGS --cocci-file $COCCI $OPT $OPTIONS --no-show-diff && \
127 run_cmd $SPATCH -D context \ 165 run_cmd $SPATCH -D context \
128 $FLAGS -sp_file $COCCI $OPT $OPTIONS || exit 1 166 $FLAGS --cocci-file $COCCI $OPT $OPTIONS || exit 1
129 else 167 else
130 run_cmd $SPATCH -D $MODE $FLAGS -sp_file $COCCI $OPT $OPTIONS || exit 1 168 run_cmd $SPATCH -D $MODE $FLAGS --cocci-file $COCCI $OPT $OPTIONS || exit 1
131 fi 169 fi
132 170
133} 171}
diff --git a/scripts/coccinelle/api/alloc/drop_kmalloc_cast.cocci b/scripts/coccinelle/api/alloc/drop_kmalloc_cast.cocci
index 7d4771d449c3..bd5d08b882ee 100644
--- a/scripts/coccinelle/api/alloc/drop_kmalloc_cast.cocci
+++ b/scripts/coccinelle/api/alloc/drop_kmalloc_cast.cocci
@@ -5,7 +5,7 @@
5// Confidence: High 5// Confidence: High
6// Copyright: 2009,2010 Nicolas Palix, DIKU. GPLv2. 6// Copyright: 2009,2010 Nicolas Palix, DIKU. GPLv2.
7// URL: http://coccinelle.lip6.fr/ 7// URL: http://coccinelle.lip6.fr/
8// Options: -no_includes -include_headers 8// Options: --no-includes --include-headers
9// 9//
10// Keywords: kmalloc, kzalloc, kcalloc 10// Keywords: kmalloc, kzalloc, kcalloc
11// Version min: < 2.6.12 kmalloc 11// Version min: < 2.6.12 kmalloc
diff --git a/scripts/coccinelle/api/alloc/kzalloc-simple.cocci b/scripts/coccinelle/api/alloc/kzalloc-simple.cocci
index 046b9b16f8f9..52c55e4fa67d 100644
--- a/scripts/coccinelle/api/alloc/kzalloc-simple.cocci
+++ b/scripts/coccinelle/api/alloc/kzalloc-simple.cocci
@@ -9,7 +9,7 @@
9// Copyright: (C) 2009-2010 Julia Lawall, Nicolas Palix, DIKU. GPLv2. 9// Copyright: (C) 2009-2010 Julia Lawall, Nicolas Palix, DIKU. GPLv2.
10// Copyright: (C) 2009-2010 Gilles Muller, INRIA/LiP6. GPLv2. 10// Copyright: (C) 2009-2010 Gilles Muller, INRIA/LiP6. GPLv2.
11// URL: http://coccinelle.lip6.fr/rules/kzalloc.html 11// URL: http://coccinelle.lip6.fr/rules/kzalloc.html
12// Options: -no_includes -include_headers 12// Options: --no-includes --include-headers
13// 13//
14// Keywords: kmalloc, kzalloc 14// Keywords: kmalloc, kzalloc
15// Version min: < 2.6.12 kmalloc 15// Version min: < 2.6.12 kmalloc
diff --git a/scripts/coccinelle/api/d_find_alias.cocci b/scripts/coccinelle/api/d_find_alias.cocci
index a9694a8d3e5a..9594c9f7eb8d 100644
--- a/scripts/coccinelle/api/d_find_alias.cocci
+++ b/scripts/coccinelle/api/d_find_alias.cocci
@@ -4,7 +4,7 @@
4// 4//
5// Confidence: Moderate 5// Confidence: Moderate
6// URL: http://coccinelle.lip6.fr/ 6// URL: http://coccinelle.lip6.fr/
7// Options: -include_headers 7// Options: --include-headers
8 8
9virtual context 9virtual context
10virtual org 10virtual org
diff --git a/scripts/coccinelle/api/devm_request_and_ioremap.cocci b/scripts/coccinelle/api/devm_request_and_ioremap.cocci
index 46beb81406ab..562ec88b6352 100644
--- a/scripts/coccinelle/api/devm_request_and_ioremap.cocci
+++ b/scripts/coccinelle/api/devm_request_and_ioremap.cocci
@@ -10,7 +10,7 @@
10// Copyright: (C) 2011 Gilles Muller, INRIA/LiP6. GPLv2. 10// Copyright: (C) 2011 Gilles Muller, INRIA/LiP6. GPLv2.
11// URL: http://coccinelle.lip6.fr/ 11// URL: http://coccinelle.lip6.fr/
12// Comments: 12// Comments:
13// Options: -no_includes -include_headers 13// Options: --no-includes --include-headers
14 14
15virtual patch 15virtual patch
16virtual org 16virtual org
diff --git a/scripts/coccinelle/api/kstrdup.cocci b/scripts/coccinelle/api/kstrdup.cocci
index 07a74b2c6196..09cba54ed0cf 100644
--- a/scripts/coccinelle/api/kstrdup.cocci
+++ b/scripts/coccinelle/api/kstrdup.cocci
@@ -6,7 +6,7 @@
6// Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6. GPLv2. 6// Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6. GPLv2.
7// URL: http://coccinelle.lip6.fr/ 7// URL: http://coccinelle.lip6.fr/
8// Comments: 8// Comments:
9// Options: -no_includes -include_headers 9// Options: --no-includes --include-headers
10 10
11virtual patch 11virtual patch
12virtual context 12virtual context
diff --git a/scripts/coccinelle/api/memdup.cocci b/scripts/coccinelle/api/memdup.cocci
index 4dceab6d54de..3d1aa71b7579 100644
--- a/scripts/coccinelle/api/memdup.cocci
+++ b/scripts/coccinelle/api/memdup.cocci
@@ -6,7 +6,7 @@
6// Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6. GPLv2. 6// Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6. GPLv2.
7// URL: http://coccinelle.lip6.fr/ 7// URL: http://coccinelle.lip6.fr/
8// Comments: 8// Comments:
9// Options: -no_includes -include_headers 9// Options: --no-includes --include-headers
10 10
11virtual patch 11virtual patch
12virtual context 12virtual context
diff --git a/scripts/coccinelle/api/memdup_user.cocci b/scripts/coccinelle/api/memdup_user.cocci
index 2b131a8a1306..c606231b0e46 100644
--- a/scripts/coccinelle/api/memdup_user.cocci
+++ b/scripts/coccinelle/api/memdup_user.cocci
@@ -7,7 +7,7 @@
7// Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6. GPLv2. 7// Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6. GPLv2.
8// URL: http://coccinelle.lip6.fr/ 8// URL: http://coccinelle.lip6.fr/
9// Comments: 9// Comments:
10// Options: -no_includes -include_headers 10// Options: --no-includes --include-headers
11 11
12virtual patch 12virtual patch
13virtual context 13virtual context
diff --git a/scripts/coccinelle/api/ptr_ret.cocci b/scripts/coccinelle/api/ptr_ret.cocci
index 15f076fdecbe..e18f8402e37c 100644
--- a/scripts/coccinelle/api/ptr_ret.cocci
+++ b/scripts/coccinelle/api/ptr_ret.cocci
@@ -1,13 +1,13 @@
1/// 1///
2/// Use PTR_RET rather than if(IS_ERR(...)) + PTR_ERR 2/// Use PTR_ERR_OR_ZERO rather than if(IS_ERR(...)) + PTR_ERR
3/// 3///
4// Confidence: High 4// Confidence: High
5// Copyright: (C) 2012 Julia Lawall, INRIA/LIP6. GPLv2. 5// Copyright: (C) 2012 Julia Lawall, INRIA/LIP6. GPLv2.
6// Copyright: (C) 2012 Gilles Muller, INRIA/LiP6. GPLv2. 6// Copyright: (C) 2012 Gilles Muller, INRIA/LiP6. GPLv2.
7// URL: http://coccinelle.lip6.fr/ 7// URL: http://coccinelle.lip6.fr/
8// Options: -no_includes -include_headers 8// Options: --no-includes --include-headers
9// 9//
10// Keywords: ERR_PTR, PTR_ERR, PTR_RET 10// Keywords: ERR_PTR, PTR_ERR, PTR_RET, PTR_ERR_OR_ZERO
11// Version min: 2.6.39 11// Version min: 2.6.39
12// 12//
13 13
@@ -21,21 +21,21 @@ expression ptr;
21@@ 21@@
22 22
23- if (IS_ERR(ptr)) return PTR_ERR(ptr); else return 0; 23- if (IS_ERR(ptr)) return PTR_ERR(ptr); else return 0;
24+ return PTR_RET(ptr); 24+ return PTR_ERR_OR_ZERO(ptr);
25 25
26@depends on patch@ 26@depends on patch@
27expression ptr; 27expression ptr;
28@@ 28@@
29 29
30- if (IS_ERR(ptr)) return PTR_ERR(ptr); return 0; 30- if (IS_ERR(ptr)) return PTR_ERR(ptr); return 0;
31+ return PTR_RET(ptr); 31+ return PTR_ERR_OR_ZERO(ptr);
32 32
33@depends on patch@ 33@depends on patch@
34expression ptr; 34expression ptr;
35@@ 35@@
36 36
37- (IS_ERR(ptr) ? PTR_ERR(ptr) : 0) 37- (IS_ERR(ptr) ? PTR_ERR(ptr) : 0)
38+ PTR_RET(ptr) 38+ PTR_ERR_OR_ZERO(ptr)
39 39
40@r1 depends on !patch@ 40@r1 depends on !patch@
41expression ptr; 41expression ptr;
diff --git a/scripts/coccinelle/api/simple_open.cocci b/scripts/coccinelle/api/simple_open.cocci
index 05962f7be155..b67e174f3d95 100644
--- a/scripts/coccinelle/api/simple_open.cocci
+++ b/scripts/coccinelle/api/simple_open.cocci
@@ -4,7 +4,7 @@
4/// 4///
5// Confidence: High 5// Confidence: High
6// Comments: 6// Comments:
7// Options: -no_includes -include_headers 7// Options: --no-includes --include-headers
8 8
9virtual patch 9virtual patch
10virtual report 10virtual report
diff --git a/scripts/coccinelle/free/devm_free.cocci b/scripts/coccinelle/free/devm_free.cocci
index 0a1e36146d76..3d9349012bb3 100644
--- a/scripts/coccinelle/free/devm_free.cocci
+++ b/scripts/coccinelle/free/devm_free.cocci
@@ -18,7 +18,7 @@
18// Copyright: (C) 2011 Gilles Muller, INRIA/LiP6. GPLv2. 18// Copyright: (C) 2011 Gilles Muller, INRIA/LiP6. GPLv2.
19// URL: http://coccinelle.lip6.fr/ 19// URL: http://coccinelle.lip6.fr/
20// Comments: 20// Comments:
21// Options: -no_includes -include_headers 21// Options: --no-includes --include-headers
22 22
23virtual org 23virtual org
24virtual report 24virtual report
diff --git a/scripts/coccinelle/free/kfree.cocci b/scripts/coccinelle/free/kfree.cocci
index d9ae6d89c2f5..577b78056990 100644
--- a/scripts/coccinelle/free/kfree.cocci
+++ b/scripts/coccinelle/free/kfree.cocci
@@ -10,7 +10,7 @@
10// Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6. GPLv2. 10// Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6. GPLv2.
11// URL: http://coccinelle.lip6.fr/ 11// URL: http://coccinelle.lip6.fr/
12// Comments: 12// Comments:
13// Options: -no_includes -include_headers 13// Options: --no-includes --include-headers
14 14
15virtual org 15virtual org
16virtual report 16virtual report
diff --git a/scripts/coccinelle/free/kfreeaddr.cocci b/scripts/coccinelle/free/kfreeaddr.cocci
new file mode 100644
index 000000000000..ce8aacc314cb
--- /dev/null
+++ b/scripts/coccinelle/free/kfreeaddr.cocci
@@ -0,0 +1,32 @@
1/// Free of a structure field
2///
3// Confidence: High
4// Copyright: (C) 2013 Julia Lawall, INRIA/LIP6. GPLv2.
5// URL: http://coccinelle.lip6.fr/
6// Comments:
7// Options: --no-includes --include-headers
8
9virtual org
10virtual report
11virtual context
12
13@r depends on context || report || org @
14expression e;
15identifier f;
16position p;
17@@
18
19* kfree@p(&e->f)
20
21@script:python depends on org@
22p << r.p;
23@@
24
25cocci.print_main("kfree",p)
26
27@script:python depends on report@
28p << r.p;
29@@
30
31msg = "ERROR: kfree of structure field"
32coccilib.report.print_report(p[0],msg)
diff --git a/scripts/coccinelle/free/pci_free_consistent.cocci b/scripts/coccinelle/free/pci_free_consistent.cocci
new file mode 100644
index 000000000000..43600ccb62a8
--- /dev/null
+++ b/scripts/coccinelle/free/pci_free_consistent.cocci
@@ -0,0 +1,52 @@
1/// Find missing pci_free_consistent for every pci_alloc_consistent.
2///
3// Confidence: Moderate
4// Copyright: (C) 2013 Petr Strnad. GPLv2.
5// URL: http://coccinelle.lip6.fr/
6// Keywords: pci_free_consistent, pci_alloc_consistent
7// Options: --no-includes --include-headers
8
9virtual report
10virtual org
11
12@search@
13local idexpression id;
14expression x,y,z,e;
15position p1,p2;
16type T;
17@@
18
19id = pci_alloc_consistent@p1(x,y,&z)
20... when != e = id
21if (id == NULL || ...) { ... return ...; }
22... when != pci_free_consistent(x,y,id,z)
23 when != if (id) { ... pci_free_consistent(x,y,id,z) ... }
24 when != if (y) { ... pci_free_consistent(x,y,id,z) ... }
25 when != e = (T)id
26 when exists
27(
28return 0;
29|
30return 1;
31|
32return id;
33|
34return@p2 ...;
35)
36
37@script:python depends on report@
38p1 << search.p1;
39p2 << search.p2;
40@@
41
42msg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on line %s and return without freeing on line %s" % (p1[0].line,p2[0].line)
43coccilib.report.print_report(p2[0],msg)
44
45@script:python depends on org@
46p1 << search.p1;
47p2 << search.p2;
48@@
49
50msg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on line %s and return without freeing on line %s" % (p1[0].line,p2[0].line)
51cocci.print_main(msg,p1)
52cocci.print_secs("",p2)
diff --git a/scripts/coccinelle/iterators/fen.cocci b/scripts/coccinelle/iterators/fen.cocci
index 0a40af828c43..48c152f224e1 100644
--- a/scripts/coccinelle/iterators/fen.cocci
+++ b/scripts/coccinelle/iterators/fen.cocci
@@ -7,7 +7,7 @@
7// Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6. GPLv2. 7// Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6. GPLv2.
8// URL: http://coccinelle.lip6.fr/ 8// URL: http://coccinelle.lip6.fr/
9// Comments: 9// Comments:
10// Options: -no_includes -include_headers 10// Options: --no-includes --include-headers
11 11
12virtual patch 12virtual patch
13virtual context 13virtual context
diff --git a/scripts/coccinelle/iterators/itnull.cocci b/scripts/coccinelle/iterators/itnull.cocci
index 259899f6838e..f58732b56a40 100644
--- a/scripts/coccinelle/iterators/itnull.cocci
+++ b/scripts/coccinelle/iterators/itnull.cocci
@@ -11,7 +11,7 @@
11// Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6. GPLv2. 11// Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6. GPLv2.
12// URL: http://coccinelle.lip6.fr/ 12// URL: http://coccinelle.lip6.fr/
13// Comments: 13// Comments:
14// Options: -no_includes -include_headers 14// Options: --no-includes --include-headers
15 15
16virtual patch 16virtual patch
17virtual context 17virtual context
diff --git a/scripts/coccinelle/iterators/list_entry_update.cocci b/scripts/coccinelle/iterators/list_entry_update.cocci
index b2967475679b..873f444e7137 100644
--- a/scripts/coccinelle/iterators/list_entry_update.cocci
+++ b/scripts/coccinelle/iterators/list_entry_update.cocci
@@ -9,7 +9,7 @@
9// Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2. 9// Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2.
10// URL: http://coccinelle.lip6.fr/ 10// URL: http://coccinelle.lip6.fr/
11// Comments: 11// Comments:
12// Options: -no_includes -include_headers 12// Options: --no-includes --include-headers
13 13
14virtual context 14virtual context
15virtual org 15virtual org
diff --git a/scripts/coccinelle/iterators/use_after_iter.cocci b/scripts/coccinelle/iterators/use_after_iter.cocci
index 06284c57a951..f085f5968c52 100644
--- a/scripts/coccinelle/iterators/use_after_iter.cocci
+++ b/scripts/coccinelle/iterators/use_after_iter.cocci
@@ -11,7 +11,7 @@
11// Copyright: (C) 2012 Gilles Muller, INRIA/LIP6. GPLv2. 11// Copyright: (C) 2012 Gilles Muller, INRIA/LIP6. GPLv2.
12// URL: http://coccinelle.lip6.fr/ 12// URL: http://coccinelle.lip6.fr/
13// Comments: 13// Comments:
14// Options: -no_includes -include_headers 14// Options: --no-includes --include-headers
15 15
16virtual context 16virtual context
17virtual org 17virtual org
diff --git a/scripts/coccinelle/locks/call_kern.cocci b/scripts/coccinelle/locks/call_kern.cocci
index 8f10b49603c3..669b24436248 100644
--- a/scripts/coccinelle/locks/call_kern.cocci
+++ b/scripts/coccinelle/locks/call_kern.cocci
@@ -9,7 +9,7 @@
9// Copyright: (C) 2012 Gilles Muller, INRIA/LiP6. GPLv2. 9// Copyright: (C) 2012 Gilles Muller, INRIA/LiP6. GPLv2.
10// URL: http://coccinelle.lip6.fr/ 10// URL: http://coccinelle.lip6.fr/
11// Comments: 11// Comments:
12// Options: -no_includes -include_headers 12// Options: --no-includes --include-headers
13 13
14virtual patch 14virtual patch
15virtual context 15virtual context
diff --git a/scripts/coccinelle/locks/double_lock.cocci b/scripts/coccinelle/locks/double_lock.cocci
index 63b24e682fad..002752f97dca 100644
--- a/scripts/coccinelle/locks/double_lock.cocci
+++ b/scripts/coccinelle/locks/double_lock.cocci
@@ -8,7 +8,7 @@
8// Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2. 8// Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2.
9// URL: http://coccinelle.lip6.fr/ 9// URL: http://coccinelle.lip6.fr/
10// Comments: 10// Comments:
11// Options: -no_includes -include_headers 11// Options: --no-includes --include-headers
12 12
13virtual org 13virtual org
14virtual report 14virtual report
diff --git a/scripts/coccinelle/locks/flags.cocci b/scripts/coccinelle/locks/flags.cocci
index 1c4ffe6fd846..debd70e46267 100644
--- a/scripts/coccinelle/locks/flags.cocci
+++ b/scripts/coccinelle/locks/flags.cocci
@@ -6,7 +6,7 @@
6// Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6. GPLv2. 6// Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6. GPLv2.
7// URL: http://coccinelle.lip6.fr/ 7// URL: http://coccinelle.lip6.fr/
8// Comments: 8// Comments:
9// Options: -no_includes -include_headers 9// Options: --no-includes --include-headers
10 10
11virtual context 11virtual context
12virtual org 12virtual org
diff --git a/scripts/coccinelle/locks/mini_lock.cocci b/scripts/coccinelle/locks/mini_lock.cocci
index 3267d7410bd5..47f649b0ea87 100644
--- a/scripts/coccinelle/locks/mini_lock.cocci
+++ b/scripts/coccinelle/locks/mini_lock.cocci
@@ -11,7 +11,7 @@
11// Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6. GPLv2. 11// Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6. GPLv2.
12// URL: http://coccinelle.lip6.fr/ 12// URL: http://coccinelle.lip6.fr/
13// Comments: 13// Comments:
14// Options: -no_includes -include_headers 14// Options: --no-includes --include-headers
15 15
16virtual context 16virtual context
17virtual org 17virtual org
diff --git a/scripts/coccinelle/misc/boolinit.cocci b/scripts/coccinelle/misc/boolinit.cocci
index 97ce41ce8135..b9abed49cd95 100644
--- a/scripts/coccinelle/misc/boolinit.cocci
+++ b/scripts/coccinelle/misc/boolinit.cocci
@@ -6,7 +6,7 @@
6// Copyright: (C) 2012 Julia Lawall, INRIA/LIP6. GPLv2. 6// Copyright: (C) 2012 Julia Lawall, INRIA/LIP6. GPLv2.
7// Copyright: (C) 2012 Gilles Muller, INRIA/LiP6. GPLv2. 7// Copyright: (C) 2012 Gilles Muller, INRIA/LiP6. GPLv2.
8// URL: http://coccinelle.lip6.fr/ 8// URL: http://coccinelle.lip6.fr/
9// Options: -include_headers 9// Options: --include-headers
10 10
11virtual patch 11virtual patch
12virtual context 12virtual context
diff --git a/scripts/coccinelle/misc/boolreturn.cocci b/scripts/coccinelle/misc/boolreturn.cocci
new file mode 100644
index 000000000000..a43c7b0c36ef
--- /dev/null
+++ b/scripts/coccinelle/misc/boolreturn.cocci
@@ -0,0 +1,58 @@
1/// Return statements in functions returning bool should use
2/// true/false instead of 1/0.
3//
4// Confidence: High
5// Options: --no-includes --include-headers
6
7virtual patch
8virtual report
9virtual context
10
11@r1 depends on patch@
12identifier fn;
13typedef bool;
14symbol false;
15symbol true;
16@@
17
18bool fn ( ... )
19{
20<...
21return
22(
23- 0
24+ false
25|
26- 1
27+ true
28)
29 ;
30...>
31}
32
33@r2 depends on report || context@
34identifier fn;
35position p;
36@@
37
38bool fn ( ... )
39{
40<...
41return
42(
43* 0@p
44|
45* 1@p
46)
47 ;
48...>
49}
50
51
52@script:python depends on report@
53p << r2.p;
54fn << r2.fn;
55@@
56
57msg = "WARNING: return of 0/1 in function '%s' with return type bool" % fn
58coccilib.report.print_report(p[0], msg)
diff --git a/scripts/coccinelle/misc/cstptr.cocci b/scripts/coccinelle/misc/cstptr.cocci
index d42564484528..f0368b3d4563 100644
--- a/scripts/coccinelle/misc/cstptr.cocci
+++ b/scripts/coccinelle/misc/cstptr.cocci
@@ -6,7 +6,7 @@
6// Copyright: (C) 2012 Gilles Muller, INRIA/LiP6. GPLv2. 6// Copyright: (C) 2012 Gilles Muller, INRIA/LiP6. GPLv2.
7// URL: http://coccinelle.lip6.fr/ 7// URL: http://coccinelle.lip6.fr/
8// Comments: 8// Comments:
9// Options: -no_includes -include_headers 9// Options: --no-includes --include-headers
10 10
11virtual org 11virtual org
12virtual report 12virtual report
diff --git a/scripts/coccinelle/misc/doubleinit.cocci b/scripts/coccinelle/misc/doubleinit.cocci
index cf74a00cf597..c0c3371d25e0 100644
--- a/scripts/coccinelle/misc/doubleinit.cocci
+++ b/scripts/coccinelle/misc/doubleinit.cocci
@@ -8,7 +8,7 @@
8// Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6. GPLv2. 8// Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6. GPLv2.
9// URL: http://coccinelle.lip6.fr/ 9// URL: http://coccinelle.lip6.fr/
10// Comments: requires at least Coccinelle 0.2.4, lex or parse error otherwise 10// Comments: requires at least Coccinelle 0.2.4, lex or parse error otherwise
11// Options: -no_includes -include_headers 11// Options: --no-includes --include-headers
12 12
13virtual org 13virtual org
14virtual report 14virtual report
diff --git a/scripts/coccinelle/misc/ifaddr.cocci b/scripts/coccinelle/misc/ifaddr.cocci
index 3e4089a77000..8aebd1875e75 100644
--- a/scripts/coccinelle/misc/ifaddr.cocci
+++ b/scripts/coccinelle/misc/ifaddr.cocci
@@ -6,7 +6,7 @@
6// Copyright: (C) 2012 Gilles Muller, INRIA/LiP6. GPLv2. 6// Copyright: (C) 2012 Gilles Muller, INRIA/LiP6. GPLv2.
7// URL: http://coccinelle.lip6.fr/ 7// URL: http://coccinelle.lip6.fr/
8// Comments: 8// Comments:
9// Options: -no_includes -include_headers 9// Options: --no-includes --include-headers
10 10
11virtual org 11virtual org
12virtual report 12virtual report
diff --git a/scripts/coccinelle/misc/ifcol.cocci b/scripts/coccinelle/misc/ifcol.cocci
index b7ed91dbeb95..d0d00ef1f12a 100644
--- a/scripts/coccinelle/misc/ifcol.cocci
+++ b/scripts/coccinelle/misc/ifcol.cocci
@@ -13,7 +13,7 @@
13// Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2. 13// Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2.
14// URL: http://coccinelle.lip6.fr/ 14// URL: http://coccinelle.lip6.fr/
15// Comments: 15// Comments:
16// Options: -no_includes -include_headers 16// Options: --no-includes --include-headers
17 17
18virtual org 18virtual org
19virtual report 19virtual report
diff --git a/scripts/coccinelle/misc/noderef.cocci b/scripts/coccinelle/misc/noderef.cocci
index c1707214e602..80a831c91161 100644
--- a/scripts/coccinelle/misc/noderef.cocci
+++ b/scripts/coccinelle/misc/noderef.cocci
@@ -6,7 +6,7 @@
6// Copyright: (C) 2012 Gilles Muller, INRIA/LiP6. GPLv2. 6// Copyright: (C) 2012 Gilles Muller, INRIA/LiP6. GPLv2.
7// URL: http://coccinelle.lip6.fr/ 7// URL: http://coccinelle.lip6.fr/
8// Comments: 8// Comments:
9// Options: -no_includes -include_headers 9// Options: --no-includes --include-headers
10 10
11virtual org 11virtual org
12virtual report 12virtual report
diff --git a/scripts/coccinelle/misc/orplus.cocci b/scripts/coccinelle/misc/orplus.cocci
index 4a28cef1484e..81fabf379390 100644
--- a/scripts/coccinelle/misc/orplus.cocci
+++ b/scripts/coccinelle/misc/orplus.cocci
@@ -7,7 +7,7 @@
7// Copyright: (C) 2013 Gilles Muller, INRIA/LIP6. GPLv2. 7// Copyright: (C) 2013 Gilles Muller, INRIA/LIP6. GPLv2.
8// URL: http://coccinelle.lip6.fr/ 8// URL: http://coccinelle.lip6.fr/
9// Comments: 9// Comments:
10// Options: -no_includes -include_headers 10// Options: --no-includes --include-headers
11 11
12virtual org 12virtual org
13virtual report 13virtual report
diff --git a/scripts/coccinelle/misc/warn.cocci b/scripts/coccinelle/misc/warn.cocci
index fda8c3558e4f..d2e5b6cedb84 100644
--- a/scripts/coccinelle/misc/warn.cocci
+++ b/scripts/coccinelle/misc/warn.cocci
@@ -5,7 +5,7 @@
5// Copyright: (C) 2012 Gilles Muller, INRIA/LiP6. GPLv2. 5// Copyright: (C) 2012 Gilles Muller, INRIA/LiP6. GPLv2.
6// URL: http://coccinelle.lip6.fr/ 6// URL: http://coccinelle.lip6.fr/
7// Comments: 7// Comments:
8// Options: -no_includes -include_headers 8// Options: --no-includes --include-headers
9 9
10virtual patch 10virtual patch
11virtual context 11virtual context
diff --git a/scripts/coccinelle/null/eno.cocci b/scripts/coccinelle/null/eno.cocci
index ed961a1f7d11..9bd29aa83399 100644
--- a/scripts/coccinelle/null/eno.cocci
+++ b/scripts/coccinelle/null/eno.cocci
@@ -6,7 +6,7 @@
6// Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6. GPLv2. 6// Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6. GPLv2.
7// URL: http://coccinelle.lip6.fr/ 7// URL: http://coccinelle.lip6.fr/
8// Comments: 8// Comments:
9// Options: -no_includes -include_headers 9// Options: --no-includes --include-headers
10 10
11virtual patch 11virtual patch
12virtual context 12virtual context
diff --git a/scripts/coccinelle/null/kmerr.cocci b/scripts/coccinelle/null/kmerr.cocci
index 949bf656c64c..5354a7903ccb 100644
--- a/scripts/coccinelle/null/kmerr.cocci
+++ b/scripts/coccinelle/null/kmerr.cocci
@@ -10,7 +10,7 @@
10// Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2. 10// Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2.
11// URL: http://coccinelle.lip6.fr/ 11// URL: http://coccinelle.lip6.fr/
12// Comments: 12// Comments:
13// Options: -no_includes -include_headers 13// Options: --no-includes --include-headers
14 14
15virtual context 15virtual context
16virtual org 16virtual org
diff --git a/scripts/coccinelle/tests/doublebitand.cocci b/scripts/coccinelle/tests/doublebitand.cocci
index 9ba73d05a77e..72f1572aaec3 100644
--- a/scripts/coccinelle/tests/doublebitand.cocci
+++ b/scripts/coccinelle/tests/doublebitand.cocci
@@ -10,7 +10,7 @@
10// Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2. 10// Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2.
11// URL: http://coccinelle.lip6.fr/ 11// URL: http://coccinelle.lip6.fr/
12// Comments: 12// Comments:
13// Options: -no_includes -include_headers 13// Options: --no-includes --include-headers
14 14
15virtual context 15virtual context
16virtual org 16virtual org
diff --git a/scripts/coccinelle/tests/doubletest.cocci b/scripts/coccinelle/tests/doubletest.cocci
index 13a2c0e8a4bf..78d74c22ca12 100644
--- a/scripts/coccinelle/tests/doubletest.cocci
+++ b/scripts/coccinelle/tests/doubletest.cocci
@@ -8,7 +8,7 @@
8// Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2. 8// Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2.
9// URL: http://coccinelle.lip6.fr/ 9// URL: http://coccinelle.lip6.fr/
10// Comments: 10// Comments:
11// Options: -no_includes -include_headers 11// Options: --no-includes --include-headers
12 12
13virtual context 13virtual context
14virtual org 14virtual org
diff --git a/scripts/coccinelle/tests/odd_ptr_err.cocci b/scripts/coccinelle/tests/odd_ptr_err.cocci
index e8dd8a6b28a2..cfe0a35cf2dd 100644
--- a/scripts/coccinelle/tests/odd_ptr_err.cocci
+++ b/scripts/coccinelle/tests/odd_ptr_err.cocci
@@ -7,7 +7,7 @@
7// Copyright: (C) 2012 Gilles Muller, INRIA. GPLv2. 7// Copyright: (C) 2012 Gilles Muller, INRIA. GPLv2.
8// URL: http://coccinelle.lip6.fr/ 8// URL: http://coccinelle.lip6.fr/
9// Comments: 9// Comments:
10// Options: -no_includes -include_headers 10// Options: --no-includes --include-headers
11 11
12virtual patch 12virtual patch
13virtual context 13virtual context
diff --git a/scripts/config b/scripts/config
index a65ecbbdd32a..68041793698c 100755
--- a/scripts/config
+++ b/scripts/config
@@ -1,6 +1,8 @@
1#!/bin/bash 1#!/bin/bash
2# Manipulate options in a .config file from the command line 2# Manipulate options in a .config file from the command line
3 3
4myname=${0##*/}
5
4# If no prefix forced, use the default CONFIG_ 6# If no prefix forced, use the default CONFIG_
5CONFIG_="${CONFIG_-CONFIG_}" 7CONFIG_="${CONFIG_-CONFIG_}"
6 8
@@ -8,7 +10,7 @@ usage() {
8 cat >&2 <<EOL 10 cat >&2 <<EOL
9Manipulate options in a .config file from the command line. 11Manipulate options in a .config file from the command line.
10Usage: 12Usage:
11config options command ... 13$myname options command ...
12commands: 14commands:
13 --enable|-e option Enable option 15 --enable|-e option Enable option
14 --disable|-d option Disable option 16 --disable|-d option Disable option
@@ -33,14 +35,14 @@ options:
33 --file config-file .config file to change (default .config) 35 --file config-file .config file to change (default .config)
34 --keep-case|-k Keep next symbols' case (dont' upper-case it) 36 --keep-case|-k Keep next symbols' case (dont' upper-case it)
35 37
36config doesn't check the validity of the .config file. This is done at next 38$myname doesn't check the validity of the .config file. This is done at next
37make time. 39make time.
38 40
39By default, config will upper-case the given symbol. Use --keep-case to keep 41By default, $myname will upper-case the given symbol. Use --keep-case to keep
40the case of all following symbols unchanged. 42the case of all following symbols unchanged.
41 43
42config uses 'CONFIG_' as the default symbol prefix. Set the environment 44$myname uses 'CONFIG_' as the default symbol prefix. Set the environment
43variable CONFIG_ to the prefix to use. Eg.: CONFIG_="FOO_" config ... 45variable CONFIG_ to the prefix to use. Eg.: CONFIG_="FOO_" $myname ...
44EOL 46EOL
45 exit 1 47 exit 1
46} 48}
@@ -60,15 +62,52 @@ checkarg() {
60 fi 62 fi
61} 63}
62 64
65txt_append() {
66 local anchor="$1"
67 local insert="$2"
68 local infile="$3"
69 local tmpfile="$infile.swp"
70
71 # sed append cmd: 'a\' + newline + text + newline
72 cmd="$(printf "a\\%b$insert" "\n")"
73
74 sed -e "/$anchor/$cmd" "$infile" >"$tmpfile"
75 # replace original file with the edited one
76 mv "$tmpfile" "$infile"
77}
78
79txt_subst() {
80 local before="$1"
81 local after="$2"
82 local infile="$3"
83 local tmpfile="$infile.swp"
84
85 sed -e "s:$before:$after:" "$infile" >"$tmpfile"
86 # replace original file with the edited one
87 mv "$tmpfile" "$infile"
88}
89
90txt_delete() {
91 local text="$1"
92 local infile="$2"
93 local tmpfile="$infile.swp"
94
95 sed -e "/$text/d" "$infile" >"$tmpfile"
96 # replace original file with the edited one
97 mv "$tmpfile" "$infile"
98}
99
63set_var() { 100set_var() {
64 local name=$1 new=$2 before=$3 101 local name=$1 new=$2 before=$3
65 102
66 name_re="^($name=|# $name is not set)" 103 name_re="^($name=|# $name is not set)"
67 before_re="^($before=|# $before is not set)" 104 before_re="^($before=|# $before is not set)"
68 if test -n "$before" && grep -Eq "$before_re" "$FN"; then 105 if test -n "$before" && grep -Eq "$before_re" "$FN"; then
69 sed -ri "/$before_re/a $new" "$FN" 106 txt_append "^$before=" "$new" "$FN"
107 txt_append "^# $before is not set" "$new" "$FN"
70 elif grep -Eq "$name_re" "$FN"; then 108 elif grep -Eq "$name_re" "$FN"; then
71 sed -ri "s:$name_re.*:$new:" "$FN" 109 txt_subst "^$name=.*" "$new" "$FN"
110 txt_subst "^# $name is not set" "$new" "$FN"
72 else 111 else
73 echo "$new" >>"$FN" 112 echo "$new" >>"$FN"
74 fi 113 fi
@@ -77,7 +116,8 @@ set_var() {
77undef_var() { 116undef_var() {
78 local name=$1 117 local name=$1
79 118
80 sed -ri "/^($name=|# $name is not set)/d" "$FN" 119 txt_delete "^$name=" "$FN"
120 txt_delete "^# $name is not set" "$FN"
81} 121}
82 122
83if [ "$1" = "--file" ]; then 123if [ "$1" = "--file" ]; then
diff --git a/scripts/diffconfig b/scripts/diffconfig
index b91f3e34d44d..6d672836e187 100755
--- a/scripts/diffconfig
+++ b/scripts/diffconfig
@@ -10,7 +10,7 @@
10import sys, os 10import sys, os
11 11
12def usage(): 12def usage():
13 print """Usage: diffconfig [-h] [-m] [<config1> <config2>] 13 print("""Usage: diffconfig [-h] [-m] [<config1> <config2>]
14 14
15Diffconfig is a simple utility for comparing two .config files. 15Diffconfig is a simple utility for comparing two .config files.
16Using standard diff to compare .config files often includes extraneous and 16Using standard diff to compare .config files often includes extraneous and
@@ -33,7 +33,7 @@ Example usage:
33 EXT2_FS y -> n 33 EXT2_FS y -> n
34 LOG_BUF_SHIFT 14 -> 16 34 LOG_BUF_SHIFT 14 -> 16
35 PRINTK_TIME n -> y 35 PRINTK_TIME n -> y
36""" 36""")
37 sys.exit(0) 37 sys.exit(0)
38 38
39# returns a dictionary of name/value pairs for config items in the file 39# returns a dictionary of name/value pairs for config items in the file
@@ -54,23 +54,23 @@ def print_config(op, config, value, new_value):
54 if merge_style: 54 if merge_style:
55 if new_value: 55 if new_value:
56 if new_value=="n": 56 if new_value=="n":
57 print "# CONFIG_%s is not set" % config 57 print("# CONFIG_%s is not set" % config)
58 else: 58 else:
59 print "CONFIG_%s=%s" % (config, new_value) 59 print("CONFIG_%s=%s" % (config, new_value))
60 else: 60 else:
61 if op=="-": 61 if op=="-":
62 print "-%s %s" % (config, value) 62 print("-%s %s" % (config, value))
63 elif op=="+": 63 elif op=="+":
64 print "+%s %s" % (config, new_value) 64 print("+%s %s" % (config, new_value))
65 else: 65 else:
66 print " %s %s -> %s" % (config, value, new_value) 66 print(" %s %s -> %s" % (config, value, new_value))
67 67
68def main(): 68def main():
69 global merge_style 69 global merge_style
70 70
71 # parse command line args 71 # parse command line args
72 if ("-h" in sys.argv or "--help" in sys.argv): 72 if ("-h" in sys.argv or "--help" in sys.argv):
73 usage() 73 usage()
74 74
75 merge_style = 0 75 merge_style = 0
76 if "-m" in sys.argv: 76 if "-m" in sys.argv:
@@ -79,23 +79,27 @@ def main():
79 79
80 argc = len(sys.argv) 80 argc = len(sys.argv)
81 if not (argc==1 or argc == 3): 81 if not (argc==1 or argc == 3):
82 print "Error: incorrect number of arguments or unrecognized option" 82 print("Error: incorrect number of arguments or unrecognized option")
83 usage() 83 usage()
84 84
85 if argc == 1: 85 if argc == 1:
86 # if no filenames given, assume .config and .config.old 86 # if no filenames given, assume .config and .config.old
87 build_dir="" 87 build_dir=""
88 if os.environ.has_key("KBUILD_OUTPUT"): 88 if "KBUILD_OUTPUT" in os.environ:
89 build_dir = os.environ["KBUILD_OUTPUT"]+"/" 89 build_dir = os.environ["KBUILD_OUTPUT"]+"/"
90
91 configa_filename = build_dir + ".config.old" 90 configa_filename = build_dir + ".config.old"
92 configb_filename = build_dir + ".config" 91 configb_filename = build_dir + ".config"
93 else: 92 else:
94 configa_filename = sys.argv[1] 93 configa_filename = sys.argv[1]
95 configb_filename = sys.argv[2] 94 configb_filename = sys.argv[2]
96 95
97 a = readconfig(file(configa_filename)) 96 try:
98 b = readconfig(file(configb_filename)) 97 a = readconfig(open(configa_filename))
98 b = readconfig(open(configb_filename))
99 except (IOError):
100 e = sys.exc_info()[1]
101 print("I/O error[%s]: %s\n" % (e.args[0],e.args[1]))
102 usage()
99 103
100 # print items in a but not b (accumulate, sort and print) 104 # print items in a but not b (accumulate, sort and print)
101 old = [] 105 old = []
@@ -121,8 +125,7 @@ def main():
121 125
122 # now print items in b but not in a 126 # now print items in b but not in a
123 # (items from b that were in a were removed above) 127 # (items from b that were in a were removed above)
124 new = b.keys() 128 new = sorted(b.keys())
125 new.sort()
126 for config in new: 129 for config in new:
127 print_config("+", config, None, b[config]) 130 print_config("+", config, None, b[config])
128 131
diff --git a/scripts/dtc/dtc-lexer.l b/scripts/dtc/dtc-lexer.l
index 254d5af88956..3b41bfca636c 100644
--- a/scripts/dtc/dtc-lexer.l
+++ b/scripts/dtc/dtc-lexer.l
@@ -71,7 +71,7 @@ static int pop_input_file(void);
71 push_input_file(name); 71 push_input_file(name);
72 } 72 }
73 73
74<*>^"#"(line)?{WS}+[0-9]+{WS}+{STRING}({WS}+[0-9]+)? { 74<*>^"#"(line)?[ \t]+[0-9]+[ \t]+{STRING}([ \t]+[0-9]+)? {
75 char *line, *tmp, *fn; 75 char *line, *tmp, *fn;
76 /* skip text before line # */ 76 /* skip text before line # */
77 line = yytext; 77 line = yytext;
diff --git a/scripts/dtc/dtc-lexer.lex.c_shipped b/scripts/dtc/dtc-lexer.lex.c_shipped
index a6c5fcdfc032..2d30f41778b7 100644
--- a/scripts/dtc/dtc-lexer.lex.c_shipped
+++ b/scripts/dtc/dtc-lexer.lex.c_shipped
@@ -405,19 +405,19 @@ static yyconst flex_int16_t yy_accept[161] =
405static yyconst flex_int32_t yy_ec[256] = 405static yyconst flex_int32_t yy_ec[256] =
406 { 0, 406 { 0,
407 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 407 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
408 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 408 4, 4, 4, 1, 1, 1, 1, 1, 1, 1,
409 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 409 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
410 1, 2, 4, 5, 6, 1, 1, 7, 8, 1, 410 1, 2, 5, 6, 7, 1, 1, 8, 9, 1,
411 1, 9, 10, 10, 11, 10, 12, 13, 14, 15, 411 1, 10, 11, 11, 12, 11, 13, 14, 15, 16,
412 15, 15, 15, 15, 15, 15, 15, 16, 1, 17, 412 16, 16, 16, 16, 16, 16, 16, 17, 1, 18,
413 18, 19, 10, 10, 20, 20, 20, 20, 20, 20, 413 19, 20, 11, 11, 21, 21, 21, 21, 21, 21,
414 21, 21, 21, 21, 21, 22, 21, 21, 21, 21, 414 22, 22, 22, 22, 22, 23, 22, 22, 22, 22,
415 21, 21, 21, 21, 23, 21, 21, 24, 21, 21, 415 22, 22, 22, 22, 24, 22, 22, 25, 22, 22,
416 1, 25, 26, 1, 21, 1, 20, 27, 28, 29, 416 1, 26, 27, 1, 22, 1, 21, 28, 29, 30,
417 417
418 30, 20, 21, 21, 31, 21, 21, 32, 33, 34, 418 31, 21, 22, 22, 32, 22, 22, 33, 34, 35,
419 35, 36, 21, 37, 38, 39, 40, 41, 21, 24, 419 36, 37, 22, 38, 39, 40, 41, 42, 22, 25,
420 42, 21, 43, 44, 45, 1, 1, 1, 1, 1, 420 43, 22, 44, 45, 46, 1, 1, 1, 1, 1,
421 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 421 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
422 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 422 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
423 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 423 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@@ -434,36 +434,36 @@ static yyconst flex_int32_t yy_ec[256] =
434 1, 1, 1, 1, 1 434 1, 1, 1, 1, 1
435 } ; 435 } ;
436 436
437static yyconst flex_int32_t yy_meta[46] = 437static yyconst flex_int32_t yy_meta[47] =
438 { 0, 438 { 0,
439 1, 1, 1, 1, 1, 2, 3, 1, 2, 2, 439 1, 1, 1, 1, 1, 1, 2, 3, 1, 2,
440 2, 4, 5, 5, 5, 6, 1, 1, 1, 7, 440 2, 2, 4, 5, 5, 5, 6, 1, 1, 1,
441 8, 8, 8, 8, 1, 1, 7, 7, 7, 7, 441 7, 8, 8, 8, 8, 1, 1, 7, 7, 7,
442 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 442 7, 8, 8, 8, 8, 8, 8, 8, 8, 8,
443 8, 8, 3, 1, 1 443 8, 8, 8, 3, 1, 1
444 } ; 444 } ;
445 445
446static yyconst flex_int16_t yy_base[175] = 446static yyconst flex_int16_t yy_base[175] =
447 { 0, 447 { 0,
448 0, 388, 381, 40, 41, 386, 71, 385, 34, 44, 448 0, 385, 378, 40, 41, 383, 72, 382, 34, 44,
449 390, 395, 60, 62, 371, 112, 111, 111, 111, 104, 449 388, 393, 61, 117, 368, 116, 115, 115, 115, 48,
450 370, 106, 371, 342, 124, 119, 0, 144, 395, 0, 450 367, 107, 368, 339, 127, 120, 0, 147, 393, 0,
451 123, 0, 159, 153, 165, 167, 395, 130, 395, 382, 451 127, 0, 133, 156, 168, 153, 393, 125, 393, 380,
452 395, 0, 372, 122, 395, 157, 374, 379, 350, 21, 452 393, 0, 369, 127, 393, 160, 371, 377, 347, 21,
453 346, 349, 395, 395, 395, 395, 395, 362, 395, 395, 453 343, 346, 393, 393, 393, 393, 393, 359, 393, 393,
454 181, 346, 342, 395, 359, 0, 191, 343, 190, 351, 454 183, 343, 339, 393, 356, 0, 183, 340, 187, 348,
455 350, 0, 0, 0, 173, 362, 177, 367, 357, 329, 455 347, 0, 0, 0, 178, 359, 195, 365, 354, 326,
456 335, 328, 337, 331, 206, 329, 334, 327, 395, 338, 456 332, 325, 334, 328, 204, 326, 331, 324, 393, 335,
457 170, 314, 346, 345, 318, 325, 343, 158, 316, 212, 457 150, 311, 343, 342, 315, 322, 340, 179, 313, 207,
458 458
459 322, 319, 320, 395, 340, 336, 308, 305, 314, 304, 459 319, 316, 317, 393, 337, 333, 305, 302, 311, 301,
460 295, 138, 208, 220, 395, 292, 305, 265, 264, 254, 460 310, 190, 338, 337, 393, 307, 322, 301, 305, 277,
461 201, 222, 285, 275, 273, 270, 236, 235, 225, 115, 461 208, 311, 307, 278, 271, 270, 248, 246, 213, 130,
462 395, 395, 252, 216, 216, 217, 214, 230, 209, 220, 462 393, 393, 263, 235, 207, 221, 218, 229, 213, 213,
463 213, 239, 211, 217, 216, 209, 229, 395, 240, 225, 463 206, 234, 218, 210, 208, 193, 219, 393, 223, 204,
464 206, 169, 395, 395, 116, 106, 99, 54, 395, 395, 464 176, 157, 393, 393, 120, 106, 97, 119, 393, 393,
465 254, 260, 268, 272, 276, 282, 289, 293, 301, 309, 465 245, 251, 259, 263, 267, 273, 280, 284, 292, 300,
466 313, 319, 327, 335 466 304, 310, 318, 326
467 } ; 467 } ;
468 468
469static yyconst flex_int16_t yy_def[175] = 469static yyconst flex_int16_t yy_def[175] =
@@ -489,108 +489,108 @@ static yyconst flex_int16_t yy_def[175] =
489 160, 160, 160, 160 489 160, 160, 160, 160
490 } ; 490 } ;
491 491
492static yyconst flex_int16_t yy_nxt[441] = 492static yyconst flex_int16_t yy_nxt[440] =
493 { 0, 493 { 0,
494 12, 13, 14, 15, 16, 12, 17, 18, 12, 12, 494 12, 13, 14, 13, 15, 16, 12, 17, 18, 12,
495 12, 19, 12, 12, 12, 12, 20, 21, 22, 23, 495 12, 12, 19, 12, 12, 12, 12, 20, 21, 22,
496 23, 23, 23, 23, 12, 12, 23, 23, 23, 23, 496 23, 23, 23, 23, 23, 12, 12, 23, 23, 23,
497 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 497 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
498 23, 23, 12, 24, 12, 25, 34, 35, 35, 25, 498 23, 23, 23, 12, 24, 12, 25, 34, 35, 35,
499 81, 26, 26, 27, 27, 27, 34, 35, 35, 82, 499 25, 81, 26, 26, 27, 27, 27, 34, 35, 35,
500 28, 36, 36, 36, 36, 159, 29, 28, 28, 28, 500 82, 28, 36, 36, 36, 53, 54, 29, 28, 28,
501 28, 12, 13, 14, 15, 16, 30, 17, 18, 30, 501 28, 28, 12, 13, 14, 13, 15, 16, 30, 17,
502 30, 30, 26, 30, 30, 30, 12, 20, 21, 22, 502 18, 30, 30, 30, 26, 30, 30, 30, 12, 20,
503 31, 31, 31, 31, 31, 32, 12, 31, 31, 31, 503 21, 22, 31, 31, 31, 31, 31, 32, 12, 31,
504 504
505 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 505 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
506 31, 31, 31, 12, 24, 12, 39, 41, 45, 47, 506 31, 31, 31, 31, 31, 12, 24, 12, 36, 36,
507 53, 54, 48, 56, 57, 61, 61, 47, 66, 45, 507 36, 39, 41, 45, 47, 56, 57, 48, 61, 47,
508 48, 66, 66, 66, 39, 46, 40, 49, 59, 50, 508 39, 159, 48, 66, 61, 45, 66, 66, 66, 158,
509 158, 51, 122, 52, 157, 49, 46, 50, 136, 63, 509 46, 40, 49, 59, 50, 157, 51, 49, 52, 50,
510 137, 52, 156, 43, 40, 62, 65, 65, 65, 59, 510 40, 63, 46, 52, 36, 36, 36, 156, 43, 62,
511 61, 61, 123, 65, 75, 69, 69, 69, 36, 36, 511 65, 65, 65, 59, 136, 68, 137, 65, 75, 69,
512 65, 65, 65, 65, 70, 71, 72, 69, 69, 69, 512 69, 69, 70, 71, 65, 65, 65, 65, 70, 71,
513 45, 46, 61, 61, 109, 77, 70, 71, 93, 110, 513 72, 69, 69, 69, 61, 46, 45, 155, 154, 66,
514 68, 70, 71, 85, 85, 85, 66, 46, 155, 66, 514 70, 71, 66, 66, 66, 122, 85, 85, 85, 59,
515 515
516 66, 66, 69, 69, 69, 122, 59, 100, 100, 61, 516 69, 69, 69, 46, 77, 100, 109, 93, 100, 70,
517 61, 70, 71, 100, 100, 148, 112, 154, 85, 85, 517 71, 110, 112, 122, 129, 123, 153, 85, 85, 85,
518 85, 61, 61, 129, 129, 123, 129, 129, 135, 135, 518 135, 135, 135, 148, 148, 160, 135, 135, 135, 152,
519 135, 142, 142, 148, 143, 149, 153, 135, 135, 135, 519 142, 142, 142, 123, 143, 142, 142, 142, 151, 143,
520 142, 142, 160, 143, 152, 151, 150, 146, 145, 144, 520 150, 146, 145, 149, 149, 38, 38, 38, 38, 38,
521 141, 140, 139, 149, 38, 38, 38, 38, 38, 38, 521 38, 38, 38, 42, 144, 141, 140, 42, 42, 44,
522 38, 38, 42, 138, 134, 133, 42, 42, 44, 44, 522 44, 44, 44, 44, 44, 44, 44, 58, 58, 58,
523 44, 44, 44, 44, 44, 44, 58, 58, 58, 58, 523 58, 64, 139, 64, 66, 138, 134, 66, 133, 66,
524 64, 132, 64, 66, 131, 130, 66, 160, 66, 66, 524 66, 67, 132, 131, 67, 67, 67, 67, 73, 130,
525 67, 128, 127, 67, 67, 67, 67, 73, 126, 73, 525 73, 73, 76, 76, 76, 76, 76, 76, 76, 76,
526 526
527 73, 76, 76, 76, 76, 76, 76, 76, 76, 78, 527 78, 78, 78, 78, 78, 78, 78, 78, 91, 160,
528 78, 78, 78, 78, 78, 78, 78, 91, 125, 91, 528 91, 92, 129, 92, 92, 128, 92, 92, 121, 121,
529 92, 124, 92, 92, 120, 92, 92, 121, 121, 121, 529 121, 121, 121, 121, 121, 121, 147, 147, 147, 147,
530 121, 121, 121, 121, 121, 147, 147, 147, 147, 147, 530 147, 147, 147, 147, 127, 126, 125, 124, 61, 61,
531 147, 147, 147, 119, 118, 117, 116, 115, 47, 114, 531 120, 119, 118, 117, 116, 115, 47, 114, 110, 113,
532 110, 113, 111, 108, 107, 106, 48, 105, 104, 89, 532 111, 108, 107, 106, 48, 105, 104, 89, 103, 102,
533 103, 102, 101, 99, 98, 97, 96, 95, 94, 79, 533 101, 99, 98, 97, 96, 95, 94, 79, 77, 90,
534 77, 90, 89, 88, 59, 87, 86, 59, 84, 83, 534 89, 88, 59, 87, 86, 59, 84, 83, 80, 79,
535 80, 79, 77, 74, 160, 60, 59, 55, 37, 160, 535 77, 74, 160, 60, 59, 55, 37, 160, 33, 25,
536 33, 25, 26, 25, 11, 160, 160, 160, 160, 160, 536 26, 25, 11, 160, 160, 160, 160, 160, 160, 160,
537 537
538 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 538 160, 160, 160, 160, 160, 160, 160, 160, 160, 160,
539 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 539 160, 160, 160, 160, 160, 160, 160, 160, 160, 160,
540 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 540 160, 160, 160, 160, 160, 160, 160, 160, 160, 160,
541 160, 160, 160, 160, 160, 160, 160, 160, 160, 160 541 160, 160, 160, 160, 160, 160, 160, 160, 160
542 } ; 542 } ;
543 543
544static yyconst flex_int16_t yy_chk[441] = 544static yyconst flex_int16_t yy_chk[440] =
545 { 0, 545 { 0,
546 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 546 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
547 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 547 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
548 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 548 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
549 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 549 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
550 1, 1, 1, 1, 1, 4, 9, 9, 9, 10, 550 1, 1, 1, 1, 1, 1, 4, 9, 9, 9,
551 50, 4, 5, 5, 5, 5, 10, 10, 10, 50, 551 10, 50, 4, 5, 5, 5, 5, 10, 10, 10,
552 5, 13, 13, 14, 14, 158, 5, 5, 5, 5, 552 50, 5, 13, 13, 13, 20, 20, 5, 5, 5,
553 5, 7, 7, 7, 7, 7, 7, 7, 7, 7, 553 5, 5, 7, 7, 7, 7, 7, 7, 7, 7,
554 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 554 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
555 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 555 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
556 556
557 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 557 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
558 7, 7, 7, 7, 7, 7, 16, 17, 18, 19, 558 7, 7, 7, 7, 7, 7, 7, 7, 14, 14,
559 20, 20, 19, 22, 22, 25, 25, 26, 31, 44, 559 14, 16, 17, 18, 19, 22, 22, 19, 25, 26,
560 26, 31, 31, 31, 38, 18, 16, 19, 31, 19, 560 38, 158, 26, 31, 33, 44, 31, 31, 31, 157,
561 157, 19, 112, 19, 156, 26, 44, 26, 130, 26, 561 18, 16, 19, 31, 19, 156, 19, 26, 19, 26,
562 130, 26, 155, 17, 38, 25, 28, 28, 28, 28, 562 38, 26, 44, 26, 36, 36, 36, 155, 17, 25,
563 33, 33, 112, 28, 46, 34, 34, 34, 36, 36, 563 28, 28, 28, 28, 130, 33, 130, 28, 46, 34,
564 28, 28, 28, 28, 34, 34, 34, 35, 35, 35, 564 34, 34, 91, 91, 28, 28, 28, 28, 34, 34,
565 75, 46, 61, 61, 98, 77, 35, 35, 77, 98, 565 34, 35, 35, 35, 61, 46, 75, 152, 151, 67,
566 33, 91, 91, 61, 61, 61, 67, 75, 152, 67, 566 35, 35, 67, 67, 67, 112, 61, 61, 61, 67,
567 567
568 67, 67, 69, 69, 69, 121, 67, 85, 85, 113, 568 69, 69, 69, 75, 77, 85, 98, 77, 100, 69,
569 113, 69, 69, 100, 100, 143, 100, 151, 85, 85, 569 69, 98, 100, 121, 129, 112, 150, 85, 85, 85,
570 85, 114, 114, 122, 122, 121, 129, 129, 135, 135, 570 135, 135, 135, 143, 147, 149, 129, 129, 129, 146,
571 135, 138, 138, 147, 138, 143, 150, 129, 129, 129, 571 138, 138, 138, 121, 138, 142, 142, 142, 145, 142,
572 142, 142, 149, 142, 146, 145, 144, 141, 140, 139, 572 144, 141, 140, 143, 147, 161, 161, 161, 161, 161,
573 137, 136, 134, 147, 161, 161, 161, 161, 161, 161, 573 161, 161, 161, 162, 139, 137, 136, 162, 162, 163,
574 161, 161, 162, 133, 128, 127, 162, 162, 163, 163, 574 163, 163, 163, 163, 163, 163, 163, 164, 164, 164,
575 163, 163, 163, 163, 163, 163, 164, 164, 164, 164, 575 164, 165, 134, 165, 166, 133, 128, 166, 127, 166,
576 165, 126, 165, 166, 125, 124, 166, 123, 166, 166, 576 166, 167, 126, 125, 167, 167, 167, 167, 168, 124,
577 167, 120, 119, 167, 167, 167, 167, 168, 118, 168, 577 168, 168, 169, 169, 169, 169, 169, 169, 169, 169,
578 578
579 168, 169, 169, 169, 169, 169, 169, 169, 169, 170, 579 170, 170, 170, 170, 170, 170, 170, 170, 171, 123,
580 170, 170, 170, 170, 170, 170, 170, 171, 117, 171, 580 171, 172, 122, 172, 172, 120, 172, 172, 173, 173,
581 172, 116, 172, 172, 111, 172, 172, 173, 173, 173, 581 173, 173, 173, 173, 173, 173, 174, 174, 174, 174,
582 173, 173, 173, 173, 173, 174, 174, 174, 174, 174, 582 174, 174, 174, 174, 119, 118, 117, 116, 114, 113,
583 174, 174, 174, 110, 109, 108, 107, 106, 105, 103, 583 111, 110, 109, 108, 107, 106, 105, 103, 102, 101,
584 102, 101, 99, 97, 96, 95, 94, 93, 92, 90, 584 99, 97, 96, 95, 94, 93, 92, 90, 88, 87,
585 88, 87, 86, 84, 83, 82, 81, 80, 79, 78, 585 86, 84, 83, 82, 81, 80, 79, 78, 76, 71,
586 76, 71, 70, 68, 65, 63, 62, 58, 52, 51, 586 70, 68, 65, 63, 62, 58, 52, 51, 49, 48,
587 49, 48, 47, 43, 40, 24, 23, 21, 15, 11, 587 47, 43, 40, 24, 23, 21, 15, 11, 8, 6,
588 8, 6, 3, 2, 160, 160, 160, 160, 160, 160, 588 3, 2, 160, 160, 160, 160, 160, 160, 160, 160,
589 589
590 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 590 160, 160, 160, 160, 160, 160, 160, 160, 160, 160,
591 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 591 160, 160, 160, 160, 160, 160, 160, 160, 160, 160,
592 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 592 160, 160, 160, 160, 160, 160, 160, 160, 160, 160,
593 160, 160, 160, 160, 160, 160, 160, 160, 160, 160 593 160, 160, 160, 160, 160, 160, 160, 160, 160
594 } ; 594 } ;
595 595
596static yy_state_type yy_last_accepting_state; 596static yy_state_type yy_last_accepting_state;
diff --git a/scripts/dtc/dtc-parser.tab.c_shipped b/scripts/dtc/dtc-parser.tab.c_shipped
index 4af55900a15b..ee1d8c3042fb 100644
--- a/scripts/dtc/dtc-parser.tab.c_shipped
+++ b/scripts/dtc/dtc-parser.tab.c_shipped
@@ -1,10 +1,8 @@
1/* A Bison parser, made by GNU Bison 2.5. */
1 2
2/* A Bison parser, made by GNU Bison 2.4.1. */ 3/* Bison implementation for Yacc-like parsers in C
3
4/* Skeleton implementation for Bison's Yacc-like parsers in C
5 4
6 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 5 Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc.
7 Free Software Foundation, Inc.
8 6
9 This program is free software: you can redistribute it and/or modify 7 This program is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
@@ -46,7 +44,7 @@
46#define YYBISON 1 44#define YYBISON 1
47 45
48/* Bison version. */ 46/* Bison version. */
49#define YYBISON_VERSION "2.4.1" 47#define YYBISON_VERSION "2.5"
50 48
51/* Skeleton name. */ 49/* Skeleton name. */
52#define YYSKELETON_NAME "yacc.c" 50#define YYSKELETON_NAME "yacc.c"
@@ -67,7 +65,7 @@
67 65
68/* Copy the first part of user declarations. */ 66/* Copy the first part of user declarations. */
69 67
70/* Line 189 of yacc.c */ 68/* Line 268 of yacc.c */
71#line 21 "dtc-parser.y" 69#line 21 "dtc-parser.y"
72 70
73#include <stdio.h> 71#include <stdio.h>
@@ -88,8 +86,8 @@ static unsigned long long eval_literal(const char *s, int base, int bits);
88static unsigned char eval_char_literal(const char *s); 86static unsigned char eval_char_literal(const char *s);
89 87
90 88
91/* Line 189 of yacc.c */ 89/* Line 268 of yacc.c */
92#line 93 "dtc-parser.tab.c" 90#line 91 "dtc-parser.tab.c"
93 91
94/* Enabling traces. */ 92/* Enabling traces. */
95#ifndef YYDEBUG 93#ifndef YYDEBUG
@@ -147,7 +145,7 @@ static unsigned char eval_char_literal(const char *s);
147typedef union YYSTYPE 145typedef union YYSTYPE
148{ 146{
149 147
150/* Line 214 of yacc.c */ 148/* Line 293 of yacc.c */
151#line 40 "dtc-parser.y" 149#line 40 "dtc-parser.y"
152 150
153 char *propnodename; 151 char *propnodename;
@@ -171,8 +169,8 @@ typedef union YYSTYPE
171 169
172 170
173 171
174/* Line 214 of yacc.c */ 172/* Line 293 of yacc.c */
175#line 176 "dtc-parser.tab.c" 173#line 174 "dtc-parser.tab.c"
176} YYSTYPE; 174} YYSTYPE;
177# define YYSTYPE_IS_TRIVIAL 1 175# define YYSTYPE_IS_TRIVIAL 1
178# define yystype YYSTYPE /* obsolescent; will be withdrawn */ 176# define yystype YYSTYPE /* obsolescent; will be withdrawn */
@@ -183,8 +181,8 @@ typedef union YYSTYPE
183/* Copy the second part of user declarations. */ 181/* Copy the second part of user declarations. */
184 182
185 183
186/* Line 264 of yacc.c */ 184/* Line 343 of yacc.c */
187#line 188 "dtc-parser.tab.c" 185#line 186 "dtc-parser.tab.c"
188 186
189#ifdef short 187#ifdef short
190# undef short 188# undef short
@@ -234,7 +232,7 @@ typedef short int yytype_int16;
234#define YYSIZE_MAXIMUM ((YYSIZE_T) -1) 232#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
235 233
236#ifndef YY_ 234#ifndef YY_
237# if YYENABLE_NLS 235# if defined YYENABLE_NLS && YYENABLE_NLS
238# if ENABLE_NLS 236# if ENABLE_NLS
239# include <libintl.h> /* INFRINGES ON USER NAME SPACE */ 237# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
240# define YY_(msgid) dgettext ("bison-runtime", msgid) 238# define YY_(msgid) dgettext ("bison-runtime", msgid)
@@ -287,11 +285,11 @@ YYID (yyi)
287# define alloca _alloca 285# define alloca _alloca
288# else 286# else
289# define YYSTACK_ALLOC alloca 287# define YYSTACK_ALLOC alloca
290# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ 288# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
291 || defined __cplusplus || defined _MSC_VER) 289 || defined __cplusplus || defined _MSC_VER)
292# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ 290# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
293# ifndef _STDLIB_H 291# ifndef EXIT_SUCCESS
294# define _STDLIB_H 1 292# define EXIT_SUCCESS 0
295# endif 293# endif
296# endif 294# endif
297# endif 295# endif
@@ -314,24 +312,24 @@ YYID (yyi)
314# ifndef YYSTACK_ALLOC_MAXIMUM 312# ifndef YYSTACK_ALLOC_MAXIMUM
315# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM 313# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
316# endif 314# endif
317# if (defined __cplusplus && ! defined _STDLIB_H \ 315# if (defined __cplusplus && ! defined EXIT_SUCCESS \
318 && ! ((defined YYMALLOC || defined malloc) \ 316 && ! ((defined YYMALLOC || defined malloc) \
319 && (defined YYFREE || defined free))) 317 && (defined YYFREE || defined free)))
320# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ 318# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
321# ifndef _STDLIB_H 319# ifndef EXIT_SUCCESS
322# define _STDLIB_H 1 320# define EXIT_SUCCESS 0
323# endif 321# endif
324# endif 322# endif
325# ifndef YYMALLOC 323# ifndef YYMALLOC
326# define YYMALLOC malloc 324# define YYMALLOC malloc
327# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ 325# if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
328 || defined __cplusplus || defined _MSC_VER) 326 || defined __cplusplus || defined _MSC_VER)
329void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ 327void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
330# endif 328# endif
331# endif 329# endif
332# ifndef YYFREE 330# ifndef YYFREE
333# define YYFREE free 331# define YYFREE free
334# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ 332# if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
335 || defined __cplusplus || defined _MSC_VER) 333 || defined __cplusplus || defined _MSC_VER)
336void free (void *); /* INFRINGES ON USER NAME SPACE */ 334void free (void *); /* INFRINGES ON USER NAME SPACE */
337# endif 335# endif
@@ -360,23 +358,7 @@ union yyalloc
360 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ 358 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
361 + YYSTACK_GAP_MAXIMUM) 359 + YYSTACK_GAP_MAXIMUM)
362 360
363/* Copy COUNT objects from FROM to TO. The source and destination do 361# define YYCOPY_NEEDED 1
364 not overlap. */
365# ifndef YYCOPY
366# if defined __GNUC__ && 1 < __GNUC__
367# define YYCOPY(To, From, Count) \
368 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
369# else
370# define YYCOPY(To, From, Count) \
371 do \
372 { \
373 YYSIZE_T yyi; \
374 for (yyi = 0; yyi < (Count); yyi++) \
375 (To)[yyi] = (From)[yyi]; \
376 } \
377 while (YYID (0))
378# endif
379# endif
380 362
381/* Relocate STACK from its old location to the new one. The 363/* Relocate STACK from its old location to the new one. The
382 local variables YYSIZE and YYSTACKSIZE give the old and new number of 364 local variables YYSIZE and YYSTACKSIZE give the old and new number of
@@ -396,6 +378,26 @@ union yyalloc
396 378
397#endif 379#endif
398 380
381#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
382/* Copy COUNT objects from FROM to TO. The source and destination do
383 not overlap. */
384# ifndef YYCOPY
385# if defined __GNUC__ && 1 < __GNUC__
386# define YYCOPY(To, From, Count) \
387 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
388# else
389# define YYCOPY(To, From, Count) \
390 do \
391 { \
392 YYSIZE_T yyi; \
393 for (yyi = 0; yyi < (Count); yyi++) \
394 (To)[yyi] = (From)[yyi]; \
395 } \
396 while (YYID (0))
397# endif
398# endif
399#endif /* !YYCOPY_NEEDED */
400
399/* YYFINAL -- State number of the termination state. */ 401/* YYFINAL -- State number of the termination state. */
400#define YYFINAL 4 402#define YYFINAL 4
401/* YYLAST -- Last index in YYTABLE. */ 403/* YYLAST -- Last index in YYTABLE. */
@@ -571,8 +573,8 @@ static const yytype_uint8 yyr2[] =
571 2, 0, 2, 2, 0, 2, 2, 2, 3, 2 573 2, 0, 2, 2, 0, 2, 2, 2, 3, 2
572}; 574};
573 575
574/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state 576/* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
575 STATE-NUM when YYTABLE doesn't specify something else to do. Zero 577 Performed when YYTABLE doesn't specify something else to do. Zero
576 means the default is an error. */ 578 means the default is an error. */
577static const yytype_uint8 yydefact[] = 579static const yytype_uint8 yydefact[] =
578{ 580{
@@ -633,8 +635,7 @@ static const yytype_int8 yypgoto[] =
633 635
634/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If 636/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
635 positive, shift that token. If negative, reduce the rule which 637 positive, shift that token. If negative, reduce the rule which
636 number is the opposite. If zero, do what YYDEFACT says. 638 number is the opposite. If YYTABLE_NINF, syntax error. */
637 If YYTABLE_NINF, syntax error. */
638#define YYTABLE_NINF -1 639#define YYTABLE_NINF -1
639static const yytype_uint8 yytable[] = 640static const yytype_uint8 yytable[] =
640{ 641{
@@ -654,6 +655,12 @@ static const yytype_uint8 yytable[] =
654 137, 0, 73, 139 655 137, 0, 73, 139
655}; 656};
656 657
658#define yypact_value_is_default(yystate) \
659 ((yystate) == (-78))
660
661#define yytable_value_is_error(yytable_value) \
662 YYID (0)
663
657static const yytype_int16 yycheck[] = 664static const yytype_int16 yycheck[] =
658{ 665{
659 5, 38, 39, 17, 18, 19, 12, 12, 17, 18, 666 5, 38, 39, 17, 18, 19, 12, 12, 17, 18,
@@ -705,9 +712,18 @@ static const yytype_uint8 yystos[] =
705 712
706/* Like YYERROR except do call yyerror. This remains here temporarily 713/* Like YYERROR except do call yyerror. This remains here temporarily
707 to ease the transition to the new meaning of YYERROR, for GCC. 714 to ease the transition to the new meaning of YYERROR, for GCC.
708 Once GCC version 2 has supplanted version 1, this can go. */ 715 Once GCC version 2 has supplanted version 1, this can go. However,
716 YYFAIL appears to be in use. Nevertheless, it is formally deprecated
717 in Bison 2.4.2's NEWS entry, where a plan to phase it out is
718 discussed. */
709 719
710#define YYFAIL goto yyerrlab 720#define YYFAIL goto yyerrlab
721#if defined YYFAIL
722 /* This is here to suppress warnings from the GCC cpp's
723 -Wunused-macros. Normally we don't worry about that warning, but
724 some users do, and we want to make it easy for users to remove
725 YYFAIL uses, which will produce warnings from Bison 2.5. */
726#endif
711 727
712#define YYRECOVERING() (!!yyerrstatus) 728#define YYRECOVERING() (!!yyerrstatus)
713 729
@@ -717,7 +733,6 @@ do \
717 { \ 733 { \
718 yychar = (Token); \ 734 yychar = (Token); \
719 yylval = (Value); \ 735 yylval = (Value); \
720 yytoken = YYTRANSLATE (yychar); \
721 YYPOPSTACK (1); \ 736 YYPOPSTACK (1); \
722 goto yybackup; \ 737 goto yybackup; \
723 } \ 738 } \
@@ -759,19 +774,10 @@ while (YYID (0))
759#endif 774#endif
760 775
761 776
762/* YY_LOCATION_PRINT -- Print the location on the stream. 777/* This macro is provided for backward compatibility. */
763 This macro was not mandated originally: define only if we know
764 we won't break user code: when these are the locations we know. */
765 778
766#ifndef YY_LOCATION_PRINT 779#ifndef YY_LOCATION_PRINT
767# if YYLTYPE_IS_TRIVIAL 780# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
768# define YY_LOCATION_PRINT(File, Loc) \
769 fprintf (File, "%d.%d-%d.%d", \
770 (Loc).first_line, (Loc).first_column, \
771 (Loc).last_line, (Loc).last_column)
772# else
773# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
774# endif
775#endif 781#endif
776 782
777 783
@@ -963,7 +969,6 @@ int yydebug;
963# define YYMAXDEPTH 10000 969# define YYMAXDEPTH 10000
964#endif 970#endif
965 971
966
967 972
968#if YYERROR_VERBOSE 973#if YYERROR_VERBOSE
969 974
@@ -1066,115 +1071,142 @@ yytnamerr (char *yyres, const char *yystr)
1066} 1071}
1067# endif 1072# endif
1068 1073
1069/* Copy into YYRESULT an error message about the unexpected token 1074/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
1070 YYCHAR while in state YYSTATE. Return the number of bytes copied, 1075 about the unexpected token YYTOKEN for the state stack whose top is
1071 including the terminating null byte. If YYRESULT is null, do not 1076 YYSSP.
1072 copy anything; just return the number of bytes that would be
1073 copied. As a special case, return 0 if an ordinary "syntax error"
1074 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
1075 size calculation. */
1076static YYSIZE_T
1077yysyntax_error (char *yyresult, int yystate, int yychar)
1078{
1079 int yyn = yypact[yystate];
1080 1077
1081 if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) 1078 Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
1082 return 0; 1079 not large enough to hold the message. In that case, also set
1083 else 1080 *YYMSG_ALLOC to the required number of bytes. Return 2 if the
1081 required number of bytes is too large to store. */
1082static int
1083yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
1084 yytype_int16 *yyssp, int yytoken)
1085{
1086 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]);
1087 YYSIZE_T yysize = yysize0;
1088 YYSIZE_T yysize1;
1089 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1090 /* Internationalized format string. */
1091 const char *yyformat = 0;
1092 /* Arguments of yyformat. */
1093 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1094 /* Number of reported tokens (one for the "unexpected", one per
1095 "expected"). */
1096 int yycount = 0;
1097
1098 /* There are many possibilities here to consider:
1099 - Assume YYFAIL is not used. It's too flawed to consider. See
1100 <http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
1101 for details. YYERROR is fine as it does not invoke this
1102 function.
1103 - If this state is a consistent state with a default action, then
1104 the only way this function was invoked is if the default action
1105 is an error action. In that case, don't check for expected
1106 tokens because there are none.
1107 - The only way there can be no lookahead present (in yychar) is if
1108 this state is a consistent state with a default action. Thus,
1109 detecting the absence of a lookahead is sufficient to determine
1110 that there is no unexpected or expected token to report. In that
1111 case, just report a simple "syntax error".
1112 - Don't assume there isn't a lookahead just because this state is a
1113 consistent state with a default action. There might have been a
1114 previous inconsistent state, consistent state with a non-default
1115 action, or user semantic action that manipulated yychar.
1116 - Of course, the expected token list depends on states to have
1117 correct lookahead information, and it depends on the parser not
1118 to perform extra reductions after fetching a lookahead from the
1119 scanner and before detecting a syntax error. Thus, state merging
1120 (from LALR or IELR) and default reductions corrupt the expected
1121 token list. However, the list is correct for canonical LR with
1122 one exception: it will still contain any token that will not be
1123 accepted due to an error action in a later state.
1124 */
1125 if (yytoken != YYEMPTY)
1084 { 1126 {
1085 int yytype = YYTRANSLATE (yychar); 1127 int yyn = yypact[*yyssp];
1086 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); 1128 yyarg[yycount++] = yytname[yytoken];
1087 YYSIZE_T yysize = yysize0; 1129 if (!yypact_value_is_default (yyn))
1088 YYSIZE_T yysize1; 1130 {
1089 int yysize_overflow = 0; 1131 /* Start YYX at -YYN if negative to avoid negative indexes in
1090 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; 1132 YYCHECK. In other words, skip the first -YYN actions for
1091 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; 1133 this state because they are default actions. */
1092 int yyx; 1134 int yyxbegin = yyn < 0 ? -yyn : 0;
1093 1135 /* Stay within bounds of both yycheck and yytname. */
1094# if 0 1136 int yychecklim = YYLAST - yyn + 1;
1095 /* This is so xgettext sees the translatable formats that are 1137 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1096 constructed on the fly. */ 1138 int yyx;
1097 YY_("syntax error, unexpected %s"); 1139
1098 YY_("syntax error, unexpected %s, expecting %s"); 1140 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1099 YY_("syntax error, unexpected %s, expecting %s or %s"); 1141 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1100 YY_("syntax error, unexpected %s, expecting %s or %s or %s"); 1142 && !yytable_value_is_error (yytable[yyx + yyn]))
1101 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); 1143 {
1102# endif 1144 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1103 char *yyfmt; 1145 {
1104 char const *yyf; 1146 yycount = 1;
1105 static char const yyunexpected[] = "syntax error, unexpected %s"; 1147 yysize = yysize0;
1106 static char const yyexpecting[] = ", expecting %s"; 1148 break;
1107 static char const yyor[] = " or %s"; 1149 }
1108 char yyformat[sizeof yyunexpected 1150 yyarg[yycount++] = yytname[yyx];
1109 + sizeof yyexpecting - 1 1151 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1110 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) 1152 if (! (yysize <= yysize1
1111 * (sizeof yyor - 1))]; 1153 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1112 char const *yyprefix = yyexpecting; 1154 return 2;
1113 1155 yysize = yysize1;
1114 /* Start YYX at -YYN if negative to avoid negative indexes in 1156 }
1115 YYCHECK. */ 1157 }
1116 int yyxbegin = yyn < 0 ? -yyn : 0; 1158 }
1117
1118 /* Stay within bounds of both yycheck and yytname. */
1119 int yychecklim = YYLAST - yyn + 1;
1120 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1121 int yycount = 1;
1122
1123 yyarg[0] = yytname[yytype];
1124 yyfmt = yystpcpy (yyformat, yyunexpected);
1125
1126 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1127 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1128 {
1129 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1130 {
1131 yycount = 1;
1132 yysize = yysize0;
1133 yyformat[sizeof yyunexpected - 1] = '\0';
1134 break;
1135 }
1136 yyarg[yycount++] = yytname[yyx];
1137 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1138 yysize_overflow |= (yysize1 < yysize);
1139 yysize = yysize1;
1140 yyfmt = yystpcpy (yyfmt, yyprefix);
1141 yyprefix = yyor;
1142 }
1143 1159
1144 yyf = YY_(yyformat); 1160 switch (yycount)
1145 yysize1 = yysize + yystrlen (yyf); 1161 {
1146 yysize_overflow |= (yysize1 < yysize); 1162# define YYCASE_(N, S) \
1147 yysize = yysize1; 1163 case N: \
1164 yyformat = S; \
1165 break
1166 YYCASE_(0, YY_("syntax error"));
1167 YYCASE_(1, YY_("syntax error, unexpected %s"));
1168 YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1169 YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1170 YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1171 YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1172# undef YYCASE_
1173 }
1148 1174
1149 if (yysize_overflow) 1175 yysize1 = yysize + yystrlen (yyformat);
1150 return YYSIZE_MAXIMUM; 1176 if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1177 return 2;
1178 yysize = yysize1;
1151 1179
1152 if (yyresult) 1180 if (*yymsg_alloc < yysize)
1153 { 1181 {
1154 /* Avoid sprintf, as that infringes on the user's name space. 1182 *yymsg_alloc = 2 * yysize;
1155 Don't have undefined behavior even if the translation 1183 if (! (yysize <= *yymsg_alloc
1156 produced a string with the wrong number of "%s"s. */ 1184 && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1157 char *yyp = yyresult; 1185 *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1158 int yyi = 0; 1186 return 1;
1159 while ((*yyp = *yyf) != '\0')
1160 {
1161 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
1162 {
1163 yyp += yytnamerr (yyp, yyarg[yyi++]);
1164 yyf += 2;
1165 }
1166 else
1167 {
1168 yyp++;
1169 yyf++;
1170 }
1171 }
1172 }
1173 return yysize;
1174 } 1187 }
1188
1189 /* Avoid sprintf, as that infringes on the user's name space.
1190 Don't have undefined behavior even if the translation
1191 produced a string with the wrong number of "%s"s. */
1192 {
1193 char *yyp = *yymsg;
1194 int yyi = 0;
1195 while ((*yyp = *yyformat) != '\0')
1196 if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1197 {
1198 yyp += yytnamerr (yyp, yyarg[yyi++]);
1199 yyformat += 2;
1200 }
1201 else
1202 {
1203 yyp++;
1204 yyformat++;
1205 }
1206 }
1207 return 0;
1175} 1208}
1176#endif /* YYERROR_VERBOSE */ 1209#endif /* YYERROR_VERBOSE */
1177
1178 1210
1179/*-----------------------------------------------. 1211/*-----------------------------------------------.
1180| Release the memory associated to this symbol. | 1212| Release the memory associated to this symbol. |
@@ -1207,6 +1239,7 @@ yydestruct (yymsg, yytype, yyvaluep)
1207 } 1239 }
1208} 1240}
1209 1241
1242
1210/* Prevent warnings from -Wmissing-prototypes. */ 1243/* Prevent warnings from -Wmissing-prototypes. */
1211#ifdef YYPARSE_PARAM 1244#ifdef YYPARSE_PARAM
1212#if defined __STDC__ || defined __cplusplus 1245#if defined __STDC__ || defined __cplusplus
@@ -1233,10 +1266,9 @@ YYSTYPE yylval;
1233int yynerrs; 1266int yynerrs;
1234 1267
1235 1268
1236 1269/*----------.
1237/*-------------------------. 1270| yyparse. |
1238| yyparse or yypush_parse. | 1271`----------*/
1239`-------------------------*/
1240 1272
1241#ifdef YYPARSE_PARAM 1273#ifdef YYPARSE_PARAM
1242#if (defined __STDC__ || defined __C99__FUNC__ \ 1274#if (defined __STDC__ || defined __C99__FUNC__ \
@@ -1260,8 +1292,6 @@ yyparse ()
1260#endif 1292#endif
1261#endif 1293#endif
1262{ 1294{
1263
1264
1265 int yystate; 1295 int yystate;
1266 /* Number of tokens to shift before error messages enabled. */ 1296 /* Number of tokens to shift before error messages enabled. */
1267 int yyerrstatus; 1297 int yyerrstatus;
@@ -1416,7 +1446,7 @@ yybackup:
1416 1446
1417 /* First try to decide what to do without reference to lookahead token. */ 1447 /* First try to decide what to do without reference to lookahead token. */
1418 yyn = yypact[yystate]; 1448 yyn = yypact[yystate];
1419 if (yyn == YYPACT_NINF) 1449 if (yypact_value_is_default (yyn))
1420 goto yydefault; 1450 goto yydefault;
1421 1451
1422 /* Not known => get a lookahead token if don't already have one. */ 1452 /* Not known => get a lookahead token if don't already have one. */
@@ -1447,8 +1477,8 @@ yybackup:
1447 yyn = yytable[yyn]; 1477 yyn = yytable[yyn];
1448 if (yyn <= 0) 1478 if (yyn <= 0)
1449 { 1479 {
1450 if (yyn == 0 || yyn == YYTABLE_NINF) 1480 if (yytable_value_is_error (yyn))
1451 goto yyerrlab; 1481 goto yyerrlab;
1452 yyn = -yyn; 1482 yyn = -yyn;
1453 goto yyreduce; 1483 goto yyreduce;
1454 } 1484 }
@@ -1503,72 +1533,72 @@ yyreduce:
1503 { 1533 {
1504 case 2: 1534 case 2:
1505 1535
1506/* Line 1455 of yacc.c */ 1536/* Line 1806 of yacc.c */
1507#line 110 "dtc-parser.y" 1537#line 110 "dtc-parser.y"
1508 { 1538 {
1509 the_boot_info = build_boot_info((yyvsp[(3) - (4)].re), (yyvsp[(4) - (4)].node), 1539 the_boot_info = build_boot_info((yyvsp[(3) - (4)].re), (yyvsp[(4) - (4)].node),
1510 guess_boot_cpuid((yyvsp[(4) - (4)].node))); 1540 guess_boot_cpuid((yyvsp[(4) - (4)].node)));
1511 ;} 1541 }
1512 break; 1542 break;
1513 1543
1514 case 3: 1544 case 3:
1515 1545
1516/* Line 1455 of yacc.c */ 1546/* Line 1806 of yacc.c */
1517#line 118 "dtc-parser.y" 1547#line 118 "dtc-parser.y"
1518 { 1548 {
1519 (yyval.re) = NULL; 1549 (yyval.re) = NULL;
1520 ;} 1550 }
1521 break; 1551 break;
1522 1552
1523 case 4: 1553 case 4:
1524 1554
1525/* Line 1455 of yacc.c */ 1555/* Line 1806 of yacc.c */
1526#line 122 "dtc-parser.y" 1556#line 122 "dtc-parser.y"
1527 { 1557 {
1528 (yyval.re) = chain_reserve_entry((yyvsp[(1) - (2)].re), (yyvsp[(2) - (2)].re)); 1558 (yyval.re) = chain_reserve_entry((yyvsp[(1) - (2)].re), (yyvsp[(2) - (2)].re));
1529 ;} 1559 }
1530 break; 1560 break;
1531 1561
1532 case 5: 1562 case 5:
1533 1563
1534/* Line 1455 of yacc.c */ 1564/* Line 1806 of yacc.c */
1535#line 129 "dtc-parser.y" 1565#line 129 "dtc-parser.y"
1536 { 1566 {
1537 (yyval.re) = build_reserve_entry((yyvsp[(2) - (4)].integer), (yyvsp[(3) - (4)].integer)); 1567 (yyval.re) = build_reserve_entry((yyvsp[(2) - (4)].integer), (yyvsp[(3) - (4)].integer));
1538 ;} 1568 }
1539 break; 1569 break;
1540 1570
1541 case 6: 1571 case 6:
1542 1572
1543/* Line 1455 of yacc.c */ 1573/* Line 1806 of yacc.c */
1544#line 133 "dtc-parser.y" 1574#line 133 "dtc-parser.y"
1545 { 1575 {
1546 add_label(&(yyvsp[(2) - (2)].re)->labels, (yyvsp[(1) - (2)].labelref)); 1576 add_label(&(yyvsp[(2) - (2)].re)->labels, (yyvsp[(1) - (2)].labelref));
1547 (yyval.re) = (yyvsp[(2) - (2)].re); 1577 (yyval.re) = (yyvsp[(2) - (2)].re);
1548 ;} 1578 }
1549 break; 1579 break;
1550 1580
1551 case 7: 1581 case 7:
1552 1582
1553/* Line 1455 of yacc.c */ 1583/* Line 1806 of yacc.c */
1554#line 141 "dtc-parser.y" 1584#line 141 "dtc-parser.y"
1555 { 1585 {
1556 (yyval.node) = name_node((yyvsp[(2) - (2)].node), ""); 1586 (yyval.node) = name_node((yyvsp[(2) - (2)].node), "");
1557 ;} 1587 }
1558 break; 1588 break;
1559 1589
1560 case 8: 1590 case 8:
1561 1591
1562/* Line 1455 of yacc.c */ 1592/* Line 1806 of yacc.c */
1563#line 145 "dtc-parser.y" 1593#line 145 "dtc-parser.y"
1564 { 1594 {
1565 (yyval.node) = merge_nodes((yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node)); 1595 (yyval.node) = merge_nodes((yyvsp[(1) - (3)].node), (yyvsp[(3) - (3)].node));
1566 ;} 1596 }
1567 break; 1597 break;
1568 1598
1569 case 9: 1599 case 9:
1570 1600
1571/* Line 1455 of yacc.c */ 1601/* Line 1806 of yacc.c */
1572#line 149 "dtc-parser.y" 1602#line 149 "dtc-parser.y"
1573 { 1603 {
1574 struct node *target = get_node_by_ref((yyvsp[(1) - (3)].node), (yyvsp[(2) - (3)].labelref)); 1604 struct node *target = get_node_by_ref((yyvsp[(1) - (3)].node), (yyvsp[(2) - (3)].labelref));
@@ -1578,12 +1608,12 @@ yyreduce:
1578 else 1608 else
1579 print_error("label or path, '%s', not found", (yyvsp[(2) - (3)].labelref)); 1609 print_error("label or path, '%s', not found", (yyvsp[(2) - (3)].labelref));
1580 (yyval.node) = (yyvsp[(1) - (3)].node); 1610 (yyval.node) = (yyvsp[(1) - (3)].node);
1581 ;} 1611 }
1582 break; 1612 break;
1583 1613
1584 case 10: 1614 case 10:
1585 1615
1586/* Line 1455 of yacc.c */ 1616/* Line 1806 of yacc.c */
1587#line 159 "dtc-parser.y" 1617#line 159 "dtc-parser.y"
1588 { 1618 {
1589 struct node *target = get_node_by_ref((yyvsp[(1) - (4)].node), (yyvsp[(3) - (4)].labelref)); 1619 struct node *target = get_node_by_ref((yyvsp[(1) - (4)].node), (yyvsp[(3) - (4)].labelref));
@@ -1594,112 +1624,112 @@ yyreduce:
1594 delete_node(target); 1624 delete_node(target);
1595 1625
1596 (yyval.node) = (yyvsp[(1) - (4)].node); 1626 (yyval.node) = (yyvsp[(1) - (4)].node);
1597 ;} 1627 }
1598 break; 1628 break;
1599 1629
1600 case 11: 1630 case 11:
1601 1631
1602/* Line 1455 of yacc.c */ 1632/* Line 1806 of yacc.c */
1603#line 173 "dtc-parser.y" 1633#line 173 "dtc-parser.y"
1604 { 1634 {
1605 (yyval.node) = build_node((yyvsp[(2) - (5)].proplist), (yyvsp[(3) - (5)].nodelist)); 1635 (yyval.node) = build_node((yyvsp[(2) - (5)].proplist), (yyvsp[(3) - (5)].nodelist));
1606 ;} 1636 }
1607 break; 1637 break;
1608 1638
1609 case 12: 1639 case 12:
1610 1640
1611/* Line 1455 of yacc.c */ 1641/* Line 1806 of yacc.c */
1612#line 180 "dtc-parser.y" 1642#line 180 "dtc-parser.y"
1613 { 1643 {
1614 (yyval.proplist) = NULL; 1644 (yyval.proplist) = NULL;
1615 ;} 1645 }
1616 break; 1646 break;
1617 1647
1618 case 13: 1648 case 13:
1619 1649
1620/* Line 1455 of yacc.c */ 1650/* Line 1806 of yacc.c */
1621#line 184 "dtc-parser.y" 1651#line 184 "dtc-parser.y"
1622 { 1652 {
1623 (yyval.proplist) = chain_property((yyvsp[(2) - (2)].prop), (yyvsp[(1) - (2)].proplist)); 1653 (yyval.proplist) = chain_property((yyvsp[(2) - (2)].prop), (yyvsp[(1) - (2)].proplist));
1624 ;} 1654 }
1625 break; 1655 break;
1626 1656
1627 case 14: 1657 case 14:
1628 1658
1629/* Line 1455 of yacc.c */ 1659/* Line 1806 of yacc.c */
1630#line 191 "dtc-parser.y" 1660#line 191 "dtc-parser.y"
1631 { 1661 {
1632 (yyval.prop) = build_property((yyvsp[(1) - (4)].propnodename), (yyvsp[(3) - (4)].data)); 1662 (yyval.prop) = build_property((yyvsp[(1) - (4)].propnodename), (yyvsp[(3) - (4)].data));
1633 ;} 1663 }
1634 break; 1664 break;
1635 1665
1636 case 15: 1666 case 15:
1637 1667
1638/* Line 1455 of yacc.c */ 1668/* Line 1806 of yacc.c */
1639#line 195 "dtc-parser.y" 1669#line 195 "dtc-parser.y"
1640 { 1670 {
1641 (yyval.prop) = build_property((yyvsp[(1) - (2)].propnodename), empty_data); 1671 (yyval.prop) = build_property((yyvsp[(1) - (2)].propnodename), empty_data);
1642 ;} 1672 }
1643 break; 1673 break;
1644 1674
1645 case 16: 1675 case 16:
1646 1676
1647/* Line 1455 of yacc.c */ 1677/* Line 1806 of yacc.c */
1648#line 199 "dtc-parser.y" 1678#line 199 "dtc-parser.y"
1649 { 1679 {
1650 (yyval.prop) = build_property_delete((yyvsp[(2) - (3)].propnodename)); 1680 (yyval.prop) = build_property_delete((yyvsp[(2) - (3)].propnodename));
1651 ;} 1681 }
1652 break; 1682 break;
1653 1683
1654 case 17: 1684 case 17:
1655 1685
1656/* Line 1455 of yacc.c */ 1686/* Line 1806 of yacc.c */
1657#line 203 "dtc-parser.y" 1687#line 203 "dtc-parser.y"
1658 { 1688 {
1659 add_label(&(yyvsp[(2) - (2)].prop)->labels, (yyvsp[(1) - (2)].labelref)); 1689 add_label(&(yyvsp[(2) - (2)].prop)->labels, (yyvsp[(1) - (2)].labelref));
1660 (yyval.prop) = (yyvsp[(2) - (2)].prop); 1690 (yyval.prop) = (yyvsp[(2) - (2)].prop);
1661 ;} 1691 }
1662 break; 1692 break;
1663 1693
1664 case 18: 1694 case 18:
1665 1695
1666/* Line 1455 of yacc.c */ 1696/* Line 1806 of yacc.c */
1667#line 211 "dtc-parser.y" 1697#line 211 "dtc-parser.y"
1668 { 1698 {
1669 (yyval.data) = data_merge((yyvsp[(1) - (2)].data), (yyvsp[(2) - (2)].data)); 1699 (yyval.data) = data_merge((yyvsp[(1) - (2)].data), (yyvsp[(2) - (2)].data));
1670 ;} 1700 }
1671 break; 1701 break;
1672 1702
1673 case 19: 1703 case 19:
1674 1704
1675/* Line 1455 of yacc.c */ 1705/* Line 1806 of yacc.c */
1676#line 215 "dtc-parser.y" 1706#line 215 "dtc-parser.y"
1677 { 1707 {
1678 (yyval.data) = data_merge((yyvsp[(1) - (3)].data), (yyvsp[(2) - (3)].array).data); 1708 (yyval.data) = data_merge((yyvsp[(1) - (3)].data), (yyvsp[(2) - (3)].array).data);
1679 ;} 1709 }
1680 break; 1710 break;
1681 1711
1682 case 20: 1712 case 20:
1683 1713
1684/* Line 1455 of yacc.c */ 1714/* Line 1806 of yacc.c */
1685#line 219 "dtc-parser.y" 1715#line 219 "dtc-parser.y"
1686 { 1716 {
1687 (yyval.data) = data_merge((yyvsp[(1) - (4)].data), (yyvsp[(3) - (4)].data)); 1717 (yyval.data) = data_merge((yyvsp[(1) - (4)].data), (yyvsp[(3) - (4)].data));
1688 ;} 1718 }
1689 break; 1719 break;
1690 1720
1691 case 21: 1721 case 21:
1692 1722
1693/* Line 1455 of yacc.c */ 1723/* Line 1806 of yacc.c */
1694#line 223 "dtc-parser.y" 1724#line 223 "dtc-parser.y"
1695 { 1725 {
1696 (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), REF_PATH, (yyvsp[(2) - (2)].labelref)); 1726 (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), REF_PATH, (yyvsp[(2) - (2)].labelref));
1697 ;} 1727 }
1698 break; 1728 break;
1699 1729
1700 case 22: 1730 case 22:
1701 1731
1702/* Line 1455 of yacc.c */ 1732/* Line 1806 of yacc.c */
1703#line 227 "dtc-parser.y" 1733#line 227 "dtc-parser.y"
1704 { 1734 {
1705 FILE *f = srcfile_relative_open((yyvsp[(4) - (9)].data).val, NULL); 1735 FILE *f = srcfile_relative_open((yyvsp[(4) - (9)].data).val, NULL);
@@ -1716,12 +1746,12 @@ yyreduce:
1716 1746
1717 (yyval.data) = data_merge((yyvsp[(1) - (9)].data), d); 1747 (yyval.data) = data_merge((yyvsp[(1) - (9)].data), d);
1718 fclose(f); 1748 fclose(f);
1719 ;} 1749 }
1720 break; 1750 break;
1721 1751
1722 case 23: 1752 case 23:
1723 1753
1724/* Line 1455 of yacc.c */ 1754/* Line 1806 of yacc.c */
1725#line 244 "dtc-parser.y" 1755#line 244 "dtc-parser.y"
1726 { 1756 {
1727 FILE *f = srcfile_relative_open((yyvsp[(4) - (5)].data).val, NULL); 1757 FILE *f = srcfile_relative_open((yyvsp[(4) - (5)].data).val, NULL);
@@ -1731,48 +1761,48 @@ yyreduce:
1731 1761
1732 (yyval.data) = data_merge((yyvsp[(1) - (5)].data), d); 1762 (yyval.data) = data_merge((yyvsp[(1) - (5)].data), d);
1733 fclose(f); 1763 fclose(f);
1734 ;} 1764 }
1735 break; 1765 break;
1736 1766
1737 case 24: 1767 case 24:
1738 1768
1739/* Line 1455 of yacc.c */ 1769/* Line 1806 of yacc.c */
1740#line 254 "dtc-parser.y" 1770#line 254 "dtc-parser.y"
1741 { 1771 {
1742 (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref)); 1772 (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref));
1743 ;} 1773 }
1744 break; 1774 break;
1745 1775
1746 case 25: 1776 case 25:
1747 1777
1748/* Line 1455 of yacc.c */ 1778/* Line 1806 of yacc.c */
1749#line 261 "dtc-parser.y" 1779#line 261 "dtc-parser.y"
1750 { 1780 {
1751 (yyval.data) = empty_data; 1781 (yyval.data) = empty_data;
1752 ;} 1782 }
1753 break; 1783 break;
1754 1784
1755 case 26: 1785 case 26:
1756 1786
1757/* Line 1455 of yacc.c */ 1787/* Line 1806 of yacc.c */
1758#line 265 "dtc-parser.y" 1788#line 265 "dtc-parser.y"
1759 { 1789 {
1760 (yyval.data) = (yyvsp[(1) - (2)].data); 1790 (yyval.data) = (yyvsp[(1) - (2)].data);
1761 ;} 1791 }
1762 break; 1792 break;
1763 1793
1764 case 27: 1794 case 27:
1765 1795
1766/* Line 1455 of yacc.c */ 1796/* Line 1806 of yacc.c */
1767#line 269 "dtc-parser.y" 1797#line 269 "dtc-parser.y"
1768 { 1798 {
1769 (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref)); 1799 (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref));
1770 ;} 1800 }
1771 break; 1801 break;
1772 1802
1773 case 28: 1803 case 28:
1774 1804
1775/* Line 1455 of yacc.c */ 1805/* Line 1806 of yacc.c */
1776#line 276 "dtc-parser.y" 1806#line 276 "dtc-parser.y"
1777 { 1807 {
1778 (yyval.array).data = empty_data; 1808 (yyval.array).data = empty_data;
@@ -1787,22 +1817,22 @@ yyreduce:
1787 " are currently supported"); 1817 " are currently supported");
1788 (yyval.array).bits = 32; 1818 (yyval.array).bits = 32;
1789 } 1819 }
1790 ;} 1820 }
1791 break; 1821 break;
1792 1822
1793 case 29: 1823 case 29:
1794 1824
1795/* Line 1455 of yacc.c */ 1825/* Line 1806 of yacc.c */
1796#line 291 "dtc-parser.y" 1826#line 291 "dtc-parser.y"
1797 { 1827 {
1798 (yyval.array).data = empty_data; 1828 (yyval.array).data = empty_data;
1799 (yyval.array).bits = 32; 1829 (yyval.array).bits = 32;
1800 ;} 1830 }
1801 break; 1831 break;
1802 1832
1803 case 30: 1833 case 30:
1804 1834
1805/* Line 1455 of yacc.c */ 1835/* Line 1806 of yacc.c */
1806#line 296 "dtc-parser.y" 1836#line 296 "dtc-parser.y"
1807 { 1837 {
1808 if ((yyvsp[(1) - (2)].array).bits < 64) { 1838 if ((yyvsp[(1) - (2)].array).bits < 64) {
@@ -1822,12 +1852,12 @@ yyreduce:
1822 } 1852 }
1823 1853
1824 (yyval.array).data = data_append_integer((yyvsp[(1) - (2)].array).data, (yyvsp[(2) - (2)].integer), (yyvsp[(1) - (2)].array).bits); 1854 (yyval.array).data = data_append_integer((yyvsp[(1) - (2)].array).data, (yyvsp[(2) - (2)].integer), (yyvsp[(1) - (2)].array).bits);
1825 ;} 1855 }
1826 break; 1856 break;
1827 1857
1828 case 31: 1858 case 31:
1829 1859
1830/* Line 1455 of yacc.c */ 1860/* Line 1806 of yacc.c */
1831#line 316 "dtc-parser.y" 1861#line 316 "dtc-parser.y"
1832 { 1862 {
1833 uint64_t val = ~0ULL >> (64 - (yyvsp[(1) - (2)].array).bits); 1863 uint64_t val = ~0ULL >> (64 - (yyvsp[(1) - (2)].array).bits);
@@ -1841,288 +1871,299 @@ yyreduce:
1841 "arrays with 32-bit elements."); 1871 "arrays with 32-bit elements.");
1842 1872
1843 (yyval.array).data = data_append_integer((yyvsp[(1) - (2)].array).data, val, (yyvsp[(1) - (2)].array).bits); 1873 (yyval.array).data = data_append_integer((yyvsp[(1) - (2)].array).data, val, (yyvsp[(1) - (2)].array).bits);
1844 ;} 1874 }
1845 break; 1875 break;
1846 1876
1847 case 32: 1877 case 32:
1848 1878
1849/* Line 1455 of yacc.c */ 1879/* Line 1806 of yacc.c */
1850#line 330 "dtc-parser.y" 1880#line 330 "dtc-parser.y"
1851 { 1881 {
1852 (yyval.array).data = data_add_marker((yyvsp[(1) - (2)].array).data, LABEL, (yyvsp[(2) - (2)].labelref)); 1882 (yyval.array).data = data_add_marker((yyvsp[(1) - (2)].array).data, LABEL, (yyvsp[(2) - (2)].labelref));
1853 ;} 1883 }
1854 break; 1884 break;
1855 1885
1856 case 33: 1886 case 33:
1857 1887
1858/* Line 1455 of yacc.c */ 1888/* Line 1806 of yacc.c */
1859#line 337 "dtc-parser.y" 1889#line 337 "dtc-parser.y"
1860 { 1890 {
1861 (yyval.integer) = eval_literal((yyvsp[(1) - (1)].literal), 0, 64); 1891 (yyval.integer) = eval_literal((yyvsp[(1) - (1)].literal), 0, 64);
1862 ;} 1892 }
1863 break; 1893 break;
1864 1894
1865 case 34: 1895 case 34:
1866 1896
1867/* Line 1455 of yacc.c */ 1897/* Line 1806 of yacc.c */
1868#line 341 "dtc-parser.y" 1898#line 341 "dtc-parser.y"
1869 { 1899 {
1870 (yyval.integer) = eval_char_literal((yyvsp[(1) - (1)].literal)); 1900 (yyval.integer) = eval_char_literal((yyvsp[(1) - (1)].literal));
1871 ;} 1901 }
1872 break; 1902 break;
1873 1903
1874 case 35: 1904 case 35:
1875 1905
1876/* Line 1455 of yacc.c */ 1906/* Line 1806 of yacc.c */
1877#line 345 "dtc-parser.y" 1907#line 345 "dtc-parser.y"
1878 { 1908 {
1879 (yyval.integer) = (yyvsp[(2) - (3)].integer); 1909 (yyval.integer) = (yyvsp[(2) - (3)].integer);
1880 ;} 1910 }
1881 break; 1911 break;
1882 1912
1883 case 38: 1913 case 38:
1884 1914
1885/* Line 1455 of yacc.c */ 1915/* Line 1806 of yacc.c */
1886#line 356 "dtc-parser.y" 1916#line 356 "dtc-parser.y"
1887 { (yyval.integer) = (yyvsp[(1) - (5)].integer) ? (yyvsp[(3) - (5)].integer) : (yyvsp[(5) - (5)].integer); ;} 1917 { (yyval.integer) = (yyvsp[(1) - (5)].integer) ? (yyvsp[(3) - (5)].integer) : (yyvsp[(5) - (5)].integer); }
1888 break; 1918 break;
1889 1919
1890 case 40: 1920 case 40:
1891 1921
1892/* Line 1455 of yacc.c */ 1922/* Line 1806 of yacc.c */
1893#line 361 "dtc-parser.y" 1923#line 361 "dtc-parser.y"
1894 { (yyval.integer) = (yyvsp[(1) - (3)].integer) || (yyvsp[(3) - (3)].integer); ;} 1924 { (yyval.integer) = (yyvsp[(1) - (3)].integer) || (yyvsp[(3) - (3)].integer); }
1895 break; 1925 break;
1896 1926
1897 case 42: 1927 case 42:
1898 1928
1899/* Line 1455 of yacc.c */ 1929/* Line 1806 of yacc.c */
1900#line 366 "dtc-parser.y" 1930#line 366 "dtc-parser.y"
1901 { (yyval.integer) = (yyvsp[(1) - (3)].integer) && (yyvsp[(3) - (3)].integer); ;} 1931 { (yyval.integer) = (yyvsp[(1) - (3)].integer) && (yyvsp[(3) - (3)].integer); }
1902 break; 1932 break;
1903 1933
1904 case 44: 1934 case 44:
1905 1935
1906/* Line 1455 of yacc.c */ 1936/* Line 1806 of yacc.c */
1907#line 371 "dtc-parser.y" 1937#line 371 "dtc-parser.y"
1908 { (yyval.integer) = (yyvsp[(1) - (3)].integer) | (yyvsp[(3) - (3)].integer); ;} 1938 { (yyval.integer) = (yyvsp[(1) - (3)].integer) | (yyvsp[(3) - (3)].integer); }
1909 break; 1939 break;
1910 1940
1911 case 46: 1941 case 46:
1912 1942
1913/* Line 1455 of yacc.c */ 1943/* Line 1806 of yacc.c */
1914#line 376 "dtc-parser.y" 1944#line 376 "dtc-parser.y"
1915 { (yyval.integer) = (yyvsp[(1) - (3)].integer) ^ (yyvsp[(3) - (3)].integer); ;} 1945 { (yyval.integer) = (yyvsp[(1) - (3)].integer) ^ (yyvsp[(3) - (3)].integer); }
1916 break; 1946 break;
1917 1947
1918 case 48: 1948 case 48:
1919 1949
1920/* Line 1455 of yacc.c */ 1950/* Line 1806 of yacc.c */
1921#line 381 "dtc-parser.y" 1951#line 381 "dtc-parser.y"
1922 { (yyval.integer) = (yyvsp[(1) - (3)].integer) & (yyvsp[(3) - (3)].integer); ;} 1952 { (yyval.integer) = (yyvsp[(1) - (3)].integer) & (yyvsp[(3) - (3)].integer); }
1923 break; 1953 break;
1924 1954
1925 case 50: 1955 case 50:
1926 1956
1927/* Line 1455 of yacc.c */ 1957/* Line 1806 of yacc.c */
1928#line 386 "dtc-parser.y" 1958#line 386 "dtc-parser.y"
1929 { (yyval.integer) = (yyvsp[(1) - (3)].integer) == (yyvsp[(3) - (3)].integer); ;} 1959 { (yyval.integer) = (yyvsp[(1) - (3)].integer) == (yyvsp[(3) - (3)].integer); }
1930 break; 1960 break;
1931 1961
1932 case 51: 1962 case 51:
1933 1963
1934/* Line 1455 of yacc.c */ 1964/* Line 1806 of yacc.c */
1935#line 387 "dtc-parser.y" 1965#line 387 "dtc-parser.y"
1936 { (yyval.integer) = (yyvsp[(1) - (3)].integer) != (yyvsp[(3) - (3)].integer); ;} 1966 { (yyval.integer) = (yyvsp[(1) - (3)].integer) != (yyvsp[(3) - (3)].integer); }
1937 break; 1967 break;
1938 1968
1939 case 53: 1969 case 53:
1940 1970
1941/* Line 1455 of yacc.c */ 1971/* Line 1806 of yacc.c */
1942#line 392 "dtc-parser.y" 1972#line 392 "dtc-parser.y"
1943 { (yyval.integer) = (yyvsp[(1) - (3)].integer) < (yyvsp[(3) - (3)].integer); ;} 1973 { (yyval.integer) = (yyvsp[(1) - (3)].integer) < (yyvsp[(3) - (3)].integer); }
1944 break; 1974 break;
1945 1975
1946 case 54: 1976 case 54:
1947 1977
1948/* Line 1455 of yacc.c */ 1978/* Line 1806 of yacc.c */
1949#line 393 "dtc-parser.y" 1979#line 393 "dtc-parser.y"
1950 { (yyval.integer) = (yyvsp[(1) - (3)].integer) > (yyvsp[(3) - (3)].integer); ;} 1980 { (yyval.integer) = (yyvsp[(1) - (3)].integer) > (yyvsp[(3) - (3)].integer); }
1951 break; 1981 break;
1952 1982
1953 case 55: 1983 case 55:
1954 1984
1955/* Line 1455 of yacc.c */ 1985/* Line 1806 of yacc.c */
1956#line 394 "dtc-parser.y" 1986#line 394 "dtc-parser.y"
1957 { (yyval.integer) = (yyvsp[(1) - (3)].integer) <= (yyvsp[(3) - (3)].integer); ;} 1987 { (yyval.integer) = (yyvsp[(1) - (3)].integer) <= (yyvsp[(3) - (3)].integer); }
1958 break; 1988 break;
1959 1989
1960 case 56: 1990 case 56:
1961 1991
1962/* Line 1455 of yacc.c */ 1992/* Line 1806 of yacc.c */
1963#line 395 "dtc-parser.y" 1993#line 395 "dtc-parser.y"
1964 { (yyval.integer) = (yyvsp[(1) - (3)].integer) >= (yyvsp[(3) - (3)].integer); ;} 1994 { (yyval.integer) = (yyvsp[(1) - (3)].integer) >= (yyvsp[(3) - (3)].integer); }
1965 break; 1995 break;
1966 1996
1967 case 57: 1997 case 57:
1968 1998
1969/* Line 1455 of yacc.c */ 1999/* Line 1806 of yacc.c */
1970#line 399 "dtc-parser.y" 2000#line 399 "dtc-parser.y"
1971 { (yyval.integer) = (yyvsp[(1) - (3)].integer) << (yyvsp[(3) - (3)].integer); ;} 2001 { (yyval.integer) = (yyvsp[(1) - (3)].integer) << (yyvsp[(3) - (3)].integer); }
1972 break; 2002 break;
1973 2003
1974 case 58: 2004 case 58:
1975 2005
1976/* Line 1455 of yacc.c */ 2006/* Line 1806 of yacc.c */
1977#line 400 "dtc-parser.y" 2007#line 400 "dtc-parser.y"
1978 { (yyval.integer) = (yyvsp[(1) - (3)].integer) >> (yyvsp[(3) - (3)].integer); ;} 2008 { (yyval.integer) = (yyvsp[(1) - (3)].integer) >> (yyvsp[(3) - (3)].integer); }
1979 break; 2009 break;
1980 2010
1981 case 60: 2011 case 60:
1982 2012
1983/* Line 1455 of yacc.c */ 2013/* Line 1806 of yacc.c */
1984#line 405 "dtc-parser.y" 2014#line 405 "dtc-parser.y"
1985 { (yyval.integer) = (yyvsp[(1) - (3)].integer) + (yyvsp[(3) - (3)].integer); ;} 2015 { (yyval.integer) = (yyvsp[(1) - (3)].integer) + (yyvsp[(3) - (3)].integer); }
1986 break; 2016 break;
1987 2017
1988 case 61: 2018 case 61:
1989 2019
1990/* Line 1455 of yacc.c */ 2020/* Line 1806 of yacc.c */
1991#line 406 "dtc-parser.y" 2021#line 406 "dtc-parser.y"
1992 { (yyval.integer) = (yyvsp[(1) - (3)].integer) - (yyvsp[(3) - (3)].integer); ;} 2022 { (yyval.integer) = (yyvsp[(1) - (3)].integer) - (yyvsp[(3) - (3)].integer); }
1993 break; 2023 break;
1994 2024
1995 case 63: 2025 case 63:
1996 2026
1997/* Line 1455 of yacc.c */ 2027/* Line 1806 of yacc.c */
1998#line 411 "dtc-parser.y" 2028#line 411 "dtc-parser.y"
1999 { (yyval.integer) = (yyvsp[(1) - (3)].integer) * (yyvsp[(3) - (3)].integer); ;} 2029 { (yyval.integer) = (yyvsp[(1) - (3)].integer) * (yyvsp[(3) - (3)].integer); }
2000 break; 2030 break;
2001 2031
2002 case 64: 2032 case 64:
2003 2033
2004/* Line 1455 of yacc.c */ 2034/* Line 1806 of yacc.c */
2005#line 412 "dtc-parser.y" 2035#line 412 "dtc-parser.y"
2006 { (yyval.integer) = (yyvsp[(1) - (3)].integer) / (yyvsp[(3) - (3)].integer); ;} 2036 { (yyval.integer) = (yyvsp[(1) - (3)].integer) / (yyvsp[(3) - (3)].integer); }
2007 break; 2037 break;
2008 2038
2009 case 65: 2039 case 65:
2010 2040
2011/* Line 1455 of yacc.c */ 2041/* Line 1806 of yacc.c */
2012#line 413 "dtc-parser.y" 2042#line 413 "dtc-parser.y"
2013 { (yyval.integer) = (yyvsp[(1) - (3)].integer) % (yyvsp[(3) - (3)].integer); ;} 2043 { (yyval.integer) = (yyvsp[(1) - (3)].integer) % (yyvsp[(3) - (3)].integer); }
2014 break; 2044 break;
2015 2045
2016 case 68: 2046 case 68:
2017 2047
2018/* Line 1455 of yacc.c */ 2048/* Line 1806 of yacc.c */
2019#line 419 "dtc-parser.y" 2049#line 419 "dtc-parser.y"
2020 { (yyval.integer) = -(yyvsp[(2) - (2)].integer); ;} 2050 { (yyval.integer) = -(yyvsp[(2) - (2)].integer); }
2021 break; 2051 break;
2022 2052
2023 case 69: 2053 case 69:
2024 2054
2025/* Line 1455 of yacc.c */ 2055/* Line 1806 of yacc.c */
2026#line 420 "dtc-parser.y" 2056#line 420 "dtc-parser.y"
2027 { (yyval.integer) = ~(yyvsp[(2) - (2)].integer); ;} 2057 { (yyval.integer) = ~(yyvsp[(2) - (2)].integer); }
2028 break; 2058 break;
2029 2059
2030 case 70: 2060 case 70:
2031 2061
2032/* Line 1455 of yacc.c */ 2062/* Line 1806 of yacc.c */
2033#line 421 "dtc-parser.y" 2063#line 421 "dtc-parser.y"
2034 { (yyval.integer) = !(yyvsp[(2) - (2)].integer); ;} 2064 { (yyval.integer) = !(yyvsp[(2) - (2)].integer); }
2035 break; 2065 break;
2036 2066
2037 case 71: 2067 case 71:
2038 2068
2039/* Line 1455 of yacc.c */ 2069/* Line 1806 of yacc.c */
2040#line 426 "dtc-parser.y" 2070#line 426 "dtc-parser.y"
2041 { 2071 {
2042 (yyval.data) = empty_data; 2072 (yyval.data) = empty_data;
2043 ;} 2073 }
2044 break; 2074 break;
2045 2075
2046 case 72: 2076 case 72:
2047 2077
2048/* Line 1455 of yacc.c */ 2078/* Line 1806 of yacc.c */
2049#line 430 "dtc-parser.y" 2079#line 430 "dtc-parser.y"
2050 { 2080 {
2051 (yyval.data) = data_append_byte((yyvsp[(1) - (2)].data), (yyvsp[(2) - (2)].byte)); 2081 (yyval.data) = data_append_byte((yyvsp[(1) - (2)].data), (yyvsp[(2) - (2)].byte));
2052 ;} 2082 }
2053 break; 2083 break;
2054 2084
2055 case 73: 2085 case 73:
2056 2086
2057/* Line 1455 of yacc.c */ 2087/* Line 1806 of yacc.c */
2058#line 434 "dtc-parser.y" 2088#line 434 "dtc-parser.y"
2059 { 2089 {
2060 (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref)); 2090 (yyval.data) = data_add_marker((yyvsp[(1) - (2)].data), LABEL, (yyvsp[(2) - (2)].labelref));
2061 ;} 2091 }
2062 break; 2092 break;
2063 2093
2064 case 74: 2094 case 74:
2065 2095
2066/* Line 1455 of yacc.c */ 2096/* Line 1806 of yacc.c */
2067#line 441 "dtc-parser.y" 2097#line 441 "dtc-parser.y"
2068 { 2098 {
2069 (yyval.nodelist) = NULL; 2099 (yyval.nodelist) = NULL;
2070 ;} 2100 }
2071 break; 2101 break;
2072 2102
2073 case 75: 2103 case 75:
2074 2104
2075/* Line 1455 of yacc.c */ 2105/* Line 1806 of yacc.c */
2076#line 445 "dtc-parser.y" 2106#line 445 "dtc-parser.y"
2077 { 2107 {
2078 (yyval.nodelist) = chain_node((yyvsp[(1) - (2)].node), (yyvsp[(2) - (2)].nodelist)); 2108 (yyval.nodelist) = chain_node((yyvsp[(1) - (2)].node), (yyvsp[(2) - (2)].nodelist));
2079 ;} 2109 }
2080 break; 2110 break;
2081 2111
2082 case 76: 2112 case 76:
2083 2113
2084/* Line 1455 of yacc.c */ 2114/* Line 1806 of yacc.c */
2085#line 449 "dtc-parser.y" 2115#line 449 "dtc-parser.y"
2086 { 2116 {
2087 print_error("syntax error: properties must precede subnodes"); 2117 print_error("syntax error: properties must precede subnodes");
2088 YYERROR; 2118 YYERROR;
2089 ;} 2119 }
2090 break; 2120 break;
2091 2121
2092 case 77: 2122 case 77:
2093 2123
2094/* Line 1455 of yacc.c */ 2124/* Line 1806 of yacc.c */
2095#line 457 "dtc-parser.y" 2125#line 457 "dtc-parser.y"
2096 { 2126 {
2097 (yyval.node) = name_node((yyvsp[(2) - (2)].node), (yyvsp[(1) - (2)].propnodename)); 2127 (yyval.node) = name_node((yyvsp[(2) - (2)].node), (yyvsp[(1) - (2)].propnodename));
2098 ;} 2128 }
2099 break; 2129 break;
2100 2130
2101 case 78: 2131 case 78:
2102 2132
2103/* Line 1455 of yacc.c */ 2133/* Line 1806 of yacc.c */
2104#line 461 "dtc-parser.y" 2134#line 461 "dtc-parser.y"
2105 { 2135 {
2106 (yyval.node) = name_node(build_node_delete(), (yyvsp[(2) - (3)].propnodename)); 2136 (yyval.node) = name_node(build_node_delete(), (yyvsp[(2) - (3)].propnodename));
2107 ;} 2137 }
2108 break; 2138 break;
2109 2139
2110 case 79: 2140 case 79:
2111 2141
2112/* Line 1455 of yacc.c */ 2142/* Line 1806 of yacc.c */
2113#line 465 "dtc-parser.y" 2143#line 465 "dtc-parser.y"
2114 { 2144 {
2115 add_label(&(yyvsp[(2) - (2)].node)->labels, (yyvsp[(1) - (2)].labelref)); 2145 add_label(&(yyvsp[(2) - (2)].node)->labels, (yyvsp[(1) - (2)].labelref));
2116 (yyval.node) = (yyvsp[(2) - (2)].node); 2146 (yyval.node) = (yyvsp[(2) - (2)].node);
2117 ;} 2147 }
2118 break; 2148 break;
2119 2149
2120 2150
2121 2151
2122/* Line 1455 of yacc.c */ 2152/* Line 1806 of yacc.c */
2123#line 2124 "dtc-parser.tab.c" 2153#line 2154 "dtc-parser.tab.c"
2124 default: break; 2154 default: break;
2125 } 2155 }
2156 /* User semantic actions sometimes alter yychar, and that requires
2157 that yytoken be updated with the new translation. We take the
2158 approach of translating immediately before every use of yytoken.
2159 One alternative is translating here after every semantic action,
2160 but that translation would be missed if the semantic action invokes
2161 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
2162 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
2163 incorrect destructor might then be invoked immediately. In the
2164 case of YYERROR or YYBACKUP, subsequent parser actions might lead
2165 to an incorrect destructor call or verbose syntax error message
2166 before the lookahead is translated. */
2126 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); 2167 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
2127 2168
2128 YYPOPSTACK (yylen); 2169 YYPOPSTACK (yylen);
@@ -2150,6 +2191,10 @@ yyreduce:
2150| yyerrlab -- here on detecting error | 2191| yyerrlab -- here on detecting error |
2151`------------------------------------*/ 2192`------------------------------------*/
2152yyerrlab: 2193yyerrlab:
2194 /* Make sure we have latest lookahead translation. See comments at
2195 user semantic actions for why this is necessary. */
2196 yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
2197
2153 /* If not already recovering from an error, report this error. */ 2198 /* If not already recovering from an error, report this error. */
2154 if (!yyerrstatus) 2199 if (!yyerrstatus)
2155 { 2200 {
@@ -2157,37 +2202,36 @@ yyerrlab:
2157#if ! YYERROR_VERBOSE 2202#if ! YYERROR_VERBOSE
2158 yyerror (YY_("syntax error")); 2203 yyerror (YY_("syntax error"));
2159#else 2204#else
2205# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
2206 yyssp, yytoken)
2160 { 2207 {
2161 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); 2208 char const *yymsgp = YY_("syntax error");
2162 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) 2209 int yysyntax_error_status;
2163 { 2210 yysyntax_error_status = YYSYNTAX_ERROR;
2164 YYSIZE_T yyalloc = 2 * yysize; 2211 if (yysyntax_error_status == 0)
2165 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) 2212 yymsgp = yymsg;
2166 yyalloc = YYSTACK_ALLOC_MAXIMUM; 2213 else if (yysyntax_error_status == 1)
2167 if (yymsg != yymsgbuf) 2214 {
2168 YYSTACK_FREE (yymsg); 2215 if (yymsg != yymsgbuf)
2169 yymsg = (char *) YYSTACK_ALLOC (yyalloc); 2216 YYSTACK_FREE (yymsg);
2170 if (yymsg) 2217 yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
2171 yymsg_alloc = yyalloc; 2218 if (!yymsg)
2172 else 2219 {
2173 { 2220 yymsg = yymsgbuf;
2174 yymsg = yymsgbuf; 2221 yymsg_alloc = sizeof yymsgbuf;
2175 yymsg_alloc = sizeof yymsgbuf; 2222 yysyntax_error_status = 2;
2176 } 2223 }
2177 } 2224 else
2178 2225 {
2179 if (0 < yysize && yysize <= yymsg_alloc) 2226 yysyntax_error_status = YYSYNTAX_ERROR;
2180 { 2227 yymsgp = yymsg;
2181 (void) yysyntax_error (yymsg, yystate, yychar); 2228 }
2182 yyerror (yymsg); 2229 }
2183 } 2230 yyerror (yymsgp);
2184 else 2231 if (yysyntax_error_status == 2)
2185 { 2232 goto yyexhaustedlab;
2186 yyerror (YY_("syntax error"));
2187 if (yysize != 0)
2188 goto yyexhaustedlab;
2189 }
2190 } 2233 }
2234# undef YYSYNTAX_ERROR
2191#endif 2235#endif
2192 } 2236 }
2193 2237
@@ -2246,7 +2290,7 @@ yyerrlab1:
2246 for (;;) 2290 for (;;)
2247 { 2291 {
2248 yyn = yypact[yystate]; 2292 yyn = yypact[yystate];
2249 if (yyn != YYPACT_NINF) 2293 if (!yypact_value_is_default (yyn))
2250 { 2294 {
2251 yyn += YYTERROR; 2295 yyn += YYTERROR;
2252 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) 2296 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
@@ -2305,8 +2349,13 @@ yyexhaustedlab:
2305 2349
2306yyreturn: 2350yyreturn:
2307 if (yychar != YYEMPTY) 2351 if (yychar != YYEMPTY)
2308 yydestruct ("Cleanup: discarding lookahead", 2352 {
2309 yytoken, &yylval); 2353 /* Make sure we have latest lookahead translation. See comments at
2354 user semantic actions for why this is necessary. */
2355 yytoken = YYTRANSLATE (yychar);
2356 yydestruct ("Cleanup: discarding lookahead",
2357 yytoken, &yylval);
2358 }
2310 /* Do not reclaim the symbols of the rule which action triggered 2359 /* Do not reclaim the symbols of the rule which action triggered
2311 this YYABORT or YYACCEPT. */ 2360 this YYABORT or YYACCEPT. */
2312 YYPOPSTACK (yylen); 2361 YYPOPSTACK (yylen);
@@ -2331,7 +2380,7 @@ yyreturn:
2331 2380
2332 2381
2333 2382
2334/* Line 1675 of yacc.c */ 2383/* Line 2067 of yacc.c */
2335#line 471 "dtc-parser.y" 2384#line 471 "dtc-parser.y"
2336 2385
2337 2386
diff --git a/scripts/dtc/dtc-parser.tab.h_shipped b/scripts/dtc/dtc-parser.tab.h_shipped
index 9d2dce41211f..25d3b88c6132 100644
--- a/scripts/dtc/dtc-parser.tab.h_shipped
+++ b/scripts/dtc/dtc-parser.tab.h_shipped
@@ -1,10 +1,8 @@
1/* A Bison parser, made by GNU Bison 2.5. */
1 2
2/* A Bison parser, made by GNU Bison 2.4.1. */ 3/* Bison interface for Yacc-like parsers in C
3
4/* Skeleton interface for Bison's Yacc-like parsers in C
5 4
6 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006 5 Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc.
7 Free Software Foundation, Inc.
8 6
9 This program is free software: you can redistribute it and/or modify 7 This program is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
@@ -70,7 +68,7 @@
70typedef union YYSTYPE 68typedef union YYSTYPE
71{ 69{
72 70
73/* Line 1676 of yacc.c */ 71/* Line 2068 of yacc.c */
74#line 40 "dtc-parser.y" 72#line 40 "dtc-parser.y"
75 73
76 char *propnodename; 74 char *propnodename;
@@ -94,8 +92,8 @@ typedef union YYSTYPE
94 92
95 93
96 94
97/* Line 1676 of yacc.c */ 95/* Line 2068 of yacc.c */
98#line 99 "dtc-parser.tab.h" 96#line 97 "dtc-parser.tab.h"
99} YYSTYPE; 97} YYSTYPE;
100# define YYSTYPE_IS_TRIVIAL 1 98# define YYSTYPE_IS_TRIVIAL 1
101# define yystype YYSTYPE /* obsolescent; will be withdrawn */ 99# define yystype YYSTYPE /* obsolescent; will be withdrawn */
diff --git a/scripts/headers_install.sh b/scripts/headers_install.sh
index 643764f53ea7..5de5660cb708 100644
--- a/scripts/headers_install.sh
+++ b/scripts/headers_install.sh
@@ -2,7 +2,7 @@
2 2
3if [ $# -lt 1 ] 3if [ $# -lt 1 ]
4then 4then
5 echo "Usage: headers_install.sh OUTDIR [FILES...] 5 echo "Usage: headers_install.sh OUTDIR SRCDIR [FILES...]
6 echo 6 echo
7 echo "Prepares kernel header files for use by user space, by removing" 7 echo "Prepares kernel header files for use by user space, by removing"
8 echo "all compiler.h definitions and #includes, removing any" 8 echo "all compiler.h definitions and #includes, removing any"
@@ -10,6 +10,7 @@ then
10 echo "asm/inline/volatile keywords." 10 echo "asm/inline/volatile keywords."
11 echo 11 echo
12 echo "OUTDIR: directory to write each userspace header FILE to." 12 echo "OUTDIR: directory to write each userspace header FILE to."
13 echo "SRCDIR: source directory where files are picked."
13 echo "FILES: list of header files to operate on." 14 echo "FILES: list of header files to operate on."
14 15
15 exit 1 16 exit 1
@@ -19,6 +20,8 @@ fi
19 20
20OUTDIR="$1" 21OUTDIR="$1"
21shift 22shift
23SRCDIR="$1"
24shift
22 25
23# Iterate through files listed on command line 26# Iterate through files listed on command line
24 27
@@ -34,7 +37,7 @@ do
34 -e 's/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g' \ 37 -e 's/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g' \
35 -e 's/(^|[ \t(])(inline|asm|volatile)([ \t(]|$)/\1__\2__\3/g' \ 38 -e 's/(^|[ \t(])(inline|asm|volatile)([ \t(]|$)/\1__\2__\3/g' \
36 -e 's@#(ifndef|define|endif[ \t]*/[*])[ \t]*_UAPI@#\1 @' \ 39 -e 's@#(ifndef|define|endif[ \t]*/[*])[ \t]*_UAPI@#\1 @' \
37 "$i" > "$OUTDIR/$FILE.sed" || exit 1 40 "$SRCDIR/$i" > "$OUTDIR/$FILE.sed" || exit 1
38 scripts/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__ "$OUTDIR/$FILE.sed" \ 41 scripts/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__ "$OUTDIR/$FILE.sed" \
39 > "$OUTDIR/$FILE" 42 > "$OUTDIR/$FILE"
40 [ $? -gt 1 ] && exit 1 43 [ $? -gt 1 ] && exit 1
diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
index bde5b95c8c19..d19944f9c3ac 100644
--- a/scripts/kconfig/conf.c
+++ b/scripts/kconfig/conf.c
@@ -527,11 +527,12 @@ int main(int ac, char **av)
527 seed_env = getenv("KCONFIG_SEED"); 527 seed_env = getenv("KCONFIG_SEED");
528 if( seed_env && *seed_env ) { 528 if( seed_env && *seed_env ) {
529 char *endp; 529 char *endp;
530 int tmp = (int)strtol(seed_env, &endp, 10); 530 int tmp = (int)strtol(seed_env, &endp, 0);
531 if (*endp == '\0') { 531 if (*endp == '\0') {
532 seed = tmp; 532 seed = tmp;
533 } 533 }
534 } 534 }
535 fprintf( stderr, "KCONFIG_SEED=0x%X\n", seed );
535 srand(seed); 536 srand(seed);
536 break; 537 break;
537 } 538 }
@@ -653,7 +654,8 @@ int main(int ac, char **av)
653 conf_set_all_new_symbols(def_default); 654 conf_set_all_new_symbols(def_default);
654 break; 655 break;
655 case randconfig: 656 case randconfig:
656 conf_set_all_new_symbols(def_random); 657 /* Really nothing to do in this loop */
658 while (conf_set_all_new_symbols(def_random)) ;
657 break; 659 break;
658 case defconfig: 660 case defconfig:
659 conf_set_all_new_symbols(def_default); 661 conf_set_all_new_symbols(def_default);
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index 43eda40c3838..87f723804079 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -140,7 +140,9 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p)
140 sym->flags |= def_flags; 140 sym->flags |= def_flags;
141 break; 141 break;
142 } 142 }
143 conf_warning("symbol value '%s' invalid for %s", p, sym->name); 143 if (def != S_DEF_AUTO)
144 conf_warning("symbol value '%s' invalid for %s",
145 p, sym->name);
144 return 1; 146 return 1;
145 case S_OTHER: 147 case S_OTHER:
146 if (*p != '"') { 148 if (*p != '"') {
@@ -161,7 +163,8 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p)
161 memmove(p2, p2 + 1, strlen(p2)); 163 memmove(p2, p2 + 1, strlen(p2));
162 } 164 }
163 if (!p2) { 165 if (!p2) {
164 conf_warning("invalid string found"); 166 if (def != S_DEF_AUTO)
167 conf_warning("invalid string found");
165 return 1; 168 return 1;
166 } 169 }
167 /* fall through */ 170 /* fall through */
@@ -172,7 +175,9 @@ static int conf_set_sym_val(struct symbol *sym, int def, int def_flags, char *p)
172 sym->def[def].val = strdup(p); 175 sym->def[def].val = strdup(p);
173 sym->flags |= def_flags; 176 sym->flags |= def_flags;
174 } else { 177 } else {
175 conf_warning("symbol value '%s' invalid for %s", p, sym->name); 178 if (def != S_DEF_AUTO)
179 conf_warning("symbol value '%s' invalid for %s",
180 p, sym->name);
176 return 1; 181 return 1;
177 } 182 }
178 break; 183 break;
@@ -1040,7 +1045,7 @@ void conf_set_changed_callback(void (*fn)(void))
1040 conf_changed_callback = fn; 1045 conf_changed_callback = fn;
1041} 1046}
1042 1047
1043static void randomize_choice_values(struct symbol *csym) 1048static bool randomize_choice_values(struct symbol *csym)
1044{ 1049{
1045 struct property *prop; 1050 struct property *prop;
1046 struct symbol *sym; 1051 struct symbol *sym;
@@ -1053,7 +1058,7 @@ static void randomize_choice_values(struct symbol *csym)
1053 * In both cases stop. 1058 * In both cases stop.
1054 */ 1059 */
1055 if (csym->curr.tri != yes) 1060 if (csym->curr.tri != yes)
1056 return; 1061 return false;
1057 1062
1058 prop = sym_get_choice_prop(csym); 1063 prop = sym_get_choice_prop(csym);
1059 1064
@@ -1077,13 +1082,18 @@ static void randomize_choice_values(struct symbol *csym)
1077 else { 1082 else {
1078 sym->def[S_DEF_USER].tri = no; 1083 sym->def[S_DEF_USER].tri = no;
1079 } 1084 }
1085 sym->flags |= SYMBOL_DEF_USER;
1086 /* clear VALID to get value calculated */
1087 sym->flags &= ~SYMBOL_VALID;
1080 } 1088 }
1081 csym->flags |= SYMBOL_DEF_USER; 1089 csym->flags |= SYMBOL_DEF_USER;
1082 /* clear VALID to get value calculated */ 1090 /* clear VALID to get value calculated */
1083 csym->flags &= ~(SYMBOL_VALID); 1091 csym->flags &= ~(SYMBOL_VALID);
1092
1093 return true;
1084} 1094}
1085 1095
1086static void set_all_choice_values(struct symbol *csym) 1096void set_all_choice_values(struct symbol *csym)
1087{ 1097{
1088 struct property *prop; 1098 struct property *prop;
1089 struct symbol *sym; 1099 struct symbol *sym;
@@ -1100,10 +1110,10 @@ static void set_all_choice_values(struct symbol *csym)
1100 } 1110 }
1101 csym->flags |= SYMBOL_DEF_USER; 1111 csym->flags |= SYMBOL_DEF_USER;
1102 /* clear VALID to get value calculated */ 1112 /* clear VALID to get value calculated */
1103 csym->flags &= ~(SYMBOL_VALID); 1113 csym->flags &= ~(SYMBOL_VALID | SYMBOL_NEED_SET_CHOICE_VALUES);
1104} 1114}
1105 1115
1106void conf_set_all_new_symbols(enum conf_def_mode mode) 1116bool conf_set_all_new_symbols(enum conf_def_mode mode)
1107{ 1117{
1108 struct symbol *sym, *csym; 1118 struct symbol *sym, *csym;
1109 int i, cnt, pby, pty, ptm; /* pby: probability of boolean = y 1119 int i, cnt, pby, pty, ptm; /* pby: probability of boolean = y
@@ -1151,6 +1161,7 @@ void conf_set_all_new_symbols(enum conf_def_mode mode)
1151 exit( 1 ); 1161 exit( 1 );
1152 } 1162 }
1153 } 1163 }
1164 bool has_changed = false;
1154 1165
1155 for_all_symbols(i, sym) { 1166 for_all_symbols(i, sym) {
1156 if (sym_has_value(sym) || (sym->flags & SYMBOL_VALID)) 1167 if (sym_has_value(sym) || (sym->flags & SYMBOL_VALID))
@@ -1158,6 +1169,7 @@ void conf_set_all_new_symbols(enum conf_def_mode mode)
1158 switch (sym_get_type(sym)) { 1169 switch (sym_get_type(sym)) {
1159 case S_BOOLEAN: 1170 case S_BOOLEAN:
1160 case S_TRISTATE: 1171 case S_TRISTATE:
1172 has_changed = true;
1161 switch (mode) { 1173 switch (mode) {
1162 case def_yes: 1174 case def_yes:
1163 sym->def[S_DEF_USER].tri = yes; 1175 sym->def[S_DEF_USER].tri = yes;
@@ -1202,14 +1214,26 @@ void conf_set_all_new_symbols(enum conf_def_mode mode)
1202 * selected in a choice block and we set it to yes, 1214 * selected in a choice block and we set it to yes,
1203 * and the rest to no. 1215 * and the rest to no.
1204 */ 1216 */
1217 if (mode != def_random) {
1218 for_all_symbols(i, csym) {
1219 if ((sym_is_choice(csym) && !sym_has_value(csym)) ||
1220 sym_is_choice_value(csym))
1221 csym->flags |= SYMBOL_NEED_SET_CHOICE_VALUES;
1222 }
1223 }
1224
1205 for_all_symbols(i, csym) { 1225 for_all_symbols(i, csym) {
1206 if (sym_has_value(csym) || !sym_is_choice(csym)) 1226 if (sym_has_value(csym) || !sym_is_choice(csym))
1207 continue; 1227 continue;
1208 1228
1209 sym_calc_value(csym); 1229 sym_calc_value(csym);
1210 if (mode == def_random) 1230 if (mode == def_random)
1211 randomize_choice_values(csym); 1231 has_changed = randomize_choice_values(csym);
1212 else 1232 else {
1213 set_all_choice_values(csym); 1233 set_all_choice_values(csym);
1234 has_changed = true;
1235 }
1214 } 1236 }
1237
1238 return has_changed;
1215} 1239}
diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h
index cdd48600e02a..df198a5f4822 100644
--- a/scripts/kconfig/expr.h
+++ b/scripts/kconfig/expr.h
@@ -106,6 +106,9 @@ struct symbol {
106#define SYMBOL_DEF3 0x40000 /* symbol.def[S_DEF_3] is valid */ 106#define SYMBOL_DEF3 0x40000 /* symbol.def[S_DEF_3] is valid */
107#define SYMBOL_DEF4 0x80000 /* symbol.def[S_DEF_4] is valid */ 107#define SYMBOL_DEF4 0x80000 /* symbol.def[S_DEF_4] is valid */
108 108
109/* choice values need to be set before calculating this symbol value */
110#define SYMBOL_NEED_SET_CHOICE_VALUES 0x100000
111
109#define SYMBOL_MAXLENGTH 256 112#define SYMBOL_MAXLENGTH 256
110#define SYMBOL_HASHSIZE 9973 113#define SYMBOL_HASHSIZE 9973
111 114
diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h
index f8aee5fc6d5e..09f4edfdc911 100644
--- a/scripts/kconfig/lkc.h
+++ b/scripts/kconfig/lkc.h
@@ -86,7 +86,8 @@ const char *conf_get_autoconfig_name(void);
86char *conf_get_default_confname(void); 86char *conf_get_default_confname(void);
87void sym_set_change_count(int count); 87void sym_set_change_count(int count);
88void sym_add_change_count(int count); 88void sym_add_change_count(int count);
89void conf_set_all_new_symbols(enum conf_def_mode mode); 89bool conf_set_all_new_symbols(enum conf_def_mode mode);
90void set_all_choice_values(struct symbol *csym);
90 91
91struct conf_printer { 92struct conf_printer {
92 void (*print_symbol)(FILE *, struct symbol *, const char *, void *); 93 void (*print_symbol)(FILE *, struct symbol *, const char *, void *);
diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h
index ef1a7381f956..ecdb9659b67d 100644
--- a/scripts/kconfig/lkc_proto.h
+++ b/scripts/kconfig/lkc_proto.h
@@ -14,6 +14,7 @@ P(conf_set_message_callback, void,(void (*fn)(const char *fmt, va_list ap)));
14/* menu.c */ 14/* menu.c */
15P(rootmenu,struct menu,); 15P(rootmenu,struct menu,);
16 16
17P(menu_is_empty, bool, (struct menu *menu));
17P(menu_is_visible, bool, (struct menu *menu)); 18P(menu_is_visible, bool, (struct menu *menu));
18P(menu_has_prompt, bool, (struct menu *menu)); 19P(menu_has_prompt, bool, (struct menu *menu));
19P(menu_get_prompt,const char *,(struct menu *menu)); 20P(menu_get_prompt,const char *,(struct menu *menu));
diff --git a/scripts/kconfig/lxdialog/checklist.c b/scripts/kconfig/lxdialog/checklist.c
index a2eb80fbc896..3b15c08ec1fa 100644
--- a/scripts/kconfig/lxdialog/checklist.c
+++ b/scripts/kconfig/lxdialog/checklist.c
@@ -132,16 +132,16 @@ int dialog_checklist(const char *title, const char *prompt, int height,
132 } 132 }
133 133
134do_resize: 134do_resize:
135 if (getmaxy(stdscr) < (height + 6)) 135 if (getmaxy(stdscr) < (height + CHECKLIST_HEIGTH_MIN))
136 return -ERRDISPLAYTOOSMALL; 136 return -ERRDISPLAYTOOSMALL;
137 if (getmaxx(stdscr) < (width + 6)) 137 if (getmaxx(stdscr) < (width + CHECKLIST_WIDTH_MIN))
138 return -ERRDISPLAYTOOSMALL; 138 return -ERRDISPLAYTOOSMALL;
139 139
140 max_choice = MIN(list_height, item_count()); 140 max_choice = MIN(list_height, item_count());
141 141
142 /* center dialog box on screen */ 142 /* center dialog box on screen */
143 x = (COLS - width) / 2; 143 x = (getmaxx(stdscr) - width) / 2;
144 y = (LINES - height) / 2; 144 y = (getmaxy(stdscr) - height) / 2;
145 145
146 draw_shadow(stdscr, y, x, height, width); 146 draw_shadow(stdscr, y, x, height, width);
147 147
diff --git a/scripts/kconfig/lxdialog/dialog.h b/scripts/kconfig/lxdialog/dialog.h
index 1099337079b6..b4343d384926 100644
--- a/scripts/kconfig/lxdialog/dialog.h
+++ b/scripts/kconfig/lxdialog/dialog.h
@@ -200,6 +200,20 @@ int item_is_tag(char tag);
200int on_key_esc(WINDOW *win); 200int on_key_esc(WINDOW *win);
201int on_key_resize(void); 201int on_key_resize(void);
202 202
203/* minimum (re)size values */
204#define CHECKLIST_HEIGTH_MIN 6 /* For dialog_checklist() */
205#define CHECKLIST_WIDTH_MIN 6
206#define INPUTBOX_HEIGTH_MIN 2 /* For dialog_inputbox() */
207#define INPUTBOX_WIDTH_MIN 2
208#define MENUBOX_HEIGTH_MIN 15 /* For dialog_menu() */
209#define MENUBOX_WIDTH_MIN 65
210#define TEXTBOX_HEIGTH_MIN 8 /* For dialog_textbox() */
211#define TEXTBOX_WIDTH_MIN 8
212#define YESNO_HEIGTH_MIN 4 /* For dialog_yesno() */
213#define YESNO_WIDTH_MIN 4
214#define WINDOW_HEIGTH_MIN 19 /* For init_dialog() */
215#define WINDOW_WIDTH_MIN 80
216
203int init_dialog(const char *backtitle); 217int init_dialog(const char *backtitle);
204void set_dialog_backtitle(const char *backtitle); 218void set_dialog_backtitle(const char *backtitle);
205void set_dialog_subtitles(struct subtitle_list *subtitles); 219void set_dialog_subtitles(struct subtitle_list *subtitles);
diff --git a/scripts/kconfig/lxdialog/inputbox.c b/scripts/kconfig/lxdialog/inputbox.c
index 21404a04d7c3..447a582198c9 100644
--- a/scripts/kconfig/lxdialog/inputbox.c
+++ b/scripts/kconfig/lxdialog/inputbox.c
@@ -56,14 +56,14 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width
56 strcpy(instr, init); 56 strcpy(instr, init);
57 57
58do_resize: 58do_resize:
59 if (getmaxy(stdscr) <= (height - 2)) 59 if (getmaxy(stdscr) <= (height - INPUTBOX_HEIGTH_MIN))
60 return -ERRDISPLAYTOOSMALL; 60 return -ERRDISPLAYTOOSMALL;
61 if (getmaxx(stdscr) <= (width - 2)) 61 if (getmaxx(stdscr) <= (width - INPUTBOX_WIDTH_MIN))
62 return -ERRDISPLAYTOOSMALL; 62 return -ERRDISPLAYTOOSMALL;
63 63
64 /* center dialog box on screen */ 64 /* center dialog box on screen */
65 x = (COLS - width) / 2; 65 x = (getmaxx(stdscr) - width) / 2;
66 y = (LINES - height) / 2; 66 y = (getmaxy(stdscr) - height) / 2;
67 67
68 draw_shadow(stdscr, y, x, height, width); 68 draw_shadow(stdscr, y, x, height, width);
69 69
diff --git a/scripts/kconfig/lxdialog/menubox.c b/scripts/kconfig/lxdialog/menubox.c
index 38cd69c5660e..c93de0b2faca 100644
--- a/scripts/kconfig/lxdialog/menubox.c
+++ b/scripts/kconfig/lxdialog/menubox.c
@@ -193,7 +193,7 @@ int dialog_menu(const char *title, const char *prompt,
193do_resize: 193do_resize:
194 height = getmaxy(stdscr); 194 height = getmaxy(stdscr);
195 width = getmaxx(stdscr); 195 width = getmaxx(stdscr);
196 if (height < 15 || width < 65) 196 if (height < MENUBOX_HEIGTH_MIN || width < MENUBOX_WIDTH_MIN)
197 return -ERRDISPLAYTOOSMALL; 197 return -ERRDISPLAYTOOSMALL;
198 198
199 height -= 4; 199 height -= 4;
@@ -203,8 +203,8 @@ do_resize:
203 max_choice = MIN(menu_height, item_count()); 203 max_choice = MIN(menu_height, item_count());
204 204
205 /* center dialog box on screen */ 205 /* center dialog box on screen */
206 x = (COLS - width) / 2; 206 x = (getmaxx(stdscr) - width) / 2;
207 y = (LINES - height) / 2; 207 y = (getmaxy(stdscr) - height) / 2;
208 208
209 draw_shadow(stdscr, y, x, height, width); 209 draw_shadow(stdscr, y, x, height, width);
210 210
diff --git a/scripts/kconfig/lxdialog/textbox.c b/scripts/kconfig/lxdialog/textbox.c
index a48bb93e0907..1773319b95e7 100644
--- a/scripts/kconfig/lxdialog/textbox.c
+++ b/scripts/kconfig/lxdialog/textbox.c
@@ -80,7 +80,7 @@ int dialog_textbox(const char *title, char *tbuf, int initial_height,
80 80
81do_resize: 81do_resize:
82 getmaxyx(stdscr, height, width); 82 getmaxyx(stdscr, height, width);
83 if (height < 8 || width < 8) 83 if (height < TEXTBOX_HEIGTH_MIN || width < TEXTBOX_WIDTH_MIN)
84 return -ERRDISPLAYTOOSMALL; 84 return -ERRDISPLAYTOOSMALL;
85 if (initial_height != 0) 85 if (initial_height != 0)
86 height = initial_height; 86 height = initial_height;
@@ -98,8 +98,8 @@ do_resize:
98 width = 0; 98 width = 0;
99 99
100 /* center dialog box on screen */ 100 /* center dialog box on screen */
101 x = (COLS - width) / 2; 101 x = (getmaxx(stdscr) - width) / 2;
102 y = (LINES - height) / 2; 102 y = (getmaxy(stdscr) - height) / 2;
103 103
104 draw_shadow(stdscr, y, x, height, width); 104 draw_shadow(stdscr, y, x, height, width);
105 105
diff --git a/scripts/kconfig/lxdialog/util.c b/scripts/kconfig/lxdialog/util.c
index a0e97c299410..58a8289dd650 100644
--- a/scripts/kconfig/lxdialog/util.c
+++ b/scripts/kconfig/lxdialog/util.c
@@ -254,7 +254,12 @@ void attr_clear(WINDOW * win, int height, int width, chtype attr)
254 254
255void dialog_clear(void) 255void dialog_clear(void)
256{ 256{
257 attr_clear(stdscr, LINES, COLS, dlg.screen.atr); 257 int lines, columns;
258
259 lines = getmaxy(stdscr);
260 columns = getmaxx(stdscr);
261
262 attr_clear(stdscr, lines, columns, dlg.screen.atr);
258 /* Display background title if it exists ... - SLH */ 263 /* Display background title if it exists ... - SLH */
259 if (dlg.backtitle != NULL) { 264 if (dlg.backtitle != NULL) {
260 int i, len = 0, skip = 0; 265 int i, len = 0, skip = 0;
@@ -269,10 +274,10 @@ void dialog_clear(void)
269 } 274 }
270 275
271 wmove(stdscr, 1, 1); 276 wmove(stdscr, 1, 1);
272 if (len > COLS - 2) { 277 if (len > columns - 2) {
273 const char *ellipsis = "[...] "; 278 const char *ellipsis = "[...] ";
274 waddstr(stdscr, ellipsis); 279 waddstr(stdscr, ellipsis);
275 skip = len - (COLS - 2 - strlen(ellipsis)); 280 skip = len - (columns - 2 - strlen(ellipsis));
276 } 281 }
277 282
278 for (pos = dlg.subtitles; pos != NULL; pos = pos->next) { 283 for (pos = dlg.subtitles; pos != NULL; pos = pos->next) {
@@ -298,7 +303,7 @@ void dialog_clear(void)
298 skip--; 303 skip--;
299 } 304 }
300 305
301 for (i = len + 1; i < COLS - 1; i++) 306 for (i = len + 1; i < columns - 1; i++)
302 waddch(stdscr, ACS_HLINE); 307 waddch(stdscr, ACS_HLINE);
303 } 308 }
304 wnoutrefresh(stdscr); 309 wnoutrefresh(stdscr);
@@ -317,7 +322,7 @@ int init_dialog(const char *backtitle)
317 getyx(stdscr, saved_y, saved_x); 322 getyx(stdscr, saved_y, saved_x);
318 323
319 getmaxyx(stdscr, height, width); 324 getmaxyx(stdscr, height, width);
320 if (height < 19 || width < 80) { 325 if (height < WINDOW_HEIGTH_MIN || width < WINDOW_WIDTH_MIN) {
321 endwin(); 326 endwin();
322 return -ERRDISPLAYTOOSMALL; 327 return -ERRDISPLAYTOOSMALL;
323 } 328 }
@@ -371,27 +376,19 @@ void print_title(WINDOW *dialog, const char *title, int width)
371/* 376/*
372 * Print a string of text in a window, automatically wrap around to the 377 * Print a string of text in a window, automatically wrap around to the
373 * next line if the string is too long to fit on one line. Newline 378 * next line if the string is too long to fit on one line. Newline
374 * characters '\n' are replaced by spaces. We start on a new line 379 * characters '\n' are propperly processed. We start on a new line
375 * if there is no room for at least 4 nonblanks following a double-space. 380 * if there is no room for at least 4 nonblanks following a double-space.
376 */ 381 */
377void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x) 382void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x)
378{ 383{
379 int newl, cur_x, cur_y; 384 int newl, cur_x, cur_y;
380 int i, prompt_len, room, wlen; 385 int prompt_len, room, wlen;
381 char tempstr[MAX_LEN + 1], *word, *sp, *sp2; 386 char tempstr[MAX_LEN + 1], *word, *sp, *sp2, *newline_separator = 0;
382 387
383 strcpy(tempstr, prompt); 388 strcpy(tempstr, prompt);
384 389
385 prompt_len = strlen(tempstr); 390 prompt_len = strlen(tempstr);
386 391
387 /*
388 * Remove newlines
389 */
390 for (i = 0; i < prompt_len; i++) {
391 if (tempstr[i] == '\n')
392 tempstr[i] = ' ';
393 }
394
395 if (prompt_len <= width - x * 2) { /* If prompt is short */ 392 if (prompt_len <= width - x * 2) { /* If prompt is short */
396 wmove(win, y, (width - prompt_len) / 2); 393 wmove(win, y, (width - prompt_len) / 2);
397 waddstr(win, tempstr); 394 waddstr(win, tempstr);
@@ -401,7 +398,10 @@ void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x)
401 newl = 1; 398 newl = 1;
402 word = tempstr; 399 word = tempstr;
403 while (word && *word) { 400 while (word && *word) {
404 sp = strchr(word, ' '); 401 sp = strpbrk(word, "\n ");
402 if (sp && *sp == '\n')
403 newline_separator = sp;
404
405 if (sp) 405 if (sp)
406 *sp++ = 0; 406 *sp++ = 0;
407 407
@@ -413,7 +413,7 @@ void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x)
413 if (wlen > room || 413 if (wlen > room ||
414 (newl && wlen < 4 && sp 414 (newl && wlen < 4 && sp
415 && wlen + 1 + strlen(sp) > room 415 && wlen + 1 + strlen(sp) > room
416 && (!(sp2 = strchr(sp, ' ')) 416 && (!(sp2 = strpbrk(sp, "\n "))
417 || wlen + 1 + (sp2 - sp) > room))) { 417 || wlen + 1 + (sp2 - sp) > room))) {
418 cur_y++; 418 cur_y++;
419 cur_x = x; 419 cur_x = x;
@@ -421,7 +421,15 @@ void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x)
421 wmove(win, cur_y, cur_x); 421 wmove(win, cur_y, cur_x);
422 waddstr(win, word); 422 waddstr(win, word);
423 getyx(win, cur_y, cur_x); 423 getyx(win, cur_y, cur_x);
424 cur_x++; 424
425 /* Move to the next line if the word separator was a newline */
426 if (newline_separator) {
427 cur_y++;
428 cur_x = x;
429 newline_separator = 0;
430 } else
431 cur_x++;
432
425 if (sp && *sp == ' ') { 433 if (sp && *sp == ' ') {
426 cur_x++; /* double space */ 434 cur_x++; /* double space */
427 while (*++sp == ' ') ; 435 while (*++sp == ' ') ;
diff --git a/scripts/kconfig/lxdialog/yesno.c b/scripts/kconfig/lxdialog/yesno.c
index 4e6e8090c20b..676fb2f824a3 100644
--- a/scripts/kconfig/lxdialog/yesno.c
+++ b/scripts/kconfig/lxdialog/yesno.c
@@ -45,14 +45,14 @@ int dialog_yesno(const char *title, const char *prompt, int height, int width)
45 WINDOW *dialog; 45 WINDOW *dialog;
46 46
47do_resize: 47do_resize:
48 if (getmaxy(stdscr) < (height + 4)) 48 if (getmaxy(stdscr) < (height + YESNO_HEIGTH_MIN))
49 return -ERRDISPLAYTOOSMALL; 49 return -ERRDISPLAYTOOSMALL;
50 if (getmaxx(stdscr) < (width + 4)) 50 if (getmaxx(stdscr) < (width + YESNO_WIDTH_MIN))
51 return -ERRDISPLAYTOOSMALL; 51 return -ERRDISPLAYTOOSMALL;
52 52
53 /* center dialog box on screen */ 53 /* center dialog box on screen */
54 x = (COLS - width) / 2; 54 x = (getmaxx(stdscr) - width) / 2;
55 y = (LINES - height) / 2; 55 y = (getmaxy(stdscr) - height) / 2;
56 56
57 draw_shadow(stdscr, y, x, height, width); 57 draw_shadow(stdscr, y, x, height, width);
58 58
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c
index a69cbd78fb38..2c3963165a0d 100644
--- a/scripts/kconfig/mconf.c
+++ b/scripts/kconfig/mconf.c
@@ -48,7 +48,7 @@ static const char mconf_readme[] = N_(
48"----------\n" 48"----------\n"
49"o Use the Up/Down arrow keys (cursor keys) to highlight the item\n" 49"o Use the Up/Down arrow keys (cursor keys) to highlight the item\n"
50" you wish to change or submenu wish to select and press <Enter>.\n" 50" you wish to change or submenu wish to select and press <Enter>.\n"
51" Submenus are designated by \"--->\".\n" 51" Submenus are designated by \"--->\", empty ones by \"----\".\n"
52"\n" 52"\n"
53" Shortcut: Press the option's highlighted letter (hotkey).\n" 53" Shortcut: Press the option's highlighted letter (hotkey).\n"
54" Pressing a hotkey more than once will sequence\n" 54" Pressing a hotkey more than once will sequence\n"
@@ -176,7 +176,7 @@ static const char mconf_readme[] = N_(
176"\n"), 176"\n"),
177menu_instructions[] = N_( 177menu_instructions[] = N_(
178 "Arrow keys navigate the menu. " 178 "Arrow keys navigate the menu. "
179 "<Enter> selects submenus --->. " 179 "<Enter> selects submenus ---> (or empty submenus ----). "
180 "Highlighted letters are hotkeys. " 180 "Highlighted letters are hotkeys. "
181 "Pressing <Y> includes, <N> excludes, <M> modularizes features. " 181 "Pressing <Y> includes, <N> excludes, <M> modularizes features. "
182 "Press <Esc><Esc> to exit, <?> for Help, </> for Search. " 182 "Press <Esc><Esc> to exit, <?> for Help, </> for Search. "
@@ -401,8 +401,8 @@ static void search_conf(void)
401 struct subtitle_part stpart; 401 struct subtitle_part stpart;
402 402
403 title = str_new(); 403 title = str_new();
404 str_printf( &title, _("Enter %s (sub)string to search for " 404 str_printf( &title, _("Enter (sub)string or regexp to search for "
405 "(with or without \"%s\")"), CONFIG_, CONFIG_); 405 "(with or without \"%s\")"), CONFIG_);
406 406
407again: 407again:
408 dialog_clear(); 408 dialog_clear();
@@ -498,8 +498,9 @@ static void build_conf(struct menu *menu)
498 menu->data ? "-->" : "++>", 498 menu->data ? "-->" : "++>",
499 indent + 1, ' ', prompt); 499 indent + 1, ' ', prompt);
500 } else 500 } else
501 item_make(" %*c%s --->", indent + 1, ' ', prompt); 501 item_make(" %*c%s %s",
502 502 indent + 1, ' ', prompt,
503 menu_is_empty(menu) ? "----" : "--->");
503 item_set_tag('m'); 504 item_set_tag('m');
504 item_set_data(menu); 505 item_set_data(menu);
505 if (single_menu_mode && menu->data) 506 if (single_menu_mode && menu->data)
@@ -630,7 +631,7 @@ static void build_conf(struct menu *menu)
630 (sym_has_value(sym) || !sym_is_changable(sym)) ? 631 (sym_has_value(sym) || !sym_is_changable(sym)) ?
631 "" : _(" (NEW)")); 632 "" : _(" (NEW)"));
632 if (menu->prompt->type == P_MENU) { 633 if (menu->prompt->type == P_MENU) {
633 item_add_str(" --->"); 634 item_add_str(" %s", menu_is_empty(menu) ? "----" : "--->");
634 return; 635 return;
635 } 636 }
636 } 637 }
@@ -826,7 +827,9 @@ static void conf_choice(struct menu *menu)
826 dialog_clear(); 827 dialog_clear();
827 res = dialog_checklist(prompt ? _(prompt) : _("Main Menu"), 828 res = dialog_checklist(prompt ? _(prompt) : _("Main Menu"),
828 _(radiolist_instructions), 829 _(radiolist_instructions),
829 15, 70, 6); 830 MENUBOX_HEIGTH_MIN,
831 MENUBOX_WIDTH_MIN,
832 CHECKLIST_HEIGTH_MIN);
830 selected = item_activate_selected(); 833 selected = item_activate_selected();
831 switch (res) { 834 switch (res) {
832 case 0: 835 case 0:
@@ -957,8 +960,8 @@ static int handle_exit(void)
957 dialog_clear(); 960 dialog_clear();
958 if (conf_get_changed()) 961 if (conf_get_changed())
959 res = dialog_yesno(NULL, 962 res = dialog_yesno(NULL,
960 _("Do you wish to save your new configuration ?\n" 963 _("Do you wish to save your new configuration?\n"
961 "<ESC><ESC> to continue."), 964 "(Press <ESC><ESC> to continue kernel configuration.)"),
962 6, 60); 965 6, 60);
963 else 966 else
964 res = -1; 967 res = -1;
diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c
index fd3f0180e08f..c1d53200c306 100644
--- a/scripts/kconfig/menu.c
+++ b/scripts/kconfig/menu.c
@@ -197,12 +197,15 @@ void menu_add_symbol(enum prop_type type, struct symbol *sym, struct expr *dep)
197 197
198void menu_add_option(int token, char *arg) 198void menu_add_option(int token, char *arg)
199{ 199{
200 struct property *prop;
201
202 switch (token) { 200 switch (token) {
203 case T_OPT_MODULES: 201 case T_OPT_MODULES:
204 prop = prop_alloc(P_DEFAULT, modules_sym); 202 if (modules_sym)
205 prop->expr = expr_alloc_symbol(current_entry->sym); 203 zconf_error("symbol '%s' redefines option 'modules'"
204 " already defined by symbol '%s'",
205 current_entry->sym->name,
206 modules_sym->name
207 );
208 modules_sym = current_entry->sym;
206 break; 209 break;
207 case T_OPT_DEFCONFIG_LIST: 210 case T_OPT_DEFCONFIG_LIST:
208 if (!sym_defconfig_list) 211 if (!sym_defconfig_list)
@@ -443,6 +446,22 @@ bool menu_has_prompt(struct menu *menu)
443 return true; 446 return true;
444} 447}
445 448
449/*
450 * Determine if a menu is empty.
451 * A menu is considered empty if it contains no or only
452 * invisible entries.
453 */
454bool menu_is_empty(struct menu *menu)
455{
456 struct menu *child;
457
458 for (child = menu->list; child; child = child->next) {
459 if (menu_is_visible(child))
460 return(false);
461 }
462 return(true);
463}
464
446bool menu_is_visible(struct menu *menu) 465bool menu_is_visible(struct menu *menu)
447{ 466{
448 struct menu *child; 467 struct menu *child;
diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c
index dbf31edd22b2..4fbecd2473bc 100644
--- a/scripts/kconfig/nconf.c
+++ b/scripts/kconfig/nconf.c
@@ -45,8 +45,8 @@ static const char nconf_global_help[] = N_(
45"<n> to remove it. You may press the <Space> key to cycle through the\n" 45"<n> to remove it. You may press the <Space> key to cycle through the\n"
46"available options.\n" 46"available options.\n"
47"\n" 47"\n"
48"A trailing \"--->\" designates a submenu.\n" 48"A trailing \"--->\" designates a submenu, a trailing \"----\" an\n"
49"\n" 49"empty submenu.\n"
50"\n" 50"\n"
51"Menu navigation keys\n" 51"Menu navigation keys\n"
52"----------------------------------------------------------------------\n" 52"----------------------------------------------------------------------\n"
@@ -131,7 +131,7 @@ static const char nconf_global_help[] = N_(
131"\n"), 131"\n"),
132menu_no_f_instructions[] = N_( 132menu_no_f_instructions[] = N_(
133"Legend: [*] built-in [ ] excluded <M> module < > module capable.\n" 133"Legend: [*] built-in [ ] excluded <M> module < > module capable.\n"
134"Submenus are designated by a trailing \"--->\".\n" 134"Submenus are designated by a trailing \"--->\", empty ones by \"----\".\n"
135"\n" 135"\n"
136"Use the following keys to navigate the menus:\n" 136"Use the following keys to navigate the menus:\n"
137"Move up or down with <Up> and <Down>.\n" 137"Move up or down with <Up> and <Down>.\n"
@@ -148,7 +148,7 @@ menu_no_f_instructions[] = N_(
148"For help related to the current menu entry press <?> or <h>.\n"), 148"For help related to the current menu entry press <?> or <h>.\n"),
149menu_instructions[] = N_( 149menu_instructions[] = N_(
150"Legend: [*] built-in [ ] excluded <M> module < > module capable.\n" 150"Legend: [*] built-in [ ] excluded <M> module < > module capable.\n"
151"Submenus are designated by a trailing \"--->\".\n" 151"Submenus are designated by a trailing \"--->\", empty ones by \"----\".\n"
152"\n" 152"\n"
153"Use the following keys to navigate the menus:\n" 153"Use the following keys to navigate the menus:\n"
154"Move up or down with <Up> or <Down>.\n" 154"Move up or down with <Up> or <Down>.\n"
@@ -365,15 +365,16 @@ static void print_function_line(void)
365 int i; 365 int i;
366 int offset = 1; 366 int offset = 1;
367 const int skip = 1; 367 const int skip = 1;
368 int lines = getmaxy(stdscr);
368 369
369 for (i = 0; i < function_keys_num; i++) { 370 for (i = 0; i < function_keys_num; i++) {
370 (void) wattrset(main_window, attributes[FUNCTION_HIGHLIGHT]); 371 (void) wattrset(main_window, attributes[FUNCTION_HIGHLIGHT]);
371 mvwprintw(main_window, LINES-3, offset, 372 mvwprintw(main_window, lines-3, offset,
372 "%s", 373 "%s",
373 function_keys[i].key_str); 374 function_keys[i].key_str);
374 (void) wattrset(main_window, attributes[FUNCTION_TEXT]); 375 (void) wattrset(main_window, attributes[FUNCTION_TEXT]);
375 offset += strlen(function_keys[i].key_str); 376 offset += strlen(function_keys[i].key_str);
376 mvwprintw(main_window, LINES-3, 377 mvwprintw(main_window, lines-3,
377 offset, "%s", 378 offset, "%s",
378 function_keys[i].func); 379 function_keys[i].func);
379 offset += strlen(function_keys[i].func) + skip; 380 offset += strlen(function_keys[i].func) + skip;
@@ -694,8 +695,8 @@ static void search_conf(void)
694 int dres; 695 int dres;
695 696
696 title = str_new(); 697 title = str_new();
697 str_printf( &title, _("Enter %s (sub)string to search for " 698 str_printf( &title, _("Enter (sub)string or regexp to search for "
698 "(with or without \"%s\")"), CONFIG_, CONFIG_); 699 "(with or without \"%s\")"), CONFIG_);
699 700
700again: 701again:
701 dres = dialog_inputbox(main_window, 702 dres = dialog_inputbox(main_window,
@@ -759,9 +760,9 @@ static void build_conf(struct menu *menu)
759 indent + 1, ' ', prompt); 760 indent + 1, ' ', prompt);
760 } else 761 } else
761 item_make(menu, 'm', 762 item_make(menu, 'm',
762 " %*c%s --->", 763 " %*c%s %s",
763 indent + 1, 764 indent + 1, ' ', prompt,
764 ' ', prompt); 765 menu_is_empty(menu) ? "----" : "--->");
765 766
766 if (single_menu_mode && menu->data) 767 if (single_menu_mode && menu->data)
767 goto conf_childs; 768 goto conf_childs;
@@ -903,7 +904,7 @@ static void build_conf(struct menu *menu)
903 (sym_has_value(sym) || !sym_is_changable(sym)) ? 904 (sym_has_value(sym) || !sym_is_changable(sym)) ?
904 "" : _(" (NEW)")); 905 "" : _(" (NEW)"));
905 if (menu->prompt && menu->prompt->type == P_MENU) { 906 if (menu->prompt && menu->prompt->type == P_MENU) {
906 item_add_str(" --->"); 907 item_add_str(" %s", menu_is_empty(menu) ? "----" : "--->");
907 return; 908 return;
908 } 909 }
909 } 910 }
@@ -954,7 +955,7 @@ static void show_menu(const char *prompt, const char *instructions,
954 955
955 clear(); 956 clear();
956 (void) wattrset(main_window, attributes[NORMAL]); 957 (void) wattrset(main_window, attributes[NORMAL]);
957 print_in_middle(stdscr, 1, 0, COLS, 958 print_in_middle(stdscr, 1, 0, getmaxx(stdscr),
958 menu_backtitle, 959 menu_backtitle,
959 attributes[MAIN_HEADING]); 960 attributes[MAIN_HEADING]);
960 961
@@ -1455,14 +1456,18 @@ static void conf_save(void)
1455 1456
1456void setup_windows(void) 1457void setup_windows(void)
1457{ 1458{
1459 int lines, columns;
1460
1461 getmaxyx(stdscr, lines, columns);
1462
1458 if (main_window != NULL) 1463 if (main_window != NULL)
1459 delwin(main_window); 1464 delwin(main_window);
1460 1465
1461 /* set up the menu and menu window */ 1466 /* set up the menu and menu window */
1462 main_window = newwin(LINES-2, COLS-2, 2, 1); 1467 main_window = newwin(lines-2, columns-2, 2, 1);
1463 keypad(main_window, TRUE); 1468 keypad(main_window, TRUE);
1464 mwin_max_lines = LINES-7; 1469 mwin_max_lines = lines-7;
1465 mwin_max_cols = COLS-6; 1470 mwin_max_cols = columns-6;
1466 1471
1467 /* panels order is from bottom to top */ 1472 /* panels order is from bottom to top */
1468 new_panel(main_window); 1473 new_panel(main_window);
@@ -1470,6 +1475,7 @@ void setup_windows(void)
1470 1475
1471int main(int ac, char **av) 1476int main(int ac, char **av)
1472{ 1477{
1478 int lines, columns;
1473 char *mode; 1479 char *mode;
1474 1480
1475 setlocale(LC_ALL, ""); 1481 setlocale(LC_ALL, "");
@@ -1495,7 +1501,8 @@ int main(int ac, char **av)
1495 keypad(stdscr, TRUE); 1501 keypad(stdscr, TRUE);
1496 curs_set(0); 1502 curs_set(0);
1497 1503
1498 if (COLS < 75 || LINES < 20) { 1504 getmaxyx(stdscr, lines, columns);
1505 if (columns < 75 || lines < 20) {
1499 endwin(); 1506 endwin();
1500 printf("Your terminal should have at " 1507 printf("Your terminal should have at "
1501 "least 20 lines and 75 columns\n"); 1508 "least 20 lines and 75 columns\n");
diff --git a/scripts/kconfig/nconf.gui.c b/scripts/kconfig/nconf.gui.c
index 9f8c44ecc703..8275f0e55106 100644
--- a/scripts/kconfig/nconf.gui.c
+++ b/scripts/kconfig/nconf.gui.c
@@ -276,8 +276,8 @@ int btn_dialog(WINDOW *main_window, const char *msg, int btn_num, ...)
276 276
277 total_width = max(msg_width, btns_width); 277 total_width = max(msg_width, btns_width);
278 /* place dialog in middle of screen */ 278 /* place dialog in middle of screen */
279 y = (LINES-(msg_lines+4))/2; 279 y = (getmaxy(stdscr)-(msg_lines+4))/2;
280 x = (COLS-(total_width+4))/2; 280 x = (getmaxx(stdscr)-(total_width+4))/2;
281 281
282 282
283 /* create the windows */ 283 /* create the windows */
@@ -387,8 +387,8 @@ int dialog_inputbox(WINDOW *main_window,
387 prompt_width = max(prompt_width, strlen(title)); 387 prompt_width = max(prompt_width, strlen(title));
388 388
389 /* place dialog in middle of screen */ 389 /* place dialog in middle of screen */
390 y = (LINES-(prompt_lines+4))/2; 390 y = (getmaxy(stdscr)-(prompt_lines+4))/2;
391 x = (COLS-(prompt_width+4))/2; 391 x = (getmaxx(stdscr)-(prompt_width+4))/2;
392 392
393 strncpy(result, init, *result_len); 393 strncpy(result, init, *result_len);
394 394
@@ -545,7 +545,7 @@ void show_scroll_win(WINDOW *main_window,
545{ 545{
546 int res; 546 int res;
547 int total_lines = get_line_no(text); 547 int total_lines = get_line_no(text);
548 int x, y; 548 int x, y, lines, columns;
549 int start_x = 0, start_y = 0; 549 int start_x = 0, start_y = 0;
550 int text_lines = 0, text_cols = 0; 550 int text_lines = 0, text_cols = 0;
551 int total_cols = 0; 551 int total_cols = 0;
@@ -556,6 +556,8 @@ void show_scroll_win(WINDOW *main_window,
556 WINDOW *pad; 556 WINDOW *pad;
557 PANEL *panel; 557 PANEL *panel;
558 558
559 getmaxyx(stdscr, lines, columns);
560
559 /* find the widest line of msg: */ 561 /* find the widest line of msg: */
560 total_lines = get_line_no(text); 562 total_lines = get_line_no(text);
561 for (i = 0; i < total_lines; i++) { 563 for (i = 0; i < total_lines; i++) {
@@ -569,14 +571,14 @@ void show_scroll_win(WINDOW *main_window,
569 (void) wattrset(pad, attributes[SCROLLWIN_TEXT]); 571 (void) wattrset(pad, attributes[SCROLLWIN_TEXT]);
570 fill_window(pad, text); 572 fill_window(pad, text);
571 573
572 win_lines = min(total_lines+4, LINES-2); 574 win_lines = min(total_lines+4, lines-2);
573 win_cols = min(total_cols+2, COLS-2); 575 win_cols = min(total_cols+2, columns-2);
574 text_lines = max(win_lines-4, 0); 576 text_lines = max(win_lines-4, 0);
575 text_cols = max(win_cols-2, 0); 577 text_cols = max(win_cols-2, 0);
576 578
577 /* place window in middle of screen */ 579 /* place window in middle of screen */
578 y = (LINES-win_lines)/2; 580 y = (lines-win_lines)/2;
579 x = (COLS-win_cols)/2; 581 x = (columns-win_cols)/2;
580 582
581 win = newwin(win_lines, win_cols, y, x); 583 win = newwin(win_lines, win_cols, y, x);
582 keypad(win, TRUE); 584 keypad(win, TRUE);
diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
index ecc5aa5f865d..c9a6775565bf 100644
--- a/scripts/kconfig/symbol.c
+++ b/scripts/kconfig/symbol.c
@@ -136,7 +136,7 @@ static struct property *sym_get_range_prop(struct symbol *sym)
136 return NULL; 136 return NULL;
137} 137}
138 138
139static int sym_get_range_val(struct symbol *sym, int base) 139static long long sym_get_range_val(struct symbol *sym, int base)
140{ 140{
141 sym_calc_value(sym); 141 sym_calc_value(sym);
142 switch (sym->type) { 142 switch (sym->type) {
@@ -149,13 +149,14 @@ static int sym_get_range_val(struct symbol *sym, int base)
149 default: 149 default:
150 break; 150 break;
151 } 151 }
152 return strtol(sym->curr.val, NULL, base); 152 return strtoll(sym->curr.val, NULL, base);
153} 153}
154 154
155static void sym_validate_range(struct symbol *sym) 155static void sym_validate_range(struct symbol *sym)
156{ 156{
157 struct property *prop; 157 struct property *prop;
158 int base, val, val2; 158 int base;
159 long long val, val2;
159 char str[64]; 160 char str[64];
160 161
161 switch (sym->type) { 162 switch (sym->type) {
@@ -171,7 +172,7 @@ static void sym_validate_range(struct symbol *sym)
171 prop = sym_get_range_prop(sym); 172 prop = sym_get_range_prop(sym);
172 if (!prop) 173 if (!prop)
173 return; 174 return;
174 val = strtol(sym->curr.val, NULL, base); 175 val = strtoll(sym->curr.val, NULL, base);
175 val2 = sym_get_range_val(prop->expr->left.sym, base); 176 val2 = sym_get_range_val(prop->expr->left.sym, base);
176 if (val >= val2) { 177 if (val >= val2) {
177 val2 = sym_get_range_val(prop->expr->right.sym, base); 178 val2 = sym_get_range_val(prop->expr->right.sym, base);
@@ -179,9 +180,9 @@ static void sym_validate_range(struct symbol *sym)
179 return; 180 return;
180 } 181 }
181 if (sym->type == S_INT) 182 if (sym->type == S_INT)
182 sprintf(str, "%d", val2); 183 sprintf(str, "%lld", val2);
183 else 184 else
184 sprintf(str, "0x%x", val2); 185 sprintf(str, "0x%llx", val2);
185 sym->curr.val = strdup(str); 186 sym->curr.val = strdup(str);
186} 187}
187 188
@@ -300,6 +301,14 @@ void sym_calc_value(struct symbol *sym)
300 301
301 if (sym->flags & SYMBOL_VALID) 302 if (sym->flags & SYMBOL_VALID)
302 return; 303 return;
304
305 if (sym_is_choice_value(sym) &&
306 sym->flags & SYMBOL_NEED_SET_CHOICE_VALUES) {
307 sym->flags &= ~SYMBOL_NEED_SET_CHOICE_VALUES;
308 prop = sym_get_choice_prop(sym);
309 sym_calc_value(prop_get_symbol(prop));
310 }
311
303 sym->flags |= SYMBOL_VALID; 312 sym->flags |= SYMBOL_VALID;
304 313
305 oldval = sym->curr; 314 oldval = sym->curr;
@@ -425,6 +434,9 @@ void sym_calc_value(struct symbol *sym)
425 434
426 if (sym->flags & SYMBOL_AUTO) 435 if (sym->flags & SYMBOL_AUTO)
427 sym->flags &= ~SYMBOL_WRITE; 436 sym->flags &= ~SYMBOL_WRITE;
437
438 if (sym->flags & SYMBOL_NEED_SET_CHOICE_VALUES)
439 set_all_choice_values(sym);
428} 440}
429 441
430void sym_clear_all_valid(void) 442void sym_clear_all_valid(void)
@@ -583,7 +595,7 @@ bool sym_string_valid(struct symbol *sym, const char *str)
583bool sym_string_within_range(struct symbol *sym, const char *str) 595bool sym_string_within_range(struct symbol *sym, const char *str)
584{ 596{
585 struct property *prop; 597 struct property *prop;
586 int val; 598 long long val;
587 599
588 switch (sym->type) { 600 switch (sym->type) {
589 case S_STRING: 601 case S_STRING:
@@ -594,7 +606,7 @@ bool sym_string_within_range(struct symbol *sym, const char *str)
594 prop = sym_get_range_prop(sym); 606 prop = sym_get_range_prop(sym);
595 if (!prop) 607 if (!prop)
596 return true; 608 return true;
597 val = strtol(str, NULL, 10); 609 val = strtoll(str, NULL, 10);
598 return val >= sym_get_range_val(prop->expr->left.sym, 10) && 610 return val >= sym_get_range_val(prop->expr->left.sym, 10) &&
599 val <= sym_get_range_val(prop->expr->right.sym, 10); 611 val <= sym_get_range_val(prop->expr->right.sym, 10);
600 case S_HEX: 612 case S_HEX:
@@ -603,7 +615,7 @@ bool sym_string_within_range(struct symbol *sym, const char *str)
603 prop = sym_get_range_prop(sym); 615 prop = sym_get_range_prop(sym);
604 if (!prop) 616 if (!prop)
605 return true; 617 return true;
606 val = strtol(str, NULL, 16); 618 val = strtoll(str, NULL, 16);
607 return val >= sym_get_range_val(prop->expr->left.sym, 16) && 619 return val >= sym_get_range_val(prop->expr->left.sym, 16) &&
608 val <= sym_get_range_val(prop->expr->right.sym, 16); 620 val <= sym_get_range_val(prop->expr->right.sym, 16);
609 case S_BOOLEAN: 621 case S_BOOLEAN:
@@ -943,38 +955,89 @@ const char *sym_escape_string_value(const char *in)
943 return res; 955 return res;
944} 956}
945 957
958struct sym_match {
959 struct symbol *sym;
960 off_t so, eo;
961};
962
963/* Compare matched symbols as thus:
964 * - first, symbols that match exactly
965 * - then, alphabetical sort
966 */
967static int sym_rel_comp(const void *sym1, const void *sym2)
968{
969 const struct sym_match *s1 = sym1;
970 const struct sym_match *s2 = sym2;
971 int exact1, exact2;
972
973 /* Exact match:
974 * - if matched length on symbol s1 is the length of that symbol,
975 * then this symbol should come first;
976 * - if matched length on symbol s2 is the length of that symbol,
977 * then this symbol should come first.
978 * Note: since the search can be a regexp, both symbols may match
979 * exactly; if this is the case, we can't decide which comes first,
980 * and we fallback to sorting alphabetically.
981 */
982 exact1 = (s1->eo - s1->so) == strlen(s1->sym->name);
983 exact2 = (s2->eo - s2->so) == strlen(s2->sym->name);
984 if (exact1 && !exact2)
985 return -1;
986 if (!exact1 && exact2)
987 return 1;
988
989 /* As a fallback, sort symbols alphabetically */
990 return strcmp(s1->sym->name, s2->sym->name);
991}
992
946struct symbol **sym_re_search(const char *pattern) 993struct symbol **sym_re_search(const char *pattern)
947{ 994{
948 struct symbol *sym, **sym_arr = NULL; 995 struct symbol *sym, **sym_arr = NULL;
996 struct sym_match *sym_match_arr = NULL;
949 int i, cnt, size; 997 int i, cnt, size;
950 regex_t re; 998 regex_t re;
999 regmatch_t match[1];
951 1000
952 cnt = size = 0; 1001 cnt = size = 0;
953 /* Skip if empty */ 1002 /* Skip if empty */
954 if (strlen(pattern) == 0) 1003 if (strlen(pattern) == 0)
955 return NULL; 1004 return NULL;
956 if (regcomp(&re, pattern, REG_EXTENDED|REG_NOSUB|REG_ICASE)) 1005 if (regcomp(&re, pattern, REG_EXTENDED|REG_ICASE))
957 return NULL; 1006 return NULL;
958 1007
959 for_all_symbols(i, sym) { 1008 for_all_symbols(i, sym) {
960 if (sym->flags & SYMBOL_CONST || !sym->name) 1009 if (sym->flags & SYMBOL_CONST || !sym->name)
961 continue; 1010 continue;
962 if (regexec(&re, sym->name, 0, NULL, 0)) 1011 if (regexec(&re, sym->name, 1, match, 0))
963 continue; 1012 continue;
964 if (cnt + 1 >= size) { 1013 if (cnt >= size) {
965 void *tmp = sym_arr; 1014 void *tmp;
966 size += 16; 1015 size += 16;
967 sym_arr = realloc(sym_arr, size * sizeof(struct symbol *)); 1016 tmp = realloc(sym_match_arr, size * sizeof(struct sym_match));
968 if (!sym_arr) { 1017 if (!tmp)
969 free(tmp); 1018 goto sym_re_search_free;
970 return NULL; 1019 sym_match_arr = tmp;
971 }
972 } 1020 }
973 sym_calc_value(sym); 1021 sym_calc_value(sym);
974 sym_arr[cnt++] = sym; 1022 /* As regexec returned 0, we know we have a match, so
1023 * we can use match[0].rm_[se]o without further checks
1024 */
1025 sym_match_arr[cnt].so = match[0].rm_so;
1026 sym_match_arr[cnt].eo = match[0].rm_eo;
1027 sym_match_arr[cnt++].sym = sym;
975 } 1028 }
976 if (sym_arr) 1029 if (sym_match_arr) {
1030 qsort(sym_match_arr, cnt, sizeof(struct sym_match), sym_rel_comp);
1031 sym_arr = malloc((cnt+1) * sizeof(struct symbol));
1032 if (!sym_arr)
1033 goto sym_re_search_free;
1034 for (i = 0; i < cnt; i++)
1035 sym_arr[i] = sym_match_arr[i].sym;
977 sym_arr[cnt] = NULL; 1036 sym_arr[cnt] = NULL;
1037 }
1038sym_re_search_free:
1039 /* sym_match_arr can be NULL if no match, but free(NULL) is OK */
1040 free(sym_match_arr);
978 regfree(&re); 1041 regfree(&re);
979 1042
980 return sym_arr; 1043 return sym_arr;
diff --git a/scripts/kconfig/zconf.tab.c_shipped b/scripts/kconfig/zconf.tab.c_shipped
index f636141e7bfd..25ae16ac75c8 100644
--- a/scripts/kconfig/zconf.tab.c_shipped
+++ b/scripts/kconfig/zconf.tab.c_shipped
@@ -1,9 +1,8 @@
1/* A Bison parser, made by GNU Bison 2.4.3. */ 1/* A Bison parser, made by GNU Bison 2.5. */
2 2
3/* Skeleton implementation for Bison's Yacc-like parsers in C 3/* Bison implementation for Yacc-like parsers in C
4 4
5 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 5 Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc.
6 2009, 2010 Free Software Foundation, Inc.
7 6
8 This program is free software: you can redistribute it and/or modify 7 This program is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
@@ -45,7 +44,7 @@
45#define YYBISON 1 44#define YYBISON 1
46 45
47/* Bison version. */ 46/* Bison version. */
48#define YYBISON_VERSION "2.4.3" 47#define YYBISON_VERSION "2.5"
49 48
50/* Skeleton name. */ 49/* Skeleton name. */
51#define YYSKELETON_NAME "yacc.c" 50#define YYSKELETON_NAME "yacc.c"
@@ -302,11 +301,11 @@ YYID (yyi)
302# define alloca _alloca 301# define alloca _alloca
303# else 302# else
304# define YYSTACK_ALLOC alloca 303# define YYSTACK_ALLOC alloca
305# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ 304# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
306 || defined __cplusplus || defined _MSC_VER) 305 || defined __cplusplus || defined _MSC_VER)
307# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ 306# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
308# ifndef _STDLIB_H 307# ifndef EXIT_SUCCESS
309# define _STDLIB_H 1 308# define EXIT_SUCCESS 0
310# endif 309# endif
311# endif 310# endif
312# endif 311# endif
@@ -329,24 +328,24 @@ YYID (yyi)
329# ifndef YYSTACK_ALLOC_MAXIMUM 328# ifndef YYSTACK_ALLOC_MAXIMUM
330# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM 329# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
331# endif 330# endif
332# if (defined __cplusplus && ! defined _STDLIB_H \ 331# if (defined __cplusplus && ! defined EXIT_SUCCESS \
333 && ! ((defined YYMALLOC || defined malloc) \ 332 && ! ((defined YYMALLOC || defined malloc) \
334 && (defined YYFREE || defined free))) 333 && (defined YYFREE || defined free)))
335# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */ 334# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
336# ifndef _STDLIB_H 335# ifndef EXIT_SUCCESS
337# define _STDLIB_H 1 336# define EXIT_SUCCESS 0
338# endif 337# endif
339# endif 338# endif
340# ifndef YYMALLOC 339# ifndef YYMALLOC
341# define YYMALLOC malloc 340# define YYMALLOC malloc
342# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ 341# if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
343 || defined __cplusplus || defined _MSC_VER) 342 || defined __cplusplus || defined _MSC_VER)
344void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ 343void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
345# endif 344# endif
346# endif 345# endif
347# ifndef YYFREE 346# ifndef YYFREE
348# define YYFREE free 347# define YYFREE free
349# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ 348# if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
350 || defined __cplusplus || defined _MSC_VER) 349 || defined __cplusplus || defined _MSC_VER)
351void free (void *); /* INFRINGES ON USER NAME SPACE */ 350void free (void *); /* INFRINGES ON USER NAME SPACE */
352# endif 351# endif
@@ -375,23 +374,7 @@ union yyalloc
375 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ 374 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
376 + YYSTACK_GAP_MAXIMUM) 375 + YYSTACK_GAP_MAXIMUM)
377 376
378/* Copy COUNT objects from FROM to TO. The source and destination do 377# define YYCOPY_NEEDED 1
379 not overlap. */
380# ifndef YYCOPY
381# if defined __GNUC__ && 1 < __GNUC__
382# define YYCOPY(To, From, Count) \
383 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
384# else
385# define YYCOPY(To, From, Count) \
386 do \
387 { \
388 YYSIZE_T yyi; \
389 for (yyi = 0; yyi < (Count); yyi++) \
390 (To)[yyi] = (From)[yyi]; \
391 } \
392 while (YYID (0))
393# endif
394# endif
395 378
396/* Relocate STACK from its old location to the new one. The 379/* Relocate STACK from its old location to the new one. The
397 local variables YYSIZE and YYSTACKSIZE give the old and new number of 380 local variables YYSIZE and YYSTACKSIZE give the old and new number of
@@ -411,6 +394,26 @@ union yyalloc
411 394
412#endif 395#endif
413 396
397#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
398/* Copy COUNT objects from FROM to TO. The source and destination do
399 not overlap. */
400# ifndef YYCOPY
401# if defined __GNUC__ && 1 < __GNUC__
402# define YYCOPY(To, From, Count) \
403 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
404# else
405# define YYCOPY(To, From, Count) \
406 do \
407 { \
408 YYSIZE_T yyi; \
409 for (yyi = 0; yyi < (Count); yyi++) \
410 (To)[yyi] = (From)[yyi]; \
411 } \
412 while (YYID (0))
413# endif
414# endif
415#endif /* !YYCOPY_NEEDED */
416
414/* YYFINAL -- State number of the termination state. */ 417/* YYFINAL -- State number of the termination state. */
415#define YYFINAL 11 418#define YYFINAL 11
416/* YYLAST -- Last index in YYTABLE. */ 419/* YYLAST -- Last index in YYTABLE. */
@@ -529,18 +532,18 @@ static const yytype_int8 yyrhs[] =
529/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ 532/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
530static const yytype_uint16 yyrline[] = 533static const yytype_uint16 yyrline[] =
531{ 534{
532 0, 104, 104, 104, 106, 106, 108, 110, 111, 112, 535 0, 103, 103, 103, 105, 105, 107, 109, 110, 111,
533 113, 114, 115, 119, 123, 123, 123, 123, 123, 123, 536 112, 113, 114, 118, 122, 122, 122, 122, 122, 122,
534 123, 123, 127, 128, 129, 130, 131, 132, 136, 137, 537 122, 122, 126, 127, 128, 129, 130, 131, 135, 136,
535 143, 151, 157, 165, 175, 177, 178, 179, 180, 181, 538 142, 150, 156, 164, 174, 176, 177, 178, 179, 180,
536 182, 185, 193, 199, 209, 215, 221, 224, 226, 237, 539 181, 184, 192, 198, 208, 214, 220, 223, 225, 236,
537 238, 243, 252, 257, 265, 268, 270, 271, 272, 273, 540 237, 242, 251, 256, 264, 267, 269, 270, 271, 272,
538 274, 277, 283, 294, 300, 310, 312, 317, 325, 333, 541 273, 276, 282, 293, 299, 309, 311, 316, 324, 332,
539 336, 338, 339, 340, 345, 352, 359, 364, 372, 375, 542 335, 337, 338, 339, 344, 351, 358, 363, 371, 374,
540 377, 378, 379, 382, 390, 397, 404, 410, 417, 419, 543 376, 377, 378, 381, 389, 396, 403, 409, 416, 418,
541 420, 421, 424, 432, 434, 435, 438, 445, 447, 452, 544 419, 420, 423, 431, 433, 434, 437, 444, 446, 451,
542 453, 456, 457, 458, 462, 463, 466, 467, 470, 471, 545 452, 455, 456, 457, 461, 462, 465, 466, 469, 470,
543 472, 473, 474, 475, 476, 479, 480, 483, 484 546 471, 472, 473, 474, 475, 478, 479, 482, 483
544}; 547};
545#endif 548#endif
546 549
@@ -615,8 +618,8 @@ static const yytype_uint8 yyr2[] =
615 3, 3, 2, 3, 3, 1, 1, 0, 1 618 3, 3, 2, 3, 3, 1, 1, 0, 1
616}; 619};
617 620
618/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state 621/* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
619 STATE-NUM when YYTABLE doesn't specify something else to do. Zero 622 Performed when YYTABLE doesn't specify something else to do. Zero
620 means the default is an error. */ 623 means the default is an error. */
621static const yytype_uint8 yydefact[] = 624static const yytype_uint8 yydefact[] =
622{ 625{
@@ -691,8 +694,7 @@ static const yytype_int16 yypgoto[] =
691 694
692/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If 695/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
693 positive, shift that token. If negative, reduce the rule which 696 positive, shift that token. If negative, reduce the rule which
694 number is the opposite. If zero, do what YYDEFACT says. 697 number is the opposite. If YYTABLE_NINF, syntax error. */
695 If YYTABLE_NINF, syntax error. */
696#define YYTABLE_NINF -86 698#define YYTABLE_NINF -86
697static const yytype_int16 yytable[] = 699static const yytype_int16 yytable[] =
698{ 700{
@@ -728,6 +730,12 @@ static const yytype_int16 yytable[] =
728 184 730 184
729}; 731};
730 732
733#define yypact_value_is_default(yystate) \
734 ((yystate) == (-90))
735
736#define yytable_value_is_error(yytable_value) \
737 YYID (0)
738
731static const yytype_int16 yycheck[] = 739static const yytype_int16 yycheck[] =
732{ 740{
733 1, 67, 68, 10, 93, 94, 76, 3, 76, 14, 741 1, 67, 68, 10, 93, 94, 76, 3, 76, 14,
@@ -821,7 +829,6 @@ do \
821 { \ 829 { \
822 yychar = (Token); \ 830 yychar = (Token); \
823 yylval = (Value); \ 831 yylval = (Value); \
824 yytoken = YYTRANSLATE (yychar); \
825 YYPOPSTACK (1); \ 832 YYPOPSTACK (1); \
826 goto yybackup; \ 833 goto yybackup; \
827 } \ 834 } \
@@ -863,19 +870,10 @@ while (YYID (0))
863#endif 870#endif
864 871
865 872
866/* YY_LOCATION_PRINT -- Print the location on the stream. 873/* This macro is provided for backward compatibility. */
867 This macro was not mandated originally: define only if we know
868 we won't break user code: when these are the locations we know. */
869 874
870#ifndef YY_LOCATION_PRINT 875#ifndef YY_LOCATION_PRINT
871# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL 876# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
872# define YY_LOCATION_PRINT(File, Loc) \
873 fprintf (File, "%d.%d-%d.%d", \
874 (Loc).first_line, (Loc).first_column, \
875 (Loc).last_line, (Loc).last_column)
876# else
877# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
878# endif
879#endif 877#endif
880 878
881 879
@@ -1067,7 +1065,6 @@ int yydebug;
1067# define YYMAXDEPTH 10000 1065# define YYMAXDEPTH 10000
1068#endif 1066#endif
1069 1067
1070
1071 1068
1072#if YYERROR_VERBOSE 1069#if YYERROR_VERBOSE
1073 1070
@@ -1170,115 +1167,142 @@ yytnamerr (char *yyres, const char *yystr)
1170} 1167}
1171# endif 1168# endif
1172 1169
1173/* Copy into YYRESULT an error message about the unexpected token 1170/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
1174 YYCHAR while in state YYSTATE. Return the number of bytes copied, 1171 about the unexpected token YYTOKEN for the state stack whose top is
1175 including the terminating null byte. If YYRESULT is null, do not 1172 YYSSP.
1176 copy anything; just return the number of bytes that would be
1177 copied. As a special case, return 0 if an ordinary "syntax error"
1178 message will do. Return YYSIZE_MAXIMUM if overflow occurs during
1179 size calculation. */
1180static YYSIZE_T
1181yysyntax_error (char *yyresult, int yystate, int yychar)
1182{
1183 int yyn = yypact[yystate];
1184 1173
1185 if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) 1174 Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
1186 return 0; 1175 not large enough to hold the message. In that case, also set
1187 else 1176 *YYMSG_ALLOC to the required number of bytes. Return 2 if the
1177 required number of bytes is too large to store. */
1178static int
1179yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
1180 yytype_int16 *yyssp, int yytoken)
1181{
1182 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]);
1183 YYSIZE_T yysize = yysize0;
1184 YYSIZE_T yysize1;
1185 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1186 /* Internationalized format string. */
1187 const char *yyformat = 0;
1188 /* Arguments of yyformat. */
1189 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1190 /* Number of reported tokens (one for the "unexpected", one per
1191 "expected"). */
1192 int yycount = 0;
1193
1194 /* There are many possibilities here to consider:
1195 - Assume YYFAIL is not used. It's too flawed to consider. See
1196 <http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
1197 for details. YYERROR is fine as it does not invoke this
1198 function.
1199 - If this state is a consistent state with a default action, then
1200 the only way this function was invoked is if the default action
1201 is an error action. In that case, don't check for expected
1202 tokens because there are none.
1203 - The only way there can be no lookahead present (in yychar) is if
1204 this state is a consistent state with a default action. Thus,
1205 detecting the absence of a lookahead is sufficient to determine
1206 that there is no unexpected or expected token to report. In that
1207 case, just report a simple "syntax error".
1208 - Don't assume there isn't a lookahead just because this state is a
1209 consistent state with a default action. There might have been a
1210 previous inconsistent state, consistent state with a non-default
1211 action, or user semantic action that manipulated yychar.
1212 - Of course, the expected token list depends on states to have
1213 correct lookahead information, and it depends on the parser not
1214 to perform extra reductions after fetching a lookahead from the
1215 scanner and before detecting a syntax error. Thus, state merging
1216 (from LALR or IELR) and default reductions corrupt the expected
1217 token list. However, the list is correct for canonical LR with
1218 one exception: it will still contain any token that will not be
1219 accepted due to an error action in a later state.
1220 */
1221 if (yytoken != YYEMPTY)
1188 { 1222 {
1189 int yytype = YYTRANSLATE (yychar); 1223 int yyn = yypact[*yyssp];
1190 YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); 1224 yyarg[yycount++] = yytname[yytoken];
1191 YYSIZE_T yysize = yysize0; 1225 if (!yypact_value_is_default (yyn))
1192 YYSIZE_T yysize1; 1226 {
1193 int yysize_overflow = 0; 1227 /* Start YYX at -YYN if negative to avoid negative indexes in
1194 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; 1228 YYCHECK. In other words, skip the first -YYN actions for
1195 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; 1229 this state because they are default actions. */
1196 int yyx; 1230 int yyxbegin = yyn < 0 ? -yyn : 0;
1197 1231 /* Stay within bounds of both yycheck and yytname. */
1198# if 0 1232 int yychecklim = YYLAST - yyn + 1;
1199 /* This is so xgettext sees the translatable formats that are 1233 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1200 constructed on the fly. */ 1234 int yyx;
1201 YY_("syntax error, unexpected %s"); 1235
1202 YY_("syntax error, unexpected %s, expecting %s"); 1236 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1203 YY_("syntax error, unexpected %s, expecting %s or %s"); 1237 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1204 YY_("syntax error, unexpected %s, expecting %s or %s or %s"); 1238 && !yytable_value_is_error (yytable[yyx + yyn]))
1205 YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); 1239 {
1206# endif 1240 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1207 char *yyfmt; 1241 {
1208 char const *yyf; 1242 yycount = 1;
1209 static char const yyunexpected[] = "syntax error, unexpected %s"; 1243 yysize = yysize0;
1210 static char const yyexpecting[] = ", expecting %s"; 1244 break;
1211 static char const yyor[] = " or %s"; 1245 }
1212 char yyformat[sizeof yyunexpected 1246 yyarg[yycount++] = yytname[yyx];
1213 + sizeof yyexpecting - 1 1247 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1214 + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) 1248 if (! (yysize <= yysize1
1215 * (sizeof yyor - 1))]; 1249 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1216 char const *yyprefix = yyexpecting; 1250 return 2;
1217 1251 yysize = yysize1;
1218 /* Start YYX at -YYN if negative to avoid negative indexes in 1252 }
1219 YYCHECK. */ 1253 }
1220 int yyxbegin = yyn < 0 ? -yyn : 0; 1254 }
1221
1222 /* Stay within bounds of both yycheck and yytname. */
1223 int yychecklim = YYLAST - yyn + 1;
1224 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1225 int yycount = 1;
1226
1227 yyarg[0] = yytname[yytype];
1228 yyfmt = yystpcpy (yyformat, yyunexpected);
1229
1230 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1231 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1232 {
1233 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1234 {
1235 yycount = 1;
1236 yysize = yysize0;
1237 yyformat[sizeof yyunexpected - 1] = '\0';
1238 break;
1239 }
1240 yyarg[yycount++] = yytname[yyx];
1241 yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1242 yysize_overflow |= (yysize1 < yysize);
1243 yysize = yysize1;
1244 yyfmt = yystpcpy (yyfmt, yyprefix);
1245 yyprefix = yyor;
1246 }
1247 1255
1248 yyf = YY_(yyformat); 1256 switch (yycount)
1249 yysize1 = yysize + yystrlen (yyf); 1257 {
1250 yysize_overflow |= (yysize1 < yysize); 1258# define YYCASE_(N, S) \
1251 yysize = yysize1; 1259 case N: \
1260 yyformat = S; \
1261 break
1262 YYCASE_(0, YY_("syntax error"));
1263 YYCASE_(1, YY_("syntax error, unexpected %s"));
1264 YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1265 YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1266 YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1267 YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1268# undef YYCASE_
1269 }
1252 1270
1253 if (yysize_overflow) 1271 yysize1 = yysize + yystrlen (yyformat);
1254 return YYSIZE_MAXIMUM; 1272 if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1273 return 2;
1274 yysize = yysize1;
1255 1275
1256 if (yyresult) 1276 if (*yymsg_alloc < yysize)
1257 { 1277 {
1258 /* Avoid sprintf, as that infringes on the user's name space. 1278 *yymsg_alloc = 2 * yysize;
1259 Don't have undefined behavior even if the translation 1279 if (! (yysize <= *yymsg_alloc
1260 produced a string with the wrong number of "%s"s. */ 1280 && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1261 char *yyp = yyresult; 1281 *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1262 int yyi = 0; 1282 return 1;
1263 while ((*yyp = *yyf) != '\0')
1264 {
1265 if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
1266 {
1267 yyp += yytnamerr (yyp, yyarg[yyi++]);
1268 yyf += 2;
1269 }
1270 else
1271 {
1272 yyp++;
1273 yyf++;
1274 }
1275 }
1276 }
1277 return yysize;
1278 } 1283 }
1284
1285 /* Avoid sprintf, as that infringes on the user's name space.
1286 Don't have undefined behavior even if the translation
1287 produced a string with the wrong number of "%s"s. */
1288 {
1289 char *yyp = *yymsg;
1290 int yyi = 0;
1291 while ((*yyp = *yyformat) != '\0')
1292 if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1293 {
1294 yyp += yytnamerr (yyp, yyarg[yyi++]);
1295 yyformat += 2;
1296 }
1297 else
1298 {
1299 yyp++;
1300 yyformat++;
1301 }
1302 }
1303 return 0;
1279} 1304}
1280#endif /* YYERROR_VERBOSE */ 1305#endif /* YYERROR_VERBOSE */
1281
1282 1306
1283/*-----------------------------------------------. 1307/*-----------------------------------------------.
1284| Release the memory associated to this symbol. | 1308| Release the memory associated to this symbol. |
@@ -1341,6 +1365,7 @@ yydestruct (yymsg, yytype, yyvaluep)
1341 } 1365 }
1342} 1366}
1343 1367
1368
1344/* Prevent warnings from -Wmissing-prototypes. */ 1369/* Prevent warnings from -Wmissing-prototypes. */
1345#ifdef YYPARSE_PARAM 1370#ifdef YYPARSE_PARAM
1346#if defined __STDC__ || defined __cplusplus 1371#if defined __STDC__ || defined __cplusplus
@@ -1367,10 +1392,9 @@ YYSTYPE yylval;
1367int yynerrs; 1392int yynerrs;
1368 1393
1369 1394
1370 1395/*----------.
1371/*-------------------------. 1396| yyparse. |
1372| yyparse or yypush_parse. | 1397`----------*/
1373`-------------------------*/
1374 1398
1375#ifdef YYPARSE_PARAM 1399#ifdef YYPARSE_PARAM
1376#if (defined __STDC__ || defined __C99__FUNC__ \ 1400#if (defined __STDC__ || defined __C99__FUNC__ \
@@ -1394,8 +1418,6 @@ yyparse ()
1394#endif 1418#endif
1395#endif 1419#endif
1396{ 1420{
1397
1398
1399 int yystate; 1421 int yystate;
1400 /* Number of tokens to shift before error messages enabled. */ 1422 /* Number of tokens to shift before error messages enabled. */
1401 int yyerrstatus; 1423 int yyerrstatus;
@@ -1550,7 +1572,7 @@ yybackup:
1550 1572
1551 /* First try to decide what to do without reference to lookahead token. */ 1573 /* First try to decide what to do without reference to lookahead token. */
1552 yyn = yypact[yystate]; 1574 yyn = yypact[yystate];
1553 if (yyn == YYPACT_NINF) 1575 if (yypact_value_is_default (yyn))
1554 goto yydefault; 1576 goto yydefault;
1555 1577
1556 /* Not known => get a lookahead token if don't already have one. */ 1578 /* Not known => get a lookahead token if don't already have one. */
@@ -1581,8 +1603,8 @@ yybackup:
1581 yyn = yytable[yyn]; 1603 yyn = yytable[yyn];
1582 if (yyn <= 0) 1604 if (yyn <= 0)
1583 { 1605 {
1584 if (yyn == 0 || yyn == YYTABLE_NINF) 1606 if (yytable_value_is_error (yyn))
1585 goto yyerrlab; 1607 goto yyerrlab;
1586 yyn = -yyn; 1608 yyn = -yyn;
1587 goto yyreduce; 1609 goto yyreduce;
1588 } 1610 }
@@ -1637,34 +1659,34 @@ yyreduce:
1637 { 1659 {
1638 case 10: 1660 case 10:
1639 1661
1640 { zconf_error("unexpected end statement"); ;} 1662 { zconf_error("unexpected end statement"); }
1641 break; 1663 break;
1642 1664
1643 case 11: 1665 case 11:
1644 1666
1645 { zconf_error("unknown statement \"%s\"", (yyvsp[(2) - (4)].string)); ;} 1667 { zconf_error("unknown statement \"%s\"", (yyvsp[(2) - (4)].string)); }
1646 break; 1668 break;
1647 1669
1648 case 12: 1670 case 12:
1649 1671
1650 { 1672 {
1651 zconf_error("unexpected option \"%s\"", kconf_id_strings + (yyvsp[(2) - (4)].id)->name); 1673 zconf_error("unexpected option \"%s\"", kconf_id_strings + (yyvsp[(2) - (4)].id)->name);
1652;} 1674}
1653 break; 1675 break;
1654 1676
1655 case 13: 1677 case 13:
1656 1678
1657 { zconf_error("invalid statement"); ;} 1679 { zconf_error("invalid statement"); }
1658 break; 1680 break;
1659 1681
1660 case 28: 1682 case 28:
1661 1683
1662 { zconf_error("unknown option \"%s\"", (yyvsp[(1) - (3)].string)); ;} 1684 { zconf_error("unknown option \"%s\"", (yyvsp[(1) - (3)].string)); }
1663 break; 1685 break;
1664 1686
1665 case 29: 1687 case 29:
1666 1688
1667 { zconf_error("invalid option"); ;} 1689 { zconf_error("invalid option"); }
1668 break; 1690 break;
1669 1691
1670 case 30: 1692 case 30:
@@ -1674,7 +1696,7 @@ yyreduce:
1674 sym->flags |= SYMBOL_OPTIONAL; 1696 sym->flags |= SYMBOL_OPTIONAL;
1675 menu_add_entry(sym); 1697 menu_add_entry(sym);
1676 printd(DEBUG_PARSE, "%s:%d:config %s\n", zconf_curname(), zconf_lineno(), (yyvsp[(2) - (3)].string)); 1698 printd(DEBUG_PARSE, "%s:%d:config %s\n", zconf_curname(), zconf_lineno(), (yyvsp[(2) - (3)].string));
1677;} 1699}
1678 break; 1700 break;
1679 1701
1680 case 31: 1702 case 31:
@@ -1682,7 +1704,7 @@ yyreduce:
1682 { 1704 {
1683 menu_end_entry(); 1705 menu_end_entry();
1684 printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno()); 1706 printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno());
1685;} 1707}
1686 break; 1708 break;
1687 1709
1688 case 32: 1710 case 32:
@@ -1692,7 +1714,7 @@ yyreduce:
1692 sym->flags |= SYMBOL_OPTIONAL; 1714 sym->flags |= SYMBOL_OPTIONAL;
1693 menu_add_entry(sym); 1715 menu_add_entry(sym);
1694 printd(DEBUG_PARSE, "%s:%d:menuconfig %s\n", zconf_curname(), zconf_lineno(), (yyvsp[(2) - (3)].string)); 1716 printd(DEBUG_PARSE, "%s:%d:menuconfig %s\n", zconf_curname(), zconf_lineno(), (yyvsp[(2) - (3)].string));
1695;} 1717}
1696 break; 1718 break;
1697 1719
1698 case 33: 1720 case 33:
@@ -1704,7 +1726,7 @@ yyreduce:
1704 zconfprint("warning: menuconfig statement without prompt"); 1726 zconfprint("warning: menuconfig statement without prompt");
1705 menu_end_entry(); 1727 menu_end_entry();
1706 printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno()); 1728 printd(DEBUG_PARSE, "%s:%d:endconfig\n", zconf_curname(), zconf_lineno());
1707;} 1729}
1708 break; 1730 break;
1709 1731
1710 case 41: 1732 case 41:
@@ -1714,7 +1736,7 @@ yyreduce:
1714 printd(DEBUG_PARSE, "%s:%d:type(%u)\n", 1736 printd(DEBUG_PARSE, "%s:%d:type(%u)\n",
1715 zconf_curname(), zconf_lineno(), 1737 zconf_curname(), zconf_lineno(),
1716 (yyvsp[(1) - (3)].id)->stype); 1738 (yyvsp[(1) - (3)].id)->stype);
1717;} 1739}
1718 break; 1740 break;
1719 1741
1720 case 42: 1742 case 42:
@@ -1722,7 +1744,7 @@ yyreduce:
1722 { 1744 {
1723 menu_add_prompt(P_PROMPT, (yyvsp[(2) - (4)].string), (yyvsp[(3) - (4)].expr)); 1745 menu_add_prompt(P_PROMPT, (yyvsp[(2) - (4)].string), (yyvsp[(3) - (4)].expr));
1724 printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); 1746 printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno());
1725;} 1747}
1726 break; 1748 break;
1727 1749
1728 case 43: 1750 case 43:
@@ -1734,7 +1756,7 @@ yyreduce:
1734 printd(DEBUG_PARSE, "%s:%d:default(%u)\n", 1756 printd(DEBUG_PARSE, "%s:%d:default(%u)\n",
1735 zconf_curname(), zconf_lineno(), 1757 zconf_curname(), zconf_lineno(),
1736 (yyvsp[(1) - (4)].id)->stype); 1758 (yyvsp[(1) - (4)].id)->stype);
1737;} 1759}
1738 break; 1760 break;
1739 1761
1740 case 44: 1762 case 44:
@@ -1742,7 +1764,7 @@ yyreduce:
1742 { 1764 {
1743 menu_add_symbol(P_SELECT, sym_lookup((yyvsp[(2) - (4)].string), 0), (yyvsp[(3) - (4)].expr)); 1765 menu_add_symbol(P_SELECT, sym_lookup((yyvsp[(2) - (4)].string), 0), (yyvsp[(3) - (4)].expr));
1744 printd(DEBUG_PARSE, "%s:%d:select\n", zconf_curname(), zconf_lineno()); 1766 printd(DEBUG_PARSE, "%s:%d:select\n", zconf_curname(), zconf_lineno());
1745;} 1767}
1746 break; 1768 break;
1747 1769
1748 case 45: 1770 case 45:
@@ -1750,7 +1772,7 @@ yyreduce:
1750 { 1772 {
1751 menu_add_expr(P_RANGE, expr_alloc_comp(E_RANGE,(yyvsp[(2) - (5)].symbol), (yyvsp[(3) - (5)].symbol)), (yyvsp[(4) - (5)].expr)); 1773 menu_add_expr(P_RANGE, expr_alloc_comp(E_RANGE,(yyvsp[(2) - (5)].symbol), (yyvsp[(3) - (5)].symbol)), (yyvsp[(4) - (5)].expr));
1752 printd(DEBUG_PARSE, "%s:%d:range\n", zconf_curname(), zconf_lineno()); 1774 printd(DEBUG_PARSE, "%s:%d:range\n", zconf_curname(), zconf_lineno());
1753;} 1775}
1754 break; 1776 break;
1755 1777
1756 case 48: 1778 case 48:
@@ -1762,17 +1784,17 @@ yyreduce:
1762 else 1784 else
1763 zconfprint("warning: ignoring unknown option %s", (yyvsp[(2) - (3)].string)); 1785 zconfprint("warning: ignoring unknown option %s", (yyvsp[(2) - (3)].string));
1764 free((yyvsp[(2) - (3)].string)); 1786 free((yyvsp[(2) - (3)].string));
1765;} 1787}
1766 break; 1788 break;
1767 1789
1768 case 49: 1790 case 49:
1769 1791
1770 { (yyval.string) = NULL; ;} 1792 { (yyval.string) = NULL; }
1771 break; 1793 break;
1772 1794
1773 case 50: 1795 case 50:
1774 1796
1775 { (yyval.string) = (yyvsp[(2) - (2)].string); ;} 1797 { (yyval.string) = (yyvsp[(2) - (2)].string); }
1776 break; 1798 break;
1777 1799
1778 case 51: 1800 case 51:
@@ -1783,14 +1805,14 @@ yyreduce:
1783 menu_add_entry(sym); 1805 menu_add_entry(sym);
1784 menu_add_expr(P_CHOICE, NULL, NULL); 1806 menu_add_expr(P_CHOICE, NULL, NULL);
1785 printd(DEBUG_PARSE, "%s:%d:choice\n", zconf_curname(), zconf_lineno()); 1807 printd(DEBUG_PARSE, "%s:%d:choice\n", zconf_curname(), zconf_lineno());
1786;} 1808}
1787 break; 1809 break;
1788 1810
1789 case 52: 1811 case 52:
1790 1812
1791 { 1813 {
1792 (yyval.menu) = menu_add_menu(); 1814 (yyval.menu) = menu_add_menu();
1793;} 1815}
1794 break; 1816 break;
1795 1817
1796 case 53: 1818 case 53:
@@ -1800,7 +1822,7 @@ yyreduce:
1800 menu_end_menu(); 1822 menu_end_menu();
1801 printd(DEBUG_PARSE, "%s:%d:endchoice\n", zconf_curname(), zconf_lineno()); 1823 printd(DEBUG_PARSE, "%s:%d:endchoice\n", zconf_curname(), zconf_lineno());
1802 } 1824 }
1803;} 1825}
1804 break; 1826 break;
1805 1827
1806 case 61: 1828 case 61:
@@ -1808,7 +1830,7 @@ yyreduce:
1808 { 1830 {
1809 menu_add_prompt(P_PROMPT, (yyvsp[(2) - (4)].string), (yyvsp[(3) - (4)].expr)); 1831 menu_add_prompt(P_PROMPT, (yyvsp[(2) - (4)].string), (yyvsp[(3) - (4)].expr));
1810 printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno()); 1832 printd(DEBUG_PARSE, "%s:%d:prompt\n", zconf_curname(), zconf_lineno());
1811;} 1833}
1812 break; 1834 break;
1813 1835
1814 case 62: 1836 case 62:
@@ -1821,7 +1843,7 @@ yyreduce:
1821 (yyvsp[(1) - (3)].id)->stype); 1843 (yyvsp[(1) - (3)].id)->stype);
1822 } else 1844 } else
1823 YYERROR; 1845 YYERROR;
1824;} 1846}
1825 break; 1847 break;
1826 1848
1827 case 63: 1849 case 63:
@@ -1829,7 +1851,7 @@ yyreduce:
1829 { 1851 {
1830 current_entry->sym->flags |= SYMBOL_OPTIONAL; 1852 current_entry->sym->flags |= SYMBOL_OPTIONAL;
1831 printd(DEBUG_PARSE, "%s:%d:optional\n", zconf_curname(), zconf_lineno()); 1853 printd(DEBUG_PARSE, "%s:%d:optional\n", zconf_curname(), zconf_lineno());
1832;} 1854}
1833 break; 1855 break;
1834 1856
1835 case 64: 1857 case 64:
@@ -1841,7 +1863,7 @@ yyreduce:
1841 zconf_curname(), zconf_lineno()); 1863 zconf_curname(), zconf_lineno());
1842 } else 1864 } else
1843 YYERROR; 1865 YYERROR;
1844;} 1866}
1845 break; 1867 break;
1846 1868
1847 case 67: 1869 case 67:
@@ -1851,7 +1873,7 @@ yyreduce:
1851 menu_add_entry(NULL); 1873 menu_add_entry(NULL);
1852 menu_add_dep((yyvsp[(2) - (3)].expr)); 1874 menu_add_dep((yyvsp[(2) - (3)].expr));
1853 (yyval.menu) = menu_add_menu(); 1875 (yyval.menu) = menu_add_menu();
1854;} 1876}
1855 break; 1877 break;
1856 1878
1857 case 68: 1879 case 68:
@@ -1861,14 +1883,14 @@ yyreduce:
1861 menu_end_menu(); 1883 menu_end_menu();
1862 printd(DEBUG_PARSE, "%s:%d:endif\n", zconf_curname(), zconf_lineno()); 1884 printd(DEBUG_PARSE, "%s:%d:endif\n", zconf_curname(), zconf_lineno());
1863 } 1885 }
1864;} 1886}
1865 break; 1887 break;
1866 1888
1867 case 74: 1889 case 74:
1868 1890
1869 { 1891 {
1870 menu_add_prompt(P_MENU, (yyvsp[(2) - (3)].string), NULL); 1892 menu_add_prompt(P_MENU, (yyvsp[(2) - (3)].string), NULL);
1871;} 1893}
1872 break; 1894 break;
1873 1895
1874 case 75: 1896 case 75:
@@ -1877,14 +1899,14 @@ yyreduce:
1877 menu_add_entry(NULL); 1899 menu_add_entry(NULL);
1878 menu_add_prompt(P_MENU, (yyvsp[(2) - (3)].string), NULL); 1900 menu_add_prompt(P_MENU, (yyvsp[(2) - (3)].string), NULL);
1879 printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno()); 1901 printd(DEBUG_PARSE, "%s:%d:menu\n", zconf_curname(), zconf_lineno());
1880;} 1902}
1881 break; 1903 break;
1882 1904
1883 case 76: 1905 case 76:
1884 1906
1885 { 1907 {
1886 (yyval.menu) = menu_add_menu(); 1908 (yyval.menu) = menu_add_menu();
1887;} 1909}
1888 break; 1910 break;
1889 1911
1890 case 77: 1912 case 77:
@@ -1894,7 +1916,7 @@ yyreduce:
1894 menu_end_menu(); 1916 menu_end_menu();
1895 printd(DEBUG_PARSE, "%s:%d:endmenu\n", zconf_curname(), zconf_lineno()); 1917 printd(DEBUG_PARSE, "%s:%d:endmenu\n", zconf_curname(), zconf_lineno());
1896 } 1918 }
1897;} 1919}
1898 break; 1920 break;
1899 1921
1900 case 83: 1922 case 83:
@@ -1902,7 +1924,7 @@ yyreduce:
1902 { 1924 {
1903 printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), (yyvsp[(2) - (3)].string)); 1925 printd(DEBUG_PARSE, "%s:%d:source %s\n", zconf_curname(), zconf_lineno(), (yyvsp[(2) - (3)].string));
1904 zconf_nextfile((yyvsp[(2) - (3)].string)); 1926 zconf_nextfile((yyvsp[(2) - (3)].string));
1905;} 1927}
1906 break; 1928 break;
1907 1929
1908 case 84: 1930 case 84:
@@ -1911,14 +1933,14 @@ yyreduce:
1911 menu_add_entry(NULL); 1933 menu_add_entry(NULL);
1912 menu_add_prompt(P_COMMENT, (yyvsp[(2) - (3)].string), NULL); 1934 menu_add_prompt(P_COMMENT, (yyvsp[(2) - (3)].string), NULL);
1913 printd(DEBUG_PARSE, "%s:%d:comment\n", zconf_curname(), zconf_lineno()); 1935 printd(DEBUG_PARSE, "%s:%d:comment\n", zconf_curname(), zconf_lineno());
1914;} 1936}
1915 break; 1937 break;
1916 1938
1917 case 85: 1939 case 85:
1918 1940
1919 { 1941 {
1920 menu_end_entry(); 1942 menu_end_entry();
1921;} 1943}
1922 break; 1944 break;
1923 1945
1924 case 86: 1946 case 86:
@@ -1926,14 +1948,14 @@ yyreduce:
1926 { 1948 {
1927 printd(DEBUG_PARSE, "%s:%d:help\n", zconf_curname(), zconf_lineno()); 1949 printd(DEBUG_PARSE, "%s:%d:help\n", zconf_curname(), zconf_lineno());
1928 zconf_starthelp(); 1950 zconf_starthelp();
1929;} 1951}
1930 break; 1952 break;
1931 1953
1932 case 87: 1954 case 87:
1933 1955
1934 { 1956 {
1935 current_entry->help = (yyvsp[(2) - (2)].string); 1957 current_entry->help = (yyvsp[(2) - (2)].string);
1936;} 1958}
1937 break; 1959 break;
1938 1960
1939 case 92: 1961 case 92:
@@ -1941,102 +1963,113 @@ yyreduce:
1941 { 1963 {
1942 menu_add_dep((yyvsp[(3) - (4)].expr)); 1964 menu_add_dep((yyvsp[(3) - (4)].expr));
1943 printd(DEBUG_PARSE, "%s:%d:depends on\n", zconf_curname(), zconf_lineno()); 1965 printd(DEBUG_PARSE, "%s:%d:depends on\n", zconf_curname(), zconf_lineno());
1944;} 1966}
1945 break; 1967 break;
1946 1968
1947 case 96: 1969 case 96:
1948 1970
1949 { 1971 {
1950 menu_add_visibility((yyvsp[(2) - (2)].expr)); 1972 menu_add_visibility((yyvsp[(2) - (2)].expr));
1951;} 1973}
1952 break; 1974 break;
1953 1975
1954 case 98: 1976 case 98:
1955 1977
1956 { 1978 {
1957 menu_add_prompt(P_PROMPT, (yyvsp[(1) - (2)].string), (yyvsp[(2) - (2)].expr)); 1979 menu_add_prompt(P_PROMPT, (yyvsp[(1) - (2)].string), (yyvsp[(2) - (2)].expr));
1958;} 1980}
1959 break; 1981 break;
1960 1982
1961 case 101: 1983 case 101:
1962 1984
1963 { (yyval.id) = (yyvsp[(1) - (2)].id); ;} 1985 { (yyval.id) = (yyvsp[(1) - (2)].id); }
1964 break; 1986 break;
1965 1987
1966 case 102: 1988 case 102:
1967 1989
1968 { (yyval.id) = (yyvsp[(1) - (2)].id); ;} 1990 { (yyval.id) = (yyvsp[(1) - (2)].id); }
1969 break; 1991 break;
1970 1992
1971 case 103: 1993 case 103:
1972 1994
1973 { (yyval.id) = (yyvsp[(1) - (2)].id); ;} 1995 { (yyval.id) = (yyvsp[(1) - (2)].id); }
1974 break; 1996 break;
1975 1997
1976 case 106: 1998 case 106:
1977 1999
1978 { (yyval.expr) = NULL; ;} 2000 { (yyval.expr) = NULL; }
1979 break; 2001 break;
1980 2002
1981 case 107: 2003 case 107:
1982 2004
1983 { (yyval.expr) = (yyvsp[(2) - (2)].expr); ;} 2005 { (yyval.expr) = (yyvsp[(2) - (2)].expr); }
1984 break; 2006 break;
1985 2007
1986 case 108: 2008 case 108:
1987 2009
1988 { (yyval.expr) = expr_alloc_symbol((yyvsp[(1) - (1)].symbol)); ;} 2010 { (yyval.expr) = expr_alloc_symbol((yyvsp[(1) - (1)].symbol)); }
1989 break; 2011 break;
1990 2012
1991 case 109: 2013 case 109:
1992 2014
1993 { (yyval.expr) = expr_alloc_comp(E_EQUAL, (yyvsp[(1) - (3)].symbol), (yyvsp[(3) - (3)].symbol)); ;} 2015 { (yyval.expr) = expr_alloc_comp(E_EQUAL, (yyvsp[(1) - (3)].symbol), (yyvsp[(3) - (3)].symbol)); }
1994 break; 2016 break;
1995 2017
1996 case 110: 2018 case 110:
1997 2019
1998 { (yyval.expr) = expr_alloc_comp(E_UNEQUAL, (yyvsp[(1) - (3)].symbol), (yyvsp[(3) - (3)].symbol)); ;} 2020 { (yyval.expr) = expr_alloc_comp(E_UNEQUAL, (yyvsp[(1) - (3)].symbol), (yyvsp[(3) - (3)].symbol)); }
1999 break; 2021 break;
2000 2022
2001 case 111: 2023 case 111:
2002 2024
2003 { (yyval.expr) = (yyvsp[(2) - (3)].expr); ;} 2025 { (yyval.expr) = (yyvsp[(2) - (3)].expr); }
2004 break; 2026 break;
2005 2027
2006 case 112: 2028 case 112:
2007 2029
2008 { (yyval.expr) = expr_alloc_one(E_NOT, (yyvsp[(2) - (2)].expr)); ;} 2030 { (yyval.expr) = expr_alloc_one(E_NOT, (yyvsp[(2) - (2)].expr)); }
2009 break; 2031 break;
2010 2032
2011 case 113: 2033 case 113:
2012 2034
2013 { (yyval.expr) = expr_alloc_two(E_OR, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} 2035 { (yyval.expr) = expr_alloc_two(E_OR, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); }
2014 break; 2036 break;
2015 2037
2016 case 114: 2038 case 114:
2017 2039
2018 { (yyval.expr) = expr_alloc_two(E_AND, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); ;} 2040 { (yyval.expr) = expr_alloc_two(E_AND, (yyvsp[(1) - (3)].expr), (yyvsp[(3) - (3)].expr)); }
2019 break; 2041 break;
2020 2042
2021 case 115: 2043 case 115:
2022 2044
2023 { (yyval.symbol) = sym_lookup((yyvsp[(1) - (1)].string), 0); free((yyvsp[(1) - (1)].string)); ;} 2045 { (yyval.symbol) = sym_lookup((yyvsp[(1) - (1)].string), 0); free((yyvsp[(1) - (1)].string)); }
2024 break; 2046 break;
2025 2047
2026 case 116: 2048 case 116:
2027 2049
2028 { (yyval.symbol) = sym_lookup((yyvsp[(1) - (1)].string), SYMBOL_CONST); free((yyvsp[(1) - (1)].string)); ;} 2050 { (yyval.symbol) = sym_lookup((yyvsp[(1) - (1)].string), SYMBOL_CONST); free((yyvsp[(1) - (1)].string)); }
2029 break; 2051 break;
2030 2052
2031 case 117: 2053 case 117:
2032 2054
2033 { (yyval.string) = NULL; ;} 2055 { (yyval.string) = NULL; }
2034 break; 2056 break;
2035 2057
2036 2058
2037 2059
2038 default: break; 2060 default: break;
2039 } 2061 }
2062 /* User semantic actions sometimes alter yychar, and that requires
2063 that yytoken be updated with the new translation. We take the
2064 approach of translating immediately before every use of yytoken.
2065 One alternative is translating here after every semantic action,
2066 but that translation would be missed if the semantic action invokes
2067 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
2068 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
2069 incorrect destructor might then be invoked immediately. In the
2070 case of YYERROR or YYBACKUP, subsequent parser actions might lead
2071 to an incorrect destructor call or verbose syntax error message
2072 before the lookahead is translated. */
2040 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); 2073 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
2041 2074
2042 YYPOPSTACK (yylen); 2075 YYPOPSTACK (yylen);
@@ -2064,6 +2097,10 @@ yyreduce:
2064| yyerrlab -- here on detecting error | 2097| yyerrlab -- here on detecting error |
2065`------------------------------------*/ 2098`------------------------------------*/
2066yyerrlab: 2099yyerrlab:
2100 /* Make sure we have latest lookahead translation. See comments at
2101 user semantic actions for why this is necessary. */
2102 yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
2103
2067 /* If not already recovering from an error, report this error. */ 2104 /* If not already recovering from an error, report this error. */
2068 if (!yyerrstatus) 2105 if (!yyerrstatus)
2069 { 2106 {
@@ -2071,37 +2108,36 @@ yyerrlab:
2071#if ! YYERROR_VERBOSE 2108#if ! YYERROR_VERBOSE
2072 yyerror (YY_("syntax error")); 2109 yyerror (YY_("syntax error"));
2073#else 2110#else
2111# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
2112 yyssp, yytoken)
2074 { 2113 {
2075 YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); 2114 char const *yymsgp = YY_("syntax error");
2076 if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) 2115 int yysyntax_error_status;
2077 { 2116 yysyntax_error_status = YYSYNTAX_ERROR;
2078 YYSIZE_T yyalloc = 2 * yysize; 2117 if (yysyntax_error_status == 0)
2079 if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) 2118 yymsgp = yymsg;
2080 yyalloc = YYSTACK_ALLOC_MAXIMUM; 2119 else if (yysyntax_error_status == 1)
2081 if (yymsg != yymsgbuf) 2120 {
2082 YYSTACK_FREE (yymsg); 2121 if (yymsg != yymsgbuf)
2083 yymsg = (char *) YYSTACK_ALLOC (yyalloc); 2122 YYSTACK_FREE (yymsg);
2084 if (yymsg) 2123 yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
2085 yymsg_alloc = yyalloc; 2124 if (!yymsg)
2086 else 2125 {
2087 { 2126 yymsg = yymsgbuf;
2088 yymsg = yymsgbuf; 2127 yymsg_alloc = sizeof yymsgbuf;
2089 yymsg_alloc = sizeof yymsgbuf; 2128 yysyntax_error_status = 2;
2090 } 2129 }
2091 } 2130 else
2092 2131 {
2093 if (0 < yysize && yysize <= yymsg_alloc) 2132 yysyntax_error_status = YYSYNTAX_ERROR;
2094 { 2133 yymsgp = yymsg;
2095 (void) yysyntax_error (yymsg, yystate, yychar); 2134 }
2096 yyerror (yymsg); 2135 }
2097 } 2136 yyerror (yymsgp);
2098 else 2137 if (yysyntax_error_status == 2)
2099 { 2138 goto yyexhaustedlab;
2100 yyerror (YY_("syntax error"));
2101 if (yysize != 0)
2102 goto yyexhaustedlab;
2103 }
2104 } 2139 }
2140# undef YYSYNTAX_ERROR
2105#endif 2141#endif
2106 } 2142 }
2107 2143
@@ -2160,7 +2196,7 @@ yyerrlab1:
2160 for (;;) 2196 for (;;)
2161 { 2197 {
2162 yyn = yypact[yystate]; 2198 yyn = yypact[yystate];
2163 if (yyn != YYPACT_NINF) 2199 if (!yypact_value_is_default (yyn))
2164 { 2200 {
2165 yyn += YYTERROR; 2201 yyn += YYTERROR;
2166 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) 2202 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
@@ -2219,8 +2255,13 @@ yyexhaustedlab:
2219 2255
2220yyreturn: 2256yyreturn:
2221 if (yychar != YYEMPTY) 2257 if (yychar != YYEMPTY)
2222 yydestruct ("Cleanup: discarding lookahead", 2258 {
2223 yytoken, &yylval); 2259 /* Make sure we have latest lookahead translation. See comments at
2260 user semantic actions for why this is necessary. */
2261 yytoken = YYTRANSLATE (yychar);
2262 yydestruct ("Cleanup: discarding lookahead",
2263 yytoken, &yylval);
2264 }
2224 /* Do not reclaim the symbols of the rule which action triggered 2265 /* Do not reclaim the symbols of the rule which action triggered
2225 this YYABORT or YYACCEPT. */ 2266 this YYABORT or YYACCEPT. */
2226 YYPOPSTACK (yylen); 2267 YYPOPSTACK (yylen);
@@ -2256,9 +2297,6 @@ void conf_parse(const char *name)
2256 2297
2257 sym_init(); 2298 sym_init();
2258 _menu_init(); 2299 _menu_init();
2259 modules_sym = sym_lookup(NULL, 0);
2260 modules_sym->type = S_BOOLEAN;
2261 modules_sym->flags |= SYMBOL_AUTO;
2262 rootmenu.prompt = menu_add_prompt(P_MENU, "Linux Kernel Configuration", NULL); 2300 rootmenu.prompt = menu_add_prompt(P_MENU, "Linux Kernel Configuration", NULL);
2263 2301
2264 if (getenv("ZCONF_DEBUG")) 2302 if (getenv("ZCONF_DEBUG"))
@@ -2266,12 +2304,8 @@ void conf_parse(const char *name)
2266 zconfparse(); 2304 zconfparse();
2267 if (zconfnerrs) 2305 if (zconfnerrs)
2268 exit(1); 2306 exit(1);
2269 if (!modules_sym->prop) { 2307 if (!modules_sym)
2270 struct property *prop; 2308 modules_sym = sym_find( "n" );
2271
2272 prop = prop_alloc(P_DEFAULT, modules_sym);
2273 prop->expr = expr_alloc_symbol(sym_lookup("MODULES", 0));
2274 }
2275 2309
2276 rootmenu.prompt->text = _(rootmenu.prompt->text); 2310 rootmenu.prompt->text = _(rootmenu.prompt->text);
2277 rootmenu.prompt->text = sym_expand_string_value(rootmenu.prompt->text); 2311 rootmenu.prompt->text = sym_expand_string_value(rootmenu.prompt->text);
diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y
index 864da07ba4aa..0653886fac48 100644
--- a/scripts/kconfig/zconf.y
+++ b/scripts/kconfig/zconf.y
@@ -493,9 +493,6 @@ void conf_parse(const char *name)
493 493
494 sym_init(); 494 sym_init();
495 _menu_init(); 495 _menu_init();
496 modules_sym = sym_lookup(NULL, 0);
497 modules_sym->type = S_BOOLEAN;
498 modules_sym->flags |= SYMBOL_AUTO;
499 rootmenu.prompt = menu_add_prompt(P_MENU, "Linux Kernel Configuration", NULL); 496 rootmenu.prompt = menu_add_prompt(P_MENU, "Linux Kernel Configuration", NULL);
500 497
501 if (getenv("ZCONF_DEBUG")) 498 if (getenv("ZCONF_DEBUG"))
@@ -503,12 +500,8 @@ void conf_parse(const char *name)
503 zconfparse(); 500 zconfparse();
504 if (zconfnerrs) 501 if (zconfnerrs)
505 exit(1); 502 exit(1);
506 if (!modules_sym->prop) { 503 if (!modules_sym)
507 struct property *prop; 504 modules_sym = sym_find( "n" );
508
509 prop = prop_alloc(P_DEFAULT, modules_sym);
510 prop->expr = expr_alloc_symbol(sym_lookup("MODULES", 0));
511 }
512 505
513 rootmenu.prompt->text = _(rootmenu.prompt->text); 506 rootmenu.prompt->text = _(rootmenu.prompt->text);
514 rootmenu.prompt->text = sym_expand_string_value(rootmenu.prompt->text); 507 rootmenu.prompt->text = sym_expand_string_value(rootmenu.prompt->text);
diff --git a/scripts/mod/Makefile b/scripts/mod/Makefile
index 75d59fcd48b8..c11212ff3510 100644
--- a/scripts/mod/Makefile
+++ b/scripts/mod/Makefile
@@ -15,8 +15,8 @@ endef
15quiet_cmd_offsets = GEN $@ 15quiet_cmd_offsets = GEN $@
16define cmd_offsets 16define cmd_offsets
17 (set -e; \ 17 (set -e; \
18 echo "#ifndef __DEVICEVTABLE_OFFSETS_H__"; \ 18 echo "#ifndef __DEVICETABLE_OFFSETS_H__"; \
19 echo "#define __DEVICEVTABLE_OFFSETS_H__"; \ 19 echo "#define __DEVICETABLE_OFFSETS_H__"; \
20 echo "/*"; \ 20 echo "/*"; \
21 echo " * DO NOT MODIFY."; \ 21 echo " * DO NOT MODIFY."; \
22 echo " *"; \ 22 echo " *"; \
@@ -29,15 +29,10 @@ define cmd_offsets
29 echo "#endif" ) > $@ 29 echo "#endif" ) > $@
30endef 30endef
31 31
32# We use internal kbuild rules to avoid the "is up to date" message from make 32$(obj)/$(devicetable-offsets-file): $(obj)/devicetable-offsets.s
33scripts/mod/devicetable-offsets.s: scripts/mod/devicetable-offsets.c FORCE 33 $(call if_changed,offsets)
34 $(Q)mkdir -p $(dir $@)
35 $(call if_changed_dep,cc_s_c)
36 34
37$(obj)/$(devicetable-offsets-file): scripts/mod/devicetable-offsets.s 35targets += $(devicetable-offsets-file) devicetable-offsets.s
38 $(call cmd,offsets)
39
40targets += $(devicetable-offsets-file)
41 36
42# dependencies on generated files need to be listed explicitly 37# dependencies on generated files need to be listed explicitly
43 38
diff --git a/scripts/mod/devicetable-offsets.c b/scripts/mod/devicetable-offsets.c
index e66d4d258e1a..bb5d115ca671 100644
--- a/scripts/mod/devicetable-offsets.c
+++ b/scripts/mod/devicetable-offsets.c
@@ -177,5 +177,11 @@ int main(void)
177 DEVID(mei_cl_device_id); 177 DEVID(mei_cl_device_id);
178 DEVID_FIELD(mei_cl_device_id, name); 178 DEVID_FIELD(mei_cl_device_id, name);
179 179
180 DEVID(rio_device_id);
181 DEVID_FIELD(rio_device_id, did);
182 DEVID_FIELD(rio_device_id, vid);
183 DEVID_FIELD(rio_device_id, asm_did);
184 DEVID_FIELD(rio_device_id, asm_vid);
185
180 return 0; 186 return 0;
181} 187}
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index 45f9a3377dcd..23708636b05c 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -79,10 +79,12 @@ struct devtable **__start___devtable, **__stop___devtable;
79extern struct devtable *__start___devtable[], *__stop___devtable[]; 79extern struct devtable *__start___devtable[], *__stop___devtable[];
80#endif /* __MACH__ */ 80#endif /* __MACH__ */
81 81
82#if __GNUC__ == 3 && __GNUC_MINOR__ < 3 82#if !defined(__used)
83# define __used __attribute__((__unused__)) 83# if __GNUC__ == 3 && __GNUC_MINOR__ < 3
84#else 84# define __used __attribute__((__unused__))
85# define __used __attribute__((__used__)) 85# else
86# define __used __attribute__((__used__))
87# endif
86#endif 88#endif
87 89
88/* Define a variable f that holds the value of field f of struct devid 90/* Define a variable f that holds the value of field f of struct devid
@@ -1145,6 +1147,26 @@ static int do_mei_entry(const char *filename, void *symval,
1145} 1147}
1146ADD_TO_DEVTABLE("mei", mei_cl_device_id, do_mei_entry); 1148ADD_TO_DEVTABLE("mei", mei_cl_device_id, do_mei_entry);
1147 1149
1150/* Looks like: rapidio:vNdNavNadN */
1151static int do_rio_entry(const char *filename,
1152 void *symval, char *alias)
1153{
1154 DEF_FIELD(symval, rio_device_id, did);
1155 DEF_FIELD(symval, rio_device_id, vid);
1156 DEF_FIELD(symval, rio_device_id, asm_did);
1157 DEF_FIELD(symval, rio_device_id, asm_vid);
1158
1159 strcpy(alias, "rapidio:");
1160 ADD(alias, "v", vid != RIO_ANY_ID, vid);
1161 ADD(alias, "d", did != RIO_ANY_ID, did);
1162 ADD(alias, "av", asm_vid != RIO_ANY_ID, asm_vid);
1163 ADD(alias, "ad", asm_did != RIO_ANY_ID, asm_did);
1164
1165 add_wildcard(alias);
1166 return 1;
1167}
1168ADD_TO_DEVTABLE("rapidio", rio_device_id, do_rio_entry);
1169
1148/* Does namelen bytes of name exactly match the symbol? */ 1170/* Does namelen bytes of name exactly match the symbol? */
1149static bool sym_is(const char *name, unsigned namelen, const char *symbol) 1171static bool sym_is(const char *name, unsigned namelen, const char *symbol)
1150{ 1172{
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index a4be8e112bb6..8247979e8f64 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -821,6 +821,7 @@ static const char *section_white_list[] =
821{ 821{
822 ".comment*", 822 ".comment*",
823 ".debug*", 823 ".debug*",
824 ".cranges", /* sh64 */
824 ".zdebug*", /* Compressed debug sections. */ 825 ".zdebug*", /* Compressed debug sections. */
825 ".GCC-command-line", /* mn10300 */ 826 ".GCC-command-line", /* mn10300 */
826 ".GCC.command.line", /* record-gcc-switches, non mn10300 */ 827 ".GCC.command.line", /* record-gcc-switches, non mn10300 */
@@ -861,37 +862,34 @@ static void check_section(const char *modname, struct elf_info *elf,
861 862
862 863
863#define ALL_INIT_DATA_SECTIONS \ 864#define ALL_INIT_DATA_SECTIONS \
864 ".init.setup$", ".init.rodata$", \ 865 ".init.setup$", ".init.rodata$", ".meminit.rodata$", \
865 ".cpuinit.rodata$", ".meminit.rodata$", \ 866 ".init.data$", ".meminit.data$"
866 ".init.data$", ".cpuinit.data$", ".meminit.data$"
867#define ALL_EXIT_DATA_SECTIONS \ 867#define ALL_EXIT_DATA_SECTIONS \
868 ".exit.data$", ".cpuexit.data$", ".memexit.data$" 868 ".exit.data$", ".memexit.data$"
869 869
870#define ALL_INIT_TEXT_SECTIONS \ 870#define ALL_INIT_TEXT_SECTIONS \
871 ".init.text$", ".cpuinit.text$", ".meminit.text$" 871 ".init.text$", ".meminit.text$"
872#define ALL_EXIT_TEXT_SECTIONS \ 872#define ALL_EXIT_TEXT_SECTIONS \
873 ".exit.text$", ".cpuexit.text$", ".memexit.text$" 873 ".exit.text$", ".memexit.text$"
874 874
875#define ALL_PCI_INIT_SECTIONS \ 875#define ALL_PCI_INIT_SECTIONS \
876 ".pci_fixup_early$", ".pci_fixup_header$", ".pci_fixup_final$", \ 876 ".pci_fixup_early$", ".pci_fixup_header$", ".pci_fixup_final$", \
877 ".pci_fixup_enable$", ".pci_fixup_resume$", \ 877 ".pci_fixup_enable$", ".pci_fixup_resume$", \
878 ".pci_fixup_resume_early$", ".pci_fixup_suspend$" 878 ".pci_fixup_resume_early$", ".pci_fixup_suspend$"
879 879
880#define ALL_XXXINIT_SECTIONS CPU_INIT_SECTIONS, MEM_INIT_SECTIONS 880#define ALL_XXXINIT_SECTIONS MEM_INIT_SECTIONS
881#define ALL_XXXEXIT_SECTIONS CPU_EXIT_SECTIONS, MEM_EXIT_SECTIONS 881#define ALL_XXXEXIT_SECTIONS MEM_EXIT_SECTIONS
882 882
883#define ALL_INIT_SECTIONS INIT_SECTIONS, ALL_XXXINIT_SECTIONS 883#define ALL_INIT_SECTIONS INIT_SECTIONS, ALL_XXXINIT_SECTIONS
884#define ALL_EXIT_SECTIONS EXIT_SECTIONS, ALL_XXXEXIT_SECTIONS 884#define ALL_EXIT_SECTIONS EXIT_SECTIONS, ALL_XXXEXIT_SECTIONS
885 885
886#define DATA_SECTIONS ".data$", ".data.rel$" 886#define DATA_SECTIONS ".data$", ".data.rel$"
887#define TEXT_SECTIONS ".text$" 887#define TEXT_SECTIONS ".text$", ".text.unlikely$"
888 888
889#define INIT_SECTIONS ".init.*" 889#define INIT_SECTIONS ".init.*"
890#define CPU_INIT_SECTIONS ".cpuinit.*"
891#define MEM_INIT_SECTIONS ".meminit.*" 890#define MEM_INIT_SECTIONS ".meminit.*"
892 891
893#define EXIT_SECTIONS ".exit.*" 892#define EXIT_SECTIONS ".exit.*"
894#define CPU_EXIT_SECTIONS ".cpuexit.*"
895#define MEM_EXIT_SECTIONS ".memexit.*" 893#define MEM_EXIT_SECTIONS ".memexit.*"
896 894
897/* init data sections */ 895/* init data sections */
@@ -979,48 +977,20 @@ const struct sectioncheck sectioncheck[] = {
979 .mismatch = DATA_TO_ANY_EXIT, 977 .mismatch = DATA_TO_ANY_EXIT,
980 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL }, 978 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
981}, 979},
982/* Do not reference init code/data from cpuinit/meminit code/data */ 980/* Do not reference init code/data from meminit code/data */
983{ 981{
984 .fromsec = { ALL_XXXINIT_SECTIONS, NULL }, 982 .fromsec = { ALL_XXXINIT_SECTIONS, NULL },
985 .tosec = { INIT_SECTIONS, NULL }, 983 .tosec = { INIT_SECTIONS, NULL },
986 .mismatch = XXXINIT_TO_SOME_INIT, 984 .mismatch = XXXINIT_TO_SOME_INIT,
987 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL }, 985 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
988}, 986},
989/* Do not reference cpuinit code/data from meminit code/data */ 987/* Do not reference exit code/data from memexit code/data */
990{
991 .fromsec = { MEM_INIT_SECTIONS, NULL },
992 .tosec = { CPU_INIT_SECTIONS, NULL },
993 .mismatch = XXXINIT_TO_SOME_INIT,
994 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
995},
996/* Do not reference meminit code/data from cpuinit code/data */
997{
998 .fromsec = { CPU_INIT_SECTIONS, NULL },
999 .tosec = { MEM_INIT_SECTIONS, NULL },
1000 .mismatch = XXXINIT_TO_SOME_INIT,
1001 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
1002},
1003/* Do not reference exit code/data from cpuexit/memexit code/data */
1004{ 988{
1005 .fromsec = { ALL_XXXEXIT_SECTIONS, NULL }, 989 .fromsec = { ALL_XXXEXIT_SECTIONS, NULL },
1006 .tosec = { EXIT_SECTIONS, NULL }, 990 .tosec = { EXIT_SECTIONS, NULL },
1007 .mismatch = XXXEXIT_TO_SOME_EXIT, 991 .mismatch = XXXEXIT_TO_SOME_EXIT,
1008 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL }, 992 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
1009}, 993},
1010/* Do not reference cpuexit code/data from memexit code/data */
1011{
1012 .fromsec = { MEM_EXIT_SECTIONS, NULL },
1013 .tosec = { CPU_EXIT_SECTIONS, NULL },
1014 .mismatch = XXXEXIT_TO_SOME_EXIT,
1015 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
1016},
1017/* Do not reference memexit code/data from cpuexit code/data */
1018{
1019 .fromsec = { CPU_EXIT_SECTIONS, NULL },
1020 .tosec = { MEM_EXIT_SECTIONS, NULL },
1021 .mismatch = XXXEXIT_TO_SOME_EXIT,
1022 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
1023},
1024/* Do not use exit code/data from init code */ 994/* Do not use exit code/data from init code */
1025{ 995{
1026 .fromsec = { ALL_INIT_SECTIONS, NULL }, 996 .fromsec = { ALL_INIT_SECTIONS, NULL },
@@ -1089,8 +1059,6 @@ static const struct sectioncheck *section_mismatch(
1089 * Pattern 2: 1059 * Pattern 2:
1090 * Many drivers utilise a *driver container with references to 1060 * Many drivers utilise a *driver container with references to
1091 * add, remove, probe functions etc. 1061 * add, remove, probe functions etc.
1092 * These functions may often be marked __cpuinit and we do not want to
1093 * warn here.
1094 * the pattern is identified by: 1062 * the pattern is identified by:
1095 * tosec = init or exit section 1063 * tosec = init or exit section
1096 * fromsec = data section 1064 * fromsec = data section
@@ -1249,7 +1217,6 @@ static Elf_Sym *find_elf_symbol2(struct elf_info *elf, Elf_Addr addr,
1249/* 1217/*
1250 * Convert a section name to the function/data attribute 1218 * Convert a section name to the function/data attribute
1251 * .init.text => __init 1219 * .init.text => __init
1252 * .cpuinit.data => __cpudata
1253 * .memexitconst => __memconst 1220 * .memexitconst => __memconst
1254 * etc. 1221 * etc.
1255 * 1222 *
diff --git a/scripts/package/builddeb b/scripts/package/builddeb
index acb86507828a..90e521fde35f 100644
--- a/scripts/package/builddeb
+++ b/scripts/package/builddeb
@@ -41,9 +41,9 @@ create_package() {
41 parisc*) 41 parisc*)
42 debarch=hppa ;; 42 debarch=hppa ;;
43 mips*) 43 mips*)
44 debarch=mips$(grep -q CPU_LITTLE_ENDIAN=y .config && echo el) ;; 44 debarch=mips$(grep -q CPU_LITTLE_ENDIAN=y $KCONFIG_CONFIG && echo el) ;;
45 arm*) 45 arm*)
46 debarch=arm$(grep -q CONFIG_AEABI=y .config && echo el) ;; 46 debarch=arm$(grep -q CONFIG_AEABI=y $KCONFIG_CONFIG && echo el) ;;
47 *) 47 *)
48 echo "" >&2 48 echo "" >&2
49 echo "** ** ** WARNING ** ** **" >&2 49 echo "** ** ** WARNING ** ** **" >&2
@@ -78,17 +78,35 @@ tmpdir="$objtree/debian/tmp"
78fwdir="$objtree/debian/fwtmp" 78fwdir="$objtree/debian/fwtmp"
79kernel_headers_dir="$objtree/debian/hdrtmp" 79kernel_headers_dir="$objtree/debian/hdrtmp"
80libc_headers_dir="$objtree/debian/headertmp" 80libc_headers_dir="$objtree/debian/headertmp"
81dbg_dir="$objtree/debian/dbgtmp"
81packagename=linux-image-$version 82packagename=linux-image-$version
82fwpackagename=linux-firmware-image 83fwpackagename=linux-firmware-image-$version
83kernel_headers_packagename=linux-headers-$version 84kernel_headers_packagename=linux-headers-$version
84libc_headers_packagename=linux-libc-dev 85libc_headers_packagename=linux-libc-dev
86dbg_packagename=$packagename-dbg
85 87
86if [ "$ARCH" = "um" ] ; then 88if [ "$ARCH" = "um" ] ; then
87 packagename=user-mode-linux-$version 89 packagename=user-mode-linux-$version
88fi 90fi
89 91
92# Not all arches have the same installed path in debian
93# XXX: have each arch Makefile export a variable of the canonical image install
94# path instead
95case $ARCH in
96um)
97 installed_image_path="usr/bin/linux-$version"
98 ;;
99parisc|mips|powerpc)
100 installed_image_path="boot/vmlinux-$version"
101 ;;
102*)
103 installed_image_path="boot/vmlinuz-$version"
104esac
105
106BUILD_DEBUG="$(grep -s '^CONFIG_DEBUG_INFO=y' $KCONFIG_CONFIG || true)"
107
90# Setup the directory structure 108# Setup the directory structure
91rm -rf "$tmpdir" "$fwdir" "$kernel_headers_dir" "$libc_headers_dir" 109rm -rf "$tmpdir" "$fwdir" "$kernel_headers_dir" "$libc_headers_dir" "$dbg_dir"
92mkdir -m 755 -p "$tmpdir/DEBIAN" 110mkdir -m 755 -p "$tmpdir/DEBIAN"
93mkdir -p "$tmpdir/lib" "$tmpdir/boot" "$tmpdir/usr/share/doc/$packagename" 111mkdir -p "$tmpdir/lib" "$tmpdir/boot" "$tmpdir/usr/share/doc/$packagename"
94mkdir -m 755 -p "$fwdir/DEBIAN" 112mkdir -m 755 -p "$fwdir/DEBIAN"
@@ -101,26 +119,29 @@ mkdir -p "$kernel_headers_dir/lib/modules/$version/"
101if [ "$ARCH" = "um" ] ; then 119if [ "$ARCH" = "um" ] ; then
102 mkdir -p "$tmpdir/usr/lib/uml/modules/$version" "$tmpdir/usr/bin" 120 mkdir -p "$tmpdir/usr/lib/uml/modules/$version" "$tmpdir/usr/bin"
103fi 121fi
122if [ -n "$BUILD_DEBUG" ] ; then
123 mkdir -p "$dbg_dir/usr/share/doc/$dbg_packagename"
124 mkdir -m 755 -p "$dbg_dir/DEBIAN"
125fi
104 126
105# Build and install the kernel 127# Build and install the kernel
106if [ "$ARCH" = "um" ] ; then 128if [ "$ARCH" = "um" ] ; then
107 $MAKE linux 129 $MAKE linux
108 cp System.map "$tmpdir/usr/lib/uml/modules/$version/System.map" 130 cp System.map "$tmpdir/usr/lib/uml/modules/$version/System.map"
109 cp .config "$tmpdir/usr/share/doc/$packagename/config" 131 cp $KCONFIG_CONFIG "$tmpdir/usr/share/doc/$packagename/config"
110 gzip "$tmpdir/usr/share/doc/$packagename/config" 132 gzip "$tmpdir/usr/share/doc/$packagename/config"
111 cp $KBUILD_IMAGE "$tmpdir/usr/bin/linux-$version"
112else 133else
113 cp System.map "$tmpdir/boot/System.map-$version" 134 cp System.map "$tmpdir/boot/System.map-$version"
114 cp .config "$tmpdir/boot/config-$version" 135 cp $KCONFIG_CONFIG "$tmpdir/boot/config-$version"
115 # Not all arches include the boot path in KBUILD_IMAGE 136fi
116 if [ -e $KBUILD_IMAGE ]; then 137# Not all arches include the boot path in KBUILD_IMAGE
117 cp $KBUILD_IMAGE "$tmpdir/boot/vmlinuz-$version" 138if [ -e $KBUILD_IMAGE ]; then
118 else 139 cp $KBUILD_IMAGE "$tmpdir/$installed_image_path"
119 cp arch/$ARCH/boot/$KBUILD_IMAGE "$tmpdir/boot/vmlinuz-$version" 140else
120 fi 141 cp arch/$ARCH/boot/$KBUILD_IMAGE "$tmpdir/$installed_image_path"
121fi 142fi
122 143
123if grep -q '^CONFIG_MODULES=y' .config ; then 144if grep -q '^CONFIG_MODULES=y' $KCONFIG_CONFIG ; then
124 INSTALL_MOD_PATH="$tmpdir" $MAKE KBUILD_SRC= modules_install 145 INSTALL_MOD_PATH="$tmpdir" $MAKE KBUILD_SRC= modules_install
125 rm -f "$tmpdir/lib/modules/$version/build" 146 rm -f "$tmpdir/lib/modules/$version/build"
126 rm -f "$tmpdir/lib/modules/$version/source" 147 rm -f "$tmpdir/lib/modules/$version/source"
@@ -128,6 +149,20 @@ if grep -q '^CONFIG_MODULES=y' .config ; then
128 mv "$tmpdir/lib/modules/$version"/* "$tmpdir/usr/lib/uml/modules/$version/" 149 mv "$tmpdir/lib/modules/$version"/* "$tmpdir/usr/lib/uml/modules/$version/"
129 rmdir "$tmpdir/lib/modules/$version" 150 rmdir "$tmpdir/lib/modules/$version"
130 fi 151 fi
152 if [ -n "$BUILD_DEBUG" ] ; then
153 (
154 cd $tmpdir
155 for module in $(find lib/modules/ -name *.ko); do
156 mkdir -p $(dirname $dbg_dir/usr/lib/debug/$module)
157 # only keep debug symbols in the debug file
158 objcopy --only-keep-debug $module $dbg_dir/usr/lib/debug/$module
159 # strip original module from debug symbols
160 objcopy --strip-debug $module
161 # then add a link to those
162 objcopy --add-gnu-debuglink=$dbg_dir/usr/lib/debug/$module $module
163 done
164 )
165 fi
131fi 166fi
132 167
133if [ "$ARCH" != "um" ]; then 168if [ "$ARCH" != "um" ]; then
@@ -149,7 +184,7 @@ set -e
149# Pass maintainer script parameters to hook scripts 184# Pass maintainer script parameters to hook scripts
150export DEB_MAINT_PARAMS="\$*" 185export DEB_MAINT_PARAMS="\$*"
151 186
152test -d $debhookdir/$script.d && run-parts --arg="$version" $debhookdir/$script.d 187test -d $debhookdir/$script.d && run-parts --arg="$version" --arg="/$installed_image_path" $debhookdir/$script.d
153exit 0 188exit 0
154EOF 189EOF
155 chmod 755 "$tmpdir/DEBIAN/$script" 190 chmod 755 "$tmpdir/DEBIAN/$script"
@@ -245,11 +280,12 @@ fi
245# Build header package 280# Build header package
246(cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles") 281(cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles")
247(cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles") 282(cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles")
248(cd $objtree; find arch/$SRCARCH/include .config Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles") 283(cd $objtree; find arch/$SRCARCH/include Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles")
249destdir=$kernel_headers_dir/usr/src/linux-headers-$version 284destdir=$kernel_headers_dir/usr/src/linux-headers-$version
250mkdir -p "$destdir" 285mkdir -p "$destdir"
251(cd $srctree; tar -c -f - -T "$objtree/debian/hdrsrcfiles") | (cd $destdir; tar -xf -) 286(cd $srctree; tar -c -f - -T "$objtree/debian/hdrsrcfiles") | (cd $destdir; tar -xf -)
252(cd $objtree; tar -c -f - -T "$objtree/debian/hdrobjfiles") | (cd $destdir; tar -xf -) 287(cd $objtree; tar -c -f - -T "$objtree/debian/hdrobjfiles") | (cd $destdir; tar -xf -)
288(cd $objtree; cp $KCONFIG_CONFIG $destdir/.config) # copy .config manually to be where it's expected to be
253ln -sf "/usr/src/linux-headers-$version" "$kernel_headers_dir/lib/modules/$version/build" 289ln -sf "/usr/src/linux-headers-$version" "$kernel_headers_dir/lib/modules/$version/build"
254rm -f "$objtree/debian/hdrsrcfiles" "$objtree/debian/hdrobjfiles" 290rm -f "$objtree/debian/hdrsrcfiles" "$objtree/debian/hdrobjfiles"
255arch=$(dpkg --print-architecture) 291arch=$(dpkg --print-architecture)
@@ -299,4 +335,30 @@ fi
299 335
300create_package "$packagename" "$tmpdir" 336create_package "$packagename" "$tmpdir"
301 337
338if [ -n "$BUILD_DEBUG" ] ; then
339 # Build debug package
340 # Different tools want the image in different locations
341 # perf
342 mkdir -p $dbg_dir/usr/lib/debug/lib/modules/$version/
343 cp vmlinux $dbg_dir/usr/lib/debug/lib/modules/$version/
344 # systemtap
345 mkdir -p $dbg_dir/usr/lib/debug/boot/
346 ln -s ../lib/modules/$version/vmlinux $dbg_dir/usr/lib/debug/boot/vmlinux-$version
347 # kdump-tools
348 ln -s lib/modules/$version/vmlinux $dbg_dir/usr/lib/debug/vmlinux-$version
349
350 cat <<EOF >> debian/control
351
352Package: $dbg_packagename
353Section: debug
354Provides: linux-debug, linux-debug-$version
355Architecture: any
356Description: Linux kernel debugging symbols for $version
357 This package will come in handy if you need to debug the kernel. It provides
358 all the necessary debug symbols for the kernel and its modules.
359EOF
360
361 create_package "$dbg_packagename" "$dbg_dir"
362fi
363
302exit 0 364exit 0
diff --git a/scripts/package/buildtar b/scripts/package/buildtar
index cdd9bb909bcd..aa22f9447ddc 100644
--- a/scripts/package/buildtar
+++ b/scripts/package/buildtar
@@ -87,6 +87,27 @@ case "${ARCH}" in
87 [ -f "${objtree}/vmlinux.SYS" ] && cp -v -- "${objtree}/vmlinux.SYS" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}.SYS" 87 [ -f "${objtree}/vmlinux.SYS" ] && cp -v -- "${objtree}/vmlinux.SYS" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}.SYS"
88 [ -f "${objtree}/vmlinux.dsk" ] && cp -v -- "${objtree}/vmlinux.dsk" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}.dsk" 88 [ -f "${objtree}/vmlinux.dsk" ] && cp -v -- "${objtree}/vmlinux.dsk" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}.dsk"
89 ;; 89 ;;
90 mips)
91 if [ -f "${objtree}/arch/mips/boot/compressed/vmlinux.bin" ]; then
92 cp -v -- "${objtree}/arch/mips/boot/compressed/vmlinux.bin" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
93 elif [ -f "${objtree}/arch/mips/boot/compressed/vmlinux.ecoff" ]; then
94 cp -v -- "${objtree}/arch/mips/boot/compressed/vmlinux.ecoff" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
95 elif [ -f "${objtree}/arch/mips/boot/compressed/vmlinux.srec" ]; then
96 cp -v -- "${objtree}/arch/mips/boot/compressed/vmlinux.srec" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
97 elif [ -f "${objtree}/vmlinux.32" ]; then
98 cp -v -- "${objtree}/vmlinux.32" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
99 elif [ -f "${objtree}/vmlinux.64" ]; then
100 cp -v -- "${objtree}/vmlinux.64" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
101 elif [ -f "${objtree}/arch/mips/boot/vmlinux.bin" ]; then
102 cp -v -- "${objtree}/arch/mips/boot/vmlinux.bin" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
103 elif [ -f "${objtree}/arch/mips/boot/vmlinux.ecoff" ]; then
104 cp -v -- "${objtree}/arch/mips/boot/vmlinux.ecoff" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
105 elif [ -f "${objtree}/arch/mips/boot/vmlinux.srec" ]; then
106 cp -v -- "${objtree}/arch/mips/boot/vmlinux.srec" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
107 elif [ -f "${objtree}/vmlinux" ]; then
108 cp -v -- "${objtree}/vmlinux" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
109 fi
110 ;;
90 *) 111 *)
91 [ -f "${KBUILD_IMAGE}" ] && cp -v -- "${KBUILD_IMAGE}" "${tmpdir}/boot/vmlinux-kbuild-${KERNELRELEASE}" 112 [ -f "${KBUILD_IMAGE}" ] && cp -v -- "${KBUILD_IMAGE}" "${tmpdir}/boot/vmlinux-kbuild-${KERNELRELEASE}"
92 echo "" >&2 113 echo "" >&2
diff --git a/scripts/package/mkspec b/scripts/package/mkspec
index fbbfd08853d3..13957602f7ca 100755
--- a/scripts/package/mkspec
+++ b/scripts/package/mkspec
@@ -1,7 +1,7 @@
1#!/bin/sh 1#!/bin/sh
2# 2#
3# Output a simple RPM spec file that uses no fancy features requiring 3# Output a simple RPM spec file.
4# RPM v4. This is intended to work with any RPM distro. 4# This version assumes a minimum of RPM 4.0.3.
5# 5#
6# The only gothic bit here is redefining install_post to avoid 6# The only gothic bit here is redefining install_post to avoid
7# stripping the symbols from files in the kernel which we want 7# stripping the symbols from files in the kernel which we want
@@ -59,6 +59,14 @@ echo "header files define structures and constants that are needed for"
59echo "building most standard programs and are also needed for rebuilding the" 59echo "building most standard programs and are also needed for rebuilding the"
60echo "glibc package." 60echo "glibc package."
61echo "" 61echo ""
62echo "%package devel"
63echo "Summary: Development package for building kernel modules to match the $__KERNELRELEASE kernel"
64echo "Group: System Environment/Kernel"
65echo "AutoReqProv: no"
66echo "%description -n kernel-devel"
67echo "This package provides kernel headers and makefiles sufficient to build modules"
68echo "against the $__KERNELRELEASE kernel package."
69echo ""
62 70
63if ! $PREBUILT; then 71if ! $PREBUILT; then
64echo "%prep" 72echo "%prep"
@@ -74,15 +82,17 @@ echo ""
74fi 82fi
75 83
76echo "%install" 84echo "%install"
85echo 'KBUILD_IMAGE=$(make image_name)'
77echo "%ifarch ia64" 86echo "%ifarch ia64"
78echo 'mkdir -p $RPM_BUILD_ROOT/boot/efi $RPM_BUILD_ROOT/lib/modules' 87echo 'mkdir -p $RPM_BUILD_ROOT/boot/efi $RPM_BUILD_ROOT/lib/modules'
79echo 'mkdir -p $RPM_BUILD_ROOT/lib/firmware'
80echo "%else" 88echo "%else"
81echo 'mkdir -p $RPM_BUILD_ROOT/boot $RPM_BUILD_ROOT/lib/modules' 89echo 'mkdir -p $RPM_BUILD_ROOT/boot $RPM_BUILD_ROOT/lib/modules'
82echo 'mkdir -p $RPM_BUILD_ROOT/lib/firmware'
83echo "%endif" 90echo "%endif"
91echo 'mkdir -p $RPM_BUILD_ROOT'"/lib/firmware/$KERNELRELEASE"
84 92
85echo 'INSTALL_MOD_PATH=$RPM_BUILD_ROOT make %{?_smp_mflags} KBUILD_SRC= modules_install' 93echo 'INSTALL_MOD_PATH=$RPM_BUILD_ROOT make %{?_smp_mflags} KBUILD_SRC= mod-fw= modules_install'
94echo 'INSTALL_FW_PATH=$RPM_BUILD_ROOT'"/lib/firmware/$KERNELRELEASE"
95echo 'make INSTALL_FW_PATH=$INSTALL_FW_PATH' firmware_install
86echo "%ifarch ia64" 96echo "%ifarch ia64"
87echo 'cp $KBUILD_IMAGE $RPM_BUILD_ROOT'"/boot/efi/vmlinuz-$KERNELRELEASE" 97echo 'cp $KBUILD_IMAGE $RPM_BUILD_ROOT'"/boot/efi/vmlinuz-$KERNELRELEASE"
88echo 'ln -s '"efi/vmlinuz-$KERNELRELEASE" '$RPM_BUILD_ROOT'"/boot/" 98echo 'ln -s '"efi/vmlinuz-$KERNELRELEASE" '$RPM_BUILD_ROOT'"/boot/"
@@ -107,18 +117,43 @@ echo 'mv vmlinux.bz2 $RPM_BUILD_ROOT'"/boot/vmlinux-$KERNELRELEASE.bz2"
107echo 'mv vmlinux.orig vmlinux' 117echo 'mv vmlinux.orig vmlinux'
108echo "%endif" 118echo "%endif"
109 119
120echo 'rm -f $RPM_BUILD_ROOT'"/lib/modules/$KERNELRELEASE/{build,source}"
121echo "mkdir -p "'$RPM_BUILD_ROOT'"/usr/src/kernels/$KERNELRELEASE"
122echo "EXCLUDES=\"$RCS_TAR_IGNORE --exclude .tmp_versions --exclude=*vmlinux* --exclude=*.o --exclude=*.ko --exclude=*.cmd --exclude=Documentation --exclude=firmware --exclude .config.old --exclude .missing-syscalls.d\""
123echo "tar "'$EXCLUDES'" -cf- . | (cd "'$RPM_BUILD_ROOT'"/usr/src/kernels/$KERNELRELEASE;tar xvf -)"
124echo 'cd $RPM_BUILD_ROOT'"/lib/modules/$KERNELRELEASE"
125echo "ln -sf /usr/src/kernels/$KERNELRELEASE build"
126echo "ln -sf /usr/src/kernels/$KERNELRELEASE source"
127
110echo "" 128echo ""
111echo "%clean" 129echo "%clean"
112echo 'rm -rf $RPM_BUILD_ROOT' 130echo 'rm -rf $RPM_BUILD_ROOT'
113echo "" 131echo ""
132echo "%post"
133echo "if [ -x /sbin/installkernel -a -r /boot/vmlinuz-$KERNELRELEASE -a -r /boot/System.map-$KERNELRELEASE ]; then"
134echo "cp /boot/vmlinuz-$KERNELRELEASE /boot/vmlinuz-$KERNELRELEASE-rpm"
135echo "cp /boot/System.map-$KERNELRELEASE /boot/System.map-$KERNELRELEASE-rpm"
136echo "rm -f /boot/vmlinuz-$KERNELRELEASE /boot/System.map-$KERNELRELEASE"
137echo "/sbin/installkernel $KERNELRELEASE /boot/vmlinuz-$KERNELRELEASE-rpm /boot/System.map-$KERNELRELEASE-rpm"
138echo "rm -f /boot/vmlinuz-$KERNELRELEASE-rpm /boot/System.map-$KERNELRELEASE-rpm"
139echo "fi"
140echo ""
114echo "%files" 141echo "%files"
115echo '%defattr (-, root, root)' 142echo '%defattr (-, root, root)'
116echo "%dir /lib/modules" 143echo "%dir /lib/modules"
117echo "/lib/modules/$KERNELRELEASE" 144echo "/lib/modules/$KERNELRELEASE"
118echo "/lib/firmware" 145echo "%exclude /lib/modules/$KERNELRELEASE/build"
146echo "%exclude /lib/modules/$KERNELRELEASE/source"
147echo "/lib/firmware/$KERNELRELEASE"
119echo "/boot/*" 148echo "/boot/*"
120echo "" 149echo ""
121echo "%files headers" 150echo "%files headers"
122echo '%defattr (-, root, root)' 151echo '%defattr (-, root, root)'
123echo "/usr/include" 152echo "/usr/include"
124echo "" 153echo ""
154echo "%files devel"
155echo '%defattr (-, root, root)'
156echo "/usr/src/kernels/$KERNELRELEASE"
157echo "/lib/modules/$KERNELRELEASE/build"
158echo "/lib/modules/$KERNELRELEASE/source"
159echo ""
diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl
index 858966ab019c..a674fd5507c1 100755
--- a/scripts/recordmcount.pl
+++ b/scripts/recordmcount.pl
@@ -364,6 +364,10 @@ if ($arch eq "x86_64") {
364} elsif ($arch eq "blackfin") { 364} elsif ($arch eq "blackfin") {
365 $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s__mcount\$"; 365 $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s__mcount\$";
366 $mcount_adjust = -4; 366 $mcount_adjust = -4;
367} elsif ($arch eq "tilegx") {
368 $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s__mcount\$";
369 $type = ".quad";
370 $alignment = 8;
367} else { 371} else {
368 die "Arch $arch is not supported with CONFIG_FTRACE_MCOUNT_RECORD"; 372 die "Arch $arch is not supported with CONFIG_FTRACE_MCOUNT_RECORD";
369} 373}
diff --git a/scripts/setlocalversion b/scripts/setlocalversion
index 84b88f109b80..d105a44b68f6 100755
--- a/scripts/setlocalversion
+++ b/scripts/setlocalversion
@@ -71,9 +71,6 @@ scm_version()
71 printf -- '-svn%s' "`git svn find-rev $head`" 71 printf -- '-svn%s' "`git svn find-rev $head`"
72 fi 72 fi
73 73
74 # Update index only on r/w media
75 [ -w . ] && git update-index --refresh --unmerged > /dev/null
76
77 # Check for uncommitted changes 74 # Check for uncommitted changes
78 if git diff-index --name-only HEAD | grep -qv "^scripts/package"; then 75 if git diff-index --name-only HEAD | grep -qv "^scripts/package"; then
79 printf '%s' -dirty 76 printf '%s' -dirty
diff --git a/scripts/sortextable.c b/scripts/sortextable.c
index 1f10e89d15b4..7c2310c5b996 100644
--- a/scripts/sortextable.c
+++ b/scripts/sortextable.c
@@ -31,6 +31,10 @@
31#include <tools/be_byteshift.h> 31#include <tools/be_byteshift.h>
32#include <tools/le_byteshift.h> 32#include <tools/le_byteshift.h>
33 33
34#ifndef EM_AARCH64
35#define EM_AARCH64 183
36#endif
37
34static int fd_map; /* File descriptor for file being modified. */ 38static int fd_map; /* File descriptor for file being modified. */
35static int mmap_failed; /* Boolean flag. */ 39static int mmap_failed; /* Boolean flag. */
36static void *ehdr_curr; /* current ElfXX_Ehdr * for resource cleanup */ 40static void *ehdr_curr; /* current ElfXX_Ehdr * for resource cleanup */
@@ -60,14 +64,6 @@ fail_file(void)
60 longjmp(jmpenv, SJ_FAIL); 64 longjmp(jmpenv, SJ_FAIL);
61} 65}
62 66
63static void __attribute__((noreturn))
64succeed_file(void)
65{
66 cleanup();
67 longjmp(jmpenv, SJ_SUCCEED);
68}
69
70
71/* 67/*
72 * Get the whole file as a programming convenience in order to avoid 68 * Get the whole file as a programming convenience in order to avoid
73 * malloc+lseek+read+free of many pieces. If successful, then mmap 69 * malloc+lseek+read+free of many pieces. If successful, then mmap
@@ -249,6 +245,7 @@ do_file(char const *const fname)
249 custom_sort = sort_relative_table; 245 custom_sort = sort_relative_table;
250 break; 246 break;
251 case EM_ARM: 247 case EM_ARM:
248 case EM_AARCH64:
252 case EM_MIPS: 249 case EM_MIPS:
253 break; 250 break;
254 } /* end switch */ 251 } /* end switch */