diff options
Diffstat (limited to 'scripts')
40 files changed, 1735 insertions, 414 deletions
diff --git a/scripts/Makefile.build b/scripts/Makefile.build index e4deb73e9a84..a1a5cf95a68d 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build | |||
| @@ -115,7 +115,10 @@ endif | |||
| 115 | # --------------------------------------------------------------------------- | 115 | # --------------------------------------------------------------------------- |
| 116 | 116 | ||
| 117 | # Default is built-in, unless we know otherwise | 117 | # Default is built-in, unless we know otherwise |
| 118 | modkern_cflags = $(if $(part-of-module), $(CFLAGS_MODULE), $(CFLAGS_KERNEL)) | 118 | modkern_cflags = \ |
| 119 | $(if $(part-of-module), \ | ||
| 120 | $(KBUILD_CFLAGS_MODULE) $(CFLAGS_MODULE), \ | ||
| 121 | $(KBUILD_CFLAGS_KERNEL) $(CFLAGS_KERNEL)) | ||
| 119 | quiet_modtag := $(empty) $(empty) | 122 | quiet_modtag := $(empty) $(empty) |
| 120 | 123 | ||
| 121 | $(real-objs-m) : part-of-module := y | 124 | $(real-objs-m) : part-of-module := y |
| @@ -156,14 +159,14 @@ $(obj)/%.i: $(src)/%.c FORCE | |||
| 156 | 159 | ||
| 157 | cmd_gensymtypes = \ | 160 | cmd_gensymtypes = \ |
| 158 | $(CPP) -D__GENKSYMS__ $(c_flags) $< | \ | 161 | $(CPP) -D__GENKSYMS__ $(c_flags) $< | \ |
| 159 | $(GENKSYMS) -T $@ -a $(ARCH) \ | 162 | $(GENKSYMS) $(if $(1), -T $(2)) -a $(ARCH) \ |
| 160 | $(if $(KBUILD_PRESERVE),-p) \ | 163 | $(if $(KBUILD_PRESERVE),-p) \ |
| 161 | $(if $(1),-r $(firstword $(wildcard $(@:.symtypes=.symref) /dev/null))) | 164 | -r $(firstword $(wildcard $(2:.symtypes=.symref) /dev/null)) |
| 162 | 165 | ||
| 163 | quiet_cmd_cc_symtypes_c = SYM $(quiet_modtag) $@ | 166 | quiet_cmd_cc_symtypes_c = SYM $(quiet_modtag) $@ |
| 164 | cmd_cc_symtypes_c = \ | 167 | cmd_cc_symtypes_c = \ |
| 165 | set -e; \ | 168 | set -e; \ |
| 166 | $(call cmd_gensymtypes, true) >/dev/null; \ | 169 | $(call cmd_gensymtypes,true,$@) >/dev/null; \ |
| 167 | test -s $@ || rm -f $@ | 170 | test -s $@ || rm -f $@ |
| 168 | 171 | ||
| 169 | $(obj)/%.symtypes : $(src)/%.c FORCE | 172 | $(obj)/%.symtypes : $(src)/%.c FORCE |
| @@ -192,16 +195,16 @@ else | |||
| 192 | # the actual value of the checksum generated by genksyms | 195 | # the actual value of the checksum generated by genksyms |
| 193 | 196 | ||
| 194 | cmd_cc_o_c = $(CC) $(c_flags) -c -o $(@D)/.tmp_$(@F) $< | 197 | cmd_cc_o_c = $(CC) $(c_flags) -c -o $(@D)/.tmp_$(@F) $< |
| 195 | cmd_modversions = \ | 198 | cmd_modversions = \ |
| 196 | if $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then \ | 199 | if $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then \ |
| 197 | $(call cmd_gensymtypes, $(KBUILD_SYMTYPES)) \ | 200 | $(call cmd_gensymtypes,$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \ |
| 198 | > $(@D)/.tmp_$(@F:.o=.ver); \ | 201 | > $(@D)/.tmp_$(@F:.o=.ver); \ |
| 199 | \ | 202 | \ |
| 200 | $(LD) $(LDFLAGS) -r -o $@ $(@D)/.tmp_$(@F) \ | 203 | $(LD) $(LDFLAGS) -r -o $@ $(@D)/.tmp_$(@F) \ |
| 201 | -T $(@D)/.tmp_$(@F:.o=.ver); \ | 204 | -T $(@D)/.tmp_$(@F:.o=.ver); \ |
| 202 | rm -f $(@D)/.tmp_$(@F) $(@D)/.tmp_$(@F:.o=.ver); \ | 205 | rm -f $(@D)/.tmp_$(@F) $(@D)/.tmp_$(@F:.o=.ver); \ |
| 203 | else \ | 206 | else \ |
| 204 | mv -f $(@D)/.tmp_$(@F) $@; \ | 207 | mv -f $(@D)/.tmp_$(@F) $@; \ |
| 205 | fi; | 208 | fi; |
| 206 | endif | 209 | endif |
| 207 | 210 | ||
| @@ -248,10 +251,10 @@ $(obj)/%.lst: $(src)/%.c FORCE | |||
| 248 | # Compile assembler sources (.S) | 251 | # Compile assembler sources (.S) |
| 249 | # --------------------------------------------------------------------------- | 252 | # --------------------------------------------------------------------------- |
| 250 | 253 | ||
| 251 | modkern_aflags := $(AFLAGS_KERNEL) | 254 | modkern_aflags := $(KBUILD_AFLAGS_KERNEL) $(AFLAGS_KERNEL) |
| 252 | 255 | ||
| 253 | $(real-objs-m) : modkern_aflags := $(AFLAGS_MODULE) | 256 | $(real-objs-m) : modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE) |
| 254 | $(real-objs-m:.o=.s): modkern_aflags := $(AFLAGS_MODULE) | 257 | $(real-objs-m:.o=.s): modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE) |
| 255 | 258 | ||
| 256 | quiet_cmd_as_s_S = CPP $(quiet_modtag) $@ | 259 | quiet_cmd_as_s_S = CPP $(quiet_modtag) $@ |
| 257 | cmd_as_s_S = $(CPP) $(a_flags) -o $@ $< | 260 | cmd_as_s_S = $(CPP) $(a_flags) -o $@ $< |
diff --git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst index 0fcd83838771..f89cb87f5c01 100644 --- a/scripts/Makefile.headersinst +++ b/scripts/Makefile.headersinst | |||
| @@ -3,7 +3,6 @@ | |||
| 3 | # | 3 | # |
| 4 | # header-y - list files to be installed. They are preprocessed | 4 | # header-y - list files to be installed. They are preprocessed |
| 5 | # to remove __KERNEL__ section of the file | 5 | # to remove __KERNEL__ section of the file |
| 6 | # unifdef-y - Same as header-y. Obsolete | ||
| 7 | # objhdr-y - Same as header-y but for generated files | 6 | # objhdr-y - Same as header-y but for generated files |
| 8 | # | 7 | # |
| 9 | # ========================================================================== | 8 | # ========================================================================== |
| @@ -20,7 +19,7 @@ include scripts/Kbuild.include | |||
| 20 | 19 | ||
| 21 | install := $(INSTALL_HDR_PATH)/$(_dst) | 20 | install := $(INSTALL_HDR_PATH)/$(_dst) |
| 22 | 21 | ||
| 23 | header-y := $(sort $(header-y) $(unifdef-y)) | 22 | header-y := $(sort $(header-y)) |
| 24 | subdirs := $(patsubst %/,%,$(filter %/, $(header-y))) | 23 | subdirs := $(patsubst %/,%,$(filter %/, $(header-y))) |
| 25 | header-y := $(filter-out %/, $(header-y)) | 24 | header-y := $(filter-out %/, $(header-y)) |
| 26 | 25 | ||
diff --git a/scripts/Makefile.help b/scripts/Makefile.help new file mode 100644 index 000000000000..d03608f5db04 --- /dev/null +++ b/scripts/Makefile.help | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | |||
| 2 | checker-help: | ||
| 3 | @echo ' coccicheck - Check with Coccinelle.' | ||
diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index 8f14c81abbc7..7d22056582c1 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost | |||
| @@ -30,7 +30,7 @@ | |||
| 30 | # - See include/linux/module.h for more details | 30 | # - See include/linux/module.h for more details |
| 31 | 31 | ||
| 32 | # Step 4 is solely used to allow module versioning in external modules, | 32 | # Step 4 is solely used to allow module versioning in external modules, |
| 33 | # where the CRC of each module is retrieved from the Module.symers file. | 33 | # where the CRC of each module is retrieved from the Module.symvers file. |
| 34 | 34 | ||
| 35 | # KBUILD_MODPOST_WARN can be set to avoid error out in case of undefined | 35 | # KBUILD_MODPOST_WARN can be set to avoid error out in case of undefined |
| 36 | # symbols in the final module linking stage | 36 | # symbols in the final module linking stage |
| @@ -107,7 +107,7 @@ $(modules:.ko=.mod.c): __modpost ; | |||
| 107 | modname = $(notdir $(@:.mod.o=)) | 107 | modname = $(notdir $(@:.mod.o=)) |
| 108 | 108 | ||
| 109 | quiet_cmd_cc_o_c = CC $@ | 109 | quiet_cmd_cc_o_c = CC $@ |
| 110 | cmd_cc_o_c = $(CC) $(c_flags) $(CFLAGS_MODULE) \ | 110 | cmd_cc_o_c = $(CC) $(c_flags) $(KBUILD_CFLAGS_MODULE) $(CFLAGS_MODULE) \ |
| 111 | -c -o $@ $< | 111 | -c -o $@ $< |
| 112 | 112 | ||
| 113 | $(modules:.ko=.mod.o): %.mod.o: %.mod.c FORCE | 113 | $(modules:.ko=.mod.o): %.mod.o: %.mod.c FORCE |
| @@ -117,8 +117,9 @@ targets += $(modules:.ko=.mod.o) | |||
| 117 | 117 | ||
| 118 | # Step 6), final link of the modules | 118 | # Step 6), final link of the modules |
| 119 | quiet_cmd_ld_ko_o = LD [M] $@ | 119 | quiet_cmd_ld_ko_o = LD [M] $@ |
| 120 | cmd_ld_ko_o = $(LD) -r $(LDFLAGS) $(LDFLAGS_MODULE) -o $@ \ | 120 | cmd_ld_ko_o = $(LD) -r $(LDFLAGS) \ |
| 121 | $(filter-out FORCE,$^) | 121 | $(KBUILD_LDFLAGS_MODULE) $(LDFLAGS_MODULE) \ |
| 122 | -o $@ $(filter-out FORCE,$^) | ||
| 122 | 123 | ||
| 123 | $(modules): %.ko :%.o %.mod.o FORCE | 124 | $(modules): %.ko :%.o %.mod.o FORCE |
| 124 | $(call if_changed,ld_ko_o) | 125 | $(call if_changed,ld_ko_o) |
diff --git a/scripts/checkkconfigsymbols.sh b/scripts/checkkconfigsymbols.sh index 46be3c5a62b7..2ca49bb31efc 100755 --- a/scripts/checkkconfigsymbols.sh +++ b/scripts/checkkconfigsymbols.sh | |||
| @@ -14,7 +14,7 @@ find $paths -name '*.[chS]' -o -name 'Makefile' -o -name 'Makefile*[^~]'| while | |||
| 14 | do | 14 | do |
| 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 |
| 16 | # the end is not removed here (would need perl an not-hungry regexp for that). | 16 | # the end is not removed here (would need perl an not-hungry regexp for that). |
| 17 | sed -ne 's!^.*\<\(UML_\)\?CONFIG_\([0-9A-Z_]\+\).*!\2 '$i'!p' < $i | 17 | sed -ne 's!^.*\<\(UML_\)\?CONFIG_\([0-9A-Za-z_]\+\).*!\2 '$i'!p' < $i |
| 18 | done | \ | 18 | done | \ |
| 19 | # Smart "sort|uniq" implemented in awk and tuned to collect the names of all | 19 | # Smart "sort|uniq" implemented in awk and tuned to collect the names of all |
| 20 | # files which use a given symbol | 20 | # files which use a given symbol |
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index bd88f11b0953..2039acdf5122 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl | |||
| @@ -195,7 +195,7 @@ our $typeTypedefs = qr{(?x: | |||
| 195 | our $logFunctions = qr{(?x: | 195 | our $logFunctions = qr{(?x: |
| 196 | printk| | 196 | printk| |
| 197 | pr_(debug|dbg|vdbg|devel|info|warning|err|notice|alert|crit|emerg|cont)| | 197 | pr_(debug|dbg|vdbg|devel|info|warning|err|notice|alert|crit|emerg|cont)| |
| 198 | dev_(printk|dbg|vdbg|info|warn|err|notice|alert|crit|emerg|WARN)| | 198 | (dev|netdev|netif)_(printk|dbg|vdbg|info|warn|err|notice|alert|crit|emerg|WARN)| |
| 199 | WARN| | 199 | WARN| |
| 200 | panic | 200 | panic |
| 201 | )}; | 201 | )}; |
| @@ -224,6 +224,12 @@ our @modifierList = ( | |||
| 224 | qr{fastcall}, | 224 | qr{fastcall}, |
| 225 | ); | 225 | ); |
| 226 | 226 | ||
| 227 | our $allowed_asm_includes = qr{(?x: | ||
| 228 | irq| | ||
| 229 | memory | ||
| 230 | )}; | ||
| 231 | # memory.h: ARM has a custom one | ||
| 232 | |||
| 227 | sub build_types { | 233 | sub build_types { |
| 228 | my $mods = "(?x: \n" . join("|\n ", @modifierList) . "\n)"; | 234 | my $mods = "(?x: \n" . join("|\n ", @modifierList) . "\n)"; |
| 229 | my $all = "(?x: \n" . join("|\n ", @typeList) . "\n)"; | 235 | my $all = "(?x: \n" . join("|\n ", @typeList) . "\n)"; |
| @@ -552,6 +558,9 @@ sub ctx_statement_block { | |||
| 552 | $type = ($level != 0)? '{' : ''; | 558 | $type = ($level != 0)? '{' : ''; |
| 553 | 559 | ||
| 554 | if ($level == 0) { | 560 | if ($level == 0) { |
| 561 | if (substr($blk, $off + 1, 1) eq ';') { | ||
| 562 | $off++; | ||
| 563 | } | ||
| 555 | last; | 564 | last; |
| 556 | } | 565 | } |
| 557 | } | 566 | } |
| @@ -1403,7 +1412,8 @@ sub process { | |||
| 1403 | #80 column limit | 1412 | #80 column limit |
| 1404 | if ($line =~ /^\+/ && $prevrawline !~ /\/\*\*/ && | 1413 | if ($line =~ /^\+/ && $prevrawline !~ /\/\*\*/ && |
| 1405 | $rawline !~ /^.\s*\*\s*\@$Ident\s/ && | 1414 | $rawline !~ /^.\s*\*\s*\@$Ident\s/ && |
| 1406 | $line !~ /^\+\s*$logFunctions\s*\(\s*(?:KERN_\S+\s*)?"[X\t]*"\s*(?:,|\)\s*;)\s*$/ && | 1415 | !($line =~ /^\+\s*$logFunctions\s*\(\s*(?:(KERN_\S+\s*|[^"]*))?"[X\t]*"\s*(?:,|\)\s*;)\s*$/ || |
| 1416 | $line =~ /^\+\s*"[^"]*"\s*(?:\s*|,|\)\s*;)\s*$/) && | ||
| 1407 | $length > 80) | 1417 | $length > 80) |
| 1408 | { | 1418 | { |
| 1409 | WARN("line over 80 characters\n" . $herecurr); | 1419 | WARN("line over 80 characters\n" . $herecurr); |
| @@ -1448,6 +1458,13 @@ sub process { | |||
| 1448 | WARN("please, no space before tabs\n" . $herevet); | 1458 | WARN("please, no space before tabs\n" . $herevet); |
| 1449 | } | 1459 | } |
| 1450 | 1460 | ||
| 1461 | # check for spaces at the beginning of a line. | ||
| 1462 | if ($rawline =~ /^\+ / && $rawline !~ /\+ +\*/) { | ||
| 1463 | my $herevet = "$here\n" . cat_vet($rawline) . "\n"; | ||
| 1464 | WARN("please, no space for starting a line, \ | ||
| 1465 | excluding comments\n" . $herevet); | ||
| 1466 | } | ||
| 1467 | |||
| 1451 | # check we are in a valid C source file if not then ignore this hunk | 1468 | # check we are in a valid C source file if not then ignore this hunk |
| 1452 | next if ($realfile !~ /\.(h|c)$/); | 1469 | next if ($realfile !~ /\.(h|c)$/); |
| 1453 | 1470 | ||
| @@ -1778,9 +1795,9 @@ sub process { | |||
| 1778 | WARN("EXPORT_SYMBOL(foo); should immediately follow its function/variable\n" . $herecurr); | 1795 | WARN("EXPORT_SYMBOL(foo); should immediately follow its function/variable\n" . $herecurr); |
| 1779 | } | 1796 | } |
| 1780 | 1797 | ||
| 1781 | # check for external initialisers. | 1798 | # check for global initialisers. |
| 1782 | if ($line =~ /^.$Type\s*$Ident\s*(?:\s+$Modifier)*\s*=\s*(0|NULL|false)\s*;/) { | 1799 | if ($line =~ /^.$Type\s*$Ident\s*(?:\s+$Modifier)*\s*=\s*(0|NULL|false)\s*;/) { |
| 1783 | ERROR("do not initialise externals to 0 or NULL\n" . | 1800 | ERROR("do not initialise globals to 0 or NULL\n" . |
| 1784 | $herecurr); | 1801 | $herecurr); |
| 1785 | } | 1802 | } |
| 1786 | # check for static initialisers. | 1803 | # check for static initialisers. |
| @@ -2308,7 +2325,7 @@ sub process { | |||
| 2308 | my $checkfile = "include/linux/$file"; | 2325 | my $checkfile = "include/linux/$file"; |
| 2309 | if (-f "$root/$checkfile" && | 2326 | if (-f "$root/$checkfile" && |
| 2310 | $realfile ne $checkfile && | 2327 | $realfile ne $checkfile && |
| 2311 | $1 ne 'irq') | 2328 | $1 !~ /$allowed_asm_includes/) |
| 2312 | { | 2329 | { |
| 2313 | if ($realfile =~ m{^arch/}) { | 2330 | if ($realfile =~ m{^arch/}) { |
| 2314 | CHK("Consider using #include <linux/$file> instead of <asm/$file>\n" . $herecurr); | 2331 | CHK("Consider using #include <linux/$file> instead of <asm/$file>\n" . $herecurr); |
| @@ -2570,6 +2587,21 @@ sub process { | |||
| 2570 | } | 2587 | } |
| 2571 | } | 2588 | } |
| 2572 | 2589 | ||
| 2590 | # prefer usleep_range over udelay | ||
| 2591 | if ($line =~ /\budelay\s*\(\s*(\w+)\s*\)/) { | ||
| 2592 | # ignore udelay's < 10, however | ||
| 2593 | if (! (($1 =~ /(\d+)/) && ($1 < 10)) ) { | ||
| 2594 | CHK("usleep_range is preferred over udelay; see Documentation/timers/timers-howto.txt\n" . $line); | ||
| 2595 | } | ||
| 2596 | } | ||
| 2597 | |||
| 2598 | # warn about unexpectedly long msleep's | ||
| 2599 | if ($line =~ /\bmsleep\s*\((\d+)\);/) { | ||
| 2600 | if ($1 < 20) { | ||
| 2601 | WARN("msleep < 20ms can sleep for up to 20ms; see Documentation/timers/timers-howto.txt\n" . $line); | ||
| 2602 | } | ||
| 2603 | } | ||
| 2604 | |||
| 2573 | # warn about #ifdefs in C files | 2605 | # warn about #ifdefs in C files |
| 2574 | # if ($line =~ /^.\s*\#\s*if(|n)def/ && ($realfile =~ /\.c$/)) { | 2606 | # if ($line =~ /^.\s*\#\s*if(|n)def/ && ($realfile =~ /\.c$/)) { |
| 2575 | # print "#ifdef in C files should be avoided\n"; | 2607 | # print "#ifdef in C files should be avoided\n"; |
diff --git a/scripts/checksyscalls.sh b/scripts/checksyscalls.sh index 66ad375612f2..6bb42e72e0e5 100755 --- a/scripts/checksyscalls.sh +++ b/scripts/checksyscalls.sh | |||
| @@ -183,7 +183,6 @@ cat << EOF | |||
| 183 | #define __IGNORE_ustat /* statfs */ | 183 | #define __IGNORE_ustat /* statfs */ |
| 184 | #define __IGNORE_utime /* utimes */ | 184 | #define __IGNORE_utime /* utimes */ |
| 185 | #define __IGNORE_vfork /* clone */ | 185 | #define __IGNORE_vfork /* clone */ |
| 186 | #define __IGNORE_wait4 /* waitid */ | ||
| 187 | 186 | ||
| 188 | /* sync_file_range had a stupid ABI. Allow sync_file_range2 instead */ | 187 | /* sync_file_range had a stupid ABI. Allow sync_file_range2 instead */ |
| 189 | #ifdef __NR_sync_file_range2 | 188 | #ifdef __NR_sync_file_range2 |
diff --git a/scripts/coccicheck b/scripts/coccicheck new file mode 100755 index 000000000000..b8bcf1f7bed7 --- /dev/null +++ b/scripts/coccicheck | |||
| @@ -0,0 +1,80 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | SPATCH="`which ${SPATCH:=spatch}`" | ||
| 4 | |||
| 5 | if [ "$C" = "1" -o "$C" = "2" ]; then | ||
| 6 | ONLINE=1 | ||
| 7 | |||
| 8 | # This requires Coccinelle >= 0.2.3 | ||
| 9 | # FLAGS="-ignore_unknown_options -very_quiet" | ||
| 10 | # OPTIONS=$* | ||
| 11 | |||
| 12 | # Workaround for Coccinelle < 0.2.3 | ||
| 13 | FLAGS="-I $srctree/include -very_quiet" | ||
| 14 | shift $(( $# - 1 )) | ||
| 15 | OPTIONS=$1 | ||
| 16 | else | ||
| 17 | ONLINE=0 | ||
| 18 | FLAGS="-very_quiet" | ||
| 19 | fi | ||
| 20 | |||
| 21 | if [ ! -x "$SPATCH" ]; then | ||
| 22 | echo 'spatch is part of the Coccinelle project and is available at http://coccinelle.lip6.fr/' | ||
| 23 | exit 1 | ||
| 24 | fi | ||
| 25 | |||
| 26 | if [ "$MODE" = "" ] ; then | ||
| 27 | if [ "$ONLINE" = "0" ] ; then | ||
| 28 | echo 'You have not explicitly specify the mode to use. Fallback to "report".' | ||
| 29 | echo 'You can specify the mode with "make coccicheck MODE=<mode>"' | ||
| 30 | echo 'Available modes are: report, patch, context, org' | ||
| 31 | fi | ||
| 32 | MODE="report" | ||
| 33 | fi | ||
| 34 | |||
| 35 | if [ "$ONLINE" = "0" ] ; then | ||
| 36 | echo '' | ||
| 37 | echo 'Please check for false positives in the output before submitting a patch.' | ||
| 38 | echo 'When using "patch" mode, carefully review the patch before submitting it.' | ||
| 39 | echo '' | ||
| 40 | fi | ||
| 41 | |||
| 42 | coccinelle () { | ||
| 43 | COCCI="$1" | ||
| 44 | |||
| 45 | OPT=`grep "Option" $COCCI | cut -d':' -f2` | ||
| 46 | |||
| 47 | # The option '-parse_cocci' can be used to syntaxically check the SmPL files. | ||
| 48 | # | ||
| 49 | # $SPATCH -D $MODE $FLAGS -parse_cocci $COCCI $OPT > /dev/null | ||
| 50 | |||
| 51 | if [ "$ONLINE" = "0" ] ; then | ||
| 52 | |||
| 53 | FILE=`echo $COCCI | sed "s|$srctree/||"` | ||
| 54 | |||
| 55 | echo "Processing `basename $COCCI` with option(s) \"$OPT\"" | ||
| 56 | echo 'Message example to submit a patch:' | ||
| 57 | |||
| 58 | sed -e '/\/\/\//!d' -e 's|^///||' $COCCI | ||
| 59 | |||
| 60 | echo ' The semantic patch that makes this change is available' | ||
| 61 | echo " in $FILE." | ||
| 62 | echo '' | ||
| 63 | echo ' More information about semantic patching is available at' | ||
| 64 | echo ' http://coccinelle.lip6.fr/' | ||
| 65 | echo '' | ||
| 66 | |||
| 67 | $SPATCH -D $MODE $FLAGS -sp_file $COCCI $OPT -dir $srctree || exit 1 | ||
| 68 | else | ||
| 69 | $SPATCH -D $MODE $FLAGS -sp_file $COCCI $OPT $OPTIONS || exit 1 | ||
| 70 | fi | ||
| 71 | |||
| 72 | } | ||
| 73 | |||
| 74 | if [ "$COCCI" = "" ] ; then | ||
| 75 | for f in `find $srctree/scripts/coccinelle/ -name '*.cocci' -type f | sort`; do | ||
| 76 | coccinelle $f | ||
| 77 | done | ||
| 78 | else | ||
| 79 | coccinelle $COCCI | ||
| 80 | fi | ||
diff --git a/scripts/coccinelle/alloc/drop_kmalloc_cast.cocci b/scripts/coccinelle/alloc/drop_kmalloc_cast.cocci new file mode 100644 index 000000000000..7d4771d449c3 --- /dev/null +++ b/scripts/coccinelle/alloc/drop_kmalloc_cast.cocci | |||
| @@ -0,0 +1,67 @@ | |||
| 1 | /// | ||
| 2 | /// Casting (void *) value returned by kmalloc is useless | ||
| 3 | /// as mentioned in Documentation/CodingStyle, Chap 14. | ||
| 4 | /// | ||
| 5 | // Confidence: High | ||
| 6 | // Copyright: 2009,2010 Nicolas Palix, DIKU. GPLv2. | ||
| 7 | // URL: http://coccinelle.lip6.fr/ | ||
| 8 | // Options: -no_includes -include_headers | ||
| 9 | // | ||
| 10 | // Keywords: kmalloc, kzalloc, kcalloc | ||
| 11 | // Version min: < 2.6.12 kmalloc | ||
| 12 | // Version min: < 2.6.12 kcalloc | ||
| 13 | // Version min: 2.6.14 kzalloc | ||
| 14 | // | ||
| 15 | |||
| 16 | virtual context | ||
| 17 | virtual patch | ||
| 18 | virtual org | ||
| 19 | virtual report | ||
| 20 | |||
| 21 | //---------------------------------------------------------- | ||
| 22 | // For context mode | ||
| 23 | //---------------------------------------------------------- | ||
| 24 | |||
| 25 | @depends on context@ | ||
| 26 | type T; | ||
| 27 | @@ | ||
| 28 | |||
| 29 | * (T *) | ||
| 30 | \(kmalloc\|kzalloc\|kcalloc\)(...) | ||
| 31 | |||
| 32 | //---------------------------------------------------------- | ||
| 33 | // For patch mode | ||
| 34 | //---------------------------------------------------------- | ||
| 35 | |||
| 36 | @depends on patch@ | ||
| 37 | type T; | ||
| 38 | @@ | ||
| 39 | |||
| 40 | - (T *) | ||
| 41 | \(kmalloc\|kzalloc\|kcalloc\)(...) | ||
| 42 | |||
| 43 | //---------------------------------------------------------- | ||
| 44 | // For org and report mode | ||
| 45 | //---------------------------------------------------------- | ||
| 46 | |||
| 47 | @r depends on org || report@ | ||
| 48 | type T; | ||
| 49 | position p; | ||
| 50 | @@ | ||
| 51 | |||
| 52 | (T@p *)\(kmalloc\|kzalloc\|kcalloc\)(...) | ||
| 53 | |||
| 54 | @script:python depends on org@ | ||
| 55 | p << r.p; | ||
| 56 | t << r.T; | ||
| 57 | @@ | ||
| 58 | |||
| 59 | coccilib.org.print_safe_todo(p[0], t) | ||
| 60 | |||
| 61 | @script:python depends on report@ | ||
| 62 | p << r.p; | ||
| 63 | t << r.T; | ||
| 64 | @@ | ||
| 65 | |||
| 66 | msg="WARNING: casting value returned by k[cmz]alloc to (%s *) is useless." % (t) | ||
| 67 | coccilib.report.print_report(p[0], msg) | ||
diff --git a/scripts/coccinelle/alloc/kzalloc-simple.cocci b/scripts/coccinelle/alloc/kzalloc-simple.cocci new file mode 100644 index 000000000000..2eae828fc657 --- /dev/null +++ b/scripts/coccinelle/alloc/kzalloc-simple.cocci | |||
| @@ -0,0 +1,82 @@ | |||
| 1 | /// | ||
| 2 | /// kzalloc should be used rather than kmalloc followed by memset 0 | ||
| 3 | /// | ||
| 4 | // Confidence: High | ||
| 5 | // Copyright: (C) 2009-2010 Julia Lawall, Nicolas Palix, DIKU. GPLv2. | ||
| 6 | // Copyright: (C) 2009-2010 Gilles Muller, INRIA/LiP6. GPLv2. | ||
| 7 | // URL: http://coccinelle.lip6.fr/rules/kzalloc.html | ||
| 8 | // Options: -no_includes -include_headers | ||
| 9 | // | ||
| 10 | // Keywords: kmalloc, kzalloc | ||
| 11 | // Version min: < 2.6.12 kmalloc | ||
| 12 | // Version min: 2.6.14 kzalloc | ||
| 13 | // | ||
| 14 | |||
| 15 | virtual context | ||
| 16 | virtual patch | ||
| 17 | virtual org | ||
| 18 | virtual report | ||
| 19 | |||
| 20 | //---------------------------------------------------------- | ||
| 21 | // For context mode | ||
| 22 | //---------------------------------------------------------- | ||
| 23 | |||
| 24 | @depends on context@ | ||
| 25 | type T, T2; | ||
| 26 | expression x; | ||
| 27 | expression E1,E2; | ||
| 28 | statement S; | ||
| 29 | @@ | ||
| 30 | |||
| 31 | * x = (T)kmalloc(E1,E2); | ||
| 32 | if ((x==NULL) || ...) S | ||
| 33 | * memset((T2)x,0,E1); | ||
| 34 | |||
| 35 | //---------------------------------------------------------- | ||
| 36 | // For patch mode | ||
| 37 | //---------------------------------------------------------- | ||
| 38 | |||
| 39 | @depends on patch@ | ||
| 40 | type T, T2; | ||
| 41 | expression x; | ||
| 42 | expression E1,E2; | ||
| 43 | statement S; | ||
| 44 | @@ | ||
| 45 | |||
| 46 | - x = (T)kmalloc(E1,E2); | ||
| 47 | + x = kzalloc(E1,E2); | ||
| 48 | if ((x==NULL) || ...) S | ||
| 49 | - memset((T2)x,0,E1); | ||
| 50 | |||
| 51 | //---------------------------------------------------------- | ||
| 52 | // For org mode | ||
| 53 | //---------------------------------------------------------- | ||
| 54 | |||
| 55 | @r depends on org || report@ | ||
| 56 | type T, T2; | ||
| 57 | expression x; | ||
| 58 | expression E1,E2; | ||
| 59 | statement S; | ||
| 60 | position p; | ||
| 61 | @@ | ||
| 62 | |||
| 63 | x = (T)kmalloc@p(E1,E2); | ||
| 64 | if ((x==NULL) || ...) S | ||
| 65 | memset((T2)x,0,E1); | ||
| 66 | |||
| 67 | @script:python depends on org@ | ||
| 68 | p << r.p; | ||
| 69 | x << r.x; | ||
| 70 | @@ | ||
| 71 | |||
| 72 | msg="%s" % (x) | ||
| 73 | msg_safe=msg.replace("[","@(").replace("]",")") | ||
| 74 | coccilib.org.print_todo(p[0], msg_safe) | ||
| 75 | |||
| 76 | @script:python depends on report@ | ||
| 77 | p << r.p; | ||
| 78 | x << r.x; | ||
| 79 | @@ | ||
| 80 | |||
| 81 | msg="WARNING: kzalloc should be used for %s, instead of kmalloc/memset" % (x) | ||
| 82 | coccilib.report.print_report(p[0], msg) | ||
diff --git a/scripts/coccinelle/deref_null.cocci b/scripts/coccinelle/deref_null.cocci new file mode 100644 index 000000000000..9969d76d0f4b --- /dev/null +++ b/scripts/coccinelle/deref_null.cocci | |||
| @@ -0,0 +1,293 @@ | |||
| 1 | /// | ||
| 2 | /// A variable is dereference under a NULL test. | ||
| 3 | /// Even though it is know to be NULL. | ||
| 4 | /// | ||
| 5 | // Confidence: Moderate | ||
| 6 | // Copyright: (C) 2010 Nicolas Palix, DIKU. GPLv2. | ||
| 7 | // Copyright: (C) 2010 Julia Lawall, DIKU. GPLv2. | ||
| 8 | // Copyright: (C) 2010 Gilles Muller, INRIA/LiP6. GPLv2. | ||
| 9 | // URL: http://coccinelle.lip6.fr/ | ||
| 10 | // Comments: -I ... -all_includes can give more complete results | ||
| 11 | // Options: | ||
| 12 | |||
| 13 | virtual context | ||
| 14 | virtual patch | ||
| 15 | virtual org | ||
| 16 | virtual report | ||
| 17 | |||
| 18 | @initialize:python depends on !context && patch && !org && !report@ | ||
| 19 | |||
| 20 | import sys | ||
| 21 | print >> sys.stderr, "This semantic patch does not support the 'patch' mode." | ||
| 22 | |||
| 23 | @depends on patch@ | ||
| 24 | @@ | ||
| 25 | |||
| 26 | this_rule_should_never_matches(); | ||
| 27 | |||
| 28 | @ifm depends on !patch@ | ||
| 29 | expression *E; | ||
| 30 | statement S1,S2; | ||
| 31 | position p1; | ||
| 32 | @@ | ||
| 33 | |||
| 34 | if@p1 ((E == NULL && ...) || ...) S1 else S2 | ||
| 35 | |||
| 36 | // The following two rules are separate, because both can match a single | ||
| 37 | // expression in different ways | ||
| 38 | @pr1 depends on !patch expression@ | ||
| 39 | expression *ifm.E; | ||
| 40 | identifier f; | ||
| 41 | position p1; | ||
| 42 | @@ | ||
| 43 | |||
| 44 | (E != NULL && ...) ? <+...E->f@p1...+> : ... | ||
| 45 | |||
| 46 | @pr2 depends on !patch expression@ | ||
| 47 | expression *ifm.E; | ||
| 48 | identifier f; | ||
| 49 | position p2; | ||
| 50 | @@ | ||
| 51 | |||
| 52 | ( | ||
| 53 | (E != NULL) && ... && <+...E->f@p2...+> | ||
| 54 | | | ||
| 55 | (E == NULL) || ... || <+...E->f@p2...+> | ||
| 56 | | | ||
| 57 | sizeof(<+...E->f@p2...+>) | ||
| 58 | ) | ||
| 59 | |||
| 60 | // For org and report modes | ||
| 61 | |||
| 62 | @r depends on !context && !patch && (org || report) exists@ | ||
| 63 | expression subE <= ifm.E; | ||
| 64 | expression *ifm.E; | ||
| 65 | expression E1,E2; | ||
| 66 | identifier f; | ||
| 67 | statement S1,S2,S3,S4; | ||
| 68 | iterator iter; | ||
| 69 | position p!={pr1.p1,pr2.p2}; | ||
| 70 | position ifm.p1; | ||
| 71 | @@ | ||
| 72 | |||
| 73 | if@p1 ((E == NULL && ...) || ...) | ||
| 74 | { | ||
| 75 | ... when != if (...) S1 else S2 | ||
| 76 | ( | ||
| 77 | iter(subE,...) S4 // no use | ||
| 78 | | | ||
| 79 | list_remove_head(E2,subE,...) | ||
| 80 | | | ||
| 81 | subE = E1 | ||
| 82 | | | ||
| 83 | for(subE = E1;...;...) S4 | ||
| 84 | | | ||
| 85 | subE++ | ||
| 86 | | | ||
| 87 | ++subE | ||
| 88 | | | ||
| 89 | --subE | ||
| 90 | | | ||
| 91 | subE-- | ||
| 92 | | | ||
| 93 | &subE | ||
| 94 | | | ||
| 95 | E->f@p // bad use | ||
| 96 | ) | ||
| 97 | ... when any | ||
| 98 | return ...; | ||
| 99 | } | ||
| 100 | else S3 | ||
| 101 | |||
| 102 | @script:python depends on !context && !patch && !org && report@ | ||
| 103 | p << r.p; | ||
| 104 | p1 << ifm.p1; | ||
| 105 | x << ifm.E; | ||
| 106 | @@ | ||
| 107 | |||
| 108 | msg="ERROR: %s is NULL but dereferenced." % (x) | ||
| 109 | coccilib.report.print_report(p[0], msg) | ||
| 110 | cocci.include_match(False) | ||
| 111 | |||
| 112 | @script:python depends on !context && !patch && org && !report@ | ||
| 113 | p << r.p; | ||
| 114 | p1 << ifm.p1; | ||
| 115 | x << ifm.E; | ||
| 116 | @@ | ||
| 117 | |||
| 118 | msg="ERROR: %s is NULL but dereferenced." % (x) | ||
| 119 | msg_safe=msg.replace("[","@(").replace("]",")") | ||
| 120 | cocci.print_main(msg_safe,p) | ||
| 121 | cocci.include_match(False) | ||
| 122 | |||
| 123 | @s depends on !context && !patch && (org || report) exists@ | ||
| 124 | expression subE <= ifm.E; | ||
| 125 | expression *ifm.E; | ||
| 126 | expression E1,E2; | ||
| 127 | identifier f; | ||
| 128 | statement S1,S2,S3,S4; | ||
| 129 | iterator iter; | ||
| 130 | position p!={pr1.p1,pr2.p2}; | ||
| 131 | position ifm.p1; | ||
| 132 | @@ | ||
| 133 | |||
| 134 | if@p1 ((E == NULL && ...) || ...) | ||
| 135 | { | ||
| 136 | ... when != if (...) S1 else S2 | ||
| 137 | ( | ||
| 138 | iter(subE,...) S4 // no use | ||
| 139 | | | ||
| 140 | list_remove_head(E2,subE,...) | ||
| 141 | | | ||
| 142 | subE = E1 | ||
| 143 | | | ||
| 144 | for(subE = E1;...;...) S4 | ||
| 145 | | | ||
| 146 | subE++ | ||
| 147 | | | ||
| 148 | ++subE | ||
| 149 | | | ||
| 150 | --subE | ||
| 151 | | | ||
| 152 | subE-- | ||
| 153 | | | ||
| 154 | &subE | ||
| 155 | | | ||
| 156 | E->f@p // bad use | ||
| 157 | ) | ||
| 158 | ... when any | ||
| 159 | } | ||
| 160 | else S3 | ||
| 161 | |||
| 162 | @script:python depends on !context && !patch && !org && report@ | ||
| 163 | p << s.p; | ||
| 164 | p1 << ifm.p1; | ||
| 165 | x << ifm.E; | ||
| 166 | @@ | ||
| 167 | |||
| 168 | msg="ERROR: %s is NULL but dereferenced." % (x) | ||
| 169 | coccilib.report.print_report(p[0], msg) | ||
| 170 | |||
| 171 | @script:python depends on !context && !patch && org && !report@ | ||
| 172 | p << s.p; | ||
| 173 | p1 << ifm.p1; | ||
| 174 | x << ifm.E; | ||
| 175 | @@ | ||
| 176 | |||
| 177 | msg="ERROR: %s is NULL but dereferenced." % (x) | ||
| 178 | msg_safe=msg.replace("[","@(").replace("]",")") | ||
| 179 | cocci.print_main(msg_safe,p) | ||
| 180 | |||
| 181 | // For context mode | ||
| 182 | |||
| 183 | @depends on context && !patch && !org && !report exists@ | ||
| 184 | expression subE <= ifm.E; | ||
| 185 | expression *ifm.E; | ||
| 186 | expression E1,E2; | ||
| 187 | identifier f; | ||
| 188 | statement S1,S2,S3,S4; | ||
| 189 | iterator iter; | ||
| 190 | position p!={pr1.p1,pr2.p2}; | ||
| 191 | position ifm.p1; | ||
| 192 | @@ | ||
| 193 | |||
| 194 | if@p1 ((E == NULL && ...) || ...) | ||
| 195 | { | ||
| 196 | ... when != if (...) S1 else S2 | ||
| 197 | ( | ||
| 198 | iter(subE,...) S4 // no use | ||
| 199 | | | ||
| 200 | list_remove_head(E2,subE,...) | ||
| 201 | | | ||
| 202 | subE = E1 | ||
| 203 | | | ||
| 204 | for(subE = E1;...;...) S4 | ||
| 205 | | | ||
| 206 | subE++ | ||
| 207 | | | ||
| 208 | ++subE | ||
| 209 | | | ||
| 210 | --subE | ||
| 211 | | | ||
| 212 | subE-- | ||
| 213 | | | ||
| 214 | &subE | ||
| 215 | | | ||
| 216 | * E->f@p // bad use | ||
| 217 | ) | ||
| 218 | ... when any | ||
| 219 | return ...; | ||
| 220 | } | ||
| 221 | else S3 | ||
| 222 | |||
| 223 | // The following three rules are duplicates of ifm, pr1 and pr2 respectively. | ||
| 224 | // It is need because the previous rule as already made a "change". | ||
| 225 | |||
| 226 | @ifm1 depends on !patch@ | ||
| 227 | expression *E; | ||
| 228 | statement S1,S2; | ||
| 229 | position p1; | ||
| 230 | @@ | ||
| 231 | |||
| 232 | if@p1 ((E == NULL && ...) || ...) S1 else S2 | ||
| 233 | |||
| 234 | @pr11 depends on !patch expression@ | ||
| 235 | expression *ifm1.E; | ||
| 236 | identifier f; | ||
| 237 | position p1; | ||
| 238 | @@ | ||
| 239 | |||
| 240 | (E != NULL && ...) ? <+...E->f@p1...+> : ... | ||
| 241 | |||
| 242 | @pr12 depends on !patch expression@ | ||
| 243 | expression *ifm1.E; | ||
| 244 | identifier f; | ||
| 245 | position p2; | ||
| 246 | @@ | ||
| 247 | |||
| 248 | ( | ||
| 249 | (E != NULL) && ... && <+...E->f@p2...+> | ||
| 250 | | | ||
| 251 | (E == NULL) || ... || <+...E->f@p2...+> | ||
| 252 | | | ||
| 253 | sizeof(<+...E->f@p2...+>) | ||
| 254 | ) | ||
| 255 | |||
| 256 | @depends on context && !patch && !org && !report exists@ | ||
| 257 | expression subE <= ifm1.E; | ||
| 258 | expression *ifm1.E; | ||
| 259 | expression E1,E2; | ||
| 260 | identifier f; | ||
| 261 | statement S1,S2,S3,S4; | ||
| 262 | iterator iter; | ||
| 263 | position p!={pr11.p1,pr12.p2}; | ||
| 264 | position ifm1.p1; | ||
| 265 | @@ | ||
| 266 | |||
| 267 | if@p1 ((E == NULL && ...) || ...) | ||
| 268 | { | ||
| 269 | ... when != if (...) S1 else S2 | ||
| 270 | ( | ||
| 271 | iter(subE,...) S4 // no use | ||
| 272 | | | ||
| 273 | list_remove_head(E2,subE,...) | ||
| 274 | | | ||
| 275 | subE = E1 | ||
| 276 | | | ||
| 277 | for(subE = E1;...;...) S4 | ||
| 278 | | | ||
| 279 | subE++ | ||
| 280 | | | ||
| 281 | ++subE | ||
| 282 | | | ||
| 283 | --subE | ||
| 284 | | | ||
| 285 | subE-- | ||
| 286 | | | ||
| 287 | &subE | ||
| 288 | | | ||
| 289 | * E->f@p // bad use | ||
| 290 | ) | ||
| 291 | ... when any | ||
| 292 | } | ||
| 293 | else S3 | ||
diff --git a/scripts/coccinelle/err_cast.cocci b/scripts/coccinelle/err_cast.cocci new file mode 100644 index 000000000000..2ce115000af6 --- /dev/null +++ b/scripts/coccinelle/err_cast.cocci | |||
| @@ -0,0 +1,56 @@ | |||
| 1 | /// | ||
| 2 | /// Use ERR_CAST inlined function instead of ERR_PTR(PTR_ERR(...)) | ||
| 3 | /// | ||
| 4 | // Confidence: High | ||
| 5 | // Copyright: (C) 2009, 2010 Nicolas Palix, DIKU. GPLv2. | ||
| 6 | // Copyright: (C) 2009, 2010 Julia Lawall, DIKU. GPLv2. | ||
| 7 | // Copyright: (C) 2009, 2010 Gilles Muller, INRIA/LiP6. GPLv2. | ||
| 8 | // URL: http://coccinelle.lip6.fr/ | ||
| 9 | // Options: | ||
| 10 | // | ||
| 11 | // Keywords: ERR_PTR, PTR_ERR, ERR_CAST | ||
| 12 | // Version min: 2.6.25 | ||
| 13 | // | ||
| 14 | |||
| 15 | virtual context | ||
| 16 | virtual patch | ||
| 17 | virtual org | ||
| 18 | virtual report | ||
| 19 | |||
| 20 | |||
| 21 | @ depends on context && !patch && !org && !report@ | ||
| 22 | expression x; | ||
| 23 | @@ | ||
| 24 | |||
| 25 | * ERR_PTR(PTR_ERR(x)) | ||
| 26 | |||
| 27 | @ depends on !context && patch && !org && !report @ | ||
| 28 | expression x; | ||
| 29 | @@ | ||
| 30 | |||
| 31 | - ERR_PTR(PTR_ERR(x)) | ||
| 32 | + ERR_CAST(x) | ||
| 33 | |||
| 34 | @r depends on !context && !patch && (org || report)@ | ||
| 35 | expression x; | ||
| 36 | position p; | ||
| 37 | @@ | ||
| 38 | |||
| 39 | ERR_PTR@p(PTR_ERR(x)) | ||
| 40 | |||
| 41 | @script:python depends on org@ | ||
| 42 | p << r.p; | ||
| 43 | x << r.x; | ||
| 44 | @@ | ||
| 45 | |||
| 46 | msg="WARNING ERR_CAST can be used with %s" % (x) | ||
| 47 | msg_safe=msg.replace("[","@(").replace("]",")") | ||
| 48 | coccilib.org.print_todo(p[0], msg_safe) | ||
| 49 | |||
| 50 | @script:python depends on report@ | ||
| 51 | p << r.p; | ||
| 52 | x << r.x; | ||
| 53 | @@ | ||
| 54 | |||
| 55 | msg="WARNING: ERR_CAST can be used with %s" % (x) | ||
| 56 | coccilib.report.print_report(p[0], msg) | ||
diff --git a/scripts/coccinelle/resource_size.cocci b/scripts/coccinelle/resource_size.cocci new file mode 100644 index 000000000000..1935a58b39d9 --- /dev/null +++ b/scripts/coccinelle/resource_size.cocci | |||
| @@ -0,0 +1,93 @@ | |||
| 1 | /// | ||
| 2 | /// Use resource_size function on resource object | ||
| 3 | /// instead of explicit computation. | ||
| 4 | /// | ||
| 5 | // Confidence: High | ||
| 6 | // Copyright: (C) 2009, 2010 Nicolas Palix, DIKU. GPLv2. | ||
| 7 | // Copyright: (C) 2009, 2010 Julia Lawall, DIKU. GPLv2. | ||
| 8 | // Copyright: (C) 2009, 2010 Gilles Muller, INRIA/LiP6. GPLv2. | ||
| 9 | // URL: http://coccinelle.lip6.fr/ | ||
| 10 | // Options: | ||
| 11 | // | ||
| 12 | // Keywords: resource_size | ||
| 13 | // Version min: 2.6.27 resource_size | ||
| 14 | // | ||
| 15 | |||
| 16 | virtual context | ||
| 17 | virtual patch | ||
| 18 | virtual org | ||
| 19 | virtual report | ||
| 20 | |||
| 21 | //---------------------------------------------------------- | ||
| 22 | // For context mode | ||
| 23 | //---------------------------------------------------------- | ||
| 24 | |||
| 25 | @r_context depends on context && !patch && !org@ | ||
| 26 | struct resource *res; | ||
| 27 | @@ | ||
| 28 | |||
| 29 | * (res->end - res->start) + 1 | ||
| 30 | |||
| 31 | //---------------------------------------------------------- | ||
| 32 | // For patch mode | ||
| 33 | //---------------------------------------------------------- | ||
| 34 | |||
| 35 | @r_patch depends on !context && patch && !org@ | ||
| 36 | struct resource *res; | ||
| 37 | @@ | ||
| 38 | |||
| 39 | - (res->end - res->start) + 1 | ||
| 40 | + resource_size(res) | ||
| 41 | |||
| 42 | //---------------------------------------------------------- | ||
| 43 | // For org mode | ||
| 44 | //---------------------------------------------------------- | ||
| 45 | |||
| 46 | |||
| 47 | @r_org depends on !context && !patch && (org || report)@ | ||
| 48 | struct resource *res; | ||
| 49 | position p; | ||
| 50 | @@ | ||
| 51 | |||
| 52 | (res->end@p - res->start) + 1 | ||
| 53 | |||
| 54 | @rbad_org depends on !context && !patch && (org || report)@ | ||
| 55 | struct resource *res; | ||
| 56 | position p != r_org.p; | ||
| 57 | @@ | ||
| 58 | |||
| 59 | res->end@p - res->start | ||
| 60 | |||
| 61 | @script:python depends on org@ | ||
| 62 | p << r_org.p; | ||
| 63 | x << r_org.res; | ||
| 64 | @@ | ||
| 65 | |||
| 66 | msg="ERROR with %s" % (x) | ||
| 67 | msg_safe=msg.replace("[","@(").replace("]",")") | ||
| 68 | coccilib.org.print_todo(p[0], msg_safe) | ||
| 69 | |||
| 70 | @script:python depends on report@ | ||
| 71 | p << r_org.p; | ||
| 72 | x << r_org.res; | ||
| 73 | @@ | ||
| 74 | |||
| 75 | msg="ERROR: Missing resource_size with %s" % (x) | ||
| 76 | coccilib.report.print_report(p[0], msg) | ||
| 77 | |||
| 78 | @script:python depends on org@ | ||
| 79 | p << rbad_org.p; | ||
| 80 | x << rbad_org.res; | ||
| 81 | @@ | ||
| 82 | |||
| 83 | msg="WARNING with %s" % (x) | ||
| 84 | msg_safe=msg.replace("[","@(").replace("]",")") | ||
| 85 | coccilib.org.print_todo(p[0], msg_safe) | ||
| 86 | |||
| 87 | @script:python depends on report@ | ||
| 88 | p << rbad_org.p; | ||
| 89 | x << rbad_org.res; | ||
| 90 | @@ | ||
| 91 | |||
| 92 | msg="WARNING: Suspicious code. resource_size is maybe missing with %s" % (x) | ||
| 93 | coccilib.report.print_report(p[0], msg) | ||
diff --git a/scripts/decodecode b/scripts/decodecode index 8b30cc36744f..18ba881c3415 100755 --- a/scripts/decodecode +++ b/scripts/decodecode | |||
| @@ -40,7 +40,7 @@ echo $code | |||
| 40 | code=`echo $code | sed -e 's/.*Code: //'` | 40 | code=`echo $code | sed -e 's/.*Code: //'` |
| 41 | 41 | ||
| 42 | width=`expr index "$code" ' '` | 42 | width=`expr index "$code" ' '` |
| 43 | width=$[($width-1)/2] | 43 | width=$((($width-1)/2)) |
| 44 | case $width in | 44 | case $width in |
| 45 | 1) type=byte ;; | 45 | 1) type=byte ;; |
| 46 | 2) type=2byte ;; | 46 | 2) type=2byte ;; |
| @@ -48,10 +48,10 @@ case $width in | |||
| 48 | esac | 48 | esac |
| 49 | 49 | ||
| 50 | disas() { | 50 | disas() { |
| 51 | ${CROSS_COMPILE}as $AFLAGS -o $1.o $1.s &> /dev/null | 51 | ${CROSS_COMPILE}as $AFLAGS -o $1.o $1.s > /dev/null 2>&1 |
| 52 | 52 | ||
| 53 | if [ "$ARCH" == "arm" ]; then | 53 | if [ "$ARCH" = "arm" ]; then |
| 54 | if [ $width == 2 ]; then | 54 | if [ $width -eq 2 ]; then |
| 55 | OBJDUMPFLAGS="-M force-thumb" | 55 | OBJDUMPFLAGS="-M force-thumb" |
| 56 | fi | 56 | fi |
| 57 | 57 | ||
| @@ -59,7 +59,7 @@ disas() { | |||
| 59 | fi | 59 | fi |
| 60 | 60 | ||
| 61 | ${CROSS_COMPILE}objdump $OBJDUMPFLAGS -S $1.o | \ | 61 | ${CROSS_COMPILE}objdump $OBJDUMPFLAGS -S $1.o | \ |
| 62 | grep -v "/tmp\|Disassembly\|\.text\|^$" &> $1.dis | 62 | grep -v "/tmp\|Disassembly\|\.text\|^$" > $1.dis 2>&1 |
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | marker=`expr index "$code" "\<"` | 65 | marker=`expr index "$code" "\<"` |
diff --git a/scripts/dtc/fstree.c b/scripts/dtc/fstree.c index 766b2694d935..8fe1bdf239f0 100644 --- a/scripts/dtc/fstree.c +++ b/scripts/dtc/fstree.c | |||
| @@ -77,6 +77,7 @@ static struct node *read_fstree(const char *dirname) | |||
| 77 | free(tmpnam); | 77 | free(tmpnam); |
| 78 | } | 78 | } |
| 79 | 79 | ||
| 80 | closedir(d); | ||
| 80 | return tree; | 81 | return tree; |
| 81 | } | 82 | } |
| 82 | 83 | ||
diff --git a/scripts/kconfig/.gitignore b/scripts/kconfig/.gitignore index 6a36a76e6606..624f6502e03e 100644 --- a/scripts/kconfig/.gitignore +++ b/scripts/kconfig/.gitignore | |||
| @@ -17,6 +17,7 @@ gconf.glade.h | |||
| 17 | # | 17 | # |
| 18 | conf | 18 | conf |
| 19 | mconf | 19 | mconf |
| 20 | nconf | ||
| 20 | qconf | 21 | qconf |
| 21 | gconf | 22 | gconf |
| 22 | kxgettext | 23 | kxgettext |
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index 7ea649da1940..de934def410f 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile | |||
| @@ -21,17 +21,17 @@ menuconfig: $(obj)/mconf | |||
| 21 | $< $(Kconfig) | 21 | $< $(Kconfig) |
| 22 | 22 | ||
| 23 | config: $(obj)/conf | 23 | config: $(obj)/conf |
| 24 | $< $(Kconfig) | 24 | $< --oldaskconfig $(Kconfig) |
| 25 | 25 | ||
| 26 | nconfig: $(obj)/nconf | 26 | nconfig: $(obj)/nconf |
| 27 | $< $(Kconfig) | 27 | $< $(Kconfig) |
| 28 | 28 | ||
| 29 | oldconfig: $(obj)/conf | 29 | oldconfig: $(obj)/conf |
| 30 | $< -o $(Kconfig) | 30 | $< --$@ $(Kconfig) |
| 31 | 31 | ||
| 32 | silentoldconfig: $(obj)/conf | 32 | silentoldconfig: $(obj)/conf |
| 33 | $(Q)mkdir -p include/generated | 33 | $(Q)mkdir -p include/generated |
| 34 | $< -s $(Kconfig) | 34 | $< --$@ $(Kconfig) |
| 35 | 35 | ||
| 36 | # if no path is given, then use src directory to find file | 36 | # if no path is given, then use src directory to find file |
| 37 | ifdef LSMOD | 37 | ifdef LSMOD |
| @@ -44,15 +44,15 @@ endif | |||
| 44 | localmodconfig: $(obj)/streamline_config.pl $(obj)/conf | 44 | localmodconfig: $(obj)/streamline_config.pl $(obj)/conf |
| 45 | $(Q)mkdir -p include/generated | 45 | $(Q)mkdir -p include/generated |
| 46 | $(Q)perl $< $(srctree) $(Kconfig) $(LSMOD_F) > .tmp.config | 46 | $(Q)perl $< $(srctree) $(Kconfig) $(LSMOD_F) > .tmp.config |
| 47 | $(Q)if [ -f .config ]; then \ | 47 | $(Q)if [ -f .config ]; then \ |
| 48 | cmp -s .tmp.config .config || \ | 48 | cmp -s .tmp.config .config || \ |
| 49 | (mv -f .config .config.old.1; \ | 49 | (mv -f .config .config.old.1; \ |
| 50 | mv -f .tmp.config .config; \ | 50 | mv -f .tmp.config .config; \ |
| 51 | $(obj)/conf -s $(Kconfig); \ | 51 | $(obj)/conf --silentoldconfig $(Kconfig); \ |
| 52 | mv -f .config.old.1 .config.old) \ | 52 | mv -f .config.old.1 .config.old) \ |
| 53 | else \ | 53 | else \ |
| 54 | mv -f .tmp.config .config; \ | 54 | mv -f .tmp.config .config; \ |
| 55 | $(obj)/conf -s $(Kconfig); \ | 55 | $(obj)/conf --silentoldconfig $(Kconfig); \ |
| 56 | fi | 56 | fi |
| 57 | $(Q)rm -f .tmp.config | 57 | $(Q)rm -f .tmp.config |
| 58 | 58 | ||
| @@ -60,15 +60,15 @@ localyesconfig: $(obj)/streamline_config.pl $(obj)/conf | |||
| 60 | $(Q)mkdir -p include/generated | 60 | $(Q)mkdir -p include/generated |
| 61 | $(Q)perl $< $(srctree) $(Kconfig) $(LSMOD_F) > .tmp.config | 61 | $(Q)perl $< $(srctree) $(Kconfig) $(LSMOD_F) > .tmp.config |
| 62 | $(Q)sed -i s/=m/=y/ .tmp.config | 62 | $(Q)sed -i s/=m/=y/ .tmp.config |
| 63 | $(Q)if [ -f .config ]; then \ | 63 | $(Q)if [ -f .config ]; then \ |
| 64 | cmp -s .tmp.config .config || \ | 64 | cmp -s .tmp.config .config || \ |
| 65 | (mv -f .config .config.old.1; \ | 65 | (mv -f .config .config.old.1; \ |
| 66 | mv -f .tmp.config .config; \ | 66 | mv -f .tmp.config .config; \ |
| 67 | $(obj)/conf -s $(Kconfig); \ | 67 | $(obj)/conf --silentoldconfig $(Kconfig); \ |
| 68 | mv -f .config.old.1 .config.old) \ | 68 | mv -f .config.old.1 .config.old) \ |
| 69 | else \ | 69 | else \ |
| 70 | mv -f .tmp.config .config; \ | 70 | mv -f .tmp.config .config; \ |
| 71 | $(obj)/conf -s $(Kconfig); \ | 71 | $(obj)/conf --silentoldconfig $(Kconfig); \ |
| 72 | fi | 72 | fi |
| 73 | $(Q)rm -f .tmp.config | 73 | $(Q)rm -f .tmp.config |
| 74 | 74 | ||
| @@ -95,30 +95,29 @@ update-po-config: $(obj)/kxgettext $(obj)/gconf.glade.h | |||
| 95 | $(Q)rm -f arch/um/Kconfig.arch | 95 | $(Q)rm -f arch/um/Kconfig.arch |
| 96 | $(Q)rm -f $(obj)/config.pot | 96 | $(Q)rm -f $(obj)/config.pot |
| 97 | 97 | ||
| 98 | PHONY += randconfig allyesconfig allnoconfig allmodconfig defconfig | 98 | PHONY += allnoconfig allyesconfig allmodconfig alldefconfig randconfig |
| 99 | 99 | ||
| 100 | randconfig: $(obj)/conf | 100 | allnoconfig allyesconfig allmodconfig alldefconfig randconfig: $(obj)/conf |
| 101 | $< -r $(Kconfig) | 101 | $< --$@ $(Kconfig) |
| 102 | 102 | ||
| 103 | allyesconfig: $(obj)/conf | 103 | PHONY += listnewconfig oldnoconfig savedefconfig defconfig |
| 104 | $< -y $(Kconfig) | ||
| 105 | 104 | ||
| 106 | allnoconfig: $(obj)/conf | 105 | listnewconfig oldnoconfig: $(obj)/conf |
| 107 | $< -n $(Kconfig) | 106 | $< --$@ $(Kconfig) |
| 108 | 107 | ||
| 109 | allmodconfig: $(obj)/conf | 108 | savedefconfig: $(obj)/conf |
| 110 | $< -m $(Kconfig) | 109 | $< --$@=defconfig $(Kconfig) |
| 111 | 110 | ||
| 112 | defconfig: $(obj)/conf | 111 | defconfig: $(obj)/conf |
| 113 | ifeq ($(KBUILD_DEFCONFIG),) | 112 | ifeq ($(KBUILD_DEFCONFIG),) |
| 114 | $< -d $(Kconfig) | 113 | $< --defconfig $(Kconfig) |
| 115 | else | 114 | else |
| 116 | @echo "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'" | 115 | @echo "*** Default configuration is based on '$(KBUILD_DEFCONFIG)'" |
| 117 | $(Q)$< -D arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig) | 116 | $(Q)$< --defconfig=arch/$(SRCARCH)/configs/$(KBUILD_DEFCONFIG) $(Kconfig) |
| 118 | endif | 117 | endif |
| 119 | 118 | ||
| 120 | %_defconfig: $(obj)/conf | 119 | %_defconfig: $(obj)/conf |
| 121 | $(Q)$< -D arch/$(SRCARCH)/configs/$@ $(Kconfig) | 120 | $(Q)$< --defconfig=arch/$(SRCARCH)/configs/$@ $(Kconfig) |
| 122 | 121 | ||
| 123 | # Help text used by make help | 122 | # Help text used by make help |
| 124 | help: | 123 | help: |
| @@ -131,11 +130,15 @@ help: | |||
| 131 | @echo ' localmodconfig - Update current config disabling modules not loaded' | 130 | @echo ' localmodconfig - Update current config disabling modules not loaded' |
| 132 | @echo ' localyesconfig - Update current config converting local mods to core' | 131 | @echo ' localyesconfig - Update current config converting local mods to core' |
| 133 | @echo ' silentoldconfig - Same as oldconfig, but quietly, additionally update deps' | 132 | @echo ' silentoldconfig - Same as oldconfig, but quietly, additionally update deps' |
| 134 | @echo ' randconfig - New config with random answer to all options' | 133 | @echo ' defconfig - New config with default from ARCH supplied defconfig' |
| 135 | @echo ' defconfig - New config with default answer to all options' | 134 | @echo ' savedefconfig - Save current config as ./defconfig (minimal config)' |
| 136 | @echo ' allmodconfig - New config selecting modules when possible' | ||
| 137 | @echo ' allyesconfig - New config where all options are accepted with yes' | ||
| 138 | @echo ' allnoconfig - New config where all options are answered with no' | 135 | @echo ' allnoconfig - New config where all options are answered with no' |
| 136 | @echo ' allyesconfig - New config where all options are accepted with yes' | ||
| 137 | @echo ' allmodconfig - New config selecting modules when possible' | ||
| 138 | @echo ' alldefconfig - New config with all symbols set to default' | ||
| 139 | @echo ' randconfig - New config with random answer to all options' | ||
| 140 | @echo ' listnewconfig - List new options' | ||
| 141 | @echo ' oldnoconfig - Same as silentoldconfig but set new symbols to n (unset)' | ||
| 139 | 142 | ||
| 140 | # lxdialog stuff | 143 | # lxdialog stuff |
| 141 | check-lxdialog := $(srctree)/$(src)/lxdialog/check-lxdialog.sh | 144 | check-lxdialog := $(srctree)/$(src)/lxdialog/check-lxdialog.sh |
diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index 9960d1c303f8..5b7c86ea43a1 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | #include <string.h> | 10 | #include <string.h> |
| 11 | #include <time.h> | 11 | #include <time.h> |
| 12 | #include <unistd.h> | 12 | #include <unistd.h> |
| 13 | #include <getopt.h> | ||
| 13 | #include <sys/stat.h> | 14 | #include <sys/stat.h> |
| 14 | #include <sys/time.h> | 15 | #include <sys/time.h> |
| 15 | 16 | ||
| @@ -19,16 +20,21 @@ | |||
| 19 | static void conf(struct menu *menu); | 20 | static void conf(struct menu *menu); |
| 20 | static void check_conf(struct menu *menu); | 21 | static void check_conf(struct menu *menu); |
| 21 | 22 | ||
| 22 | enum { | 23 | enum input_mode { |
| 23 | ask_all, | 24 | oldaskconfig, |
| 24 | ask_new, | 25 | silentoldconfig, |
| 25 | ask_silent, | 26 | oldconfig, |
| 26 | set_default, | 27 | allnoconfig, |
| 27 | set_yes, | 28 | allyesconfig, |
| 28 | set_mod, | 29 | allmodconfig, |
| 29 | set_no, | 30 | alldefconfig, |
| 30 | set_random | 31 | randconfig, |
| 31 | } input_mode = ask_all; | 32 | defconfig, |
| 33 | savedefconfig, | ||
| 34 | listnewconfig, | ||
| 35 | oldnoconfig, | ||
| 36 | } input_mode = oldaskconfig; | ||
| 37 | |||
| 32 | char *defconfig_file; | 38 | char *defconfig_file; |
| 33 | 39 | ||
| 34 | static int indent = 1; | 40 | static int indent = 1; |
| @@ -93,16 +99,16 @@ static int conf_askvalue(struct symbol *sym, const char *def) | |||
| 93 | } | 99 | } |
| 94 | 100 | ||
| 95 | switch (input_mode) { | 101 | switch (input_mode) { |
| 96 | case ask_new: | 102 | case oldconfig: |
| 97 | case ask_silent: | 103 | case silentoldconfig: |
| 98 | if (sym_has_value(sym)) { | 104 | if (sym_has_value(sym)) { |
| 99 | printf("%s\n", def); | 105 | printf("%s\n", def); |
| 100 | return 0; | 106 | return 0; |
| 101 | } | 107 | } |
| 102 | check_stdin(); | 108 | check_stdin(); |
| 103 | case ask_all: | 109 | case oldaskconfig: |
| 104 | fflush(stdout); | 110 | fflush(stdout); |
| 105 | fgets(line, 128, stdin); | 111 | xfgets(line, 128, stdin); |
| 106 | return 1; | 112 | return 1; |
| 107 | default: | 113 | default: |
| 108 | break; | 114 | break; |
| @@ -156,14 +162,12 @@ static int conf_string(struct menu *menu) | |||
| 156 | static int conf_sym(struct menu *menu) | 162 | static int conf_sym(struct menu *menu) |
| 157 | { | 163 | { |
| 158 | struct symbol *sym = menu->sym; | 164 | struct symbol *sym = menu->sym; |
| 159 | int type; | ||
| 160 | tristate oldval, newval; | 165 | tristate oldval, newval; |
| 161 | 166 | ||
| 162 | while (1) { | 167 | while (1) { |
| 163 | printf("%*s%s ", indent - 1, "", _(menu->prompt->text)); | 168 | printf("%*s%s ", indent - 1, "", _(menu->prompt->text)); |
| 164 | if (sym->name) | 169 | if (sym->name) |
| 165 | printf("(%s) ", sym->name); | 170 | printf("(%s) ", sym->name); |
| 166 | type = sym_get_type(sym); | ||
| 167 | putchar('['); | 171 | putchar('['); |
| 168 | oldval = sym_get_tristate_value(sym); | 172 | oldval = sym_get_tristate_value(sym); |
| 169 | switch (oldval) { | 173 | switch (oldval) { |
| @@ -228,11 +232,9 @@ static int conf_choice(struct menu *menu) | |||
| 228 | { | 232 | { |
| 229 | struct symbol *sym, *def_sym; | 233 | struct symbol *sym, *def_sym; |
| 230 | struct menu *child; | 234 | struct menu *child; |
| 231 | int type; | ||
| 232 | bool is_new; | 235 | bool is_new; |
| 233 | 236 | ||
| 234 | sym = menu->sym; | 237 | sym = menu->sym; |
| 235 | type = sym_get_type(sym); | ||
| 236 | is_new = !sym_has_value(sym); | 238 | is_new = !sym_has_value(sym); |
| 237 | if (sym_is_changable(sym)) { | 239 | if (sym_is_changable(sym)) { |
| 238 | conf_sym(menu); | 240 | conf_sym(menu); |
| @@ -294,17 +296,17 @@ static int conf_choice(struct menu *menu) | |||
| 294 | printf("?"); | 296 | printf("?"); |
| 295 | printf("]: "); | 297 | printf("]: "); |
| 296 | switch (input_mode) { | 298 | switch (input_mode) { |
| 297 | case ask_new: | 299 | case oldconfig: |
| 298 | case ask_silent: | 300 | case silentoldconfig: |
| 299 | if (!is_new) { | 301 | if (!is_new) { |
| 300 | cnt = def; | 302 | cnt = def; |
| 301 | printf("%d\n", cnt); | 303 | printf("%d\n", cnt); |
| 302 | break; | 304 | break; |
| 303 | } | 305 | } |
| 304 | check_stdin(); | 306 | check_stdin(); |
| 305 | case ask_all: | 307 | case oldaskconfig: |
| 306 | fflush(stdout); | 308 | fflush(stdout); |
| 307 | fgets(line, 128, stdin); | 309 | xfgets(line, 128, stdin); |
| 308 | strip(line); | 310 | strip(line); |
| 309 | if (line[0] == '?') { | 311 | if (line[0] == '?') { |
| 310 | print_help(menu); | 312 | print_help(menu); |
| @@ -360,7 +362,10 @@ static void conf(struct menu *menu) | |||
| 360 | 362 | ||
| 361 | switch (prop->type) { | 363 | switch (prop->type) { |
| 362 | case P_MENU: | 364 | case P_MENU: |
| 363 | if (input_mode == ask_silent && rootEntry != menu) { | 365 | if ((input_mode == silentoldconfig || |
| 366 | input_mode == listnewconfig || | ||
| 367 | input_mode == oldnoconfig) && | ||
| 368 | rootEntry != menu) { | ||
| 364 | check_conf(menu); | 369 | check_conf(menu); |
| 365 | return; | 370 | return; |
| 366 | } | 371 | } |
| @@ -418,10 +423,16 @@ static void check_conf(struct menu *menu) | |||
| 418 | if (sym && !sym_has_value(sym)) { | 423 | if (sym && !sym_has_value(sym)) { |
| 419 | if (sym_is_changable(sym) || | 424 | if (sym_is_changable(sym) || |
| 420 | (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)) { | 425 | (sym_is_choice(sym) && sym_get_tristate_value(sym) == yes)) { |
| 421 | if (!conf_cnt++) | 426 | if (input_mode == listnewconfig) { |
| 422 | printf(_("*\n* Restart config...\n*\n")); | 427 | if (sym->name && !sym_is_choice_value(sym)) { |
| 423 | rootEntry = menu_get_parent_menu(menu); | 428 | printf("CONFIG_%s\n", sym->name); |
| 424 | conf(rootEntry); | 429 | } |
| 430 | } else { | ||
| 431 | if (!conf_cnt++) | ||
| 432 | printf(_("*\n* Restart config...\n*\n")); | ||
| 433 | rootEntry = menu_get_parent_menu(menu); | ||
| 434 | conf(rootEntry); | ||
| 435 | } | ||
| 425 | } | 436 | } |
| 426 | } | 437 | } |
| 427 | 438 | ||
| @@ -429,6 +440,22 @@ static void check_conf(struct menu *menu) | |||
| 429 | check_conf(child); | 440 | check_conf(child); |
| 430 | } | 441 | } |
| 431 | 442 | ||
| 443 | static struct option long_opts[] = { | ||
| 444 | {"oldaskconfig", no_argument, NULL, oldaskconfig}, | ||
| 445 | {"oldconfig", no_argument, NULL, oldconfig}, | ||
| 446 | {"silentoldconfig", no_argument, NULL, silentoldconfig}, | ||
| 447 | {"defconfig", optional_argument, NULL, defconfig}, | ||
| 448 | {"savedefconfig", required_argument, NULL, savedefconfig}, | ||
| 449 | {"allnoconfig", no_argument, NULL, allnoconfig}, | ||
| 450 | {"allyesconfig", no_argument, NULL, allyesconfig}, | ||
| 451 | {"allmodconfig", no_argument, NULL, allmodconfig}, | ||
| 452 | {"alldefconfig", no_argument, NULL, alldefconfig}, | ||
| 453 | {"randconfig", no_argument, NULL, randconfig}, | ||
| 454 | {"listnewconfig", no_argument, NULL, listnewconfig}, | ||
| 455 | {"oldnoconfig", no_argument, NULL, oldnoconfig}, | ||
| 456 | {NULL, 0, NULL, 0} | ||
| 457 | }; | ||
| 458 | |||
| 432 | int main(int ac, char **av) | 459 | int main(int ac, char **av) |
| 433 | { | 460 | { |
| 434 | int opt; | 461 | int opt; |
| @@ -439,32 +466,17 @@ int main(int ac, char **av) | |||
| 439 | bindtextdomain(PACKAGE, LOCALEDIR); | 466 | bindtextdomain(PACKAGE, LOCALEDIR); |
| 440 | textdomain(PACKAGE); | 467 | textdomain(PACKAGE); |
| 441 | 468 | ||
| 442 | while ((opt = getopt(ac, av, "osdD:nmyrh")) != -1) { | 469 | while ((opt = getopt_long_only(ac, av, "", long_opts, NULL)) != -1) { |
| 470 | input_mode = (enum input_mode)opt; | ||
| 443 | switch (opt) { | 471 | switch (opt) { |
| 444 | case 'o': | 472 | case silentoldconfig: |
| 445 | input_mode = ask_silent; | ||
| 446 | break; | ||
| 447 | case 's': | ||
| 448 | input_mode = ask_silent; | ||
| 449 | sync_kconfig = 1; | 473 | sync_kconfig = 1; |
| 450 | break; | 474 | break; |
| 451 | case 'd': | 475 | case defconfig: |
| 452 | input_mode = set_default; | 476 | case savedefconfig: |
| 453 | break; | ||
| 454 | case 'D': | ||
| 455 | input_mode = set_default; | ||
| 456 | defconfig_file = optarg; | 477 | defconfig_file = optarg; |
| 457 | break; | 478 | break; |
| 458 | case 'n': | 479 | case randconfig: |
| 459 | input_mode = set_no; | ||
| 460 | break; | ||
| 461 | case 'm': | ||
| 462 | input_mode = set_mod; | ||
| 463 | break; | ||
| 464 | case 'y': | ||
| 465 | input_mode = set_yes; | ||
| 466 | break; | ||
| 467 | case 'r': | ||
| 468 | { | 480 | { |
| 469 | struct timeval now; | 481 | struct timeval now; |
| 470 | unsigned int seed; | 482 | unsigned int seed; |
| @@ -477,17 +489,12 @@ int main(int ac, char **av) | |||
| 477 | 489 | ||
| 478 | seed = (unsigned int)((now.tv_sec + 1) * (now.tv_usec + 1)); | 490 | seed = (unsigned int)((now.tv_sec + 1) * (now.tv_usec + 1)); |
| 479 | srand(seed); | 491 | srand(seed); |
| 480 | |||
| 481 | input_mode = set_random; | ||
| 482 | break; | 492 | break; |
| 483 | } | 493 | } |
| 484 | case 'h': | 494 | case '?': |
| 485 | printf(_("See README for usage info\n")); | ||
| 486 | exit(0); | ||
| 487 | break; | ||
| 488 | default: | ||
| 489 | fprintf(stderr, _("See README for usage info\n")); | 495 | fprintf(stderr, _("See README for usage info\n")); |
| 490 | exit(1); | 496 | exit(1); |
| 497 | break; | ||
| 491 | } | 498 | } |
| 492 | } | 499 | } |
| 493 | if (ac == optind) { | 500 | if (ac == optind) { |
| @@ -512,7 +519,7 @@ int main(int ac, char **av) | |||
| 512 | } | 519 | } |
| 513 | 520 | ||
| 514 | switch (input_mode) { | 521 | switch (input_mode) { |
| 515 | case set_default: | 522 | case defconfig: |
| 516 | if (!defconfig_file) | 523 | if (!defconfig_file) |
| 517 | defconfig_file = conf_get_default_confname(); | 524 | defconfig_file = conf_get_default_confname(); |
| 518 | if (conf_read(defconfig_file)) { | 525 | if (conf_read(defconfig_file)) { |
| @@ -522,25 +529,32 @@ int main(int ac, char **av) | |||
| 522 | exit(1); | 529 | exit(1); |
| 523 | } | 530 | } |
| 524 | break; | 531 | break; |
| 525 | case ask_silent: | 532 | case savedefconfig: |
| 526 | case ask_all: | 533 | conf_read(NULL); |
| 527 | case ask_new: | 534 | break; |
| 535 | case silentoldconfig: | ||
| 536 | case oldaskconfig: | ||
| 537 | case oldconfig: | ||
| 538 | case listnewconfig: | ||
| 539 | case oldnoconfig: | ||
| 528 | conf_read(NULL); | 540 | conf_read(NULL); |
| 529 | break; | 541 | break; |
| 530 | case set_no: | 542 | case allnoconfig: |
| 531 | case set_mod: | 543 | case allyesconfig: |
| 532 | case set_yes: | 544 | case allmodconfig: |
| 533 | case set_random: | 545 | case alldefconfig: |
| 546 | case randconfig: | ||
| 534 | name = getenv("KCONFIG_ALLCONFIG"); | 547 | name = getenv("KCONFIG_ALLCONFIG"); |
| 535 | if (name && !stat(name, &tmpstat)) { | 548 | if (name && !stat(name, &tmpstat)) { |
| 536 | conf_read_simple(name, S_DEF_USER); | 549 | conf_read_simple(name, S_DEF_USER); |
| 537 | break; | 550 | break; |
| 538 | } | 551 | } |
| 539 | switch (input_mode) { | 552 | switch (input_mode) { |
| 540 | case set_no: name = "allno.config"; break; | 553 | case allnoconfig: name = "allno.config"; break; |
| 541 | case set_mod: name = "allmod.config"; break; | 554 | case allyesconfig: name = "allyes.config"; break; |
| 542 | case set_yes: name = "allyes.config"; break; | 555 | case allmodconfig: name = "allmod.config"; break; |
| 543 | case set_random: name = "allrandom.config"; break; | 556 | case alldefconfig: name = "alldef.config"; break; |
| 557 | case randconfig: name = "allrandom.config"; break; | ||
| 544 | default: break; | 558 | default: break; |
| 545 | } | 559 | } |
| 546 | if (!stat(name, &tmpstat)) | 560 | if (!stat(name, &tmpstat)) |
| @@ -565,33 +579,42 @@ int main(int ac, char **av) | |||
| 565 | } | 579 | } |
| 566 | 580 | ||
| 567 | switch (input_mode) { | 581 | switch (input_mode) { |
| 568 | case set_no: | 582 | case allnoconfig: |
| 569 | conf_set_all_new_symbols(def_no); | 583 | conf_set_all_new_symbols(def_no); |
| 570 | break; | 584 | break; |
| 571 | case set_yes: | 585 | case allyesconfig: |
| 572 | conf_set_all_new_symbols(def_yes); | 586 | conf_set_all_new_symbols(def_yes); |
| 573 | break; | 587 | break; |
| 574 | case set_mod: | 588 | case allmodconfig: |
| 575 | conf_set_all_new_symbols(def_mod); | 589 | conf_set_all_new_symbols(def_mod); |
| 576 | break; | 590 | break; |
| 577 | case set_random: | 591 | case alldefconfig: |
| 592 | conf_set_all_new_symbols(def_default); | ||
| 593 | break; | ||
| 594 | case randconfig: | ||
| 578 | conf_set_all_new_symbols(def_random); | 595 | conf_set_all_new_symbols(def_random); |
| 579 | break; | 596 | break; |
| 580 | case set_default: | 597 | case defconfig: |
| 581 | conf_set_all_new_symbols(def_default); | 598 | conf_set_all_new_symbols(def_default); |
| 582 | break; | 599 | break; |
| 583 | case ask_new: | 600 | case savedefconfig: |
| 584 | case ask_all: | 601 | break; |
| 602 | case oldaskconfig: | ||
| 585 | rootEntry = &rootmenu; | 603 | rootEntry = &rootmenu; |
| 586 | conf(&rootmenu); | 604 | conf(&rootmenu); |
| 587 | input_mode = ask_silent; | 605 | input_mode = silentoldconfig; |
| 588 | /* fall through */ | 606 | /* fall through */ |
| 589 | case ask_silent: | 607 | case oldconfig: |
| 608 | case listnewconfig: | ||
| 609 | case oldnoconfig: | ||
| 610 | case silentoldconfig: | ||
| 590 | /* Update until a loop caused no more changes */ | 611 | /* Update until a loop caused no more changes */ |
| 591 | do { | 612 | do { |
| 592 | conf_cnt = 0; | 613 | conf_cnt = 0; |
| 593 | check_conf(&rootmenu); | 614 | check_conf(&rootmenu); |
| 594 | } while (conf_cnt); | 615 | } while (conf_cnt && |
| 616 | (input_mode != listnewconfig && | ||
| 617 | input_mode != oldnoconfig)); | ||
| 595 | break; | 618 | break; |
| 596 | } | 619 | } |
| 597 | 620 | ||
| @@ -607,7 +630,13 @@ int main(int ac, char **av) | |||
| 607 | fprintf(stderr, _("\n*** Error during update of the kernel configuration.\n\n")); | 630 | fprintf(stderr, _("\n*** Error during update of the kernel configuration.\n\n")); |
| 608 | return 1; | 631 | return 1; |
| 609 | } | 632 | } |
| 610 | } else { | 633 | } else if (input_mode == savedefconfig) { |
| 634 | if (conf_write_defconfig(defconfig_file)) { | ||
| 635 | fprintf(stderr, _("n*** Error while saving defconfig to: %s\n\n"), | ||
| 636 | defconfig_file); | ||
| 637 | return 1; | ||
| 638 | } | ||
| 639 | } else if (input_mode != listnewconfig) { | ||
| 611 | if (conf_write(NULL)) { | 640 | if (conf_write(NULL)) { |
| 612 | fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n")); | 641 | fprintf(stderr, _("\n*** Error during writing of the kernel configuration.\n\n")); |
| 613 | exit(1); | 642 | exit(1); |
| @@ -615,3 +644,14 @@ int main(int ac, char **av) | |||
| 615 | } | 644 | } |
| 616 | return 0; | 645 | return 0; |
| 617 | } | 646 | } |
| 647 | /* | ||
| 648 | * Helper function to facilitate fgets() by Jean Sacren. | ||
| 649 | */ | ||
| 650 | void xfgets(str, size, in) | ||
| 651 | char *str; | ||
| 652 | int size; | ||
| 653 | FILE *in; | ||
| 654 | { | ||
| 655 | if (fgets(str, size, in) == NULL) | ||
| 656 | fprintf(stderr, "\nError in reading or end of file.\n"); | ||
| 657 | } | ||
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index c4dec80cfd8e..515253fe46cf 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c | |||
| @@ -170,8 +170,11 @@ int conf_read_simple(const char *name, int def) | |||
| 170 | if (in) | 170 | if (in) |
| 171 | goto load; | 171 | goto load; |
| 172 | sym_add_change_count(1); | 172 | sym_add_change_count(1); |
| 173 | if (!sym_defconfig_list) | 173 | if (!sym_defconfig_list) { |
| 174 | if (modules_sym) | ||
| 175 | sym_calc_value(modules_sym); | ||
| 174 | return 1; | 176 | return 1; |
| 177 | } | ||
| 175 | 178 | ||
| 176 | for_all_defaults(sym_defconfig_list, prop) { | 179 | for_all_defaults(sym_defconfig_list, prop) { |
| 177 | if (expr_calc_value(prop->visible.expr) == no || | 180 | if (expr_calc_value(prop->visible.expr) == no || |
| @@ -396,15 +399,150 @@ int conf_read(const char *name) | |||
| 396 | return 0; | 399 | return 0; |
| 397 | } | 400 | } |
| 398 | 401 | ||
| 402 | /* Write a S_STRING */ | ||
| 403 | static void conf_write_string(bool headerfile, const char *name, | ||
| 404 | const char *str, FILE *out) | ||
| 405 | { | ||
| 406 | int l; | ||
| 407 | if (headerfile) | ||
| 408 | fprintf(out, "#define CONFIG_%s \"", name); | ||
| 409 | else | ||
| 410 | fprintf(out, "CONFIG_%s=\"", name); | ||
| 411 | |||
| 412 | while (1) { | ||
| 413 | l = strcspn(str, "\"\\"); | ||
| 414 | if (l) { | ||
| 415 | xfwrite(str, l, 1, out); | ||
| 416 | str += l; | ||
| 417 | } | ||
| 418 | if (!*str) | ||
| 419 | break; | ||
| 420 | fprintf(out, "\\%c", *str++); | ||
| 421 | } | ||
| 422 | fputs("\"\n", out); | ||
| 423 | } | ||
| 424 | |||
| 425 | static void conf_write_symbol(struct symbol *sym, enum symbol_type type, | ||
| 426 | FILE *out, bool write_no) | ||
| 427 | { | ||
| 428 | const char *str; | ||
| 429 | |||
| 430 | switch (type) { | ||
| 431 | case S_BOOLEAN: | ||
| 432 | case S_TRISTATE: | ||
| 433 | switch (sym_get_tristate_value(sym)) { | ||
| 434 | case no: | ||
| 435 | if (write_no) | ||
| 436 | fprintf(out, "# CONFIG_%s is not set\n", sym->name); | ||
| 437 | break; | ||
| 438 | case mod: | ||
| 439 | fprintf(out, "CONFIG_%s=m\n", sym->name); | ||
| 440 | break; | ||
| 441 | case yes: | ||
| 442 | fprintf(out, "CONFIG_%s=y\n", sym->name); | ||
| 443 | break; | ||
| 444 | } | ||
| 445 | break; | ||
| 446 | case S_STRING: | ||
| 447 | conf_write_string(false, sym->name, sym_get_string_value(sym), out); | ||
| 448 | break; | ||
| 449 | case S_HEX: | ||
| 450 | case S_INT: | ||
| 451 | str = sym_get_string_value(sym); | ||
| 452 | fprintf(out, "CONFIG_%s=%s\n", sym->name, str); | ||
| 453 | break; | ||
| 454 | case S_OTHER: | ||
| 455 | case S_UNKNOWN: | ||
| 456 | break; | ||
| 457 | } | ||
| 458 | } | ||
| 459 | |||
| 460 | /* | ||
| 461 | * Write out a minimal config. | ||
| 462 | * All values that has default values are skipped as this is redundant. | ||
| 463 | */ | ||
| 464 | int conf_write_defconfig(const char *filename) | ||
| 465 | { | ||
| 466 | struct symbol *sym; | ||
| 467 | struct menu *menu; | ||
| 468 | FILE *out; | ||
| 469 | |||
| 470 | out = fopen(filename, "w"); | ||
| 471 | if (!out) | ||
| 472 | return 1; | ||
| 473 | |||
| 474 | sym_clear_all_valid(); | ||
| 475 | |||
| 476 | /* Traverse all menus to find all relevant symbols */ | ||
| 477 | menu = rootmenu.list; | ||
| 478 | |||
| 479 | while (menu != NULL) | ||
| 480 | { | ||
| 481 | sym = menu->sym; | ||
| 482 | if (sym == NULL) { | ||
| 483 | if (!menu_is_visible(menu)) | ||
| 484 | goto next_menu; | ||
| 485 | } else if (!sym_is_choice(sym)) { | ||
| 486 | sym_calc_value(sym); | ||
| 487 | if (!(sym->flags & SYMBOL_WRITE)) | ||
| 488 | goto next_menu; | ||
| 489 | sym->flags &= ~SYMBOL_WRITE; | ||
| 490 | /* If we cannot change the symbol - skip */ | ||
| 491 | if (!sym_is_changable(sym)) | ||
| 492 | goto next_menu; | ||
| 493 | /* If symbol equals to default value - skip */ | ||
| 494 | if (strcmp(sym_get_string_value(sym), sym_get_string_default(sym)) == 0) | ||
| 495 | goto next_menu; | ||
| 496 | |||
| 497 | /* | ||
| 498 | * If symbol is a choice value and equals to the | ||
| 499 | * default for a choice - skip. | ||
| 500 | * But only if value is bool and equal to "y" and | ||
| 501 | * choice is not "optional". | ||
| 502 | * (If choice is "optional" then all values can be "n") | ||
| 503 | */ | ||
| 504 | if (sym_is_choice_value(sym)) { | ||
| 505 | struct symbol *cs; | ||
| 506 | struct symbol *ds; | ||
| 507 | |||
| 508 | cs = prop_get_symbol(sym_get_choice_prop(sym)); | ||
| 509 | ds = sym_choice_default(cs); | ||
| 510 | if (!sym_is_optional(cs) && sym == ds) { | ||
| 511 | if ((sym->type == S_BOOLEAN) && | ||
| 512 | sym_get_tristate_value(sym) == yes) | ||
| 513 | goto next_menu; | ||
| 514 | } | ||
| 515 | } | ||
| 516 | conf_write_symbol(sym, sym->type, out, true); | ||
| 517 | } | ||
| 518 | next_menu: | ||
| 519 | if (menu->list != NULL) { | ||
| 520 | menu = menu->list; | ||
| 521 | } | ||
| 522 | else if (menu->next != NULL) { | ||
| 523 | menu = menu->next; | ||
| 524 | } else { | ||
| 525 | while ((menu = menu->parent)) { | ||
| 526 | if (menu->next != NULL) { | ||
| 527 | menu = menu->next; | ||
| 528 | break; | ||
| 529 | } | ||
| 530 | } | ||
| 531 | } | ||
| 532 | } | ||
| 533 | fclose(out); | ||
| 534 | return 0; | ||
| 535 | } | ||
| 536 | |||
| 399 | int conf_write(const char *name) | 537 | int conf_write(const char *name) |
| 400 | { | 538 | { |
| 401 | FILE *out; | 539 | FILE *out; |
| 402 | struct symbol *sym; | 540 | struct symbol *sym; |
| 403 | struct menu *menu; | 541 | struct menu *menu; |
| 404 | const char *basename; | 542 | const char *basename; |
| 405 | char dirname[128], tmpname[128], newname[128]; | ||
| 406 | int type, l; | ||
| 407 | const char *str; | 543 | const char *str; |
| 544 | char dirname[128], tmpname[128], newname[128]; | ||
| 545 | enum symbol_type type; | ||
| 408 | time_t now; | 546 | time_t now; |
| 409 | int use_timestamp = 1; | 547 | int use_timestamp = 1; |
| 410 | char *env; | 548 | char *env; |
| @@ -484,50 +622,11 @@ int conf_write(const char *name) | |||
| 484 | if (modules_sym->curr.tri == no) | 622 | if (modules_sym->curr.tri == no) |
| 485 | type = S_BOOLEAN; | 623 | type = S_BOOLEAN; |
| 486 | } | 624 | } |
| 487 | switch (type) { | 625 | /* Write config symbol to file */ |
| 488 | case S_BOOLEAN: | 626 | conf_write_symbol(sym, type, out, true); |
| 489 | case S_TRISTATE: | ||
| 490 | switch (sym_get_tristate_value(sym)) { | ||
| 491 | case no: | ||
| 492 | fprintf(out, "# CONFIG_%s is not set\n", sym->name); | ||
| 493 | break; | ||
| 494 | case mod: | ||
| 495 | fprintf(out, "CONFIG_%s=m\n", sym->name); | ||
| 496 | break; | ||
| 497 | case yes: | ||
| 498 | fprintf(out, "CONFIG_%s=y\n", sym->name); | ||
| 499 | break; | ||
| 500 | } | ||
| 501 | break; | ||
| 502 | case S_STRING: | ||
| 503 | str = sym_get_string_value(sym); | ||
| 504 | fprintf(out, "CONFIG_%s=\"", sym->name); | ||
| 505 | while (1) { | ||
| 506 | l = strcspn(str, "\"\\"); | ||
| 507 | if (l) { | ||
| 508 | fwrite(str, l, 1, out); | ||
| 509 | str += l; | ||
| 510 | } | ||
| 511 | if (!*str) | ||
| 512 | break; | ||
| 513 | fprintf(out, "\\%c", *str++); | ||
| 514 | } | ||
| 515 | fputs("\"\n", out); | ||
| 516 | break; | ||
| 517 | case S_HEX: | ||
| 518 | str = sym_get_string_value(sym); | ||
| 519 | if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) { | ||
| 520 | fprintf(out, "CONFIG_%s=%s\n", sym->name, str); | ||
| 521 | break; | ||
| 522 | } | ||
| 523 | case S_INT: | ||
| 524 | str = sym_get_string_value(sym); | ||
| 525 | fprintf(out, "CONFIG_%s=%s\n", sym->name, str); | ||
| 526 | break; | ||
| 527 | } | ||
| 528 | } | 627 | } |
| 529 | 628 | ||
| 530 | next: | 629 | next: |
| 531 | if (menu->list) { | 630 | if (menu->list) { |
| 532 | menu = menu->list; | 631 | menu = menu->list; |
| 533 | continue; | 632 | continue; |
| @@ -679,7 +778,7 @@ int conf_write_autoconf(void) | |||
| 679 | const char *name; | 778 | const char *name; |
| 680 | FILE *out, *tristate, *out_h; | 779 | FILE *out, *tristate, *out_h; |
| 681 | time_t now; | 780 | time_t now; |
| 682 | int i, l; | 781 | int i; |
| 683 | 782 | ||
| 684 | sym_clear_all_valid(); | 783 | sym_clear_all_valid(); |
| 685 | 784 | ||
| @@ -729,6 +828,11 @@ int conf_write_autoconf(void) | |||
| 729 | sym_calc_value(sym); | 828 | sym_calc_value(sym); |
| 730 | if (!(sym->flags & SYMBOL_WRITE) || !sym->name) | 829 | if (!(sym->flags & SYMBOL_WRITE) || !sym->name) |
| 731 | continue; | 830 | continue; |
| 831 | |||
| 832 | /* write symbol to config file */ | ||
| 833 | conf_write_symbol(sym, sym->type, out, false); | ||
| 834 | |||
| 835 | /* update autoconf and tristate files */ | ||
| 732 | switch (sym->type) { | 836 | switch (sym->type) { |
| 733 | case S_BOOLEAN: | 837 | case S_BOOLEAN: |
| 734 | case S_TRISTATE: | 838 | case S_TRISTATE: |
| @@ -736,12 +840,10 @@ int conf_write_autoconf(void) | |||
| 736 | case no: | 840 | case no: |
| 737 | break; | 841 | break; |
| 738 | case mod: | 842 | case mod: |
| 739 | fprintf(out, "CONFIG_%s=m\n", sym->name); | ||
| 740 | fprintf(tristate, "CONFIG_%s=M\n", sym->name); | 843 | fprintf(tristate, "CONFIG_%s=M\n", sym->name); |
| 741 | fprintf(out_h, "#define CONFIG_%s_MODULE 1\n", sym->name); | 844 | fprintf(out_h, "#define CONFIG_%s_MODULE 1\n", sym->name); |
| 742 | break; | 845 | break; |
| 743 | case yes: | 846 | case yes: |
| 744 | fprintf(out, "CONFIG_%s=y\n", sym->name); | ||
| 745 | if (sym->type == S_TRISTATE) | 847 | if (sym->type == S_TRISTATE) |
| 746 | fprintf(tristate, "CONFIG_%s=Y\n", | 848 | fprintf(tristate, "CONFIG_%s=Y\n", |
| 747 | sym->name); | 849 | sym->name); |
| @@ -750,35 +852,16 @@ int conf_write_autoconf(void) | |||
| 750 | } | 852 | } |
| 751 | break; | 853 | break; |
| 752 | case S_STRING: | 854 | case S_STRING: |
| 753 | str = sym_get_string_value(sym); | 855 | conf_write_string(true, sym->name, sym_get_string_value(sym), out_h); |
| 754 | fprintf(out, "CONFIG_%s=\"", sym->name); | ||
| 755 | fprintf(out_h, "#define CONFIG_%s \"", sym->name); | ||
| 756 | while (1) { | ||
| 757 | l = strcspn(str, "\"\\"); | ||
| 758 | if (l) { | ||
| 759 | fwrite(str, l, 1, out); | ||
| 760 | fwrite(str, l, 1, out_h); | ||
| 761 | str += l; | ||
| 762 | } | ||
| 763 | if (!*str) | ||
| 764 | break; | ||
| 765 | fprintf(out, "\\%c", *str); | ||
| 766 | fprintf(out_h, "\\%c", *str); | ||
| 767 | str++; | ||
| 768 | } | ||
| 769 | fputs("\"\n", out); | ||
| 770 | fputs("\"\n", out_h); | ||
| 771 | break; | 856 | break; |
| 772 | case S_HEX: | 857 | case S_HEX: |
| 773 | str = sym_get_string_value(sym); | 858 | str = sym_get_string_value(sym); |
| 774 | if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) { | 859 | if (str[0] != '0' || (str[1] != 'x' && str[1] != 'X')) { |
| 775 | fprintf(out, "CONFIG_%s=%s\n", sym->name, str); | ||
| 776 | fprintf(out_h, "#define CONFIG_%s 0x%s\n", sym->name, str); | 860 | fprintf(out_h, "#define CONFIG_%s 0x%s\n", sym->name, str); |
| 777 | break; | 861 | break; |
| 778 | } | 862 | } |
| 779 | case S_INT: | 863 | case S_INT: |
| 780 | str = sym_get_string_value(sym); | 864 | str = sym_get_string_value(sym); |
| 781 | fprintf(out, "CONFIG_%s=%s\n", sym->name, str); | ||
| 782 | fprintf(out_h, "#define CONFIG_%s %s\n", sym->name, str); | 865 | fprintf(out_h, "#define CONFIG_%s %s\n", sym->name, str); |
| 783 | break; | 866 | break; |
| 784 | default: | 867 | default: |
| @@ -837,13 +920,73 @@ void conf_set_changed_callback(void (*fn)(void)) | |||
| 837 | conf_changed_callback = fn; | 920 | conf_changed_callback = fn; |
| 838 | } | 921 | } |
| 839 | 922 | ||
| 923 | static void randomize_choice_values(struct symbol *csym) | ||
| 924 | { | ||
| 925 | struct property *prop; | ||
| 926 | struct symbol *sym; | ||
| 927 | struct expr *e; | ||
| 928 | int cnt, def; | ||
| 840 | 929 | ||
| 841 | void conf_set_all_new_symbols(enum conf_def_mode mode) | 930 | /* |
| 931 | * If choice is mod then we may have more items slected | ||
| 932 | * and if no then no-one. | ||
| 933 | * In both cases stop. | ||
| 934 | */ | ||
| 935 | if (csym->curr.tri != yes) | ||
| 936 | return; | ||
| 937 | |||
| 938 | prop = sym_get_choice_prop(csym); | ||
| 939 | |||
| 940 | /* count entries in choice block */ | ||
| 941 | cnt = 0; | ||
| 942 | expr_list_for_each_sym(prop->expr, e, sym) | ||
| 943 | cnt++; | ||
| 944 | |||
| 945 | /* | ||
| 946 | * find a random value and set it to yes, | ||
| 947 | * set the rest to no so we have only one set | ||
| 948 | */ | ||
| 949 | def = (rand() % cnt); | ||
| 950 | |||
| 951 | cnt = 0; | ||
| 952 | expr_list_for_each_sym(prop->expr, e, sym) { | ||
| 953 | if (def == cnt++) { | ||
| 954 | sym->def[S_DEF_USER].tri = yes; | ||
| 955 | csym->def[S_DEF_USER].val = sym; | ||
| 956 | } | ||
| 957 | else { | ||
| 958 | sym->def[S_DEF_USER].tri = no; | ||
| 959 | } | ||
| 960 | } | ||
| 961 | csym->flags |= SYMBOL_DEF_USER; | ||
| 962 | /* clear VALID to get value calculated */ | ||
| 963 | csym->flags &= ~(SYMBOL_VALID); | ||
| 964 | } | ||
| 965 | |||
| 966 | static void set_all_choice_values(struct symbol *csym) | ||
| 842 | { | 967 | { |
| 843 | struct symbol *sym, *csym; | ||
| 844 | struct property *prop; | 968 | struct property *prop; |
| 969 | struct symbol *sym; | ||
| 845 | struct expr *e; | 970 | struct expr *e; |
| 846 | int i, cnt, def; | 971 | |
| 972 | prop = sym_get_choice_prop(csym); | ||
| 973 | |||
| 974 | /* | ||
| 975 | * Set all non-assinged choice values to no | ||
| 976 | */ | ||
| 977 | expr_list_for_each_sym(prop->expr, e, sym) { | ||
| 978 | if (!sym_has_value(sym)) | ||
| 979 | sym->def[S_DEF_USER].tri = no; | ||
| 980 | } | ||
| 981 | csym->flags |= SYMBOL_DEF_USER; | ||
| 982 | /* clear VALID to get value calculated */ | ||
| 983 | csym->flags &= ~(SYMBOL_VALID); | ||
| 984 | } | ||
| 985 | |||
| 986 | void conf_set_all_new_symbols(enum conf_def_mode mode) | ||
| 987 | { | ||
| 988 | struct symbol *sym, *csym; | ||
| 989 | int i, cnt; | ||
| 847 | 990 | ||
| 848 | for_all_symbols(i, sym) { | 991 | for_all_symbols(i, sym) { |
| 849 | if (sym_has_value(sym)) | 992 | if (sym_has_value(sym)) |
| @@ -862,7 +1005,8 @@ void conf_set_all_new_symbols(enum conf_def_mode mode) | |||
| 862 | sym->def[S_DEF_USER].tri = no; | 1005 | sym->def[S_DEF_USER].tri = no; |
| 863 | break; | 1006 | break; |
| 864 | case def_random: | 1007 | case def_random: |
| 865 | sym->def[S_DEF_USER].tri = (tristate)(rand() % 3); | 1008 | cnt = sym_get_type(sym) == S_TRISTATE ? 3 : 2; |
| 1009 | sym->def[S_DEF_USER].tri = (tristate)(rand() % cnt); | ||
| 866 | break; | 1010 | break; |
| 867 | default: | 1011 | default: |
| 868 | continue; | 1012 | continue; |
| @@ -878,8 +1022,6 @@ void conf_set_all_new_symbols(enum conf_def_mode mode) | |||
| 878 | 1022 | ||
| 879 | sym_clear_all_valid(); | 1023 | sym_clear_all_valid(); |
| 880 | 1024 | ||
| 881 | if (mode != def_random) | ||
| 882 | return; | ||
| 883 | /* | 1025 | /* |
| 884 | * We have different type of choice blocks. | 1026 | * We have different type of choice blocks. |
| 885 | * If curr.tri equal to mod then we can select several | 1027 | * If curr.tri equal to mod then we can select several |
| @@ -894,35 +1036,9 @@ void conf_set_all_new_symbols(enum conf_def_mode mode) | |||
| 894 | continue; | 1036 | continue; |
| 895 | 1037 | ||
| 896 | sym_calc_value(csym); | 1038 | sym_calc_value(csym); |
| 897 | 1039 | if (mode == def_random) | |
| 898 | if (csym->curr.tri != yes) | 1040 | randomize_choice_values(csym); |
| 899 | continue; | 1041 | else |
| 900 | 1042 | set_all_choice_values(csym); | |
| 901 | prop = sym_get_choice_prop(csym); | ||
| 902 | |||
| 903 | /* count entries in choice block */ | ||
| 904 | cnt = 0; | ||
| 905 | expr_list_for_each_sym(prop->expr, e, sym) | ||
| 906 | cnt++; | ||
| 907 | |||
| 908 | /* | ||
| 909 | * find a random value and set it to yes, | ||
| 910 | * set the rest to no so we have only one set | ||
| 911 | */ | ||
| 912 | def = (rand() % cnt); | ||
| 913 | |||
| 914 | cnt = 0; | ||
| 915 | expr_list_for_each_sym(prop->expr, e, sym) { | ||
| 916 | if (def == cnt++) { | ||
| 917 | sym->def[S_DEF_USER].tri = yes; | ||
| 918 | csym->def[S_DEF_USER].val = sym; | ||
| 919 | } | ||
| 920 | else { | ||
| 921 | sym->def[S_DEF_USER].tri = no; | ||
| 922 | } | ||
| 923 | } | ||
| 924 | csym->flags |= SYMBOL_DEF_USER; | ||
| 925 | /* clear VALID to get value calculated */ | ||
| 926 | csym->flags &= ~(SYMBOL_VALID); | ||
| 927 | } | 1043 | } |
| 928 | } | 1044 | } |
diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c index d83f2322893a..330e7c0048a8 100644 --- a/scripts/kconfig/expr.c +++ b/scripts/kconfig/expr.c | |||
| @@ -1087,7 +1087,7 @@ void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char * | |||
| 1087 | 1087 | ||
| 1088 | static void expr_print_file_helper(void *data, struct symbol *sym, const char *str) | 1088 | static void expr_print_file_helper(void *data, struct symbol *sym, const char *str) |
| 1089 | { | 1089 | { |
| 1090 | fwrite(str, strlen(str), 1, data); | 1090 | xfwrite(str, strlen(str), 1, data); |
| 1091 | } | 1091 | } |
| 1092 | 1092 | ||
| 1093 | void expr_fprint(struct expr *e, FILE *out) | 1093 | void expr_fprint(struct expr *e, FILE *out) |
| @@ -1121,7 +1121,7 @@ static void expr_print_gstr_helper(void *data, struct symbol *sym, const char *s | |||
| 1121 | } | 1121 | } |
| 1122 | 1122 | ||
| 1123 | str_append(gs, str); | 1123 | str_append(gs, str); |
| 1124 | if (sym) | 1124 | if (sym && sym->type != S_UNKNOWN) |
| 1125 | str_printf(gs, " [=%s]", sym_str); | 1125 | str_printf(gs, " [=%s]", sym_str); |
| 1126 | } | 1126 | } |
| 1127 | 1127 | ||
diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index 891cd9ce9ba2..6ee2e4fb1481 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h | |||
| @@ -83,6 +83,7 @@ struct symbol { | |||
| 83 | tristate visible; | 83 | tristate visible; |
| 84 | int flags; | 84 | int flags; |
| 85 | struct property *prop; | 85 | struct property *prop; |
| 86 | struct expr_value dir_dep; | ||
| 86 | struct expr_value rev_dep; | 87 | struct expr_value rev_dep; |
| 87 | }; | 88 | }; |
| 88 | 89 | ||
| @@ -131,6 +132,7 @@ enum prop_type { | |||
| 131 | P_SELECT, /* select BAR */ | 132 | P_SELECT, /* select BAR */ |
| 132 | P_RANGE, /* range 7..100 (for a symbol) */ | 133 | P_RANGE, /* range 7..100 (for a symbol) */ |
| 133 | P_ENV, /* value from environment variable */ | 134 | P_ENV, /* value from environment variable */ |
| 135 | P_SYMBOL, /* where a symbol is defined */ | ||
| 134 | }; | 136 | }; |
| 135 | 137 | ||
| 136 | struct property { | 138 | struct property { |
| @@ -163,6 +165,7 @@ struct menu { | |||
| 163 | struct symbol *sym; | 165 | struct symbol *sym; |
| 164 | struct property *prompt; | 166 | struct property *prompt; |
| 165 | struct expr *dep; | 167 | struct expr *dep; |
| 168 | struct expr *dir_dep; | ||
| 166 | unsigned int flags; | 169 | unsigned int flags; |
| 167 | char *help; | 170 | char *help; |
| 168 | struct file *file; | 171 | struct file *file; |
diff --git a/scripts/kconfig/gconf.c b/scripts/kconfig/gconf.c index bef10411837f..d66988265f89 100644 --- a/scripts/kconfig/gconf.c +++ b/scripts/kconfig/gconf.c | |||
| @@ -1114,7 +1114,7 @@ static gchar **fill_row(struct menu *menu) | |||
| 1114 | 1114 | ||
| 1115 | row[COL_OPTION] = | 1115 | row[COL_OPTION] = |
| 1116 | g_strdup_printf("%s %s", _(menu_get_prompt(menu)), | 1116 | g_strdup_printf("%s %s", _(menu_get_prompt(menu)), |
| 1117 | sym && sym_has_value(sym) ? "(NEW)" : ""); | 1117 | sym && !sym_has_value(sym) ? "(NEW)" : ""); |
| 1118 | 1118 | ||
| 1119 | if (opt_mode == OPT_ALL && !menu_is_visible(menu)) | 1119 | if (opt_mode == OPT_ALL && !menu_is_visible(menu)) |
| 1120 | row[COL_COLOR] = g_strdup("DarkGray"); | 1120 | row[COL_COLOR] = g_strdup("DarkGray"); |
| @@ -1343,7 +1343,8 @@ static void update_tree(struct menu *src, GtkTreeIter * dst) | |||
| 1343 | #endif | 1343 | #endif |
| 1344 | 1344 | ||
| 1345 | if ((opt_mode == OPT_NORMAL && !menu_is_visible(child1)) || | 1345 | if ((opt_mode == OPT_NORMAL && !menu_is_visible(child1)) || |
| 1346 | (opt_mode == OPT_PROMPT && !menu_has_prompt(child1))) { | 1346 | (opt_mode == OPT_PROMPT && !menu_has_prompt(child1)) || |
| 1347 | (opt_mode == OPT_ALL && !menu_get_prompt(child1))) { | ||
| 1347 | 1348 | ||
| 1348 | /* remove node */ | 1349 | /* remove node */ |
| 1349 | if (gtktree_iter_find_node(dst, menu1) != NULL) { | 1350 | if (gtktree_iter_find_node(dst, menu1) != NULL) { |
| @@ -1425,7 +1426,7 @@ static void display_tree(struct menu *menu) | |||
| 1425 | 1426 | ||
| 1426 | if ((opt_mode == OPT_NORMAL && menu_is_visible(child)) || | 1427 | if ((opt_mode == OPT_NORMAL && menu_is_visible(child)) || |
| 1427 | (opt_mode == OPT_PROMPT && menu_has_prompt(child)) || | 1428 | (opt_mode == OPT_PROMPT && menu_has_prompt(child)) || |
| 1428 | (opt_mode == OPT_ALL)) | 1429 | (opt_mode == OPT_ALL && menu_get_prompt(child))) |
| 1429 | place_node(child, fill_row(child)); | 1430 | place_node(child, fill_row(child)); |
| 1430 | #ifdef DEBUG | 1431 | #ifdef DEBUG |
| 1431 | printf("%*c%s: ", indent, ' ', menu_get_prompt(child)); | 1432 | printf("%*c%s: ", indent, ' ', menu_get_prompt(child)); |
diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index ce6549cdaccf..bdf71bd31412 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h | |||
| @@ -72,6 +72,9 @@ void zconf_nextfile(const char *name); | |||
| 72 | int zconf_lineno(void); | 72 | int zconf_lineno(void); |
| 73 | char *zconf_curname(void); | 73 | char *zconf_curname(void); |
| 74 | 74 | ||
| 75 | /* conf.c */ | ||
| 76 | void xfgets(char *str, int size, FILE *in); | ||
| 77 | |||
| 75 | /* confdata.c */ | 78 | /* confdata.c */ |
| 76 | const char *conf_get_configname(void); | 79 | const char *conf_get_configname(void); |
| 77 | const char *conf_get_autoconfig_name(void); | 80 | const char *conf_get_autoconfig_name(void); |
| @@ -80,6 +83,13 @@ void sym_set_change_count(int count); | |||
| 80 | void sym_add_change_count(int count); | 83 | void sym_add_change_count(int count); |
| 81 | void conf_set_all_new_symbols(enum conf_def_mode mode); | 84 | void conf_set_all_new_symbols(enum conf_def_mode mode); |
| 82 | 85 | ||
| 86 | /* confdata.c and expr.c */ | ||
| 87 | static inline void xfwrite(const void *str, size_t len, size_t count, FILE *out) | ||
| 88 | { | ||
| 89 | if (fwrite(str, len, count, out) < count) | ||
| 90 | fprintf(stderr, "\nError in writing or end of file.\n"); | ||
| 91 | } | ||
| 92 | |||
| 83 | /* kconfig_load.c */ | 93 | /* kconfig_load.c */ |
| 84 | void kconfig_load(void); | 94 | void kconfig_load(void); |
| 85 | 95 | ||
| @@ -126,6 +136,8 @@ void sym_init(void); | |||
| 126 | void sym_clear_all_valid(void); | 136 | void sym_clear_all_valid(void); |
| 127 | void sym_set_all_changed(void); | 137 | void sym_set_all_changed(void); |
| 128 | void sym_set_changed(struct symbol *sym); | 138 | void sym_set_changed(struct symbol *sym); |
| 139 | struct symbol *sym_choice_default(struct symbol *sym); | ||
| 140 | const char *sym_get_string_default(struct symbol *sym); | ||
| 129 | struct symbol *sym_check_deps(struct symbol *sym); | 141 | struct symbol *sym_check_deps(struct symbol *sym); |
| 130 | struct property *prop_alloc(enum prop_type type, struct symbol *sym); | 142 | struct property *prop_alloc(enum prop_type type, struct symbol *sym); |
| 131 | struct symbol *prop_get_symbol(struct property *prop); | 143 | struct symbol *prop_get_symbol(struct property *prop); |
diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h index 7cadcad8233b..9a948c9ce44e 100644 --- a/scripts/kconfig/lkc_proto.h +++ b/scripts/kconfig/lkc_proto.h | |||
| @@ -3,6 +3,7 @@ | |||
| 3 | P(conf_parse,void,(const char *name)); | 3 | P(conf_parse,void,(const char *name)); |
| 4 | P(conf_read,int,(const char *name)); | 4 | P(conf_read,int,(const char *name)); |
| 5 | P(conf_read_simple,int,(const char *name, int)); | 5 | P(conf_read_simple,int,(const char *name, int)); |
| 6 | P(conf_write_defconfig,int,(const char *name)); | ||
| 6 | P(conf_write,int,(const char *name)); | 7 | P(conf_write,int,(const char *name)); |
| 7 | P(conf_write_autoconf,int,(void)); | 8 | P(conf_write_autoconf,int,(void)); |
| 8 | P(conf_get_changed,bool,(void)); | 9 | P(conf_get_changed,bool,(void)); |
diff --git a/scripts/kconfig/lxdialog/checklist.c b/scripts/kconfig/lxdialog/checklist.c index bcc6f19c3a35..a2eb80fbc896 100644 --- a/scripts/kconfig/lxdialog/checklist.c +++ b/scripts/kconfig/lxdialog/checklist.c | |||
| @@ -31,6 +31,10 @@ static int list_width, check_x, item_x; | |||
| 31 | static void print_item(WINDOW * win, int choice, int selected) | 31 | static void print_item(WINDOW * win, int choice, int selected) |
| 32 | { | 32 | { |
| 33 | int i; | 33 | int i; |
| 34 | char *list_item = malloc(list_width + 1); | ||
| 35 | |||
| 36 | strncpy(list_item, item_str(), list_width - item_x); | ||
| 37 | list_item[list_width - item_x] = '\0'; | ||
| 34 | 38 | ||
| 35 | /* Clear 'residue' of last item */ | 39 | /* Clear 'residue' of last item */ |
| 36 | wattrset(win, dlg.menubox.atr); | 40 | wattrset(win, dlg.menubox.atr); |
| @@ -45,13 +49,14 @@ static void print_item(WINDOW * win, int choice, int selected) | |||
| 45 | wprintw(win, "(%c)", item_is_tag('X') ? 'X' : ' '); | 49 | wprintw(win, "(%c)", item_is_tag('X') ? 'X' : ' '); |
| 46 | 50 | ||
| 47 | wattrset(win, selected ? dlg.tag_selected.atr : dlg.tag.atr); | 51 | wattrset(win, selected ? dlg.tag_selected.atr : dlg.tag.atr); |
| 48 | mvwaddch(win, choice, item_x, item_str()[0]); | 52 | mvwaddch(win, choice, item_x, list_item[0]); |
| 49 | wattrset(win, selected ? dlg.item_selected.atr : dlg.item.atr); | 53 | wattrset(win, selected ? dlg.item_selected.atr : dlg.item.atr); |
| 50 | waddstr(win, (char *)item_str() + 1); | 54 | waddstr(win, list_item + 1); |
| 51 | if (selected) { | 55 | if (selected) { |
| 52 | wmove(win, choice, check_x + 1); | 56 | wmove(win, choice, check_x + 1); |
| 53 | wrefresh(win); | 57 | wrefresh(win); |
| 54 | } | 58 | } |
| 59 | free(list_item); | ||
| 55 | } | 60 | } |
| 56 | 61 | ||
| 57 | /* | 62 | /* |
| @@ -175,6 +180,7 @@ do_resize: | |||
| 175 | check_x = 0; | 180 | check_x = 0; |
| 176 | item_foreach() | 181 | item_foreach() |
| 177 | check_x = MAX(check_x, strlen(item_str()) + 4); | 182 | check_x = MAX(check_x, strlen(item_str()) + 4); |
| 183 | check_x = MIN(check_x, list_width); | ||
| 178 | 184 | ||
| 179 | check_x = (list_width - check_x) / 2; | 185 | check_x = (list_width - check_x) / 2; |
| 180 | item_x = check_x + 4; | 186 | item_x = check_x + 4; |
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index 2c83d3234d30..d2f6e056c058 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c | |||
| @@ -74,7 +74,7 @@ static const char mconf_readme[] = N_( | |||
| 74 | "\n" | 74 | "\n" |
| 75 | " Shortcut: Press <H> or <?>.\n" | 75 | " Shortcut: Press <H> or <?>.\n" |
| 76 | "\n" | 76 | "\n" |
| 77 | "o To show hidden options, press <Z>.\n" | 77 | "o To toggle the display of hidden options, press <Z>.\n" |
| 78 | "\n" | 78 | "\n" |
| 79 | "\n" | 79 | "\n" |
| 80 | "Radiolists (Choice lists)\n" | 80 | "Radiolists (Choice lists)\n" |
diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index 203632cc30bd..4fb590247f33 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c | |||
| @@ -58,6 +58,8 @@ void menu_add_entry(struct symbol *sym) | |||
| 58 | *last_entry_ptr = menu; | 58 | *last_entry_ptr = menu; |
| 59 | last_entry_ptr = &menu->next; | 59 | last_entry_ptr = &menu->next; |
| 60 | current_entry = menu; | 60 | current_entry = menu; |
| 61 | if (sym) | ||
| 62 | menu_add_symbol(P_SYMBOL, sym, NULL); | ||
| 61 | } | 63 | } |
| 62 | 64 | ||
| 63 | void menu_end_entry(void) | 65 | void menu_end_entry(void) |
| @@ -105,6 +107,7 @@ static struct expr *menu_check_dep(struct expr *e) | |||
| 105 | void menu_add_dep(struct expr *dep) | 107 | void menu_add_dep(struct expr *dep) |
| 106 | { | 108 | { |
| 107 | current_entry->dep = expr_alloc_and(current_entry->dep, menu_check_dep(dep)); | 109 | current_entry->dep = expr_alloc_and(current_entry->dep, menu_check_dep(dep)); |
| 110 | current_entry->dir_dep = current_entry->dep; | ||
| 108 | } | 111 | } |
| 109 | 112 | ||
| 110 | void menu_set_type(int type) | 113 | void menu_set_type(int type) |
| @@ -288,6 +291,10 @@ void menu_finalize(struct menu *parent) | |||
| 288 | for (menu = parent->list; menu; menu = menu->next) | 291 | for (menu = parent->list; menu; menu = menu->next) |
| 289 | menu_finalize(menu); | 292 | menu_finalize(menu); |
| 290 | } else if (sym) { | 293 | } else if (sym) { |
| 294 | /* ignore inherited dependencies for dir_dep */ | ||
| 295 | sym->dir_dep.expr = expr_transform(expr_copy(parent->dir_dep)); | ||
| 296 | sym->dir_dep.expr = expr_eliminate_dups(sym->dir_dep.expr); | ||
| 297 | |||
| 291 | basedep = parent->prompt ? parent->prompt->visible.expr : NULL; | 298 | basedep = parent->prompt ? parent->prompt->visible.expr : NULL; |
| 292 | basedep = expr_trans_compare(basedep, E_UNEQUAL, &symbol_no); | 299 | basedep = expr_trans_compare(basedep, E_UNEQUAL, &symbol_no); |
| 293 | basedep = expr_eliminate_dups(expr_transform(basedep)); | 300 | basedep = expr_eliminate_dups(expr_transform(basedep)); |
| @@ -419,9 +426,13 @@ bool menu_is_visible(struct menu *menu) | |||
| 419 | if (!sym || sym_get_tristate_value(menu->sym) == no) | 426 | if (!sym || sym_get_tristate_value(menu->sym) == no) |
| 420 | return false; | 427 | return false; |
| 421 | 428 | ||
| 422 | for (child = menu->list; child; child = child->next) | 429 | for (child = menu->list; child; child = child->next) { |
| 423 | if (menu_is_visible(child)) | 430 | if (menu_is_visible(child)) { |
| 431 | if (sym) | ||
| 432 | sym->flags |= SYMBOL_DEF_USER; | ||
| 424 | return true; | 433 | return true; |
| 434 | } | ||
| 435 | } | ||
| 425 | 436 | ||
| 426 | return false; | 437 | return false; |
| 427 | } | 438 | } |
| @@ -501,9 +512,19 @@ void get_symbol_str(struct gstr *r, struct symbol *sym) | |||
| 501 | bool hit; | 512 | bool hit; |
| 502 | struct property *prop; | 513 | struct property *prop; |
| 503 | 514 | ||
| 504 | if (sym && sym->name) | 515 | if (sym && sym->name) { |
| 505 | str_printf(r, "Symbol: %s [=%s]\n", sym->name, | 516 | str_printf(r, "Symbol: %s [=%s]\n", sym->name, |
| 506 | sym_get_string_value(sym)); | 517 | sym_get_string_value(sym)); |
| 518 | str_printf(r, "Type : %s\n", sym_type_name(sym->type)); | ||
| 519 | if (sym->type == S_INT || sym->type == S_HEX) { | ||
| 520 | prop = sym_get_range_prop(sym); | ||
| 521 | if (prop) { | ||
| 522 | str_printf(r, "Range : "); | ||
| 523 | expr_gstr_print(prop->expr, r); | ||
| 524 | str_append(r, "\n"); | ||
| 525 | } | ||
| 526 | } | ||
| 527 | } | ||
| 507 | for_all_prompts(sym, prop) | 528 | for_all_prompts(sym, prop) |
| 508 | get_prompt_str(r, prop); | 529 | get_prompt_str(r, prop); |
| 509 | hit = false; | 530 | hit = false; |
diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c index 762caf80ce37..2ba71bcd38e6 100644 --- a/scripts/kconfig/nconf.c +++ b/scripts/kconfig/nconf.c | |||
| @@ -676,6 +676,8 @@ static void *item_data(void) | |||
| 676 | struct mitem *mcur; | 676 | struct mitem *mcur; |
| 677 | 677 | ||
| 678 | cur = current_item(curses_menu); | 678 | cur = current_item(curses_menu); |
| 679 | if (!cur) | ||
| 680 | return NULL; | ||
| 679 | mcur = (struct mitem *) item_userptr(cur); | 681 | mcur = (struct mitem *) item_userptr(cur); |
| 680 | return mcur->usrptr; | 682 | return mcur->usrptr; |
| 681 | 683 | ||
diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc index 00c51507cfcc..820df2d1217b 100644 --- a/scripts/kconfig/qconf.cc +++ b/scripts/kconfig/qconf.cc | |||
| @@ -58,11 +58,10 @@ QValueList<int> ConfigSettings::readSizes(const QString& key, bool *ok) | |||
| 58 | { | 58 | { |
| 59 | QValueList<int> result; | 59 | QValueList<int> result; |
| 60 | QStringList entryList = readListEntry(key, ok); | 60 | QStringList entryList = readListEntry(key, ok); |
| 61 | if (ok) { | 61 | QStringList::Iterator it; |
| 62 | QStringList::Iterator it; | 62 | |
| 63 | for (it = entryList.begin(); it != entryList.end(); ++it) | 63 | for (it = entryList.begin(); it != entryList.end(); ++it) |
| 64 | result.push_back((*it).toInt()); | 64 | result.push_back((*it).toInt()); |
| 65 | } | ||
| 66 | 65 | ||
| 67 | return result; | 66 | return result; |
| 68 | } | 67 | } |
| @@ -149,7 +148,7 @@ void ConfigItem::updateMenu(void) | |||
| 149 | case S_TRISTATE: | 148 | case S_TRISTATE: |
| 150 | char ch; | 149 | char ch; |
| 151 | 150 | ||
| 152 | if (!sym_is_changable(sym) && !list->showAll) { | 151 | if (!sym_is_changable(sym) && list->optMode == normalOpt) { |
| 153 | setPixmap(promptColIdx, 0); | 152 | setPixmap(promptColIdx, 0); |
| 154 | setText(noColIdx, QString::null); | 153 | setText(noColIdx, QString::null); |
| 155 | setText(modColIdx, QString::null); | 154 | setText(modColIdx, QString::null); |
| @@ -320,7 +319,7 @@ ConfigList::ConfigList(ConfigView* p, const char *name) | |||
| 320 | symbolYesPix(xpm_symbol_yes), symbolModPix(xpm_symbol_mod), symbolNoPix(xpm_symbol_no), | 319 | symbolYesPix(xpm_symbol_yes), symbolModPix(xpm_symbol_mod), symbolNoPix(xpm_symbol_no), |
| 321 | choiceYesPix(xpm_choice_yes), choiceNoPix(xpm_choice_no), | 320 | choiceYesPix(xpm_choice_yes), choiceNoPix(xpm_choice_no), |
| 322 | menuPix(xpm_menu), menuInvPix(xpm_menu_inv), menuBackPix(xpm_menuback), voidPix(xpm_void), | 321 | menuPix(xpm_menu), menuInvPix(xpm_menu_inv), menuBackPix(xpm_menuback), voidPix(xpm_void), |
| 323 | showAll(false), showName(false), showRange(false), showData(false), | 322 | showName(false), showRange(false), showData(false), optMode(normalOpt), |
| 324 | rootEntry(0), headerPopup(0) | 323 | rootEntry(0), headerPopup(0) |
| 325 | { | 324 | { |
| 326 | int i; | 325 | int i; |
| @@ -337,10 +336,10 @@ ConfigList::ConfigList(ConfigView* p, const char *name) | |||
| 337 | 336 | ||
| 338 | if (name) { | 337 | if (name) { |
| 339 | configSettings->beginGroup(name); | 338 | configSettings->beginGroup(name); |
| 340 | showAll = configSettings->readBoolEntry("/showAll", false); | ||
| 341 | showName = configSettings->readBoolEntry("/showName", false); | 339 | showName = configSettings->readBoolEntry("/showName", false); |
| 342 | showRange = configSettings->readBoolEntry("/showRange", false); | 340 | showRange = configSettings->readBoolEntry("/showRange", false); |
| 343 | showData = configSettings->readBoolEntry("/showData", false); | 341 | showData = configSettings->readBoolEntry("/showData", false); |
| 342 | optMode = (enum optionMode)configSettings->readNumEntry("/optionMode", false); | ||
| 344 | configSettings->endGroup(); | 343 | configSettings->endGroup(); |
| 345 | connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings())); | 344 | connect(configApp, SIGNAL(aboutToQuit()), SLOT(saveSettings())); |
| 346 | } | 345 | } |
| @@ -352,6 +351,17 @@ ConfigList::ConfigList(ConfigView* p, const char *name) | |||
| 352 | reinit(); | 351 | reinit(); |
| 353 | } | 352 | } |
| 354 | 353 | ||
| 354 | bool ConfigList::menuSkip(struct menu *menu) | ||
| 355 | { | ||
| 356 | if (optMode == normalOpt && menu_is_visible(menu)) | ||
| 357 | return false; | ||
| 358 | if (optMode == promptOpt && menu_has_prompt(menu)) | ||
| 359 | return false; | ||
| 360 | if (optMode == allOpt) | ||
| 361 | return false; | ||
| 362 | return true; | ||
| 363 | } | ||
| 364 | |||
| 355 | void ConfigList::reinit(void) | 365 | void ConfigList::reinit(void) |
| 356 | { | 366 | { |
| 357 | removeColumn(dataColIdx); | 367 | removeColumn(dataColIdx); |
| @@ -380,7 +390,7 @@ void ConfigList::saveSettings(void) | |||
| 380 | configSettings->writeEntry("/showName", showName); | 390 | configSettings->writeEntry("/showName", showName); |
| 381 | configSettings->writeEntry("/showRange", showRange); | 391 | configSettings->writeEntry("/showRange", showRange); |
| 382 | configSettings->writeEntry("/showData", showData); | 392 | configSettings->writeEntry("/showData", showData); |
| 383 | configSettings->writeEntry("/showAll", showAll); | 393 | configSettings->writeEntry("/optionMode", (int)optMode); |
| 384 | configSettings->endGroup(); | 394 | configSettings->endGroup(); |
| 385 | } | 395 | } |
| 386 | } | 396 | } |
| @@ -606,7 +616,7 @@ void ConfigList::updateMenuList(P* parent, struct menu* menu) | |||
| 606 | } | 616 | } |
| 607 | 617 | ||
| 608 | visible = menu_is_visible(child); | 618 | visible = menu_is_visible(child); |
| 609 | if (showAll || visible) { | 619 | if (!menuSkip(child)) { |
| 610 | if (!child->sym && !child->list && !child->prompt) | 620 | if (!child->sym && !child->list && !child->prompt) |
| 611 | continue; | 621 | continue; |
| 612 | if (!item || item->menu != child) | 622 | if (!item || item->menu != child) |
| @@ -835,7 +845,10 @@ void ConfigList::contextMenuEvent(QContextMenuEvent *e) | |||
| 835 | e->ignore(); | 845 | e->ignore(); |
| 836 | } | 846 | } |
| 837 | 847 | ||
| 838 | ConfigView* ConfigView::viewList; | 848 | ConfigView*ConfigView::viewList; |
| 849 | QAction *ConfigView::showNormalAction; | ||
| 850 | QAction *ConfigView::showAllAction; | ||
| 851 | QAction *ConfigView::showPromptAction; | ||
| 839 | 852 | ||
| 840 | ConfigView::ConfigView(QWidget* parent, const char *name) | 853 | ConfigView::ConfigView(QWidget* parent, const char *name) |
| 841 | : Parent(parent, name) | 854 | : Parent(parent, name) |
| @@ -860,13 +873,16 @@ ConfigView::~ConfigView(void) | |||
| 860 | } | 873 | } |
| 861 | } | 874 | } |
| 862 | 875 | ||
| 863 | void ConfigView::setShowAll(bool b) | 876 | void ConfigView::setOptionMode(QAction *act) |
| 864 | { | 877 | { |
| 865 | if (list->showAll != b) { | 878 | if (act == showNormalAction) |
| 866 | list->showAll = b; | 879 | list->optMode = normalOpt; |
| 867 | list->updateListAll(); | 880 | else if (act == showAllAction) |
| 868 | emit showAllChanged(b); | 881 | list->optMode = allOpt; |
| 869 | } | 882 | else |
| 883 | list->optMode = promptOpt; | ||
| 884 | |||
| 885 | list->updateListAll(); | ||
| 870 | } | 886 | } |
| 871 | 887 | ||
| 872 | void ConfigView::setShowName(bool b) | 888 | void ConfigView::setShowName(bool b) |
| @@ -964,34 +980,6 @@ void ConfigInfoView::setInfo(struct menu *m) | |||
| 964 | menuInfo(); | 980 | menuInfo(); |
| 965 | } | 981 | } |
| 966 | 982 | ||
| 967 | void ConfigInfoView::setSource(const QString& name) | ||
| 968 | { | ||
| 969 | const char *p = name.latin1(); | ||
| 970 | |||
| 971 | menu = NULL; | ||
| 972 | sym = NULL; | ||
| 973 | |||
| 974 | switch (p[0]) { | ||
| 975 | case 'm': | ||
| 976 | struct menu *m; | ||
| 977 | |||
| 978 | if (sscanf(p, "m%p", &m) == 1 && menu != m) { | ||
| 979 | menu = m; | ||
| 980 | menuInfo(); | ||
| 981 | emit menuSelected(menu); | ||
| 982 | } | ||
| 983 | break; | ||
| 984 | case 's': | ||
| 985 | struct symbol *s; | ||
| 986 | |||
| 987 | if (sscanf(p, "s%p", &s) == 1 && sym != s) { | ||
| 988 | sym = s; | ||
| 989 | symbolInfo(); | ||
| 990 | } | ||
| 991 | break; | ||
| 992 | } | ||
| 993 | } | ||
| 994 | |||
| 995 | void ConfigInfoView::symbolInfo(void) | 983 | void ConfigInfoView::symbolInfo(void) |
| 996 | { | 984 | { |
| 997 | QString str; | 985 | QString str; |
| @@ -1349,11 +1337,24 @@ ConfigMainWindow::ConfigMainWindow(void) | |||
| 1349 | connect(showDataAction, SIGNAL(toggled(bool)), configView, SLOT(setShowData(bool))); | 1337 | connect(showDataAction, SIGNAL(toggled(bool)), configView, SLOT(setShowData(bool))); |
| 1350 | connect(configView, SIGNAL(showDataChanged(bool)), showDataAction, SLOT(setOn(bool))); | 1338 | connect(configView, SIGNAL(showDataChanged(bool)), showDataAction, SLOT(setOn(bool))); |
| 1351 | showDataAction->setOn(configList->showData); | 1339 | showDataAction->setOn(configList->showData); |
| 1352 | QAction *showAllAction = new QAction(NULL, _("Show All Options"), 0, this); | 1340 | |
| 1353 | showAllAction->setToggleAction(TRUE); | 1341 | QActionGroup *optGroup = new QActionGroup(this); |
| 1354 | connect(showAllAction, SIGNAL(toggled(bool)), configView, SLOT(setShowAll(bool))); | 1342 | optGroup->setExclusive(TRUE); |
| 1355 | connect(showAllAction, SIGNAL(toggled(bool)), menuView, SLOT(setShowAll(bool))); | 1343 | connect(optGroup, SIGNAL(selected(QAction *)), configView, |
| 1356 | showAllAction->setOn(configList->showAll); | 1344 | SLOT(setOptionMode(QAction *))); |
| 1345 | connect(optGroup, SIGNAL(selected(QAction *)), menuView, | ||
| 1346 | SLOT(setOptionMode(QAction *))); | ||
| 1347 | |||
| 1348 | configView->showNormalAction = new QAction(NULL, _("Show Normal Options"), 0, optGroup); | ||
| 1349 | configView->showAllAction = new QAction(NULL, _("Show All Options"), 0, optGroup); | ||
| 1350 | configView->showPromptAction = new QAction(NULL, _("Show Prompt Options"), 0, optGroup); | ||
| 1351 | configView->showNormalAction->setToggleAction(TRUE); | ||
| 1352 | configView->showNormalAction->setOn(configList->optMode == normalOpt); | ||
| 1353 | configView->showAllAction->setToggleAction(TRUE); | ||
| 1354 | configView->showAllAction->setOn(configList->optMode == allOpt); | ||
| 1355 | configView->showPromptAction->setToggleAction(TRUE); | ||
| 1356 | configView->showPromptAction->setOn(configList->optMode == promptOpt); | ||
| 1357 | |||
| 1357 | QAction *showDebugAction = new QAction(NULL, _("Show Debug Info"), 0, this); | 1358 | QAction *showDebugAction = new QAction(NULL, _("Show Debug Info"), 0, this); |
| 1358 | showDebugAction->setToggleAction(TRUE); | 1359 | showDebugAction->setToggleAction(TRUE); |
| 1359 | connect(showDebugAction, SIGNAL(toggled(bool)), helpText, SLOT(setShowDebug(bool))); | 1360 | connect(showDebugAction, SIGNAL(toggled(bool)), helpText, SLOT(setShowDebug(bool))); |
| @@ -1396,7 +1397,8 @@ ConfigMainWindow::ConfigMainWindow(void) | |||
| 1396 | showRangeAction->addTo(optionMenu); | 1397 | showRangeAction->addTo(optionMenu); |
| 1397 | showDataAction->addTo(optionMenu); | 1398 | showDataAction->addTo(optionMenu); |
| 1398 | optionMenu->insertSeparator(); | 1399 | optionMenu->insertSeparator(); |
| 1399 | showAllAction->addTo(optionMenu); | 1400 | optGroup->addTo(optionMenu); |
| 1401 | optionMenu->insertSeparator(); | ||
| 1400 | showDebugAction->addTo(optionMenu); | 1402 | showDebugAction->addTo(optionMenu); |
| 1401 | 1403 | ||
| 1402 | // create help menu | 1404 | // create help menu |
| @@ -1491,7 +1493,7 @@ void ConfigMainWindow::setMenuLink(struct menu *menu) | |||
| 1491 | ConfigList* list = NULL; | 1493 | ConfigList* list = NULL; |
| 1492 | ConfigItem* item; | 1494 | ConfigItem* item; |
| 1493 | 1495 | ||
| 1494 | if (!menu_is_visible(menu) && !configView->showAll()) | 1496 | if (configList->menuSkip(menu)) |
| 1495 | return; | 1497 | return; |
| 1496 | 1498 | ||
| 1497 | switch (configList->mode) { | 1499 | switch (configList->mode) { |
diff --git a/scripts/kconfig/qconf.h b/scripts/kconfig/qconf.h index b3b5657b6b35..636a74b23bf9 100644 --- a/scripts/kconfig/qconf.h +++ b/scripts/kconfig/qconf.h | |||
| @@ -44,6 +44,9 @@ enum colIdx { | |||
| 44 | enum listMode { | 44 | enum listMode { |
| 45 | singleMode, menuMode, symbolMode, fullMode, listMode | 45 | singleMode, menuMode, symbolMode, fullMode, listMode |
| 46 | }; | 46 | }; |
| 47 | enum optionMode { | ||
| 48 | normalOpt = 0, allOpt, promptOpt | ||
| 49 | }; | ||
| 47 | 50 | ||
| 48 | class ConfigList : public QListView { | 51 | class ConfigList : public QListView { |
| 49 | Q_OBJECT | 52 | Q_OBJECT |
| @@ -115,6 +118,8 @@ public: | |||
| 115 | void setAllOpen(bool open); | 118 | void setAllOpen(bool open); |
| 116 | void setParentMenu(void); | 119 | void setParentMenu(void); |
| 117 | 120 | ||
| 121 | bool menuSkip(struct menu *); | ||
| 122 | |||
| 118 | template <class P> | 123 | template <class P> |
| 119 | void updateMenuList(P*, struct menu*); | 124 | void updateMenuList(P*, struct menu*); |
| 120 | 125 | ||
| @@ -124,8 +129,9 @@ public: | |||
| 124 | QPixmap choiceYesPix, choiceNoPix; | 129 | QPixmap choiceYesPix, choiceNoPix; |
| 125 | QPixmap menuPix, menuInvPix, menuBackPix, voidPix; | 130 | QPixmap menuPix, menuInvPix, menuBackPix, voidPix; |
| 126 | 131 | ||
| 127 | bool showAll, showName, showRange, showData; | 132 | bool showName, showRange, showData; |
| 128 | enum listMode mode; | 133 | enum listMode mode; |
| 134 | enum optionMode optMode; | ||
| 129 | struct menu *rootEntry; | 135 | struct menu *rootEntry; |
| 130 | QColorGroup disabledColorGroup; | 136 | QColorGroup disabledColorGroup; |
| 131 | QColorGroup inactivedColorGroup; | 137 | QColorGroup inactivedColorGroup; |
| @@ -222,17 +228,15 @@ public: | |||
| 222 | static void updateList(ConfigItem* item); | 228 | static void updateList(ConfigItem* item); |
| 223 | static void updateListAll(void); | 229 | static void updateListAll(void); |
| 224 | 230 | ||
| 225 | bool showAll(void) const { return list->showAll; } | ||
| 226 | bool showName(void) const { return list->showName; } | 231 | bool showName(void) const { return list->showName; } |
| 227 | bool showRange(void) const { return list->showRange; } | 232 | bool showRange(void) const { return list->showRange; } |
| 228 | bool showData(void) const { return list->showData; } | 233 | bool showData(void) const { return list->showData; } |
| 229 | public slots: | 234 | public slots: |
| 230 | void setShowAll(bool); | ||
| 231 | void setShowName(bool); | 235 | void setShowName(bool); |
| 232 | void setShowRange(bool); | 236 | void setShowRange(bool); |
| 233 | void setShowData(bool); | 237 | void setShowData(bool); |
| 238 | void setOptionMode(QAction *); | ||
| 234 | signals: | 239 | signals: |
| 235 | void showAllChanged(bool); | ||
| 236 | void showNameChanged(bool); | 240 | void showNameChanged(bool); |
| 237 | void showRangeChanged(bool); | 241 | void showRangeChanged(bool); |
| 238 | void showDataChanged(bool); | 242 | void showDataChanged(bool); |
| @@ -242,6 +246,10 @@ public: | |||
| 242 | 246 | ||
| 243 | static ConfigView* viewList; | 247 | static ConfigView* viewList; |
| 244 | ConfigView* nextView; | 248 | ConfigView* nextView; |
| 249 | |||
| 250 | static QAction *showNormalAction; | ||
| 251 | static QAction *showAllAction; | ||
| 252 | static QAction *showPromptAction; | ||
| 245 | }; | 253 | }; |
| 246 | 254 | ||
| 247 | class ConfigInfoView : public QTextBrowser { | 255 | class ConfigInfoView : public QTextBrowser { |
| @@ -254,7 +262,6 @@ public: | |||
| 254 | public slots: | 262 | public slots: |
| 255 | void setInfo(struct menu *menu); | 263 | void setInfo(struct menu *menu); |
| 256 | void saveSettings(void); | 264 | void saveSettings(void); |
| 257 | void setSource(const QString& name); | ||
| 258 | void setShowDebug(bool); | 265 | void setShowDebug(bool); |
| 259 | 266 | ||
| 260 | signals: | 267 | signals: |
diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index 2e7a048e0cfc..943712ca6c0a 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c | |||
| @@ -205,6 +205,16 @@ static void sym_calc_visibility(struct symbol *sym) | |||
| 205 | } | 205 | } |
| 206 | if (sym_is_choice_value(sym)) | 206 | if (sym_is_choice_value(sym)) |
| 207 | return; | 207 | return; |
| 208 | /* defaulting to "yes" if no explicit "depends on" are given */ | ||
| 209 | tri = yes; | ||
| 210 | if (sym->dir_dep.expr) | ||
| 211 | tri = expr_calc_value(sym->dir_dep.expr); | ||
| 212 | if (tri == mod) | ||
| 213 | tri = yes; | ||
| 214 | if (sym->dir_dep.tri != tri) { | ||
| 215 | sym->dir_dep.tri = tri; | ||
| 216 | sym_set_changed(sym); | ||
| 217 | } | ||
| 208 | tri = no; | 218 | tri = no; |
| 209 | if (sym->rev_dep.expr) | 219 | if (sym->rev_dep.expr) |
| 210 | tri = expr_calc_value(sym->rev_dep.expr); | 220 | tri = expr_calc_value(sym->rev_dep.expr); |
| @@ -216,44 +226,63 @@ static void sym_calc_visibility(struct symbol *sym) | |||
| 216 | } | 226 | } |
| 217 | } | 227 | } |
| 218 | 228 | ||
| 219 | static struct symbol *sym_calc_choice(struct symbol *sym) | 229 | /* |
| 230 | * Find the default symbol for a choice. | ||
| 231 | * First try the default values for the choice symbol | ||
| 232 | * Next locate the first visible choice value | ||
| 233 | * Return NULL if none was found | ||
| 234 | */ | ||
| 235 | struct symbol *sym_choice_default(struct symbol *sym) | ||
| 220 | { | 236 | { |
| 221 | struct symbol *def_sym; | 237 | struct symbol *def_sym; |
| 222 | struct property *prop; | 238 | struct property *prop; |
| 223 | struct expr *e; | 239 | struct expr *e; |
| 224 | 240 | ||
| 225 | /* is the user choice visible? */ | ||
| 226 | def_sym = sym->def[S_DEF_USER].val; | ||
| 227 | if (def_sym) { | ||
| 228 | sym_calc_visibility(def_sym); | ||
| 229 | if (def_sym->visible != no) | ||
| 230 | return def_sym; | ||
| 231 | } | ||
| 232 | |||
| 233 | /* any of the defaults visible? */ | 241 | /* any of the defaults visible? */ |
| 234 | for_all_defaults(sym, prop) { | 242 | for_all_defaults(sym, prop) { |
| 235 | prop->visible.tri = expr_calc_value(prop->visible.expr); | 243 | prop->visible.tri = expr_calc_value(prop->visible.expr); |
| 236 | if (prop->visible.tri == no) | 244 | if (prop->visible.tri == no) |
| 237 | continue; | 245 | continue; |
| 238 | def_sym = prop_get_symbol(prop); | 246 | def_sym = prop_get_symbol(prop); |
| 239 | sym_calc_visibility(def_sym); | ||
| 240 | if (def_sym->visible != no) | 247 | if (def_sym->visible != no) |
| 241 | return def_sym; | 248 | return def_sym; |
| 242 | } | 249 | } |
| 243 | 250 | ||
| 244 | /* just get the first visible value */ | 251 | /* just get the first visible value */ |
| 245 | prop = sym_get_choice_prop(sym); | 252 | prop = sym_get_choice_prop(sym); |
| 246 | expr_list_for_each_sym(prop->expr, e, def_sym) { | 253 | expr_list_for_each_sym(prop->expr, e, def_sym) |
| 247 | sym_calc_visibility(def_sym); | ||
| 248 | if (def_sym->visible != no) | 254 | if (def_sym->visible != no) |
| 249 | return def_sym; | 255 | return def_sym; |
| 250 | } | ||
| 251 | 256 | ||
| 252 | /* no choice? reset tristate value */ | 257 | /* failed to locate any defaults */ |
| 253 | sym->curr.tri = no; | ||
| 254 | return NULL; | 258 | return NULL; |
| 255 | } | 259 | } |
| 256 | 260 | ||
| 261 | static struct symbol *sym_calc_choice(struct symbol *sym) | ||
| 262 | { | ||
| 263 | struct symbol *def_sym; | ||
| 264 | struct property *prop; | ||
| 265 | struct expr *e; | ||
| 266 | |||
| 267 | /* first calculate all choice values' visibilities */ | ||
| 268 | prop = sym_get_choice_prop(sym); | ||
| 269 | expr_list_for_each_sym(prop->expr, e, def_sym) | ||
| 270 | sym_calc_visibility(def_sym); | ||
| 271 | |||
| 272 | /* is the user choice visible? */ | ||
| 273 | def_sym = sym->def[S_DEF_USER].val; | ||
| 274 | if (def_sym && def_sym->visible != no) | ||
| 275 | return def_sym; | ||
| 276 | |||
| 277 | def_sym = sym_choice_default(sym); | ||
| 278 | |||
| 279 | if (def_sym == NULL) | ||
| 280 | /* no choice? reset tristate value */ | ||
| 281 | sym->curr.tri = no; | ||
| 282 | |||
| 283 | return def_sym; | ||
| 284 | } | ||
| 285 | |||
| 257 | void sym_calc_value(struct symbol *sym) | 286 | void sym_calc_value(struct symbol *sym) |
| 258 | { | 287 | { |
| 259 | struct symbol_value newval, oldval; | 288 | struct symbol_value newval, oldval; |
| @@ -321,6 +350,14 @@ void sym_calc_value(struct symbol *sym) | |||
| 321 | } | 350 | } |
| 322 | } | 351 | } |
| 323 | calc_newval: | 352 | calc_newval: |
| 353 | if (sym->dir_dep.tri == no && sym->rev_dep.tri != no) { | ||
| 354 | fprintf(stderr, "warning: ("); | ||
| 355 | expr_fprint(sym->rev_dep.expr, stderr); | ||
| 356 | fprintf(stderr, ") selects %s which has unmet direct dependencies (", | ||
| 357 | sym->name); | ||
| 358 | expr_fprint(sym->dir_dep.expr, stderr); | ||
| 359 | fprintf(stderr, ")\n"); | ||
| 360 | } | ||
| 324 | newval.tri = EXPR_OR(newval.tri, sym->rev_dep.tri); | 361 | newval.tri = EXPR_OR(newval.tri, sym->rev_dep.tri); |
| 325 | } | 362 | } |
| 326 | if (newval.tri == mod && sym_get_type(sym) == S_BOOLEAN) | 363 | if (newval.tri == mod && sym_get_type(sym) == S_BOOLEAN) |
| @@ -365,12 +402,13 @@ void sym_calc_value(struct symbol *sym) | |||
| 365 | 402 | ||
| 366 | if (sym_is_choice(sym)) { | 403 | if (sym_is_choice(sym)) { |
| 367 | struct symbol *choice_sym; | 404 | struct symbol *choice_sym; |
| 368 | int flags = sym->flags & (SYMBOL_CHANGED | SYMBOL_WRITE); | ||
| 369 | 405 | ||
| 370 | prop = sym_get_choice_prop(sym); | 406 | prop = sym_get_choice_prop(sym); |
| 371 | expr_list_for_each_sym(prop->expr, e, choice_sym) { | 407 | expr_list_for_each_sym(prop->expr, e, choice_sym) { |
| 372 | choice_sym->flags |= flags; | 408 | if ((sym->flags & SYMBOL_WRITE) && |
| 373 | if (flags & SYMBOL_CHANGED) | 409 | choice_sym->visible != no) |
| 410 | choice_sym->flags |= SYMBOL_WRITE; | ||
| 411 | if (sym->flags & SYMBOL_CHANGED) | ||
| 374 | sym_set_changed(choice_sym); | 412 | sym_set_changed(choice_sym); |
| 375 | } | 413 | } |
| 376 | } | 414 | } |
| @@ -623,6 +661,80 @@ bool sym_set_string_value(struct symbol *sym, const char *newval) | |||
| 623 | return true; | 661 | return true; |
| 624 | } | 662 | } |
| 625 | 663 | ||
| 664 | /* | ||
| 665 | * Find the default value associated to a symbol. | ||
| 666 | * For tristate symbol handle the modules=n case | ||
| 667 | * in which case "m" becomes "y". | ||
| 668 | * If the symbol does not have any default then fallback | ||
| 669 | * to the fixed default values. | ||
| 670 | */ | ||
| 671 | const char *sym_get_string_default(struct symbol *sym) | ||
| 672 | { | ||
| 673 | struct property *prop; | ||
| 674 | struct symbol *ds; | ||
| 675 | const char *str; | ||
| 676 | tristate val; | ||
| 677 | |||
| 678 | sym_calc_visibility(sym); | ||
| 679 | sym_calc_value(modules_sym); | ||
| 680 | val = symbol_no.curr.tri; | ||
| 681 | str = symbol_empty.curr.val; | ||
| 682 | |||
| 683 | /* If symbol has a default value look it up */ | ||
| 684 | prop = sym_get_default_prop(sym); | ||
| 685 | if (prop != NULL) { | ||
| 686 | switch (sym->type) { | ||
| 687 | case S_BOOLEAN: | ||
| 688 | case S_TRISTATE: | ||
| 689 | /* The visibility imay limit the value from yes => mod */ | ||
| 690 | val = EXPR_AND(expr_calc_value(prop->expr), prop->visible.tri); | ||
| 691 | break; | ||
| 692 | default: | ||
| 693 | /* | ||
| 694 | * The following fails to handle the situation | ||
| 695 | * where a default value is further limited by | ||
| 696 | * the valid range. | ||
| 697 | */ | ||
| 698 | ds = prop_get_symbol(prop); | ||
| 699 | if (ds != NULL) { | ||
| 700 | sym_calc_value(ds); | ||
| 701 | str = (const char *)ds->curr.val; | ||
| 702 | } | ||
| 703 | } | ||
| 704 | } | ||
| 705 | |||
| 706 | /* Handle select statements */ | ||
| 707 | val = EXPR_OR(val, sym->rev_dep.tri); | ||
| 708 | |||
| 709 | /* transpose mod to yes if modules are not enabled */ | ||
| 710 | if (val == mod) | ||
| 711 | if (!sym_is_choice_value(sym) && modules_sym->curr.tri == no) | ||
| 712 | val = yes; | ||
| 713 | |||
| 714 | /* transpose mod to yes if type is bool */ | ||
| 715 | if (sym->type == S_BOOLEAN && val == mod) | ||
| 716 | val = yes; | ||
| 717 | |||
| 718 | switch (sym->type) { | ||
| 719 | case S_BOOLEAN: | ||
| 720 | case S_TRISTATE: | ||
| 721 | switch (val) { | ||
| 722 | case no: return "n"; | ||
| 723 | case mod: return "m"; | ||
| 724 | case yes: return "y"; | ||
| 725 | } | ||
| 726 | case S_INT: | ||
| 727 | case S_HEX: | ||
| 728 | return str; | ||
| 729 | case S_STRING: | ||
| 730 | return str; | ||
| 731 | case S_OTHER: | ||
| 732 | case S_UNKNOWN: | ||
| 733 | break; | ||
| 734 | } | ||
| 735 | return ""; | ||
| 736 | } | ||
| 737 | |||
| 626 | const char *sym_get_string_value(struct symbol *sym) | 738 | const char *sym_get_string_value(struct symbol *sym) |
| 627 | { | 739 | { |
| 628 | tristate val; | 740 | tristate val; |
| @@ -765,6 +877,112 @@ struct symbol **sym_re_search(const char *pattern) | |||
| 765 | return sym_arr; | 877 | return sym_arr; |
| 766 | } | 878 | } |
| 767 | 879 | ||
| 880 | /* | ||
| 881 | * When we check for recursive dependencies we use a stack to save | ||
| 882 | * current state so we can print out relevant info to user. | ||
| 883 | * The entries are located on the call stack so no need to free memory. | ||
| 884 | * Note inser() remove() must always match to properly clear the stack. | ||
| 885 | */ | ||
| 886 | static struct dep_stack { | ||
| 887 | struct dep_stack *prev, *next; | ||
| 888 | struct symbol *sym; | ||
| 889 | struct property *prop; | ||
| 890 | struct expr *expr; | ||
| 891 | } *check_top; | ||
| 892 | |||
| 893 | static void dep_stack_insert(struct dep_stack *stack, struct symbol *sym) | ||
| 894 | { | ||
| 895 | memset(stack, 0, sizeof(*stack)); | ||
| 896 | if (check_top) | ||
| 897 | check_top->next = stack; | ||
| 898 | stack->prev = check_top; | ||
| 899 | stack->sym = sym; | ||
| 900 | check_top = stack; | ||
| 901 | } | ||
| 902 | |||
| 903 | static void dep_stack_remove(void) | ||
| 904 | { | ||
| 905 | check_top = check_top->prev; | ||
| 906 | if (check_top) | ||
| 907 | check_top->next = NULL; | ||
| 908 | } | ||
| 909 | |||
| 910 | /* | ||
| 911 | * Called when we have detected a recursive dependency. | ||
| 912 | * check_top point to the top of the stact so we use | ||
| 913 | * the ->prev pointer to locate the bottom of the stack. | ||
| 914 | */ | ||
| 915 | static void sym_check_print_recursive(struct symbol *last_sym) | ||
| 916 | { | ||
| 917 | struct dep_stack *stack; | ||
| 918 | struct symbol *sym, *next_sym; | ||
| 919 | struct menu *menu = NULL; | ||
| 920 | struct property *prop; | ||
| 921 | struct dep_stack cv_stack; | ||
| 922 | |||
| 923 | if (sym_is_choice_value(last_sym)) { | ||
| 924 | dep_stack_insert(&cv_stack, last_sym); | ||
| 925 | last_sym = prop_get_symbol(sym_get_choice_prop(last_sym)); | ||
| 926 | } | ||
| 927 | |||
| 928 | for (stack = check_top; stack != NULL; stack = stack->prev) | ||
| 929 | if (stack->sym == last_sym) | ||
| 930 | break; | ||
| 931 | if (!stack) { | ||
| 932 | fprintf(stderr, "unexpected recursive dependency error\n"); | ||
| 933 | return; | ||
| 934 | } | ||
| 935 | |||
| 936 | for (; stack; stack = stack->next) { | ||
| 937 | sym = stack->sym; | ||
| 938 | next_sym = stack->next ? stack->next->sym : last_sym; | ||
| 939 | prop = stack->prop; | ||
| 940 | if (prop == NULL) | ||
| 941 | prop = stack->sym->prop; | ||
| 942 | |||
| 943 | /* for choice values find the menu entry (used below) */ | ||
| 944 | if (sym_is_choice(sym) || sym_is_choice_value(sym)) { | ||
| 945 | for (prop = sym->prop; prop; prop = prop->next) { | ||
| 946 | menu = prop->menu; | ||
| 947 | if (prop->menu) | ||
| 948 | break; | ||
| 949 | } | ||
| 950 | } | ||
| 951 | if (stack->sym == last_sym) | ||
| 952 | fprintf(stderr, "%s:%d:error: recursive dependency detected!\n", | ||
| 953 | prop->file->name, prop->lineno); | ||
| 954 | if (stack->expr) { | ||
| 955 | fprintf(stderr, "%s:%d:\tsymbol %s %s value contains %s\n", | ||
| 956 | prop->file->name, prop->lineno, | ||
| 957 | sym->name ? sym->name : "<choice>", | ||
| 958 | prop_get_type_name(prop->type), | ||
| 959 | next_sym->name ? next_sym->name : "<choice>"); | ||
| 960 | } else if (stack->prop) { | ||
| 961 | fprintf(stderr, "%s:%d:\tsymbol %s depends on %s\n", | ||
| 962 | prop->file->name, prop->lineno, | ||
| 963 | sym->name ? sym->name : "<choice>", | ||
| 964 | next_sym->name ? next_sym->name : "<choice>"); | ||
| 965 | } else if (sym_is_choice(sym)) { | ||
| 966 | fprintf(stderr, "%s:%d:\tchoice %s contains symbol %s\n", | ||
| 967 | menu->file->name, menu->lineno, | ||
| 968 | sym->name ? sym->name : "<choice>", | ||
| 969 | next_sym->name ? next_sym->name : "<choice>"); | ||
| 970 | } else if (sym_is_choice_value(sym)) { | ||
| 971 | fprintf(stderr, "%s:%d:\tsymbol %s is part of choice %s\n", | ||
| 972 | menu->file->name, menu->lineno, | ||
| 973 | sym->name ? sym->name : "<choice>", | ||
| 974 | next_sym->name ? next_sym->name : "<choice>"); | ||
| 975 | } else { | ||
| 976 | fprintf(stderr, "%s:%d:\tsymbol %s is selected by %s\n", | ||
| 977 | prop->file->name, prop->lineno, | ||
| 978 | sym->name ? sym->name : "<choice>", | ||
| 979 | next_sym->name ? next_sym->name : "<choice>"); | ||
| 980 | } | ||
| 981 | } | ||
| 982 | |||
| 983 | if (check_top == &cv_stack) | ||
| 984 | dep_stack_remove(); | ||
| 985 | } | ||
| 768 | 986 | ||
| 769 | static struct symbol *sym_check_expr_deps(struct expr *e) | 987 | static struct symbol *sym_check_expr_deps(struct expr *e) |
| 770 | { | 988 | { |
| @@ -801,24 +1019,33 @@ static struct symbol *sym_check_sym_deps(struct symbol *sym) | |||
| 801 | { | 1019 | { |
| 802 | struct symbol *sym2; | 1020 | struct symbol *sym2; |
| 803 | struct property *prop; | 1021 | struct property *prop; |
| 1022 | struct dep_stack stack; | ||
| 1023 | |||
| 1024 | dep_stack_insert(&stack, sym); | ||
| 804 | 1025 | ||
| 805 | sym2 = sym_check_expr_deps(sym->rev_dep.expr); | 1026 | sym2 = sym_check_expr_deps(sym->rev_dep.expr); |
| 806 | if (sym2) | 1027 | if (sym2) |
| 807 | return sym2; | 1028 | goto out; |
| 808 | 1029 | ||
| 809 | for (prop = sym->prop; prop; prop = prop->next) { | 1030 | for (prop = sym->prop; prop; prop = prop->next) { |
| 810 | if (prop->type == P_CHOICE || prop->type == P_SELECT) | 1031 | if (prop->type == P_CHOICE || prop->type == P_SELECT) |
| 811 | continue; | 1032 | continue; |
| 1033 | stack.prop = prop; | ||
| 812 | sym2 = sym_check_expr_deps(prop->visible.expr); | 1034 | sym2 = sym_check_expr_deps(prop->visible.expr); |
| 813 | if (sym2) | 1035 | if (sym2) |
| 814 | break; | 1036 | break; |
| 815 | if (prop->type != P_DEFAULT || sym_is_choice(sym)) | 1037 | if (prop->type != P_DEFAULT || sym_is_choice(sym)) |
| 816 | continue; | 1038 | continue; |
| 1039 | stack.expr = prop->expr; | ||
| 817 | sym2 = sym_check_expr_deps(prop->expr); | 1040 | sym2 = sym_check_expr_deps(prop->expr); |
| 818 | if (sym2) | 1041 | if (sym2) |
| 819 | break; | 1042 | break; |
| 1043 | stack.expr = NULL; | ||
| 820 | } | 1044 | } |
| 821 | 1045 | ||
| 1046 | out: | ||
| 1047 | dep_stack_remove(); | ||
| 1048 | |||
| 822 | return sym2; | 1049 | return sym2; |
| 823 | } | 1050 | } |
| 824 | 1051 | ||
| @@ -827,6 +1054,9 @@ static struct symbol *sym_check_choice_deps(struct symbol *choice) | |||
| 827 | struct symbol *sym, *sym2; | 1054 | struct symbol *sym, *sym2; |
| 828 | struct property *prop; | 1055 | struct property *prop; |
| 829 | struct expr *e; | 1056 | struct expr *e; |
| 1057 | struct dep_stack stack; | ||
| 1058 | |||
| 1059 | dep_stack_insert(&stack, choice); | ||
| 830 | 1060 | ||
| 831 | prop = sym_get_choice_prop(choice); | 1061 | prop = sym_get_choice_prop(choice); |
| 832 | expr_list_for_each_sym(prop->expr, e, sym) | 1062 | expr_list_for_each_sym(prop->expr, e, sym) |
| @@ -840,10 +1070,8 @@ static struct symbol *sym_check_choice_deps(struct symbol *choice) | |||
| 840 | 1070 | ||
| 841 | expr_list_for_each_sym(prop->expr, e, sym) { | 1071 | expr_list_for_each_sym(prop->expr, e, sym) { |
| 842 | sym2 = sym_check_sym_deps(sym); | 1072 | sym2 = sym_check_sym_deps(sym); |
| 843 | if (sym2) { | 1073 | if (sym2) |
| 844 | fprintf(stderr, " -> %s", sym->name); | ||
| 845 | break; | 1074 | break; |
| 846 | } | ||
| 847 | } | 1075 | } |
| 848 | out: | 1076 | out: |
| 849 | expr_list_for_each_sym(prop->expr, e, sym) | 1077 | expr_list_for_each_sym(prop->expr, e, sym) |
| @@ -853,6 +1081,8 @@ out: | |||
| 853 | prop_get_symbol(sym_get_choice_prop(sym2)) == choice) | 1081 | prop_get_symbol(sym_get_choice_prop(sym2)) == choice) |
| 854 | sym2 = choice; | 1082 | sym2 = choice; |
| 855 | 1083 | ||
| 1084 | dep_stack_remove(); | ||
| 1085 | |||
| 856 | return sym2; | 1086 | return sym2; |
| 857 | } | 1087 | } |
| 858 | 1088 | ||
| @@ -862,18 +1092,20 @@ struct symbol *sym_check_deps(struct symbol *sym) | |||
| 862 | struct property *prop; | 1092 | struct property *prop; |
| 863 | 1093 | ||
| 864 | if (sym->flags & SYMBOL_CHECK) { | 1094 | if (sym->flags & SYMBOL_CHECK) { |
| 865 | fprintf(stderr, "%s:%d:error: found recursive dependency: %s", | 1095 | sym_check_print_recursive(sym); |
| 866 | sym->prop->file->name, sym->prop->lineno, | ||
| 867 | sym->name ? sym->name : "<choice>"); | ||
| 868 | return sym; | 1096 | return sym; |
| 869 | } | 1097 | } |
| 870 | if (sym->flags & SYMBOL_CHECKED) | 1098 | if (sym->flags & SYMBOL_CHECKED) |
| 871 | return NULL; | 1099 | return NULL; |
| 872 | 1100 | ||
| 873 | if (sym_is_choice_value(sym)) { | 1101 | if (sym_is_choice_value(sym)) { |
| 1102 | struct dep_stack stack; | ||
| 1103 | |||
| 874 | /* for choice groups start the check with main choice symbol */ | 1104 | /* for choice groups start the check with main choice symbol */ |
| 1105 | dep_stack_insert(&stack, sym); | ||
| 875 | prop = sym_get_choice_prop(sym); | 1106 | prop = sym_get_choice_prop(sym); |
| 876 | sym2 = sym_check_deps(prop_get_symbol(prop)); | 1107 | sym2 = sym_check_deps(prop_get_symbol(prop)); |
| 1108 | dep_stack_remove(); | ||
| 877 | } else if (sym_is_choice(sym)) { | 1109 | } else if (sym_is_choice(sym)) { |
| 878 | sym2 = sym_check_choice_deps(sym); | 1110 | sym2 = sym_check_choice_deps(sym); |
| 879 | } else { | 1111 | } else { |
| @@ -882,14 +1114,8 @@ struct symbol *sym_check_deps(struct symbol *sym) | |||
| 882 | sym->flags &= ~SYMBOL_CHECK; | 1114 | sym->flags &= ~SYMBOL_CHECK; |
| 883 | } | 1115 | } |
| 884 | 1116 | ||
| 885 | if (sym2) { | 1117 | if (sym2 && sym2 == sym) |
| 886 | fprintf(stderr, " -> %s", sym->name ? sym->name : "<choice>"); | 1118 | sym2 = NULL; |
| 887 | if (sym2 == sym) { | ||
| 888 | fprintf(stderr, "\n"); | ||
| 889 | zconfnerrs++; | ||
| 890 | sym2 = NULL; | ||
| 891 | } | ||
| 892 | } | ||
| 893 | 1119 | ||
| 894 | return sym2; | 1120 | return sym2; |
| 895 | } | 1121 | } |
| @@ -943,6 +1169,8 @@ const char *prop_get_type_name(enum prop_type type) | |||
| 943 | return "select"; | 1169 | return "select"; |
| 944 | case P_RANGE: | 1170 | case P_RANGE: |
| 945 | return "range"; | 1171 | return "range"; |
| 1172 | case P_SYMBOL: | ||
| 1173 | return "symbol"; | ||
| 946 | case P_UNKNOWN: | 1174 | case P_UNKNOWN: |
| 947 | break; | 1175 | break; |
| 948 | } | 1176 | } |
diff --git a/scripts/kernel-doc b/scripts/kernel-doc index fcdfb245a575..102e1235fd5c 100755 --- a/scripts/kernel-doc +++ b/scripts/kernel-doc | |||
| @@ -1454,6 +1454,8 @@ sub dump_enum($$) { | |||
| 1454 | my $file = shift; | 1454 | my $file = shift; |
| 1455 | 1455 | ||
| 1456 | $x =~ s@/\*.*?\*/@@gos; # strip comments. | 1456 | $x =~ s@/\*.*?\*/@@gos; # strip comments. |
| 1457 | $x =~ s/^#\s*define\s+.*$//; # strip #define macros inside enums | ||
| 1458 | |||
| 1457 | if ($x =~ /enum\s+(\w+)\s*{(.*)}/) { | 1459 | if ($x =~ /enum\s+(\w+)\s*{(.*)}/) { |
| 1458 | $declaration_name = $1; | 1460 | $declaration_name = $1; |
| 1459 | my $members = $2; | 1461 | my $members = $2; |
diff --git a/scripts/mkmakefile b/scripts/mkmakefile index 67d59c7a18dc..5325423ceab4 100644 --- a/scripts/mkmakefile +++ b/scripts/mkmakefile | |||
| @@ -44,7 +44,9 @@ all: | |||
| 44 | 44 | ||
| 45 | Makefile:; | 45 | Makefile:; |
| 46 | 46 | ||
| 47 | \$(all) %/: all | 47 | \$(all): all |
| 48 | @: | 48 | @: |
| 49 | 49 | ||
| 50 | %/: all | ||
| 51 | @: | ||
| 50 | EOF | 52 | EOF |
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index 5758aab0d8bb..88f3f07205f8 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c | |||
| @@ -884,16 +884,16 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, | |||
| 884 | char *zeros = NULL; | 884 | char *zeros = NULL; |
| 885 | 885 | ||
| 886 | /* We're looking for a section relative symbol */ | 886 | /* We're looking for a section relative symbol */ |
| 887 | if (!sym->st_shndx || sym->st_shndx >= info->hdr->e_shnum) | 887 | if (!sym->st_shndx || get_secindex(info, sym) >= info->num_sections) |
| 888 | return; | 888 | return; |
| 889 | 889 | ||
| 890 | /* Handle all-NULL symbols allocated into .bss */ | 890 | /* Handle all-NULL symbols allocated into .bss */ |
| 891 | if (info->sechdrs[sym->st_shndx].sh_type & SHT_NOBITS) { | 891 | if (info->sechdrs[get_secindex(info, sym)].sh_type & SHT_NOBITS) { |
| 892 | zeros = calloc(1, sym->st_size); | 892 | zeros = calloc(1, sym->st_size); |
| 893 | symval = zeros; | 893 | symval = zeros; |
| 894 | } else { | 894 | } else { |
| 895 | symval = (void *)info->hdr | 895 | symval = (void *)info->hdr |
| 896 | + info->sechdrs[sym->st_shndx].sh_offset | 896 | + info->sechdrs[get_secindex(info, sym)].sh_offset |
| 897 | + sym->st_value; | 897 | + sym->st_value; |
| 898 | } | 898 | } |
| 899 | 899 | ||
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index f6127b9f5aca..1ec7158b6c1f 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c | |||
| @@ -14,6 +14,7 @@ | |||
| 14 | #define _GNU_SOURCE | 14 | #define _GNU_SOURCE |
| 15 | #include <stdio.h> | 15 | #include <stdio.h> |
| 16 | #include <ctype.h> | 16 | #include <ctype.h> |
| 17 | #include <string.h> | ||
| 17 | #include "modpost.h" | 18 | #include "modpost.h" |
| 18 | #include "../../include/generated/autoconf.h" | 19 | #include "../../include/generated/autoconf.h" |
| 19 | #include "../../include/linux/license.h" | 20 | #include "../../include/linux/license.h" |
| @@ -253,7 +254,7 @@ static enum export export_no(const char *s) | |||
| 253 | return export_unknown; | 254 | return export_unknown; |
| 254 | } | 255 | } |
| 255 | 256 | ||
| 256 | static enum export export_from_sec(struct elf_info *elf, Elf_Section sec) | 257 | static enum export export_from_sec(struct elf_info *elf, unsigned int sec) |
| 257 | { | 258 | { |
| 258 | if (sec == elf->export_sec) | 259 | if (sec == elf->export_sec) |
| 259 | return export_plain; | 260 | return export_plain; |
| @@ -373,6 +374,8 @@ static int parse_elf(struct elf_info *info, const char *filename) | |||
| 373 | Elf_Ehdr *hdr; | 374 | Elf_Ehdr *hdr; |
| 374 | Elf_Shdr *sechdrs; | 375 | Elf_Shdr *sechdrs; |
| 375 | Elf_Sym *sym; | 376 | Elf_Sym *sym; |
| 377 | const char *secstrings; | ||
| 378 | unsigned int symtab_idx = ~0U, symtab_shndx_idx = ~0U; | ||
| 376 | 379 | ||
| 377 | hdr = grab_file(filename, &info->size); | 380 | hdr = grab_file(filename, &info->size); |
| 378 | if (!hdr) { | 381 | if (!hdr) { |
| @@ -417,8 +420,27 @@ static int parse_elf(struct elf_info *info, const char *filename) | |||
| 417 | return 0; | 420 | return 0; |
| 418 | } | 421 | } |
| 419 | 422 | ||
| 423 | if (hdr->e_shnum == 0) { | ||
| 424 | /* | ||
| 425 | * There are more than 64k sections, | ||
| 426 | * read count from .sh_size. | ||
| 427 | * note: it doesn't need shndx2secindex() | ||
| 428 | */ | ||
| 429 | info->num_sections = TO_NATIVE(sechdrs[0].sh_size); | ||
| 430 | } | ||
| 431 | else { | ||
| 432 | info->num_sections = hdr->e_shnum; | ||
| 433 | } | ||
| 434 | if (hdr->e_shstrndx == SHN_XINDEX) { | ||
| 435 | info->secindex_strings = | ||
| 436 | shndx2secindex(TO_NATIVE(sechdrs[0].sh_link)); | ||
| 437 | } | ||
| 438 | else { | ||
| 439 | info->secindex_strings = hdr->e_shstrndx; | ||
| 440 | } | ||
| 441 | |||
| 420 | /* Fix endianness in section headers */ | 442 | /* Fix endianness in section headers */ |
| 421 | for (i = 0; i < hdr->e_shnum; i++) { | 443 | for (i = 0; i < info->num_sections; i++) { |
| 422 | sechdrs[i].sh_name = TO_NATIVE(sechdrs[i].sh_name); | 444 | sechdrs[i].sh_name = TO_NATIVE(sechdrs[i].sh_name); |
| 423 | sechdrs[i].sh_type = TO_NATIVE(sechdrs[i].sh_type); | 445 | sechdrs[i].sh_type = TO_NATIVE(sechdrs[i].sh_type); |
| 424 | sechdrs[i].sh_flags = TO_NATIVE(sechdrs[i].sh_flags); | 446 | sechdrs[i].sh_flags = TO_NATIVE(sechdrs[i].sh_flags); |
| @@ -431,9 +453,8 @@ static int parse_elf(struct elf_info *info, const char *filename) | |||
| 431 | sechdrs[i].sh_entsize = TO_NATIVE(sechdrs[i].sh_entsize); | 453 | sechdrs[i].sh_entsize = TO_NATIVE(sechdrs[i].sh_entsize); |
| 432 | } | 454 | } |
| 433 | /* Find symbol table. */ | 455 | /* Find symbol table. */ |
| 434 | for (i = 1; i < hdr->e_shnum; i++) { | 456 | secstrings = (void *)hdr + sechdrs[info->secindex_strings].sh_offset; |
| 435 | const char *secstrings | 457 | for (i = 1; i < info->num_sections; i++) { |
| 436 | = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset; | ||
| 437 | const char *secname; | 458 | const char *secname; |
| 438 | int nobits = sechdrs[i].sh_type == SHT_NOBITS; | 459 | int nobits = sechdrs[i].sh_type == SHT_NOBITS; |
| 439 | 460 | ||
| @@ -461,14 +482,26 @@ static int parse_elf(struct elf_info *info, const char *filename) | |||
| 461 | else if (strcmp(secname, "__ksymtab_gpl_future") == 0) | 482 | else if (strcmp(secname, "__ksymtab_gpl_future") == 0) |
| 462 | info->export_gpl_future_sec = i; | 483 | info->export_gpl_future_sec = i; |
| 463 | 484 | ||
| 464 | if (sechdrs[i].sh_type != SHT_SYMTAB) | 485 | if (sechdrs[i].sh_type == SHT_SYMTAB) { |
| 465 | continue; | 486 | unsigned int sh_link_idx; |
| 487 | symtab_idx = i; | ||
| 488 | info->symtab_start = (void *)hdr + | ||
| 489 | sechdrs[i].sh_offset; | ||
| 490 | info->symtab_stop = (void *)hdr + | ||
| 491 | sechdrs[i].sh_offset + sechdrs[i].sh_size; | ||
| 492 | sh_link_idx = shndx2secindex(sechdrs[i].sh_link); | ||
| 493 | info->strtab = (void *)hdr + | ||
| 494 | sechdrs[sh_link_idx].sh_offset; | ||
| 495 | } | ||
| 466 | 496 | ||
| 467 | info->symtab_start = (void *)hdr + sechdrs[i].sh_offset; | 497 | /* 32bit section no. table? ("more than 64k sections") */ |
| 468 | info->symtab_stop = (void *)hdr + sechdrs[i].sh_offset | 498 | if (sechdrs[i].sh_type == SHT_SYMTAB_SHNDX) { |
| 469 | + sechdrs[i].sh_size; | 499 | symtab_shndx_idx = i; |
| 470 | info->strtab = (void *)hdr + | 500 | info->symtab_shndx_start = (void *)hdr + |
| 471 | sechdrs[sechdrs[i].sh_link].sh_offset; | 501 | sechdrs[i].sh_offset; |
| 502 | info->symtab_shndx_stop = (void *)hdr + | ||
| 503 | sechdrs[i].sh_offset + sechdrs[i].sh_size; | ||
| 504 | } | ||
| 472 | } | 505 | } |
| 473 | if (!info->symtab_start) | 506 | if (!info->symtab_start) |
| 474 | fatal("%s has no symtab?\n", filename); | 507 | fatal("%s has no symtab?\n", filename); |
| @@ -480,6 +513,21 @@ static int parse_elf(struct elf_info *info, const char *filename) | |||
| 480 | sym->st_value = TO_NATIVE(sym->st_value); | 513 | sym->st_value = TO_NATIVE(sym->st_value); |
| 481 | sym->st_size = TO_NATIVE(sym->st_size); | 514 | sym->st_size = TO_NATIVE(sym->st_size); |
| 482 | } | 515 | } |
| 516 | |||
| 517 | if (symtab_shndx_idx != ~0U) { | ||
| 518 | Elf32_Word *p; | ||
| 519 | if (symtab_idx != | ||
| 520 | shndx2secindex(sechdrs[symtab_shndx_idx].sh_link)) | ||
| 521 | fatal("%s: SYMTAB_SHNDX has bad sh_link: %u!=%u\n", | ||
| 522 | filename, | ||
| 523 | shndx2secindex(sechdrs[symtab_shndx_idx].sh_link), | ||
| 524 | symtab_idx); | ||
| 525 | /* Fix endianness */ | ||
| 526 | for (p = info->symtab_shndx_start; p < info->symtab_shndx_stop; | ||
| 527 | p++) | ||
| 528 | *p = TO_NATIVE(*p); | ||
| 529 | } | ||
| 530 | |||
| 483 | return 1; | 531 | return 1; |
| 484 | } | 532 | } |
| 485 | 533 | ||
| @@ -519,7 +567,7 @@ static void handle_modversions(struct module *mod, struct elf_info *info, | |||
| 519 | Elf_Sym *sym, const char *symname) | 567 | Elf_Sym *sym, const char *symname) |
| 520 | { | 568 | { |
| 521 | unsigned int crc; | 569 | unsigned int crc; |
| 522 | enum export export = export_from_sec(info, sym->st_shndx); | 570 | enum export export = export_from_sec(info, get_secindex(info, sym)); |
| 523 | 571 | ||
| 524 | switch (sym->st_shndx) { | 572 | switch (sym->st_shndx) { |
| 525 | case SHN_COMMON: | 573 | case SHN_COMMON: |
| @@ -661,19 +709,19 @@ static const char *sym_name(struct elf_info *elf, Elf_Sym *sym) | |||
| 661 | return "(unknown)"; | 709 | return "(unknown)"; |
| 662 | } | 710 | } |
| 663 | 711 | ||
| 664 | static const char *sec_name(struct elf_info *elf, int shndx) | 712 | static const char *sec_name(struct elf_info *elf, int secindex) |
| 665 | { | 713 | { |
| 666 | Elf_Shdr *sechdrs = elf->sechdrs; | 714 | Elf_Shdr *sechdrs = elf->sechdrs; |
| 667 | return (void *)elf->hdr + | 715 | return (void *)elf->hdr + |
| 668 | elf->sechdrs[elf->hdr->e_shstrndx].sh_offset + | 716 | elf->sechdrs[elf->secindex_strings].sh_offset + |
| 669 | sechdrs[shndx].sh_name; | 717 | sechdrs[secindex].sh_name; |
| 670 | } | 718 | } |
| 671 | 719 | ||
| 672 | static const char *sech_name(struct elf_info *elf, Elf_Shdr *sechdr) | 720 | static const char *sech_name(struct elf_info *elf, Elf_Shdr *sechdr) |
| 673 | { | 721 | { |
| 674 | return (void *)elf->hdr + | 722 | return (void *)elf->hdr + |
| 675 | elf->sechdrs[elf->hdr->e_shstrndx].sh_offset + | 723 | elf->sechdrs[elf->secindex_strings].sh_offset + |
| 676 | sechdr->sh_name; | 724 | sechdr->sh_name; |
| 677 | } | 725 | } |
| 678 | 726 | ||
| 679 | /* if sym is empty or point to a string | 727 | /* if sym is empty or point to a string |
| @@ -742,6 +790,7 @@ static const char *section_white_list[] = | |||
| 742 | { | 790 | { |
| 743 | ".comment*", | 791 | ".comment*", |
| 744 | ".debug*", | 792 | ".debug*", |
| 793 | ".GCC-command-line", /* mn10300 */ | ||
| 745 | ".mdebug*", /* alpha, score, mips etc. */ | 794 | ".mdebug*", /* alpha, score, mips etc. */ |
| 746 | ".pdr", /* alpha, score, mips etc. */ | 795 | ".pdr", /* alpha, score, mips etc. */ |
| 747 | ".stab*", | 796 | ".stab*", |
| @@ -986,6 +1035,13 @@ static const struct sectioncheck *section_mismatch( | |||
| 986 | * fromsec = .data* | 1035 | * fromsec = .data* |
| 987 | * atsym =__param* | 1036 | * atsym =__param* |
| 988 | * | 1037 | * |
| 1038 | * Pattern 1a: | ||
| 1039 | * module_param_call() ops can refer to __init set function if permissions=0 | ||
| 1040 | * The pattern is identified by: | ||
| 1041 | * tosec = .init.text | ||
| 1042 | * fromsec = .data* | ||
| 1043 | * atsym = __param_ops_* | ||
| 1044 | * | ||
| 989 | * Pattern 2: | 1045 | * Pattern 2: |
| 990 | * Many drivers utilise a *driver container with references to | 1046 | * Many drivers utilise a *driver container with references to |
| 991 | * add, remove, probe functions etc. | 1047 | * add, remove, probe functions etc. |
| @@ -1020,6 +1076,12 @@ static int secref_whitelist(const struct sectioncheck *mismatch, | |||
| 1020 | (strncmp(fromsym, "__param", strlen("__param")) == 0)) | 1076 | (strncmp(fromsym, "__param", strlen("__param")) == 0)) |
| 1021 | return 0; | 1077 | return 0; |
| 1022 | 1078 | ||
| 1079 | /* Check for pattern 1a */ | ||
| 1080 | if (strcmp(tosec, ".init.text") == 0 && | ||
| 1081 | match(fromsec, data_sections) && | ||
| 1082 | (strncmp(fromsym, "__param_ops_", strlen("__param_ops_")) == 0)) | ||
| 1083 | return 0; | ||
| 1084 | |||
| 1023 | /* Check for pattern 2 */ | 1085 | /* Check for pattern 2 */ |
| 1024 | if (match(tosec, init_exit_sections) && | 1086 | if (match(tosec, init_exit_sections) && |
| 1025 | match(fromsec, data_sections) && | 1087 | match(fromsec, data_sections) && |
| @@ -1052,11 +1114,14 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr, | |||
| 1052 | Elf_Sym *near = NULL; | 1114 | Elf_Sym *near = NULL; |
| 1053 | Elf64_Sword distance = 20; | 1115 | Elf64_Sword distance = 20; |
| 1054 | Elf64_Sword d; | 1116 | Elf64_Sword d; |
| 1117 | unsigned int relsym_secindex; | ||
| 1055 | 1118 | ||
| 1056 | if (relsym->st_name != 0) | 1119 | if (relsym->st_name != 0) |
| 1057 | return relsym; | 1120 | return relsym; |
| 1121 | |||
| 1122 | relsym_secindex = get_secindex(elf, relsym); | ||
| 1058 | for (sym = elf->symtab_start; sym < elf->symtab_stop; sym++) { | 1123 | for (sym = elf->symtab_start; sym < elf->symtab_stop; sym++) { |
| 1059 | if (sym->st_shndx != relsym->st_shndx) | 1124 | if (get_secindex(elf, sym) != relsym_secindex) |
| 1060 | continue; | 1125 | continue; |
| 1061 | if (ELF_ST_TYPE(sym->st_info) == STT_SECTION) | 1126 | if (ELF_ST_TYPE(sym->st_info) == STT_SECTION) |
| 1062 | continue; | 1127 | continue; |
| @@ -1118,9 +1183,9 @@ static Elf_Sym *find_elf_symbol2(struct elf_info *elf, Elf_Addr addr, | |||
| 1118 | for (sym = elf->symtab_start; sym < elf->symtab_stop; sym++) { | 1183 | for (sym = elf->symtab_start; sym < elf->symtab_stop; sym++) { |
| 1119 | const char *symsec; | 1184 | const char *symsec; |
| 1120 | 1185 | ||
| 1121 | if (sym->st_shndx >= SHN_LORESERVE) | 1186 | if (is_shndx_special(sym->st_shndx)) |
| 1122 | continue; | 1187 | continue; |
| 1123 | symsec = sec_name(elf, sym->st_shndx); | 1188 | symsec = sec_name(elf, get_secindex(elf, sym)); |
| 1124 | if (strcmp(symsec, sec) != 0) | 1189 | if (strcmp(symsec, sec) != 0) |
| 1125 | continue; | 1190 | continue; |
| 1126 | if (!is_valid_name(elf, sym)) | 1191 | if (!is_valid_name(elf, sym)) |
| @@ -1167,7 +1232,7 @@ static char *sec2annotation(const char *s) | |||
| 1167 | strcat(p, " "); | 1232 | strcat(p, " "); |
| 1168 | return r; /* we leak her but we do not care */ | 1233 | return r; /* we leak her but we do not care */ |
| 1169 | } else { | 1234 | } else { |
| 1170 | return ""; | 1235 | return strdup(""); |
| 1171 | } | 1236 | } |
| 1172 | } | 1237 | } |
| 1173 | 1238 | ||
| @@ -1195,6 +1260,8 @@ static void report_sec_mismatch(const char *modname, | |||
| 1195 | { | 1260 | { |
| 1196 | const char *from, *from_p; | 1261 | const char *from, *from_p; |
| 1197 | const char *to, *to_p; | 1262 | const char *to, *to_p; |
| 1263 | char *prl_from; | ||
| 1264 | char *prl_to; | ||
| 1198 | 1265 | ||
| 1199 | switch (from_is_func) { | 1266 | switch (from_is_func) { |
| 1200 | case 0: from = "variable"; from_p = ""; break; | 1267 | case 0: from = "variable"; from_p = ""; break; |
| @@ -1218,16 +1285,21 @@ static void report_sec_mismatch(const char *modname, | |||
| 1218 | 1285 | ||
| 1219 | switch (mismatch->mismatch) { | 1286 | switch (mismatch->mismatch) { |
| 1220 | case TEXT_TO_ANY_INIT: | 1287 | case TEXT_TO_ANY_INIT: |
| 1288 | prl_from = sec2annotation(fromsec); | ||
| 1289 | prl_to = sec2annotation(tosec); | ||
| 1221 | fprintf(stderr, | 1290 | fprintf(stderr, |
| 1222 | "The function %s%s() references\n" | 1291 | "The function %s%s() references\n" |
| 1223 | "the %s %s%s%s.\n" | 1292 | "the %s %s%s%s.\n" |
| 1224 | "This is often because %s lacks a %s\n" | 1293 | "This is often because %s lacks a %s\n" |
| 1225 | "annotation or the annotation of %s is wrong.\n", | 1294 | "annotation or the annotation of %s is wrong.\n", |
| 1226 | sec2annotation(fromsec), fromsym, | 1295 | prl_from, fromsym, |
| 1227 | to, sec2annotation(tosec), tosym, to_p, | 1296 | to, prl_to, tosym, to_p, |
| 1228 | fromsym, sec2annotation(tosec), tosym); | 1297 | fromsym, prl_to, tosym); |
| 1298 | free(prl_from); | ||
| 1299 | free(prl_to); | ||
| 1229 | break; | 1300 | break; |
| 1230 | case DATA_TO_ANY_INIT: { | 1301 | case DATA_TO_ANY_INIT: { |
| 1302 | prl_to = sec2annotation(tosec); | ||
| 1231 | const char *const *s = mismatch->symbol_white_list; | 1303 | const char *const *s = mismatch->symbol_white_list; |
| 1232 | fprintf(stderr, | 1304 | fprintf(stderr, |
| 1233 | "The variable %s references\n" | 1305 | "The variable %s references\n" |
| @@ -1235,20 +1307,24 @@ static void report_sec_mismatch(const char *modname, | |||
| 1235 | "If the reference is valid then annotate the\n" | 1307 | "If the reference is valid then annotate the\n" |
| 1236 | "variable with __init* or __refdata (see linux/init.h) " | 1308 | "variable with __init* or __refdata (see linux/init.h) " |
| 1237 | "or name the variable:\n", | 1309 | "or name the variable:\n", |
| 1238 | fromsym, to, sec2annotation(tosec), tosym, to_p); | 1310 | fromsym, to, prl_to, tosym, to_p); |
| 1239 | while (*s) | 1311 | while (*s) |
| 1240 | fprintf(stderr, "%s, ", *s++); | 1312 | fprintf(stderr, "%s, ", *s++); |
| 1241 | fprintf(stderr, "\n"); | 1313 | fprintf(stderr, "\n"); |
| 1314 | free(prl_to); | ||
| 1242 | break; | 1315 | break; |
| 1243 | } | 1316 | } |
| 1244 | case TEXT_TO_ANY_EXIT: | 1317 | case TEXT_TO_ANY_EXIT: |
| 1318 | prl_to = sec2annotation(tosec); | ||
| 1245 | fprintf(stderr, | 1319 | fprintf(stderr, |
| 1246 | "The function %s() references a %s in an exit section.\n" | 1320 | "The function %s() references a %s in an exit section.\n" |
| 1247 | "Often the %s %s%s has valid usage outside the exit section\n" | 1321 | "Often the %s %s%s has valid usage outside the exit section\n" |
| 1248 | "and the fix is to remove the %sannotation of %s.\n", | 1322 | "and the fix is to remove the %sannotation of %s.\n", |
| 1249 | fromsym, to, to, tosym, to_p, sec2annotation(tosec), tosym); | 1323 | fromsym, to, to, tosym, to_p, prl_to, tosym); |
| 1324 | free(prl_to); | ||
| 1250 | break; | 1325 | break; |
| 1251 | case DATA_TO_ANY_EXIT: { | 1326 | case DATA_TO_ANY_EXIT: { |
| 1327 | prl_to = sec2annotation(tosec); | ||
| 1252 | const char *const *s = mismatch->symbol_white_list; | 1328 | const char *const *s = mismatch->symbol_white_list; |
| 1253 | fprintf(stderr, | 1329 | fprintf(stderr, |
| 1254 | "The variable %s references\n" | 1330 | "The variable %s references\n" |
| @@ -1256,24 +1332,31 @@ static void report_sec_mismatch(const char *modname, | |||
| 1256 | "If the reference is valid then annotate the\n" | 1332 | "If the reference is valid then annotate the\n" |
| 1257 | "variable with __exit* (see linux/init.h) or " | 1333 | "variable with __exit* (see linux/init.h) or " |
| 1258 | "name the variable:\n", | 1334 | "name the variable:\n", |
| 1259 | fromsym, to, sec2annotation(tosec), tosym, to_p); | 1335 | fromsym, to, prl_to, tosym, to_p); |
| 1260 | while (*s) | 1336 | while (*s) |
| 1261 | fprintf(stderr, "%s, ", *s++); | 1337 | fprintf(stderr, "%s, ", *s++); |
| 1262 | fprintf(stderr, "\n"); | 1338 | fprintf(stderr, "\n"); |
| 1339 | free(prl_to); | ||
| 1263 | break; | 1340 | break; |
| 1264 | } | 1341 | } |
| 1265 | case XXXINIT_TO_SOME_INIT: | 1342 | case XXXINIT_TO_SOME_INIT: |
| 1266 | case XXXEXIT_TO_SOME_EXIT: | 1343 | case XXXEXIT_TO_SOME_EXIT: |
| 1344 | prl_from = sec2annotation(fromsec); | ||
| 1345 | prl_to = sec2annotation(tosec); | ||
| 1267 | fprintf(stderr, | 1346 | fprintf(stderr, |
| 1268 | "The %s %s%s%s references\n" | 1347 | "The %s %s%s%s references\n" |
| 1269 | "a %s %s%s%s.\n" | 1348 | "a %s %s%s%s.\n" |
| 1270 | "If %s is only used by %s then\n" | 1349 | "If %s is only used by %s then\n" |
| 1271 | "annotate %s with a matching annotation.\n", | 1350 | "annotate %s with a matching annotation.\n", |
| 1272 | from, sec2annotation(fromsec), fromsym, from_p, | 1351 | from, prl_from, fromsym, from_p, |
| 1273 | to, sec2annotation(tosec), tosym, to_p, | 1352 | to, prl_to, tosym, to_p, |
| 1274 | tosym, fromsym, tosym); | 1353 | tosym, fromsym, tosym); |
| 1354 | free(prl_from); | ||
| 1355 | free(prl_to); | ||
| 1275 | break; | 1356 | break; |
| 1276 | case ANY_INIT_TO_ANY_EXIT: | 1357 | case ANY_INIT_TO_ANY_EXIT: |
| 1358 | prl_from = sec2annotation(fromsec); | ||
| 1359 | prl_to = sec2annotation(tosec); | ||
| 1277 | fprintf(stderr, | 1360 | fprintf(stderr, |
| 1278 | "The %s %s%s%s references\n" | 1361 | "The %s %s%s%s references\n" |
| 1279 | "a %s %s%s%s.\n" | 1362 | "a %s %s%s%s.\n" |
| @@ -1282,11 +1365,15 @@ static void report_sec_mismatch(const char *modname, | |||
| 1282 | "uses functionality in the exit path.\n" | 1365 | "uses functionality in the exit path.\n" |
| 1283 | "The fix is often to remove the %sannotation of\n" | 1366 | "The fix is often to remove the %sannotation of\n" |
| 1284 | "%s%s so it may be used outside an exit section.\n", | 1367 | "%s%s so it may be used outside an exit section.\n", |
| 1285 | from, sec2annotation(fromsec), fromsym, from_p, | 1368 | from, prl_from, fromsym, from_p, |
| 1286 | to, sec2annotation(tosec), tosym, to_p, | 1369 | to, prl_to, tosym, to_p, |
| 1287 | sec2annotation(tosec), tosym, to_p); | 1370 | prl_to, tosym, to_p); |
| 1371 | free(prl_from); | ||
| 1372 | free(prl_to); | ||
| 1288 | break; | 1373 | break; |
| 1289 | case ANY_EXIT_TO_ANY_INIT: | 1374 | case ANY_EXIT_TO_ANY_INIT: |
| 1375 | prl_from = sec2annotation(fromsec); | ||
| 1376 | prl_to = sec2annotation(tosec); | ||
| 1290 | fprintf(stderr, | 1377 | fprintf(stderr, |
| 1291 | "The %s %s%s%s references\n" | 1378 | "The %s %s%s%s references\n" |
| 1292 | "a %s %s%s%s.\n" | 1379 | "a %s %s%s%s.\n" |
| @@ -1295,16 +1382,20 @@ static void report_sec_mismatch(const char *modname, | |||
| 1295 | "uses functionality in the init path.\n" | 1382 | "uses functionality in the init path.\n" |
| 1296 | "The fix is often to remove the %sannotation of\n" | 1383 | "The fix is often to remove the %sannotation of\n" |
| 1297 | "%s%s so it may be used outside an init section.\n", | 1384 | "%s%s so it may be used outside an init section.\n", |
| 1298 | from, sec2annotation(fromsec), fromsym, from_p, | 1385 | from, prl_from, fromsym, from_p, |
| 1299 | to, sec2annotation(tosec), tosym, to_p, | 1386 | to, prl_to, tosym, to_p, |
| 1300 | sec2annotation(tosec), tosym, to_p); | 1387 | prl_to, tosym, to_p); |
| 1388 | free(prl_from); | ||
| 1389 | free(prl_to); | ||
| 1301 | break; | 1390 | break; |
| 1302 | case EXPORT_TO_INIT_EXIT: | 1391 | case EXPORT_TO_INIT_EXIT: |
| 1392 | prl_to = sec2annotation(tosec); | ||
| 1303 | fprintf(stderr, | 1393 | fprintf(stderr, |
| 1304 | "The symbol %s is exported and annotated %s\n" | 1394 | "The symbol %s is exported and annotated %s\n" |
| 1305 | "Fix this by removing the %sannotation of %s " | 1395 | "Fix this by removing the %sannotation of %s " |
| 1306 | "or drop the export.\n", | 1396 | "or drop the export.\n", |
| 1307 | tosym, sec2annotation(tosec), sec2annotation(tosec), tosym); | 1397 | tosym, prl_to, prl_to, tosym); |
| 1398 | free(prl_to); | ||
| 1308 | break; | 1399 | break; |
| 1309 | } | 1400 | } |
| 1310 | fprintf(stderr, "\n"); | 1401 | fprintf(stderr, "\n"); |
| @@ -1316,7 +1407,7 @@ static void check_section_mismatch(const char *modname, struct elf_info *elf, | |||
| 1316 | const char *tosec; | 1407 | const char *tosec; |
| 1317 | const struct sectioncheck *mismatch; | 1408 | const struct sectioncheck *mismatch; |
| 1318 | 1409 | ||
| 1319 | tosec = sec_name(elf, sym->st_shndx); | 1410 | tosec = sec_name(elf, get_secindex(elf, sym)); |
| 1320 | mismatch = section_mismatch(fromsec, tosec); | 1411 | mismatch = section_mismatch(fromsec, tosec); |
| 1321 | if (mismatch) { | 1412 | if (mismatch) { |
| 1322 | Elf_Sym *to; | 1413 | Elf_Sym *to; |
| @@ -1344,7 +1435,7 @@ static unsigned int *reloc_location(struct elf_info *elf, | |||
| 1344 | Elf_Shdr *sechdr, Elf_Rela *r) | 1435 | Elf_Shdr *sechdr, Elf_Rela *r) |
| 1345 | { | 1436 | { |
| 1346 | Elf_Shdr *sechdrs = elf->sechdrs; | 1437 | Elf_Shdr *sechdrs = elf->sechdrs; |
| 1347 | int section = sechdr->sh_info; | 1438 | int section = shndx2secindex(sechdr->sh_info); |
| 1348 | 1439 | ||
| 1349 | return (void *)elf->hdr + sechdrs[section].sh_offset + | 1440 | return (void *)elf->hdr + sechdrs[section].sh_offset + |
| 1350 | r->r_offset - sechdrs[section].sh_addr; | 1441 | r->r_offset - sechdrs[section].sh_addr; |
| @@ -1452,7 +1543,7 @@ static void section_rela(const char *modname, struct elf_info *elf, | |||
| 1452 | r.r_addend = TO_NATIVE(rela->r_addend); | 1543 | r.r_addend = TO_NATIVE(rela->r_addend); |
| 1453 | sym = elf->symtab_start + r_sym; | 1544 | sym = elf->symtab_start + r_sym; |
| 1454 | /* Skip special sections */ | 1545 | /* Skip special sections */ |
| 1455 | if (sym->st_shndx >= SHN_LORESERVE) | 1546 | if (is_shndx_special(sym->st_shndx)) |
| 1456 | continue; | 1547 | continue; |
| 1457 | check_section_mismatch(modname, elf, &r, sym, fromsec); | 1548 | check_section_mismatch(modname, elf, &r, sym, fromsec); |
| 1458 | } | 1549 | } |
| @@ -1510,7 +1601,7 @@ static void section_rel(const char *modname, struct elf_info *elf, | |||
| 1510 | } | 1601 | } |
| 1511 | sym = elf->symtab_start + r_sym; | 1602 | sym = elf->symtab_start + r_sym; |
| 1512 | /* Skip special sections */ | 1603 | /* Skip special sections */ |
| 1513 | if (sym->st_shndx >= SHN_LORESERVE) | 1604 | if (is_shndx_special(sym->st_shndx)) |
| 1514 | continue; | 1605 | continue; |
| 1515 | check_section_mismatch(modname, elf, &r, sym, fromsec); | 1606 | check_section_mismatch(modname, elf, &r, sym, fromsec); |
| 1516 | } | 1607 | } |
| @@ -1535,7 +1626,7 @@ static void check_sec_ref(struct module *mod, const char *modname, | |||
| 1535 | Elf_Shdr *sechdrs = elf->sechdrs; | 1626 | Elf_Shdr *sechdrs = elf->sechdrs; |
| 1536 | 1627 | ||
| 1537 | /* Walk through all sections */ | 1628 | /* Walk through all sections */ |
| 1538 | for (i = 0; i < elf->hdr->e_shnum; i++) { | 1629 | for (i = 0; i < elf->num_sections; i++) { |
| 1539 | check_section(modname, elf, &elf->sechdrs[i]); | 1630 | check_section(modname, elf, &elf->sechdrs[i]); |
| 1540 | /* We want to process only relocation sections and not .init */ | 1631 | /* We want to process only relocation sections and not .init */ |
| 1541 | if (sechdrs[i].sh_type == SHT_RELA) | 1632 | if (sechdrs[i].sh_type == SHT_RELA) |
diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h index be987a44f250..0388cfccac8d 100644 --- a/scripts/mod/modpost.h +++ b/scripts/mod/modpost.h | |||
| @@ -129,8 +129,51 @@ struct elf_info { | |||
| 129 | const char *strtab; | 129 | const char *strtab; |
| 130 | char *modinfo; | 130 | char *modinfo; |
| 131 | unsigned int modinfo_len; | 131 | unsigned int modinfo_len; |
| 132 | |||
| 133 | /* support for 32bit section numbers */ | ||
| 134 | |||
| 135 | unsigned int num_sections; /* max_secindex + 1 */ | ||
| 136 | unsigned int secindex_strings; | ||
| 137 | /* if Nth symbol table entry has .st_shndx = SHN_XINDEX, | ||
| 138 | * take shndx from symtab_shndx_start[N] instead */ | ||
| 139 | Elf32_Word *symtab_shndx_start; | ||
| 140 | Elf32_Word *symtab_shndx_stop; | ||
| 132 | }; | 141 | }; |
| 133 | 142 | ||
| 143 | static inline int is_shndx_special(unsigned int i) | ||
| 144 | { | ||
| 145 | return i != SHN_XINDEX && i >= SHN_LORESERVE && i <= SHN_HIRESERVE; | ||
| 146 | } | ||
| 147 | |||
| 148 | /* shndx is in [0..SHN_LORESERVE) U (SHN_HIRESERVE, 0xfffffff], thus: | ||
| 149 | * shndx == 0 <=> sechdrs[0] | ||
| 150 | * ...... | ||
| 151 | * shndx == SHN_LORESERVE-1 <=> sechdrs[SHN_LORESERVE-1] | ||
| 152 | * shndx == SHN_HIRESERVE+1 <=> sechdrs[SHN_LORESERVE] | ||
| 153 | * shndx == SHN_HIRESERVE+2 <=> sechdrs[SHN_LORESERVE+1] | ||
| 154 | * ...... | ||
| 155 | * fyi: sym->st_shndx is uint16, SHN_LORESERVE = ff00, SHN_HIRESERVE = ffff, | ||
| 156 | * so basically we map 0000..feff -> 0000..feff | ||
| 157 | * ff00..ffff -> (you are a bad boy, dont do it) | ||
| 158 | * 10000..xxxx -> ff00..(xxxx-0x100) | ||
| 159 | */ | ||
| 160 | static inline unsigned int shndx2secindex(unsigned int i) | ||
| 161 | { | ||
| 162 | if (i <= SHN_HIRESERVE) | ||
| 163 | return i; | ||
| 164 | return i - (SHN_HIRESERVE + 1 - SHN_LORESERVE); | ||
| 165 | } | ||
| 166 | |||
| 167 | /* Accessor for sym->st_shndx, hides ugliness of "64k sections" */ | ||
| 168 | static inline unsigned int get_secindex(const struct elf_info *info, | ||
| 169 | const Elf_Sym *sym) | ||
| 170 | { | ||
| 171 | if (sym->st_shndx != SHN_XINDEX) | ||
| 172 | return sym->st_shndx; | ||
| 173 | return shndx2secindex(info->symtab_shndx_start[sym - | ||
| 174 | info->symtab_start]); | ||
| 175 | } | ||
| 176 | |||
| 134 | /* file2alias.c */ | 177 | /* file2alias.c */ |
| 135 | extern unsigned int cross_build; | 178 | extern unsigned int cross_build; |
| 136 | void handle_moddevtable(struct module *mod, struct elf_info *info, | 179 | void handle_moddevtable(struct module *mod, struct elf_info *info, |
diff --git a/scripts/package/Makefile b/scripts/package/Makefile index d2c29b63adda..d0b931b994fc 100644 --- a/scripts/package/Makefile +++ b/scripts/package/Makefile | |||
| @@ -111,13 +111,38 @@ tar%pkg: FORCE | |||
| 111 | clean-dirs += $(objtree)/tar-install/ | 111 | clean-dirs += $(objtree)/tar-install/ |
| 112 | 112 | ||
| 113 | 113 | ||
| 114 | # perf-pkg - generate a source tarball with perf source | ||
| 115 | # --------------------------------------------------------------------------- | ||
| 116 | |||
| 117 | perf-tar=perf-$(KERNELVERSION) | ||
| 118 | |||
| 119 | quiet_cmd_perf_tar = TAR | ||
| 120 | cmd_perf_tar = \ | ||
| 121 | git archive --prefix=$(perf-tar)/ HEAD^{tree} \ | ||
| 122 | $$(cat $(srctree)/tools/perf/MANIFEST) -o $(perf-tar).tar; \ | ||
| 123 | mkdir -p $(perf-tar); \ | ||
| 124 | git rev-parse HEAD > $(perf-tar)/HEAD; \ | ||
| 125 | tar rf $(perf-tar).tar $(perf-tar)/HEAD; \ | ||
| 126 | rm -r $(perf-tar); \ | ||
| 127 | $(if $(findstring tar-src,$@),, \ | ||
| 128 | $(if $(findstring bz2,$@),bzip2, \ | ||
| 129 | $(if $(findstring gz,$@),gzip, \ | ||
| 130 | $(error unknown target $@))) \ | ||
| 131 | -f -9 $(perf-tar).tar) | ||
| 132 | |||
| 133 | perf-%pkg: FORCE | ||
| 134 | $(call cmd,perf_tar) | ||
| 135 | |||
| 114 | # Help text displayed when executing 'make help' | 136 | # Help text displayed when executing 'make help' |
| 115 | # --------------------------------------------------------------------------- | 137 | # --------------------------------------------------------------------------- |
| 116 | help: FORCE | 138 | help: FORCE |
| 117 | @echo ' rpm-pkg - Build both source and binary RPM kernel packages' | 139 | @echo ' rpm-pkg - Build both source and binary RPM kernel packages' |
| 118 | @echo ' binrpm-pkg - Build only the binary kernel package' | 140 | @echo ' binrpm-pkg - Build only the binary kernel package' |
| 119 | @echo ' deb-pkg - Build the kernel as an deb package' | 141 | @echo ' deb-pkg - Build the kernel as an deb package' |
| 120 | @echo ' tar-pkg - Build the kernel as an uncompressed tarball' | 142 | @echo ' tar-pkg - Build the kernel as an uncompressed tarball' |
| 121 | @echo ' targz-pkg - Build the kernel as a gzip compressed tarball' | 143 | @echo ' targz-pkg - Build the kernel as a gzip compressed tarball' |
| 122 | @echo ' tarbz2-pkg - Build the kernel as a bzip2 compressed tarball' | 144 | @echo ' tarbz2-pkg - Build the kernel as a bzip2 compressed tarball' |
| 145 | @echo ' perf-tar-src-pkg - Build $(perf-tar).tar source tarball' | ||
| 146 | @echo ' perf-targz-src-pkg - Build $(perf-tar).tar.gz source tarball' | ||
| 147 | @echo ' perf-tarbz2-src-pkg - Build $(perf-tar).tar.bz2 source tarball' | ||
| 123 | 148 | ||
diff --git a/scripts/package/builddeb b/scripts/package/builddeb index 07f2fbde2abf..5f1e2fc7f171 100644 --- a/scripts/package/builddeb +++ b/scripts/package/builddeb | |||
| @@ -148,10 +148,11 @@ EOF | |||
| 148 | # Generate a control file | 148 | # Generate a control file |
| 149 | cat <<EOF > debian/control | 149 | cat <<EOF > debian/control |
| 150 | Source: linux-upstream | 150 | Source: linux-upstream |
| 151 | Section: admin | 151 | Section: kernel |
| 152 | Priority: optional | 152 | Priority: optional |
| 153 | Maintainer: $maintainer | 153 | Maintainer: $maintainer |
| 154 | Standards-Version: 3.8.1 | 154 | Standards-Version: 3.8.4 |
| 155 | Homepage: http://www.kernel.org/ | ||
| 155 | EOF | 156 | EOF |
| 156 | 157 | ||
| 157 | if [ "$ARCH" = "um" ]; then | 158 | if [ "$ARCH" = "um" ]; then |
diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl index f3c9c0a90b98..e67f05486087 100755 --- a/scripts/recordmcount.pl +++ b/scripts/recordmcount.pl | |||
| @@ -159,6 +159,7 @@ my $section_regex; # Find the start of a section | |||
| 159 | my $function_regex; # Find the name of a function | 159 | my $function_regex; # Find the name of a function |
| 160 | # (return offset and func name) | 160 | # (return offset and func name) |
| 161 | my $mcount_regex; # Find the call site to mcount (return offset) | 161 | my $mcount_regex; # Find the call site to mcount (return offset) |
| 162 | my $mcount_adjust; # Address adjustment to mcount offset | ||
| 162 | my $alignment; # The .align value to use for $mcount_section | 163 | my $alignment; # The .align value to use for $mcount_section |
| 163 | my $section_type; # Section header plus possible alignment command | 164 | my $section_type; # Section header plus possible alignment command |
| 164 | my $can_use_local = 0; # If we can use local function references | 165 | my $can_use_local = 0; # If we can use local function references |
| @@ -213,6 +214,7 @@ $section_regex = "Disassembly of section\\s+(\\S+):"; | |||
| 213 | $function_regex = "^([0-9a-fA-F]+)\\s+<(.*?)>:"; | 214 | $function_regex = "^([0-9a-fA-F]+)\\s+<(.*?)>:"; |
| 214 | $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\smcount\$"; | 215 | $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\smcount\$"; |
| 215 | $section_type = '@progbits'; | 216 | $section_type = '@progbits'; |
| 217 | $mcount_adjust = 0; | ||
| 216 | $type = ".long"; | 218 | $type = ".long"; |
| 217 | 219 | ||
| 218 | if ($arch eq "x86_64") { | 220 | if ($arch eq "x86_64") { |
| @@ -326,7 +328,7 @@ if ($arch eq "x86_64") { | |||
| 326 | # 14: R_MIPS_NONE *ABS* | 328 | # 14: R_MIPS_NONE *ABS* |
| 327 | # 18: 00020021 nop | 329 | # 18: 00020021 nop |
| 328 | if ($is_module eq "0") { | 330 | if ($is_module eq "0") { |
| 329 | $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s_mcount\$"; | 331 | $mcount_regex = "^\\s*([0-9a-fA-F]+): R_MIPS_26\\s+_mcount\$"; |
| 330 | } else { | 332 | } else { |
| 331 | $mcount_regex = "^\\s*([0-9a-fA-F]+): R_MIPS_HI16\\s+_mcount\$"; | 333 | $mcount_regex = "^\\s*([0-9a-fA-F]+): R_MIPS_HI16\\s+_mcount\$"; |
| 332 | } | 334 | } |
| @@ -351,6 +353,9 @@ if ($arch eq "x86_64") { | |||
| 351 | } elsif ($arch eq "microblaze") { | 353 | } elsif ($arch eq "microblaze") { |
| 352 | # Microblaze calls '_mcount' instead of plain 'mcount'. | 354 | # Microblaze calls '_mcount' instead of plain 'mcount'. |
| 353 | $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s_mcount\$"; | 355 | $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s_mcount\$"; |
| 356 | } elsif ($arch eq "blackfin") { | ||
| 357 | $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s__mcount\$"; | ||
| 358 | $mcount_adjust = -4; | ||
| 354 | } else { | 359 | } else { |
| 355 | die "Arch $arch is not supported with CONFIG_FTRACE_MCOUNT_RECORD"; | 360 | die "Arch $arch is not supported with CONFIG_FTRACE_MCOUNT_RECORD"; |
| 356 | } | 361 | } |
| @@ -511,7 +516,7 @@ while (<IN>) { | |||
| 511 | } | 516 | } |
| 512 | # is this a call site to mcount? If so, record it to print later | 517 | # is this a call site to mcount? If so, record it to print later |
| 513 | if ($text_found && /$mcount_regex/) { | 518 | if ($text_found && /$mcount_regex/) { |
| 514 | push(@offsets, hex $1); | 519 | push(@offsets, (hex $1) + $mcount_adjust); |
| 515 | } | 520 | } |
| 516 | } | 521 | } |
| 517 | 522 | ||
diff --git a/scripts/setlocalversion b/scripts/setlocalversion index 64a9cb5556cd..057b6b3c5dfb 100755 --- a/scripts/setlocalversion +++ b/scripts/setlocalversion | |||
| @@ -43,7 +43,7 @@ scm_version() | |||
| 43 | fi | 43 | fi |
| 44 | 44 | ||
| 45 | # Check for git and a git repo. | 45 | # Check for git and a git repo. |
| 46 | if head=`git rev-parse --verify --short HEAD 2>/dev/null`; then | 46 | if test -d .git && head=`git rev-parse --verify --short HEAD 2>/dev/null`; then |
| 47 | 47 | ||
| 48 | # If we are at a tagged commit (like "v2.6.30-rc6"), we ignore | 48 | # If we are at a tagged commit (like "v2.6.30-rc6"), we ignore |
| 49 | # it, because this version is defined in the top level Makefile. | 49 | # it, because this version is defined in the top level Makefile. |
| @@ -85,8 +85,8 @@ scm_version() | |||
| 85 | fi | 85 | fi |
| 86 | 86 | ||
| 87 | # Check for mercurial and a mercurial repo. | 87 | # Check for mercurial and a mercurial repo. |
| 88 | if hgid=`hg id 2>/dev/null`; then | 88 | if test -d .hg && hgid=`hg id 2>/dev/null`; then |
| 89 | tag=`printf '%s' "$hgid" | cut -d' ' -f2` | 89 | tag=`printf '%s' "$hgid" | cut -s -d' ' -f2` |
| 90 | 90 | ||
| 91 | # Do we have an untagged version? | 91 | # Do we have an untagged version? |
| 92 | if [ -z "$tag" -o "$tag" = tip ]; then | 92 | if [ -z "$tag" -o "$tag" = tip ]; then |
