diff options
Diffstat (limited to 'scripts')
64 files changed, 1042 insertions, 333 deletions
| diff --git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst index 182084d728c8..8ccf83056a7a 100644 --- a/scripts/Makefile.headersinst +++ b/scripts/Makefile.headersinst @@ -47,18 +47,24 @@ header-y      := $(filter-out $(generic-y), $(header-y))  all-files     := $(header-y) $(genhdr-y) $(wrapper-files)  output-files  := $(addprefix $(installdir)/, $(all-files)) -input-files   := $(foreach hdr, $(header-y), \ +input-files1  := $(foreach hdr, $(header-y), \  		   $(if $(wildcard $(srcdir)/$(hdr)), \ -			$(wildcard $(srcdir)/$(hdr)), \ +			$(wildcard $(srcdir)/$(hdr))) \ +		   ) +input-files1-name := $(notdir $(input-files1)) +input-files2  := $(foreach hdr, $(header-y), \ +		   $(if  $(wildcard $(srcdir)/$(hdr)),, \  			$(if $(wildcard $(oldsrcdir)/$(hdr)), \  				$(wildcard $(oldsrcdir)/$(hdr)), \  				$(error Missing UAPI file $(srcdir)/$(hdr))) \ -		   )) \ -		 $(foreach hdr, $(genhdr-y), \ +		   )) +input-files2-name := $(notdir $(input-files2)) +input-files3  := $(foreach hdr, $(genhdr-y), \  		   $(if	$(wildcard $(gendir)/$(hdr)), \  			$(wildcard $(gendir)/$(hdr)), \  			$(error Missing generated UAPI file $(gendir)/$(hdr)) \  		   )) +input-files3-name := $(notdir $(input-files3))  # Work out what needs to be removed  oldheaders    := $(patsubst $(installdir)/%,%,$(wildcard $(installdir)/*.h)) @@ -72,7 +78,9 @@ printdir = $(patsubst $(INSTALL_HDR_PATH)/%/,%,$(dir $@))  quiet_cmd_install = INSTALL $(printdir) ($(words $(all-files))\                              file$(if $(word 2, $(all-files)),s))        cmd_install = \ -        $(CONFIG_SHELL) $< $(installdir) $(input-files); \ +        $(CONFIG_SHELL) $< $(installdir) $(srcdir) $(input-files1-name); \ +        $(CONFIG_SHELL) $< $(installdir) $(oldsrcdir) $(input-files2-name); \ +        $(CONFIG_SHELL) $< $(installdir) $(gendir) $(input-files3-name); \          for F in $(wrapper-files); do                                   \                  echo "\#include <asm-generic/$$F>" > $(installdir)/$$F;    \          done;                                                           \ @@ -98,7 +106,7 @@ __headersinst: $(subdirs) $(install-file)  	@:  targets += $(install-file) -$(install-file): scripts/headers_install.sh $(input-files) FORCE +$(install-file): scripts/headers_install.sh $(input-files1) $(input-files2) $(input-files3) FORCE  	$(if $(unwanted),$(call cmd,remove),)  	$(if $(wildcard $(dir $@)),,$(shell mkdir -p $(dir $@)))  	$(call if_changed,install) diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index f97869f1f09b..49392ecbef17 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -63,7 +63,7 @@ multi-objs   := $(multi-objs-y) $(multi-objs-m)  subdir-obj-y := $(filter %/built-in.o, $(obj-y))  # $(obj-dirs) is a list of directories that contain object files -obj-dirs := $(dir $(multi-objs) $(subdir-obj-y)) +obj-dirs := $(dir $(multi-objs) $(obj-y))  # Replace multi-part objects by their individual parts, look at local dir only  real-objs-y := $(foreach m, $(filter-out $(subdir-obj-y), $(obj-y)), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m))) $(extra-y) @@ -244,7 +244,7 @@ cmd_gzip = (cat $(filter-out FORCE,$^) | gzip -n -f -9 > $@) || \  # ---------------------------------------------------------------------------  # Generate an assembly file to wrap the output of the device tree compiler -quiet_cmd_dt_S_dtb= DTB    $@ +quiet_cmd_dt_S_dtb= DTB     $@  cmd_dt_S_dtb=						\  (							\  	echo '\#include <asm-generic/vmlinux.lds.h>'; 	\ @@ -311,6 +311,11 @@ cmd_lzo = (cat $(filter-out FORCE,$^) | \  	lzop -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \  	(rm -f $@ ; false) +quiet_cmd_lz4 = LZ4     $@ +cmd_lz4 = (cat $(filter-out FORCE,$^) | \ +	lz4c -l -c1 stdin stdout && $(call size_append, $(filter-out FORCE,$^))) > $@ || \ +	(rm -f $@ ; false) +  # U-Boot mkimage  # --------------------------------------------------------------------------- diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index b954de58304f..2ee9eb750560 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -6,6 +6,7 @@  # Licensed under the terms of the GNU GPL License version 2  use strict; +use POSIX;  my $P = $0;  $P =~ s@.*/@@g; @@ -27,9 +28,11 @@ my $summary = 1;  my $mailback = 0;  my $summary_file = 0;  my $show_types = 0; +my $fix = 0;  my $root;  my %debug;  my %ignore_type = (); +my %camelcase = ();  my @ignore = ();  my $help = 0;  my $configuration_file = ".checkpatch.conf"; @@ -63,6 +66,11 @@ Options:                               is all off)    --test-only=WORD           report only warnings/errors containing WORD                               literally +  --fix                      EXPERIMENTAL - may create horrible results +                             If correctable single-line errors exist, create +                             "<inputfile>.EXPERIMENTAL-checkpatch-fixes" +                             with potential errors corrected to the preferred +                             checkpatch style    -h, --help, --version      display this help and exit  When FILE is - read standard input. @@ -114,7 +122,7 @@ GetOptions(  	'summary!'	=> \$summary,  	'mailback!'	=> \$mailback,  	'summary-file!'	=> \$summary_file, - +	'fix!'		=> \$fix,  	'debug=s'	=> \%debug,  	'test-only=s'	=> \$tst_only,  	'h|help'	=> \$help, @@ -230,17 +238,22 @@ our $Inline	= qr{inline|__always_inline|noinline};  our $Member	= qr{->$Ident|\.$Ident|\[[^]]*\]};  our $Lval	= qr{$Ident(?:$Member)*}; +our $Int_type	= qr{(?i)llu|ull|ll|lu|ul|l|u}; +our $Binary	= qr{(?i)0b[01]+$Int_type?}; +our $Hex	= qr{(?i)0x[0-9a-f]+$Int_type?}; +our $Int	= qr{[0-9]+$Int_type?};  our $Float_hex	= qr{(?i)0x[0-9a-f]+p-?[0-9]+[fl]?};  our $Float_dec	= qr{(?i)(?:[0-9]+\.[0-9]*|[0-9]*\.[0-9]+)(?:e-?[0-9]+)?[fl]?};  our $Float_int	= qr{(?i)[0-9]+e-?[0-9]+[fl]?};  our $Float	= qr{$Float_hex|$Float_dec|$Float_int}; -our $Constant	= qr{$Float|(?i)(?:0x[0-9a-f]+|[0-9]+)[ul]*}; +our $Constant	= qr{$Float|$Binary|$Hex|$Int};  our $Assignment	= qr{\*\=|/=|%=|\+=|-=|<<=|>>=|&=|\^=|\|=|=};  our $Compare    = qr{<=|>=|==|!=|<|>}; +our $Arithmetic = qr{\+|-|\*|\/|%};  our $Operators	= qr{  			<=|>=|==|!=|  			=>|->|<<|>>|<|>|!|~| -			&&|\|\||,|\^|\+\+|--|&|\||\+|-|\*|\/|% +			&&|\|\||,|\^|\+\+|--|&|\||$Arithmetic  		  }x;  our $NonptrType; @@ -269,7 +282,7 @@ our $typeTypedefs = qr{(?x:  our $logFunctions = qr{(?x:  	printk(?:_ratelimited|_once|)| -	[a-z0-9]+_(?:printk|emerg|alert|crit|err|warning|warn|notice|info|debug|dbg|vdbg|devel|cont|WARN)(?:_ratelimited|_once|)| +	(?:[a-z0-9]+_){1,2}(?:printk|emerg|alert|crit|err|warning|warn|notice|info|debug|dbg|vdbg|devel|cont|WARN)(?:_ratelimited|_once|)|  	WARN(?:_RATELIMIT|_ONCE|)|  	panic|  	MODULE_[A-Z_]+ @@ -338,7 +351,6 @@ sub build_types {  }  build_types(); -  our $Typecast	= qr{\s*(\(\s*$NonptrType\s*\)){0,1}\s*};  # Using $balanced_parens, $LvalOrFunc, or $FuncArg @@ -358,10 +370,94 @@ sub deparenthesize {  	return $string;  } +sub seed_camelcase_file { +	my ($file) = @_; + +	return if (!(-f $file)); + +	local $/; + +	open(my $include_file, '<', "$file") +	    or warn "$P: Can't read '$file' $!\n"; +	my $text = <$include_file>; +	close($include_file); + +	my @lines = split('\n', $text); + +	foreach my $line (@lines) { +		next if ($line !~ /(?:[A-Z][a-z]|[a-z][A-Z])/); +		if ($line =~ /^[ \t]*(?:#[ \t]*define|typedef\s+$Type)\s+(\w*(?:[A-Z][a-z]|[a-z][A-Z])\w*)/) { +			$camelcase{$1} = 1; +		} +	        elsif ($line =~ /^\s*$Declare\s+(\w*(?:[A-Z][a-z]|[a-z][A-Z])\w*)\s*\(/) { +			$camelcase{$1} = 1; +		} +	} +} + +my $camelcase_seeded = 0; +sub seed_camelcase_includes { +	return if ($camelcase_seeded); + +	my $files; +	my $camelcase_cache = ""; +	my @include_files = (); + +	$camelcase_seeded = 1; + +	if (-d ".git") { +		my $git_last_include_commit = `git log --no-merges --pretty=format:"%h%n" -1 -- include`; +		chomp $git_last_include_commit; +		$camelcase_cache = ".checkpatch-camelcase.git.$git_last_include_commit"; +	} else { +		my $last_mod_date = 0; +		$files = `find $root/include -name "*.h"`; +		@include_files = split('\n', $files); +		foreach my $file (@include_files) { +			my $date = POSIX::strftime("%Y%m%d%H%M", +						   localtime((stat $file)[9])); +			$last_mod_date = $date if ($last_mod_date < $date); +		} +		$camelcase_cache = ".checkpatch-camelcase.date.$last_mod_date"; +	} + +	if ($camelcase_cache ne "" && -f $camelcase_cache) { +		open(my $camelcase_file, '<', "$camelcase_cache") +		    or warn "$P: Can't read '$camelcase_cache' $!\n"; +		while (<$camelcase_file>) { +			chomp; +			$camelcase{$_} = 1; +		} +		close($camelcase_file); + +		return; +	} + +	if (-d ".git") { +		$files = `git ls-files "include/*.h"`; +		@include_files = split('\n', $files); +	} + +	foreach my $file (@include_files) { +		seed_camelcase_file($file); +	} + +	if ($camelcase_cache ne "") { +		unlink glob ".checkpatch-camelcase.*"; +		open(my $camelcase_file, '>', "$camelcase_cache") +		    or warn "$P: Can't write '$camelcase_cache' $!\n"; +		foreach (sort { lc($a) cmp lc($b) } keys(%camelcase)) { +			print $camelcase_file ("$_\n"); +		} +		close($camelcase_file); +	} +} +  $chk_signoff = 0 if ($file);  my @rawlines = ();  my @lines = (); +my @fixed = ();  my $vname;  for my $filename (@ARGV) {  	my $FILE; @@ -389,6 +485,7 @@ for my $filename (@ARGV) {  	}  	@rawlines = ();  	@lines = (); +	@fixed = ();  }  exit($exit); @@ -429,7 +526,7 @@ sub parse_email {  		$comment = $2 if defined $2;  		$formatted_email =~ s/$address.*$//;  		$name = $formatted_email; -		$name =~ s/^\s+|\s+$//g; +		$name = trim($name);  		$name =~ s/^\"|\"$//g;  		# If there's a name left after stripping spaces and  		# leading quotes, and the address doesn't have both @@ -444,9 +541,9 @@ sub parse_email {  		}  	} -	$name =~ s/^\s+|\s+$//g; +	$name = trim($name);  	$name =~ s/^\"|\"$//g; -	$address =~ s/^\s+|\s+$//g; +	$address = trim($address);  	$address =~ s/^\<|\>$//g;  	if ($name =~ /[^\w \-]/i) { ##has "must quote" chars @@ -462,9 +559,9 @@ sub format_email {  	my $formatted_email; -	$name =~ s/^\s+|\s+$//g; +	$name = trim($name);  	$name =~ s/^\"|\"$//g; -	$address =~ s/^\s+|\s+$//g; +	$address = trim($address);  	if ($name =~ /[^\w \-]/i) { ##has "must quote" chars  		$name =~ s/(?<!\\)"/\\"/g; ##escape quotes @@ -1286,19 +1383,25 @@ sub ERROR {  	if (report("ERROR", $_[0], $_[1])) {  		our $clean = 0;  		our $cnt_error++; +		return 1;  	} +	return 0;  }  sub WARN {  	if (report("WARNING", $_[0], $_[1])) {  		our $clean = 0;  		our $cnt_warn++; +		return 1;  	} +	return 0;  }  sub CHK {  	if ($check && report("CHECK", $_[0], $_[1])) {  		our $clean = 0;  		our $cnt_chk++; +		return 1;  	} +	return 0;  }  sub check_absolute_file { @@ -1329,6 +1432,29 @@ sub check_absolute_file {  	}  } +sub trim { +	my ($string) = @_; + +	$string =~ s/(^\s+|\s+$)//g; + +	return $string; +} + +sub tabify { +	my ($leading) = @_; + +	my $source_indent = 8; +	my $max_spaces_before_tab = $source_indent - 1; +	my $spaces_to_tab = " " x $source_indent; + +	#convert leading spaces to tabs +	1 while $leading =~ s@^([\t]*)$spaces_to_tab@$1\t@g; +	#Remove spaces before a tab +	1 while $leading =~ s@^([\t]*)( {1,$max_spaces_before_tab})\t@$1\t@g; + +	return "$leading"; +} +  sub pos_last_openparen {  	my ($line) = @_; @@ -1406,7 +1532,6 @@ sub process {  	my %suppress_export;  	my $suppress_statement = 0; -	my %camelcase = ();  	# Pre-scan the patch sanitizing the lines.  	# Pre-scan the patch looking for any __setup documentation. @@ -1420,6 +1545,8 @@ sub process {  		$linenr++;  		$line = $rawline; +		push(@fixed, $rawline) if ($fix); +  		if ($rawline=~/^\+\+\+\s+(\S+)/) {  			$setup_docs = 0;  			if ($1 =~ m@Documentation/kernel-parameters.txt$@) { @@ -1611,16 +1738,29 @@ sub process {  				     "Non-standard signature: $sign_off\n" . $herecurr);  			}  			if (defined $space_before && $space_before ne "") { -				WARN("BAD_SIGN_OFF", -				     "Do not use whitespace before $ucfirst_sign_off\n" . $herecurr); +				if (WARN("BAD_SIGN_OFF", +					 "Do not use whitespace before $ucfirst_sign_off\n" . $herecurr) && +				    $fix) { +					$fixed[$linenr - 1] = +					    "$ucfirst_sign_off $email"; +				}  			}  			if ($sign_off =~ /-by:$/i && $sign_off ne $ucfirst_sign_off) { -				WARN("BAD_SIGN_OFF", -				     "'$ucfirst_sign_off' is the preferred signature form\n" . $herecurr); +				if (WARN("BAD_SIGN_OFF", +					 "'$ucfirst_sign_off' is the preferred signature form\n" . $herecurr) && +				    $fix) { +					$fixed[$linenr - 1] = +					    "$ucfirst_sign_off $email"; +				} +  			}  			if (!defined $space_after || $space_after ne " ") { -				WARN("BAD_SIGN_OFF", -				     "Use a single space after $ucfirst_sign_off\n" . $herecurr); +				if (WARN("BAD_SIGN_OFF", +					 "Use a single space after $ucfirst_sign_off\n" . $herecurr) && +				    $fix) { +					$fixed[$linenr - 1] = +					    "$ucfirst_sign_off $email"; +				}  			}  			my ($email_name, $email_address, $comment) = parse_email($email); @@ -1710,8 +1850,12 @@ sub process {  		} elsif ($rawline =~ /^\+.*\S\s+$/ || $rawline =~ /^\+\s+$/) {  			my $herevet = "$here\n" . cat_vet($rawline) . "\n"; -			ERROR("TRAILING_WHITESPACE", -			      "trailing whitespace\n" . $herevet); +			if (ERROR("TRAILING_WHITESPACE", +				  "trailing whitespace\n" . $herevet) && +			    $fix) { +				$fixed[$linenr - 1] =~ s/^(\+.*?)\s+$/$1/; +			} +  			$rpt_cleaners = 1;  		} @@ -1806,8 +1950,12 @@ sub process {  # check for spaces before a quoted newline  		if ($rawline =~ /^.*\".*\s\\n/) { -			WARN("QUOTED_WHITESPACE_BEFORE_NEWLINE", -			     "unnecessary whitespace before a quoted newline\n" . $herecurr); +			if (WARN("QUOTED_WHITESPACE_BEFORE_NEWLINE", +				 "unnecessary whitespace before a quoted newline\n" . $herecurr) && +			    $fix) { +				$fixed[$linenr - 1] =~ s/^(\+.*\".*)\s+\\n/$1\\n/; +			} +  		}  # check for adding lines without a newline. @@ -1838,16 +1986,23 @@ sub process {  		if ($rawline =~ /^\+\s* \t\s*\S/ ||  		    $rawline =~ /^\+\s*        \s*/) {  			my $herevet = "$here\n" . cat_vet($rawline) . "\n"; -			ERROR("CODE_INDENT", -			      "code indent should use tabs where possible\n" . $herevet);  			$rpt_cleaners = 1; +			if (ERROR("CODE_INDENT", +				  "code indent should use tabs where possible\n" . $herevet) && +			    $fix) { +				$fixed[$linenr - 1] =~ s/^\+([ \t]+)/"\+" . tabify($1)/e; +			}  		}  # check for space before tabs.  		if ($rawline =~ /^\+/ && $rawline =~ / \t/) {  			my $herevet = "$here\n" . cat_vet($rawline) . "\n"; -			WARN("SPACE_BEFORE_TAB", -			     "please, no space before tabs\n" . $herevet); +			if (WARN("SPACE_BEFORE_TAB", +				"please, no space before tabs\n" . $herevet) && +			    $fix) { +				$fixed[$linenr - 1] =~ +				    s/(^\+.*) +\t/$1\t/; +			}  		}  # check for && or || at the start of a line @@ -1875,25 +2030,42 @@ sub process {  				if ($newindent ne $goodtabindent &&  				    $newindent ne $goodspaceindent) { -					CHK("PARENTHESIS_ALIGNMENT", -					    "Alignment should match open parenthesis\n" . $hereprev); + +					if (CHK("PARENTHESIS_ALIGNMENT", +						"Alignment should match open parenthesis\n" . $hereprev) && +					    $fix && $line =~ /^\+/) { +						$fixed[$linenr - 1] =~ +						    s/^\+[ \t]*/\+$goodtabindent/; +					}  				}  			}  		} -		if ($line =~ /^\+.*\*[ \t]*\)[ \t]+/) { -			CHK("SPACING", -			    "No space is necessary after a cast\n" . $hereprev); +		if ($line =~ /^\+.*\*[ \t]*\)[ \t]+(?!$Assignment|$Arithmetic)/) { +			if (CHK("SPACING", +				"No space is necessary after a cast\n" . $hereprev) && +			    $fix) { +				$fixed[$linenr - 1] =~ +				    s/^(\+.*\*[ \t]*\))[ \t]+/$1/; +			}  		}  		if ($realfile =~ m@^(drivers/net/|net/)@ && -		    $rawline =~ /^\+[ \t]*\/\*[ \t]*$/ && -		    $prevrawline =~ /^\+[ \t]*$/) { +		    $prevrawline =~ /^\+[ \t]*\/\*[ \t]*$/ && +		    $rawline =~ /^\+[ \t]*\*/) {  			WARN("NETWORKING_BLOCK_COMMENT_STYLE",  			     "networking block comments don't use an empty /* line, use /* Comment...\n" . $hereprev);  		}  		if ($realfile =~ m@^(drivers/net/|net/)@ && +		    $prevrawline =~ /^\+[ \t]*\/\*/ &&		#starting /* +		    $prevrawline !~ /\*\/[ \t]*$/ &&		#no trailing */ +		    $rawline !~ /^\+[ \t]*\*/) {		#no leading * +			WARN("NETWORKING_BLOCK_COMMENT_STYLE", +			     "networking block comments start with * on subsequent lines\n" . $hereprev); +		} + +		if ($realfile =~ m@^(drivers/net/|net/)@ &&  		    $rawline !~ m@^\+[ \t]*\*/[ \t]*$@ &&	#trailing */  		    $rawline !~ m@^\+.*/\*.*\*/[ \t]*$@ &&	#inline /*...*/  		    $rawline !~ m@^\+.*\*{2,}/[ \t]*$@ &&	#trailing **/ @@ -1907,10 +2079,13 @@ sub process {  #  1) within comments  #  2) indented preprocessor commands  #  3) hanging labels -		if ($rawline =~ /^\+ / && $line !~ /\+ *(?:$;|#|$Ident:)/)  { +		if ($rawline =~ /^\+ / && $line !~ /^\+ *(?:$;|#|$Ident:)/)  {  			my $herevet = "$here\n" . cat_vet($rawline) . "\n"; -			WARN("LEADING_SPACE", -			     "please, no spaces at the start of a line\n" . $herevet); +			if (WARN("LEADING_SPACE", +				 "please, no spaces at the start of a line\n" . $herevet) && +			    $fix) { +				$fixed[$linenr - 1] =~ s/^\+([ \t]+)/"\+" . tabify($1)/e; +			}  		}  # check we are in a valid C source file if not then ignore this hunk @@ -2200,7 +2375,7 @@ sub process {  		$prev_values = substr($curr_values, -1);  #ignore lines not being added -		if ($line=~/^[^\+]/) {next;} +		next if ($line =~ /^[^\+]/);  # TEST: allow direct testing of the type matcher.  		if ($dbg_type) { @@ -2251,8 +2426,15 @@ sub process {  # no C99 // comments  		if ($line =~ m{//}) { -			ERROR("C99_COMMENTS", -			      "do not use C99 // comments\n" . $herecurr); +			if (ERROR("C99_COMMENTS", +				  "do not use C99 // comments\n" . $herecurr) && +			    $fix) { +				my $line = $fixed[$linenr - 1]; +				if ($line =~ /\/\/(.*)$/) { +					my $comment = trim($1); +					$fixed[$linenr - 1] =~ s@\/\/(.*)$@/\* $comment \*/@; +				} +			}  		}  		# Remove C99 comments.  		$line =~ s@//.*@@; @@ -2351,7 +2533,7 @@ sub process {  		# (char*[ const])  		while ($line =~ m{(\($NonptrType(\s*(?:$Modifier\b\s*|\*\s*)+)\))}g) {  			#print "AA<$1>\n"; -			my ($from, $to) = ($2, $2); +			my ($ident, $from, $to) = ($1, $2, $2);  			# Should start with a space.  			$to =~ s/^(\S)/ $1/; @@ -2361,15 +2543,22 @@ sub process {  			while ($to =~ s/\*\s+\*/\*\*/) {  			} -			#print "from<$from> to<$to>\n"; +##			print "1: from<$from> to<$to> ident<$ident>\n";  			if ($from ne $to) { -				ERROR("POINTER_LOCATION", -				      "\"(foo$from)\" should be \"(foo$to)\"\n" .  $herecurr); +				if (ERROR("POINTER_LOCATION", +					  "\"(foo$from)\" should be \"(foo$to)\"\n" .  $herecurr) && +				    $fix) { +					my $sub_from = $ident; +					my $sub_to = $ident; +					$sub_to =~ s/\Q$from\E/$to/; +					$fixed[$linenr - 1] =~ +					    s@\Q$sub_from\E@$sub_to@; +				}  			}  		}  		while ($line =~ m{(\b$NonptrType(\s*(?:$Modifier\b\s*|\*\s*)+)($Ident))}g) {  			#print "BB<$1>\n"; -			my ($from, $to, $ident) = ($2, $2, $3); +			my ($match, $from, $to, $ident) = ($1, $2, $2, $3);  			# Should start with a space.  			$to =~ s/^(\S)/ $1/; @@ -2381,10 +2570,18 @@ sub process {  			# Modifiers should have spaces.  			$to =~ s/(\b$Modifier$)/$1 /; -			#print "from<$from> to<$to> ident<$ident>\n"; +##			print "2: from<$from> to<$to> ident<$ident>\n";  			if ($from ne $to && $ident !~ /^$Modifier$/) { -				ERROR("POINTER_LOCATION", -				      "\"foo${from}bar\" should be \"foo${to}bar\"\n" .  $herecurr); +				if (ERROR("POINTER_LOCATION", +					  "\"foo${from}bar\" should be \"foo${to}bar\"\n" .  $herecurr) && +				    $fix) { + +					my $sub_from = $match; +					my $sub_to = $match; +					$sub_to =~ s/\Q$from\E/$to/; +					$fixed[$linenr - 1] =~ +					    s@\Q$sub_from\E@$sub_to@; +				}  			}  		} @@ -2470,9 +2667,13 @@ sub process {  		}  # missing space after union, struct or enum definition -		if ($line =~ /^.\s*(?:typedef\s+)?(enum|union|struct)(?:\s+$Ident)?(?:\s+$Ident)?[=\{]/) { -		    WARN("SPACING", -			 "missing space after $1 definition\n" . $herecurr); +		if ($line =~ /^.\s*(?:typedef\s+)?(enum|union|struct)(?:\s+$Ident){1,2}[=\{]/) { +			if (WARN("SPACING", +				 "missing space after $1 definition\n" . $herecurr) && +			    $fix) { +				$fixed[$linenr - 1] =~ +				    s/^(.\s*(?:typedef\s+)?(?:enum|union|struct)(?:\s+$Ident){1,2})([=\{])/$1 $2/; +			}  		}  # check for spacing round square brackets; allowed: @@ -2484,8 +2685,12 @@ sub process {  			if ($prefix !~ /$Type\s+$/ &&  			    ($where != 0 || $prefix !~ /^.\s+$/) &&  			    $prefix !~ /[{,]\s+$/) { -				ERROR("BRACKET_SPACE", -				      "space prohibited before open square bracket '['\n" . $herecurr); +				if (ERROR("BRACKET_SPACE", +					  "space prohibited before open square bracket '['\n" . $herecurr) && +				    $fix) { +				    $fixed[$linenr - 1] =~ +					s/^(\+.*?)\s+\[/$1\[/; +				}  			}  		} @@ -2502,7 +2707,6 @@ sub process {  				__attribute__|format|__extension__|  				asm|__asm__)$/x)  			{ -  			# cpp #define statements have non-optional spaces, ie  			# if there is a space between the name and the open  			# parenthesis it is simply not a parameter group. @@ -2516,19 +2720,20 @@ sub process {  			} elsif ($ctx =~ /$Type$/) {  			} else { -				WARN("SPACING", -				     "space prohibited between function name and open parenthesis '('\n" . $herecurr); +				if (WARN("SPACING", +					 "space prohibited between function name and open parenthesis '('\n" . $herecurr) && +					     $fix) { +					$fixed[$linenr - 1] =~ +					    s/\b$name\s+\(/$name\(/; +				}  			}  		} -# check for whitespace before a non-naked semicolon -		if ($line =~ /^\+.*\S\s+;/) { -			WARN("SPACING", -			     "space prohibited before semicolon\n" . $herecurr); -		} -  # Check operator spacing.  		if (!($line=~/\#\s*include/)) { +			my $fixed_line = ""; +			my $line_fixed = 0; +  			my $ops = qr{  				<<=|>>=|<=|>=|==|!=|  				\+=|-=|\*=|\/=|%=|\^=|\|=|&=| @@ -2537,11 +2742,30 @@ sub process {  				\?|:  			}x;  			my @elements = split(/($ops|;)/, $opline); + +##			print("element count: <" . $#elements . ">\n"); +##			foreach my $el (@elements) { +##				print("el: <$el>\n"); +##			} + +			my @fix_elements = ();  			my $off = 0; +			foreach my $el (@elements) { +				push(@fix_elements, substr($rawline, $off, length($el))); +				$off += length($el); +			} + +			$off = 0; +  			my $blank = copy_spacing($opline);  			for (my $n = 0; $n < $#elements; $n += 2) { + +				my $good = $fix_elements[$n] . $fix_elements[$n + 1]; + +##				print("n: <$n> good: <$good>\n"); +  				$off += length($elements[$n]);  				# Pick up the preceding and succeeding characters. @@ -2598,8 +2822,11 @@ sub process {  				} elsif ($op eq ';') {  					if ($ctx !~ /.x[WEBC]/ &&  					    $cc !~ /^\\/ && $cc !~ /^;/) { -						ERROR("SPACING", -						      "space required after that '$op' $at\n" . $hereptr); +						if (ERROR("SPACING", +							  "space required after that '$op' $at\n" . $hereptr)) { +							$good = trim($fix_elements[$n]) . " " . trim($fix_elements[$n + 1]) . " "; +							$line_fixed = 1; +						}  					}  				# // is a comment @@ -2610,15 +2837,24 @@ sub process {  				#   :   when part of a bitfield  				} elsif ($op eq '->' || $opv eq ':B') {  					if ($ctx =~ /Wx.|.xW/) { -						ERROR("SPACING", -						      "spaces prohibited around that '$op' $at\n" . $hereptr); +						if (ERROR("SPACING", +							  "spaces prohibited around that '$op' $at\n" . $hereptr)) { +							$good = trim($fix_elements[$n]) . trim($fix_elements[$n + 1]); +							$line_fixed = 1; +							if (defined $fix_elements[$n + 2]) { +								$fix_elements[$n + 2] =~ s/^\s+//; +							} +						}  					}  				# , must have a space on the right.  				} elsif ($op eq ',') {  					if ($ctx !~ /.x[WEC]/ && $cc !~ /^}/) { -						ERROR("SPACING", -						      "space required after that '$op' $at\n" . $hereptr); +						if (ERROR("SPACING", +							  "space required after that '$op' $at\n" . $hereptr)) { +							$good = trim($fix_elements[$n]) . trim($fix_elements[$n + 1]) . " "; +							$line_fixed = 1; +						}  					}  				# '*' as part of a type definition -- reported already. @@ -2632,34 +2868,58 @@ sub process {  					 $opv eq '*U' || $opv eq '-U' ||  					 $opv eq '&U' || $opv eq '&&U') {  					if ($ctx !~ /[WEBC]x./ && $ca !~ /(?:\)|!|~|\*|-|\&|\||\+\+|\-\-|\{)$/) { -						ERROR("SPACING", -						      "space required before that '$op' $at\n" . $hereptr); +						if (ERROR("SPACING", +							  "space required before that '$op' $at\n" . $hereptr)) { +							$good = trim($fix_elements[$n]) . " " . trim($fix_elements[$n + 1]); +							$line_fixed = 1; +						}  					}  					if ($op eq '*' && $cc =~/\s*$Modifier\b/) {  						# A unary '*' may be const  					} elsif ($ctx =~ /.xW/) { -						ERROR("SPACING", -						      "space prohibited after that '$op' $at\n" . $hereptr); +						if (ERROR("SPACING", +							  "space prohibited after that '$op' $at\n" . $hereptr)) { +							$fixed_line =~ s/\s+$//; +							$good = trim($fix_elements[$n]) . trim($fix_elements[$n + 1]); +							$line_fixed = 1; +							if (defined $fix_elements[$n + 2]) { +								$fix_elements[$n + 2] =~ s/^\s+//; +							} +						}  					}  				# unary ++ and unary -- are allowed no space on one side.  				} elsif ($op eq '++' or $op eq '--') {  					if ($ctx !~ /[WEOBC]x[^W]/ && $ctx !~ /[^W]x[WOBEC]/) { -						ERROR("SPACING", -						      "space required one side of that '$op' $at\n" . $hereptr); +						if (ERROR("SPACING", +							  "space required one side of that '$op' $at\n" . $hereptr)) { +							$fixed_line =~ s/\s+$//; +							$good = trim($fix_elements[$n]) . trim($fix_elements[$n + 1]) . " "; +							$line_fixed = 1; +						}  					}  					if ($ctx =~ /Wx[BE]/ ||  					    ($ctx =~ /Wx./ && $cc =~ /^;/)) { -						ERROR("SPACING", -						      "space prohibited before that '$op' $at\n" . $hereptr); +						if (ERROR("SPACING", +							  "space prohibited before that '$op' $at\n" . $hereptr)) { +							$fixed_line =~ s/\s+$//; +							$good = trim($fix_elements[$n]) . trim($fix_elements[$n + 1]); +							$line_fixed = 1; +						}  					}  					if ($ctx =~ /ExW/) { -						ERROR("SPACING", -						      "space prohibited after that '$op' $at\n" . $hereptr); +						if (ERROR("SPACING", +							  "space prohibited after that '$op' $at\n" . $hereptr)) { +							$fixed_line =~ s/\s+$//; +							$good = trim($fix_elements[$n]) . trim($fix_elements[$n + 1]); +							$line_fixed = 1; +							if (defined $fix_elements[$n + 2]) { +								$fix_elements[$n + 2] =~ s/^\s+//; +							} +						}  					} -  				# << and >> may either have or not have spaces both sides  				} elsif ($op eq '<<' or $op eq '>>' or  					 $op eq '&' or $op eq '^' or $op eq '|' or @@ -2668,17 +2928,23 @@ sub process {  					 $op eq '%')  				{  					if ($ctx =~ /Wx[^WCE]|[^WCE]xW/) { -						ERROR("SPACING", -						      "need consistent spacing around '$op' $at\n" . -							$hereptr); +						if (ERROR("SPACING", +							  "need consistent spacing around '$op' $at\n" . $hereptr)) { +							$fixed_line =~ s/\s+$//; +							$good = trim($fix_elements[$n]) . " " . trim($fix_elements[$n + 1]) . " "; +							$line_fixed = 1; +						}  					}  				# A colon needs no spaces before when it is  				# terminating a case value or a label.  				} elsif ($opv eq ':C' || $opv eq ':L') {  					if ($ctx =~ /Wx./) { -						ERROR("SPACING", -						      "space prohibited before that '$op' $at\n" . $hereptr); +						if (ERROR("SPACING", +							  "space prohibited before that '$op' $at\n" . $hereptr)) { +							$good = trim($fix_elements[$n]) . trim($fix_elements[$n + 1]); +							$line_fixed = 1; +						}  					}  				# All the others need spaces both sides. @@ -2701,11 +2967,39 @@ sub process {  					}  					if ($ok == 0) { -						ERROR("SPACING", -						      "spaces required around that '$op' $at\n" . $hereptr); +						if (ERROR("SPACING", +							  "spaces required around that '$op' $at\n" . $hereptr)) { +							$good = trim($fix_elements[$n]) . " " . trim($fix_elements[$n + 1]) . " "; +							$good = $fix_elements[$n] . " " . trim($fix_elements[$n + 1]) . " "; +							$line_fixed = 1; +						}  					}  				}  				$off += length($elements[$n + 1]); + +##				print("n: <$n> GOOD: <$good>\n"); + +				$fixed_line = $fixed_line . $good; +			} + +			if (($#elements % 2) == 0) { +				$fixed_line = $fixed_line . $fix_elements[$#elements]; +			} + +			if ($fix && $line_fixed && $fixed_line ne $fixed[$linenr - 1]) { +				$fixed[$linenr - 1] = $fixed_line; +			} + + +		} + +# check for whitespace before a non-naked semicolon +		if ($line =~ /^\+.*\S\s+;/) { +			if (WARN("SPACING", +				 "space prohibited before semicolon\n" . $herecurr) && +			    $fix) { +				1 while $fixed[$linenr - 1] =~ +				    s/^(\+.*\S)\s+;/$1;/;  			}  		} @@ -2734,10 +3028,22 @@ sub process {  #need space before brace following if, while, etc  		if (($line =~ /\(.*\){/ && $line !~ /\($Type\){/) ||  		    $line =~ /do{/) { -			ERROR("SPACING", -			      "space required before the open brace '{'\n" . $herecurr); +			if (ERROR("SPACING", +				  "space required before the open brace '{'\n" . $herecurr) && +			    $fix) { +				$fixed[$linenr - 1] =~ +				    s/^(\+.*(?:do|\))){/$1 {/; +			}  		} +## # check for blank lines before declarations +##		if ($line =~ /^.\t+$Type\s+$Ident(?:\s*=.*)?;/ && +##		    $prevrawline =~ /^.\s*$/) { +##			WARN("SPACING", +##			     "No blank lines before declarations\n" . $hereprev); +##		} +## +  # closing brace should have a space following it when it has anything  # on the line  		if ($line =~ /}(?!(?:,|;|\)))\S/) { @@ -2747,32 +3053,52 @@ sub process {  # check spacing on square brackets  		if ($line =~ /\[\s/ && $line !~ /\[\s*$/) { -			ERROR("SPACING", -			      "space prohibited after that open square bracket '['\n" . $herecurr); +			if (ERROR("SPACING", +				  "space prohibited after that open square bracket '['\n" . $herecurr) && +			    $fix) { +				$fixed[$linenr - 1] =~ +				    s/\[\s+/\[/; +			}  		}  		if ($line =~ /\s\]/) { -			ERROR("SPACING", -			      "space prohibited before that close square bracket ']'\n" . $herecurr); +			if (ERROR("SPACING", +				  "space prohibited before that close square bracket ']'\n" . $herecurr) && +			    $fix) { +				$fixed[$linenr - 1] =~ +				    s/\s+\]/\]/; +			}  		}  # check spacing on parentheses  		if ($line =~ /\(\s/ && $line !~ /\(\s*(?:\\)?$/ &&  		    $line !~ /for\s*\(\s+;/) { -			ERROR("SPACING", -			      "space prohibited after that open parenthesis '('\n" . $herecurr); +			if (ERROR("SPACING", +				  "space prohibited after that open parenthesis '('\n" . $herecurr) && +			    $fix) { +				$fixed[$linenr - 1] =~ +				    s/\(\s+/\(/; +			}  		}  		if ($line =~ /(\s+)\)/ && $line !~ /^.\s*\)/ &&  		    $line !~ /for\s*\(.*;\s+\)/ &&  		    $line !~ /:\s+\)/) { -			ERROR("SPACING", -			      "space prohibited before that close parenthesis ')'\n" . $herecurr); +			if (ERROR("SPACING", +				  "space prohibited before that close parenthesis ')'\n" . $herecurr) && +			    $fix) { +				$fixed[$linenr - 1] =~ +				    s/\s+\)/\)/; +			}  		}  #goto labels aren't indented, allow a single space however  		if ($line=~/^.\s+[A-Za-z\d_]+:(?![0-9]+)/ and  		   !($line=~/^. [A-Za-z\d_]+:/) and !($line=~/^.\s+default:/)) { -			WARN("INDENTED_LABEL", -			     "labels should not be indented\n" . $herecurr); +			if (WARN("INDENTED_LABEL", +				 "labels should not be indented\n" . $herecurr) && +			    $fix) { +				$fixed[$linenr - 1] =~ +				    s/^(.)\s+/$1/; +			}  		}  # Return is not a function. @@ -2809,8 +3135,13 @@ sub process {  		}  # Need a space before open parenthesis after if, while etc -		if ($line=~/\b(if|while|for|switch)\(/) { -			ERROR("SPACING", "space required before the open parenthesis '('\n" . $herecurr); +		if ($line =~ /\b(if|while|for|switch)\(/) { +			if (ERROR("SPACING", +				  "space required before the open parenthesis '('\n" . $herecurr) && +			    $fix) { +				$fixed[$linenr - 1] =~ +				    s/\b(if|while|for|switch)\(/$1 \(/; +			}  		}  # Check for illegal assignment in if conditional -- and check for trailing @@ -2934,16 +3265,29 @@ sub process {  			}  		} -#CamelCase +#Specific variable tests  		while ($line =~ m{($Constant|$Lval)}g) {  			my $var = $1; -			if ($var !~ /$Constant/ && -			    $var =~ /[A-Z]\w*[a-z]|[a-z]\w*[A-Z]/ && -			    $var !~ /"^(?:Clear|Set|TestClear|TestSet|)Page[A-Z]/ && -			    !defined $camelcase{$var}) { -				$camelcase{$var} = 1; -				WARN("CAMELCASE", -				     "Avoid CamelCase: <$var>\n" . $herecurr); + +#gcc binary extension +			if ($var =~ /^$Binary$/) { +				WARN("GCC_BINARY_CONSTANT", +				     "Avoid gcc v4.3+ binary constant extension: <$var>\n" . $herecurr); +			} + +#CamelCase +			if ($var !~ /^$Constant$/ && +			    $var =~ /[A-Z][a-z]|[a-z][A-Z]/ && +#Ignore Page<foo> variants +			    $var !~ /^(?:Clear|Set|TestClear|TestSet|)Page[A-Z]/ && +#Ignore SI style variants like nS, mV and dB (ie: max_uV, regulator_min_uA_show) +			    $var !~ /^(?:[a-z_]*?)_?[a-z][A-Z](?:_[a-z_]+)?$/) { +				seed_camelcase_includes() if ($check); +				if (!defined $camelcase{$var}) { +					$camelcase{$var} = 1; +					CHK("CAMELCASE", +					    "Avoid CamelCase: <$var>\n" . $herecurr); +				}  			}  		} @@ -3021,7 +3365,7 @@ sub process {  			if ($dstat ne '' &&  			    $dstat !~ /^(?:$Ident|-?$Constant),$/ &&			# 10, // foo(),  			    $dstat !~ /^(?:$Ident|-?$Constant);$/ &&			# foo(); -			    $dstat !~ /^[!~-]?(?:$Ident|$Constant)$/ &&		# 10 // foo() // !foo // ~foo // -foo +			    $dstat !~ /^[!~-]?(?:$Lval|$Constant)$/ &&		# 10 // foo() // !foo // ~foo // -foo // foo->bar // foo.bar->baz  			    $dstat !~ /^'X'$/ &&					# character constants  			    $dstat !~ /$exceptions/ &&  			    $dstat !~ /^\.$Ident\s*=/ &&				# .foo = @@ -3230,11 +3574,11 @@ sub process {  		}  # check for unnecessary blank lines around braces -		if (($line =~ /^.\s*}\s*$/ && $prevline =~ /^.\s*$/)) { +		if (($line =~ /^.\s*}\s*$/ && $prevrawline =~ /^.\s*$/)) {  			CHK("BRACES",  			    "Blank lines aren't necessary before a close brace '}'\n" . $hereprev);  		} -		if (($line =~ /^.\s*$/ && $prevline =~ /^..*{\s*$/)) { +		if (($rawline =~ /^.\s*$/ && $prevline =~ /^..*{\s*$/)) {  			CHK("BRACES",  			    "Blank lines aren't necessary after an open brace '{'\n" . $hereprev);  		} @@ -3279,6 +3623,18 @@ sub process {  			}  		} +# check for comparisons of jiffies +		if ($line =~ /\bjiffies\s*$Compare|$Compare\s*jiffies\b/) { +			WARN("JIFFIES_COMPARISON", +			     "Comparing jiffies is almost always wrong; prefer time_after, time_before and friends\n" . $herecurr); +		} + +# check for comparisons of get_jiffies_64() +		if ($line =~ /\bget_jiffies_64\s*\(\s*\)\s*$Compare|$Compare\s*get_jiffies_64\s*\(\s*\)/) { +			WARN("JIFFIES_COMPARISON", +			     "Comparing get_jiffies_64() is almost always wrong; prefer time_after64, time_before64 and friends\n" . $herecurr); +		} +  # warn about #ifdefs in C files  #		if ($line =~ /^.\s*\#\s*if(|n)def/ && ($realfile =~ /\.c$/)) {  #			print "#ifdef in C files should be avoided\n"; @@ -3288,8 +3644,13 @@ sub process {  # warn about spacing in #ifdefs  		if ($line =~ /^.\s*\#\s*(ifdef|ifndef|elif)\s\s+/) { -			ERROR("SPACING", -			      "exactly one space required after that #$1\n" . $herecurr); +			if (ERROR("SPACING", +				  "exactly one space required after that #$1\n" . $herecurr) && +			    $fix) { +				$fixed[$linenr - 1] =~ +				    s/^(.\s*\#\s*(ifdef|ifndef|elif))\s{2,}/$1 /; +			} +  		}  # check for spinlock_t definitions without a comment. @@ -3495,6 +3856,14 @@ sub process {  			     "unnecessary cast may hide bugs, see http://c-faq.com/malloc/mallocnocast.html\n" . $herecurr);  		} +# alloc style +# p = alloc(sizeof(struct foo), ...) should be p = alloc(sizeof(*p), ...) +		if ($^V && $^V ge 5.10.0 && +		    $line =~ /\b($Lval)\s*\=\s*(?:$balanced_parens)?\s*([kv][mz]alloc(?:_node)?)\s*\(\s*(sizeof\s*\(\s*struct\s+$Lval\s*\))/) { +			CHK("ALLOC_SIZEOF_STRUCT", +			    "Prefer $3(sizeof(*$1)...) over $3($4...)\n" . $herecurr); +		} +  # check for krealloc arg reuse  		if ($^V && $^V ge 5.10.0 &&  		    $line =~ /\b($Lval)\s*\=\s*(?:$balanced_parens)?\s*krealloc\s*\(\s*\1\s*,/) { @@ -3540,6 +3909,33 @@ sub process {  			     "Using yield() is generally wrong. See yield() kernel-doc (sched/core.c)\n"  . $herecurr);  		} +# check for comparisons against true and false +		if ($line =~ /\+\s*(.*?)\b(true|false|$Lval)\s*(==|\!=)\s*(true|false|$Lval)\b(.*)$/i) { +			my $lead = $1; +			my $arg = $2; +			my $test = $3; +			my $otype = $4; +			my $trail = $5; +			my $op = "!"; + +			($arg, $otype) = ($otype, $arg) if ($arg =~ /^(?:true|false)$/i); + +			my $type = lc($otype); +			if ($type =~ /^(?:true|false)$/) { +				if (("$test" eq "==" && "$type" eq "true") || +				    ("$test" eq "!=" && "$type" eq "false")) { +					$op = ""; +				} + +				CHK("BOOL_COMPARISON", +				    "Using comparison to $otype is error prone\n" . $herecurr); + +## maybe suggesting a correct construct would better +##				    "Using comparison to $otype is error prone.  Perhaps use '${lead}${op}${arg}${trail}'\n" . $herecurr); + +			} +		} +  # check for semaphores initialized locked  		if ($line =~ /^.\s*sema_init.+,\W?0\W?\)/) {  			WARN("CONSIDER_COMPLETION", @@ -3717,6 +4113,40 @@ sub process {  	    print "\n\n";  	} +	if ($clean == 0 && $fix && "@rawlines" ne "@fixed") { +		my $newfile = $filename . ".EXPERIMENTAL-checkpatch-fixes"; +		my $linecount = 0; +		my $f; + +		open($f, '>', $newfile) +		    or die "$P: Can't open $newfile for write\n"; +		foreach my $fixed_line (@fixed) { +			$linecount++; +			if ($file) { +				if ($linecount > 3) { +					$fixed_line =~ s/^\+//; +					print $f $fixed_line. "\n"; +				} +			} else { +				print $f $fixed_line . "\n"; +			} +		} +		close($f); + +		if (!$quiet) { +			print << "EOM"; +Wrote EXPERIMENTAL --fix correction(s) to '$newfile' + +Do _NOT_ trust the results written to this file. +Do _NOT_ submit these changes without inspecting them for correctness. + +This EXPERIMENTAL file is simply a convenience to help rewrite patches. +No warranties, expressed or implied... + +EOM +		} +	} +  	if ($clean == 1 && $quiet == 0) {  		print "$vname has no obvious style problems and is ready for submission.\n"  	} diff --git a/scripts/coccicheck b/scripts/coccicheck index 06fcb3333247..bbf901afb606 100755 --- a/scripts/coccicheck +++ b/scripts/coccicheck @@ -1,17 +1,31 @@  #!/bin/bash +# +# This script requires at least spatch +# version 1.0.0-rc11. +# +  SPATCH="`which ${SPATCH:=spatch}`" +trap kill_running SIGTERM SIGINT +declare -a SPATCH_PID +  # The verbosity may be set by the environmental parameter V=  # as for example with 'make V=1 coccicheck'  if [ -n "$V" -a "$V" != "0" ]; then -	VERBOSE=1 +	VERBOSE="$V"  else  	VERBOSE=0  fi -FLAGS="$SPFLAGS -very_quiet" +if [ -z "$J" ]; then +	NPROC=$(getconf _NPROCESSORS_ONLN) +else +	NPROC="$J" +fi + +FLAGS="$SPFLAGS --very-quiet"  # spatch only allows include directories with the syntax "-I include"  # while gcc also allows "-Iinclude" and "-include include" @@ -27,14 +41,14 @@ if [ "$C" = "1" -o "$C" = "2" ]; then  else      ONLINE=0      if [ "$KBUILD_EXTMOD" = "" ] ; then -        OPTIONS="-dir $srctree $COCCIINCLUDE" +        OPTIONS="--dir $srctree $COCCIINCLUDE"      else -        OPTIONS="-dir $KBUILD_EXTMOD $COCCIINCLUDE" +        OPTIONS="--dir $KBUILD_EXTMOD $COCCIINCLUDE"      fi  fi  if [ "$KBUILD_EXTMOD" != "" ] ; then -    OPTIONS="-patch $srctree $OPTIONS" +    OPTIONS="--patch $srctree $OPTIONS"  fi  if [ ! -x "$SPATCH" ]; then @@ -44,13 +58,21 @@ fi  if [ "$MODE" = "" ] ; then      if [ "$ONLINE" = "0" ] ; then -	echo 'You have not explicitly specified the mode to use. Using default "chain" mode.' -	echo 'All available modes will be tried (in that order): patch, report, context, org' +	echo 'You have not explicitly specified the mode to use. Using default "report" mode.' +	echo 'Available modes are the following: patch, report, context, org'  	echo 'You can specify the mode with "make coccicheck MODE=<mode>"' +	echo 'Note however that some modes are not implemented by some semantic patches.' +    fi +    MODE="report" +fi + +if [ "$MODE" = "chain" ] ; then +    if [ "$ONLINE" = "0" ] ; then +	echo 'You have selected the "chain" mode.' +	echo 'All available modes will be tried (in that order): patch, report, context, org'      fi -    MODE="chain"  elif [ "$MODE" = "report" -o "$MODE" = "org" ] ; then -    FLAGS="$FLAGS -no_show_diff" +    FLAGS="$FLAGS --no-show-diff"  fi  if [ "$ONLINE" = "0" ] ; then @@ -61,19 +83,35 @@ if [ "$ONLINE" = "0" ] ; then  fi  run_cmd() { +	local i  	if [ $VERBOSE -ne 0 ] ; then -		echo "Running: $@" +		echo "Running ($NPROC in parallel): $@"  	fi -	eval $@ +	for i in $(seq 0 $(( NPROC - 1)) ); do +		eval "$@ --max $NPROC --index $i &" +		SPATCH_PID[$i]=$! +		if [ $VERBOSE -eq 2 ] ; then +			echo "${SPATCH_PID[$i]} running" +		fi +	done +	wait  } +kill_running() { +	for i in $(seq $(( NPROC - 1 )) ); do +		if [ $VERBOSE -eq 2 ] ; then +			echo "Killing ${SPATCH_PID[$i]}" +		fi +		kill ${SPATCH_PID[$i]} 2>/dev/null +	done +}  coccinelle () {      COCCI="$1"      OPT=`grep "Option" $COCCI | cut -d':' -f2` -#   The option '-parse_cocci' can be used to syntactically check the SmPL files. +#   The option '--parse-cocci' can be used to syntactically check the SmPL files.  #  #    $SPATCH -D $MODE $FLAGS -parse_cocci $COCCI $OPT > /dev/null @@ -114,20 +152,20 @@ coccinelle () {      if [ "$MODE" = "chain" ] ; then  	run_cmd $SPATCH -D patch   \ -		$FLAGS -sp_file $COCCI $OPT $OPTIONS               || \ +		$FLAGS --cocci-file $COCCI $OPT $OPTIONS               || \  	run_cmd $SPATCH -D report  \ -		$FLAGS -sp_file $COCCI $OPT $OPTIONS -no_show_diff || \ +		$FLAGS --cocci-file $COCCI $OPT $OPTIONS --no-show-diff || \  	run_cmd $SPATCH -D context \ -		$FLAGS -sp_file $COCCI $OPT $OPTIONS               || \ +		$FLAGS --cocci-file $COCCI $OPT $OPTIONS               || \  	run_cmd $SPATCH -D org     \ -		$FLAGS -sp_file $COCCI $OPT $OPTIONS -no_show_diff || exit 1 +		$FLAGS --cocci-file $COCCI $OPT $OPTIONS --no-show-diff || exit 1      elif [ "$MODE" = "rep+ctxt" ] ; then  	run_cmd $SPATCH -D report  \ -		$FLAGS -sp_file $COCCI $OPT $OPTIONS -no_show_diff && \ +		$FLAGS --cocci-file $COCCI $OPT $OPTIONS --no-show-diff && \  	run_cmd $SPATCH -D context \ -		$FLAGS -sp_file $COCCI $OPT $OPTIONS || exit 1 +		$FLAGS --cocci-file $COCCI $OPT $OPTIONS || exit 1      else -	run_cmd $SPATCH -D $MODE   $FLAGS -sp_file $COCCI $OPT $OPTIONS || exit 1 +	run_cmd $SPATCH -D $MODE   $FLAGS --cocci-file $COCCI $OPT $OPTIONS || exit 1      fi  } diff --git a/scripts/coccinelle/api/alloc/drop_kmalloc_cast.cocci b/scripts/coccinelle/api/alloc/drop_kmalloc_cast.cocci index 7d4771d449c3..bd5d08b882ee 100644 --- a/scripts/coccinelle/api/alloc/drop_kmalloc_cast.cocci +++ b/scripts/coccinelle/api/alloc/drop_kmalloc_cast.cocci @@ -5,7 +5,7 @@  // Confidence: High  // Copyright: 2009,2010 Nicolas Palix, DIKU.  GPLv2.  // URL: http://coccinelle.lip6.fr/ -// Options: -no_includes -include_headers +// Options: --no-includes --include-headers  //  // Keywords: kmalloc, kzalloc, kcalloc  // Version min: < 2.6.12 kmalloc diff --git a/scripts/coccinelle/api/alloc/kzalloc-simple.cocci b/scripts/coccinelle/api/alloc/kzalloc-simple.cocci index 046b9b16f8f9..52c55e4fa67d 100644 --- a/scripts/coccinelle/api/alloc/kzalloc-simple.cocci +++ b/scripts/coccinelle/api/alloc/kzalloc-simple.cocci @@ -9,7 +9,7 @@  // Copyright: (C) 2009-2010 Julia Lawall, Nicolas Palix, DIKU.  GPLv2.  // Copyright: (C) 2009-2010 Gilles Muller, INRIA/LiP6.  GPLv2.  // URL: http://coccinelle.lip6.fr/rules/kzalloc.html -// Options: -no_includes -include_headers +// Options: --no-includes --include-headers  //  // Keywords: kmalloc, kzalloc  // Version min: < 2.6.12 kmalloc diff --git a/scripts/coccinelle/api/d_find_alias.cocci b/scripts/coccinelle/api/d_find_alias.cocci index a9694a8d3e5a..9594c9f7eb8d 100644 --- a/scripts/coccinelle/api/d_find_alias.cocci +++ b/scripts/coccinelle/api/d_find_alias.cocci @@ -4,7 +4,7 @@  //  // Confidence: Moderate  // URL: http://coccinelle.lip6.fr/ -// Options: -include_headers +// Options: --include-headers  virtual context  virtual org diff --git a/scripts/coccinelle/api/devm_request_and_ioremap.cocci b/scripts/coccinelle/api/devm_request_and_ioremap.cocci index 46beb81406ab..562ec88b6352 100644 --- a/scripts/coccinelle/api/devm_request_and_ioremap.cocci +++ b/scripts/coccinelle/api/devm_request_and_ioremap.cocci @@ -10,7 +10,7 @@  // Copyright: (C) 2011 Gilles Muller, INRIA/LiP6.  GPLv2.  // URL: http://coccinelle.lip6.fr/  // Comments: -// Options: -no_includes -include_headers +// Options: --no-includes --include-headers  virtual patch  virtual org diff --git a/scripts/coccinelle/api/kstrdup.cocci b/scripts/coccinelle/api/kstrdup.cocci index 07a74b2c6196..09cba54ed0cf 100644 --- a/scripts/coccinelle/api/kstrdup.cocci +++ b/scripts/coccinelle/api/kstrdup.cocci @@ -6,7 +6,7 @@  // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6.  GPLv2.  // URL: http://coccinelle.lip6.fr/  // Comments: -// Options: -no_includes -include_headers +// Options: --no-includes --include-headers  virtual patch  virtual context diff --git a/scripts/coccinelle/api/memdup.cocci b/scripts/coccinelle/api/memdup.cocci index 4dceab6d54de..3d1aa71b7579 100644 --- a/scripts/coccinelle/api/memdup.cocci +++ b/scripts/coccinelle/api/memdup.cocci @@ -6,7 +6,7 @@  // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6.  GPLv2.  // URL: http://coccinelle.lip6.fr/  // Comments: -// Options: -no_includes -include_headers +// Options: --no-includes --include-headers  virtual patch  virtual context diff --git a/scripts/coccinelle/api/memdup_user.cocci b/scripts/coccinelle/api/memdup_user.cocci index 2b131a8a1306..c606231b0e46 100644 --- a/scripts/coccinelle/api/memdup_user.cocci +++ b/scripts/coccinelle/api/memdup_user.cocci @@ -7,7 +7,7 @@  // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6.  GPLv2.  // URL: http://coccinelle.lip6.fr/  // Comments: -// Options: -no_includes -include_headers +// Options: --no-includes --include-headers  virtual patch  virtual context diff --git a/scripts/coccinelle/api/ptr_ret.cocci b/scripts/coccinelle/api/ptr_ret.cocci index 15f076fdecbe..2274638d005b 100644 --- a/scripts/coccinelle/api/ptr_ret.cocci +++ b/scripts/coccinelle/api/ptr_ret.cocci @@ -5,7 +5,7 @@  // Copyright: (C) 2012 Julia Lawall, INRIA/LIP6.  GPLv2.  // Copyright: (C) 2012 Gilles Muller, INRIA/LiP6.  GPLv2.  // URL: http://coccinelle.lip6.fr/ -// Options: -no_includes -include_headers +// Options: --no-includes --include-headers  //  // Keywords: ERR_PTR, PTR_ERR, PTR_RET  // Version min: 2.6.39 diff --git a/scripts/coccinelle/api/simple_open.cocci b/scripts/coccinelle/api/simple_open.cocci index 05962f7be155..b67e174f3d95 100644 --- a/scripts/coccinelle/api/simple_open.cocci +++ b/scripts/coccinelle/api/simple_open.cocci @@ -4,7 +4,7 @@  ///  // Confidence: High  // Comments: -// Options: -no_includes -include_headers +// Options: --no-includes --include-headers  virtual patch  virtual report diff --git a/scripts/coccinelle/free/devm_free.cocci b/scripts/coccinelle/free/devm_free.cocci index 0a1e36146d76..3d9349012bb3 100644 --- a/scripts/coccinelle/free/devm_free.cocci +++ b/scripts/coccinelle/free/devm_free.cocci @@ -18,7 +18,7 @@  // Copyright: (C) 2011 Gilles Muller, INRIA/LiP6.  GPLv2.  // URL: http://coccinelle.lip6.fr/  // Comments: -// Options: -no_includes -include_headers +// Options: --no-includes --include-headers  virtual org  virtual report diff --git a/scripts/coccinelle/free/kfree.cocci b/scripts/coccinelle/free/kfree.cocci index d9ae6d89c2f5..577b78056990 100644 --- a/scripts/coccinelle/free/kfree.cocci +++ b/scripts/coccinelle/free/kfree.cocci @@ -10,7 +10,7 @@  // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6.  GPLv2.  // URL: http://coccinelle.lip6.fr/  // Comments: -// Options: -no_includes -include_headers +// Options: --no-includes --include-headers  virtual org  virtual report diff --git a/scripts/coccinelle/free/kfreeaddr.cocci b/scripts/coccinelle/free/kfreeaddr.cocci new file mode 100644 index 000000000000..ce8aacc314cb --- /dev/null +++ b/scripts/coccinelle/free/kfreeaddr.cocci @@ -0,0 +1,32 @@ +/// Free of a structure field +/// +// Confidence: High +// Copyright: (C) 2013 Julia Lawall, INRIA/LIP6.  GPLv2. +// URL: http://coccinelle.lip6.fr/ +// Comments: +// Options: --no-includes --include-headers + +virtual org +virtual report +virtual context + +@r depends on context || report || org @ +expression e; +identifier f; +position p; +@@ + +* kfree@p(&e->f) + +@script:python depends on org@ +p << r.p; +@@ + +cocci.print_main("kfree",p) + +@script:python depends on report@ +p << r.p; +@@ + +msg = "ERROR: kfree of structure field" +coccilib.report.print_report(p[0],msg) diff --git a/scripts/coccinelle/free/pci_free_consistent.cocci b/scripts/coccinelle/free/pci_free_consistent.cocci new file mode 100644 index 000000000000..43600ccb62a8 --- /dev/null +++ b/scripts/coccinelle/free/pci_free_consistent.cocci @@ -0,0 +1,52 @@ +/// Find missing pci_free_consistent for every pci_alloc_consistent. +/// +// Confidence: Moderate +// Copyright: (C) 2013 Petr Strnad.  GPLv2. +// URL: http://coccinelle.lip6.fr/ +// Keywords: pci_free_consistent, pci_alloc_consistent +// Options: --no-includes --include-headers + +virtual report +virtual org + +@search@ +local idexpression id; +expression x,y,z,e; +position p1,p2; +type T; +@@ + +id = pci_alloc_consistent@p1(x,y,&z) +... when != e = id +if (id == NULL || ...) { ... return ...; } +... when != pci_free_consistent(x,y,id,z) +    when != if (id) { ... pci_free_consistent(x,y,id,z) ... } +    when != if (y) { ... pci_free_consistent(x,y,id,z) ... } +    when != e = (T)id +    when exists +( +return 0; +| +return 1; +| +return id; +| +return@p2 ...; +) + +@script:python depends on report@ +p1 << search.p1; +p2 << search.p2; +@@ + +msg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on line %s and return without freeing on line %s" % (p1[0].line,p2[0].line) +coccilib.report.print_report(p2[0],msg) + +@script:python depends on org@ +p1 << search.p1; +p2 << search.p2; +@@ + +msg = "ERROR: missing pci_free_consistent; pci_alloc_consistent on line %s and return without freeing on line %s" % (p1[0].line,p2[0].line) +cocci.print_main(msg,p1) +cocci.print_secs("",p2) diff --git a/scripts/coccinelle/iterators/fen.cocci b/scripts/coccinelle/iterators/fen.cocci index 0a40af828c43..48c152f224e1 100644 --- a/scripts/coccinelle/iterators/fen.cocci +++ b/scripts/coccinelle/iterators/fen.cocci @@ -7,7 +7,7 @@  // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6.  GPLv2.  // URL: http://coccinelle.lip6.fr/  // Comments: -// Options: -no_includes -include_headers +// Options: --no-includes --include-headers  virtual patch  virtual context diff --git a/scripts/coccinelle/iterators/itnull.cocci b/scripts/coccinelle/iterators/itnull.cocci index 259899f6838e..f58732b56a40 100644 --- a/scripts/coccinelle/iterators/itnull.cocci +++ b/scripts/coccinelle/iterators/itnull.cocci @@ -11,7 +11,7 @@  // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6.  GPLv2.  // URL: http://coccinelle.lip6.fr/  // Comments: -// Options: -no_includes -include_headers +// Options: --no-includes --include-headers  virtual patch  virtual context diff --git a/scripts/coccinelle/iterators/list_entry_update.cocci b/scripts/coccinelle/iterators/list_entry_update.cocci index b2967475679b..873f444e7137 100644 --- a/scripts/coccinelle/iterators/list_entry_update.cocci +++ b/scripts/coccinelle/iterators/list_entry_update.cocci @@ -9,7 +9,7 @@  // Copyright: (C) 2010 Gilles Muller, INRIA/LiP6.  GPLv2.  // URL: http://coccinelle.lip6.fr/  // Comments: -// Options: -no_includes -include_headers +// Options: --no-includes --include-headers  virtual context  virtual org diff --git a/scripts/coccinelle/iterators/use_after_iter.cocci b/scripts/coccinelle/iterators/use_after_iter.cocci index 06284c57a951..f085f5968c52 100644 --- a/scripts/coccinelle/iterators/use_after_iter.cocci +++ b/scripts/coccinelle/iterators/use_after_iter.cocci @@ -11,7 +11,7 @@  // Copyright: (C) 2012 Gilles Muller, INRIA/LIP6.  GPLv2.  // URL: http://coccinelle.lip6.fr/  // Comments: -// Options: -no_includes -include_headers +// Options: --no-includes --include-headers  virtual context  virtual org diff --git a/scripts/coccinelle/locks/call_kern.cocci b/scripts/coccinelle/locks/call_kern.cocci index 8f10b49603c3..669b24436248 100644 --- a/scripts/coccinelle/locks/call_kern.cocci +++ b/scripts/coccinelle/locks/call_kern.cocci @@ -9,7 +9,7 @@  // Copyright: (C) 2012 Gilles Muller, INRIA/LiP6.  GPLv2.  // URL: http://coccinelle.lip6.fr/  // Comments: -// Options: -no_includes -include_headers +// Options: --no-includes --include-headers  virtual patch  virtual context diff --git a/scripts/coccinelle/locks/double_lock.cocci b/scripts/coccinelle/locks/double_lock.cocci index 63b24e682fad..002752f97dca 100644 --- a/scripts/coccinelle/locks/double_lock.cocci +++ b/scripts/coccinelle/locks/double_lock.cocci @@ -8,7 +8,7 @@  // Copyright: (C) 2010 Gilles Muller, INRIA/LiP6.  GPLv2.  // URL: http://coccinelle.lip6.fr/  // Comments: -// Options: -no_includes -include_headers +// Options: --no-includes --include-headers  virtual org  virtual report diff --git a/scripts/coccinelle/locks/flags.cocci b/scripts/coccinelle/locks/flags.cocci index 1c4ffe6fd846..debd70e46267 100644 --- a/scripts/coccinelle/locks/flags.cocci +++ b/scripts/coccinelle/locks/flags.cocci @@ -6,7 +6,7 @@  // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6.  GPLv2.  // URL: http://coccinelle.lip6.fr/  // Comments: -// Options: -no_includes -include_headers +// Options: --no-includes --include-headers  virtual context  virtual org diff --git a/scripts/coccinelle/locks/mini_lock.cocci b/scripts/coccinelle/locks/mini_lock.cocci index 3267d7410bd5..47f649b0ea87 100644 --- a/scripts/coccinelle/locks/mini_lock.cocci +++ b/scripts/coccinelle/locks/mini_lock.cocci @@ -11,7 +11,7 @@  // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6.  GPLv2.  // URL: http://coccinelle.lip6.fr/  // Comments: -// Options: -no_includes -include_headers +// Options: --no-includes --include-headers  virtual context  virtual org diff --git a/scripts/coccinelle/misc/boolinit.cocci b/scripts/coccinelle/misc/boolinit.cocci index 97ce41ce8135..b9abed49cd95 100644 --- a/scripts/coccinelle/misc/boolinit.cocci +++ b/scripts/coccinelle/misc/boolinit.cocci @@ -6,7 +6,7 @@  // Copyright: (C) 2012 Julia Lawall, INRIA/LIP6.  GPLv2.  // Copyright: (C) 2012 Gilles Muller, INRIA/LiP6.  GPLv2.  // URL: http://coccinelle.lip6.fr/ -// Options: -include_headers +// Options: --include-headers  virtual patch  virtual context diff --git a/scripts/coccinelle/misc/cstptr.cocci b/scripts/coccinelle/misc/cstptr.cocci index d42564484528..f0368b3d4563 100644 --- a/scripts/coccinelle/misc/cstptr.cocci +++ b/scripts/coccinelle/misc/cstptr.cocci @@ -6,7 +6,7 @@  // Copyright: (C) 2012 Gilles Muller, INRIA/LiP6.  GPLv2.  // URL: http://coccinelle.lip6.fr/  // Comments: -// Options: -no_includes -include_headers +// Options: --no-includes --include-headers  virtual org  virtual report diff --git a/scripts/coccinelle/misc/doubleinit.cocci b/scripts/coccinelle/misc/doubleinit.cocci index cf74a00cf597..c0c3371d25e0 100644 --- a/scripts/coccinelle/misc/doubleinit.cocci +++ b/scripts/coccinelle/misc/doubleinit.cocci @@ -8,7 +8,7 @@  // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6.  GPLv2.  // URL: http://coccinelle.lip6.fr/  // Comments: requires at least Coccinelle 0.2.4, lex or parse error otherwise -// Options: -no_includes -include_headers +// Options: --no-includes --include-headers  virtual org  virtual report diff --git a/scripts/coccinelle/misc/ifaddr.cocci b/scripts/coccinelle/misc/ifaddr.cocci index 3e4089a77000..8aebd1875e75 100644 --- a/scripts/coccinelle/misc/ifaddr.cocci +++ b/scripts/coccinelle/misc/ifaddr.cocci @@ -6,7 +6,7 @@  // Copyright: (C) 2012 Gilles Muller, INRIA/LiP6.  GPLv2.  // URL: http://coccinelle.lip6.fr/  // Comments: -// Options: -no_includes -include_headers +// Options: --no-includes --include-headers  virtual org  virtual report diff --git a/scripts/coccinelle/misc/ifcol.cocci b/scripts/coccinelle/misc/ifcol.cocci index b7ed91dbeb95..d0d00ef1f12a 100644 --- a/scripts/coccinelle/misc/ifcol.cocci +++ b/scripts/coccinelle/misc/ifcol.cocci @@ -13,7 +13,7 @@  // Copyright: (C) 2010 Gilles Muller, INRIA/LiP6.  GPLv2.  // URL: http://coccinelle.lip6.fr/  // Comments: -// Options: -no_includes -include_headers +// Options: --no-includes --include-headers  virtual org  virtual report diff --git a/scripts/coccinelle/misc/noderef.cocci b/scripts/coccinelle/misc/noderef.cocci index c1707214e602..80a831c91161 100644 --- a/scripts/coccinelle/misc/noderef.cocci +++ b/scripts/coccinelle/misc/noderef.cocci @@ -6,7 +6,7 @@  // Copyright: (C) 2012 Gilles Muller, INRIA/LiP6.  GPLv2.  // URL: http://coccinelle.lip6.fr/  // Comments: -// Options: -no_includes -include_headers +// Options: --no-includes --include-headers  virtual org  virtual report diff --git a/scripts/coccinelle/misc/orplus.cocci b/scripts/coccinelle/misc/orplus.cocci index 4a28cef1484e..81fabf379390 100644 --- a/scripts/coccinelle/misc/orplus.cocci +++ b/scripts/coccinelle/misc/orplus.cocci @@ -7,7 +7,7 @@  // Copyright: (C) 2013 Gilles Muller, INRIA/LIP6.  GPLv2.  // URL: http://coccinelle.lip6.fr/  // Comments: -// Options: -no_includes -include_headers +// Options: --no-includes --include-headers  virtual org  virtual report diff --git a/scripts/coccinelle/misc/warn.cocci b/scripts/coccinelle/misc/warn.cocci index fda8c3558e4f..d2e5b6cedb84 100644 --- a/scripts/coccinelle/misc/warn.cocci +++ b/scripts/coccinelle/misc/warn.cocci @@ -5,7 +5,7 @@  // Copyright: (C) 2012 Gilles Muller, INRIA/LiP6.  GPLv2.  // URL: http://coccinelle.lip6.fr/  // Comments: -// Options: -no_includes -include_headers +// Options: --no-includes --include-headers  virtual patch  virtual context diff --git a/scripts/coccinelle/null/eno.cocci b/scripts/coccinelle/null/eno.cocci index ed961a1f7d11..9bd29aa83399 100644 --- a/scripts/coccinelle/null/eno.cocci +++ b/scripts/coccinelle/null/eno.cocci @@ -6,7 +6,7 @@  // Copyright: (C) 2010-2012 Gilles Muller, INRIA/LiP6.  GPLv2.  // URL: http://coccinelle.lip6.fr/  // Comments: -// Options: -no_includes -include_headers +// Options: --no-includes --include-headers  virtual patch  virtual context diff --git a/scripts/coccinelle/null/kmerr.cocci b/scripts/coccinelle/null/kmerr.cocci index 949bf656c64c..5354a7903ccb 100644 --- a/scripts/coccinelle/null/kmerr.cocci +++ b/scripts/coccinelle/null/kmerr.cocci @@ -10,7 +10,7 @@  // Copyright: (C) 2010 Gilles Muller, INRIA/LiP6.  GPLv2.  // URL: http://coccinelle.lip6.fr/  // Comments: -// Options: -no_includes -include_headers +// Options: --no-includes --include-headers  virtual context  virtual org diff --git a/scripts/coccinelle/tests/doublebitand.cocci b/scripts/coccinelle/tests/doublebitand.cocci index 9ba73d05a77e..72f1572aaec3 100644 --- a/scripts/coccinelle/tests/doublebitand.cocci +++ b/scripts/coccinelle/tests/doublebitand.cocci @@ -10,7 +10,7 @@  // Copyright: (C) 2010 Gilles Muller, INRIA/LiP6.  GPLv2.  // URL: http://coccinelle.lip6.fr/  // Comments: -// Options: -no_includes -include_headers +// Options: --no-includes --include-headers  virtual context  virtual org diff --git a/scripts/coccinelle/tests/doubletest.cocci b/scripts/coccinelle/tests/doubletest.cocci index 13a2c0e8a4bf..78d74c22ca12 100644 --- a/scripts/coccinelle/tests/doubletest.cocci +++ b/scripts/coccinelle/tests/doubletest.cocci @@ -8,7 +8,7 @@  // Copyright: (C) 2010 Gilles Muller, INRIA/LiP6.  GPLv2.  // URL: http://coccinelle.lip6.fr/  // Comments: -// Options: -no_includes -include_headers +// Options: --no-includes --include-headers  virtual context  virtual org diff --git a/scripts/coccinelle/tests/odd_ptr_err.cocci b/scripts/coccinelle/tests/odd_ptr_err.cocci index e8dd8a6b28a2..cfe0a35cf2dd 100644 --- a/scripts/coccinelle/tests/odd_ptr_err.cocci +++ b/scripts/coccinelle/tests/odd_ptr_err.cocci @@ -7,7 +7,7 @@  // Copyright: (C) 2012 Gilles Muller, INRIA.  GPLv2.  // URL: http://coccinelle.lip6.fr/  // Comments: -// Options: -no_includes -include_headers +// Options: --no-includes --include-headers  virtual patch  virtual context diff --git a/scripts/config b/scripts/config index a65ecbbdd32a..567120a87c39 100755 --- a/scripts/config +++ b/scripts/config @@ -1,6 +1,8 @@  #!/bin/bash  # Manipulate options in a .config file from the command line +myname=${0##*/} +  # If no prefix forced, use the default CONFIG_  CONFIG_="${CONFIG_-CONFIG_}" @@ -8,7 +10,7 @@ usage() {  	cat >&2 <<EOL  Manipulate options in a .config file from the command line.  Usage: -config options command ... +$myname options command ...  commands:  	--enable|-e option   Enable option  	--disable|-d option  Disable option @@ -33,14 +35,14 @@ options:  	--file config-file   .config file to change (default .config)  	--keep-case|-k       Keep next symbols' case (dont' upper-case it) -config doesn't check the validity of the .config file. This is done at next +$myname doesn't check the validity of the .config file. This is done at next  make time. -By default, config will upper-case the given symbol. Use --keep-case to keep +By default, $myname will upper-case the given symbol. Use --keep-case to keep  the case of all following symbols unchanged. -config uses 'CONFIG_' as the default symbol prefix. Set the environment -variable CONFIG_ to the prefix to use. Eg.: CONFIG_="FOO_" config ... +$myname uses 'CONFIG_' as the default symbol prefix. Set the environment +variable CONFIG_ to the prefix to use. Eg.: CONFIG_="FOO_" $myname ...  EOL  	exit 1  } diff --git a/scripts/headers_install.sh b/scripts/headers_install.sh index 643764f53ea7..5de5660cb708 100644 --- a/scripts/headers_install.sh +++ b/scripts/headers_install.sh @@ -2,7 +2,7 @@  if [ $# -lt 1 ]  then -	echo "Usage: headers_install.sh OUTDIR [FILES...] +	echo "Usage: headers_install.sh OUTDIR SRCDIR [FILES...]  	echo  	echo "Prepares kernel header files for use by user space, by removing"  	echo "all compiler.h definitions and #includes, removing any" @@ -10,6 +10,7 @@ then  	echo "asm/inline/volatile keywords."  	echo  	echo "OUTDIR: directory to write each userspace header FILE to." +	echo "SRCDIR: source directory where files are picked."  	echo "FILES:  list of header files to operate on."  	exit 1 @@ -19,6 +20,8 @@ fi  OUTDIR="$1"  shift +SRCDIR="$1" +shift  # Iterate through files listed on command line @@ -34,7 +37,7 @@ do  		-e 's/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g' \  		-e 's/(^|[ \t(])(inline|asm|volatile)([ \t(]|$)/\1__\2__\3/g' \  		-e 's@#(ifndef|define|endif[ \t]*/[*])[ \t]*_UAPI@#\1 @' \ -		"$i" > "$OUTDIR/$FILE.sed" || exit 1 +		"$SRCDIR/$i" > "$OUTDIR/$FILE.sed" || exit 1  	scripts/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__ "$OUTDIR/$FILE.sed" \  		> "$OUTDIR/$FILE"  	[ $? -gt 1 ] && exit 1 diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index bde5b95c8c19..d19944f9c3ac 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c @@ -527,11 +527,12 @@ int main(int ac, char **av)  			seed_env = getenv("KCONFIG_SEED");  			if( seed_env && *seed_env ) {  				char *endp; -				int tmp = (int)strtol(seed_env, &endp, 10); +				int tmp = (int)strtol(seed_env, &endp, 0);  				if (*endp == '\0') {  					seed = tmp;  				}  			} +			fprintf( stderr, "KCONFIG_SEED=0x%X\n", seed );  			srand(seed);  			break;  		} @@ -653,7 +654,8 @@ int main(int ac, char **av)  		conf_set_all_new_symbols(def_default);  		break;  	case randconfig: -		conf_set_all_new_symbols(def_random); +		/* Really nothing to do in this loop */ +		while (conf_set_all_new_symbols(def_random)) ;  		break;  	case defconfig:  		conf_set_all_new_symbols(def_default); diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 43eda40c3838..c55c227af463 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -1040,7 +1040,7 @@ void conf_set_changed_callback(void (*fn)(void))  	conf_changed_callback = fn;  } -static void randomize_choice_values(struct symbol *csym) +static bool randomize_choice_values(struct symbol *csym)  {  	struct property *prop;  	struct symbol *sym; @@ -1053,7 +1053,7 @@ static void randomize_choice_values(struct symbol *csym)  	 * In both cases stop.  	 */  	if (csym->curr.tri != yes) -		return; +		return false;  	prop = sym_get_choice_prop(csym); @@ -1077,13 +1077,18 @@ static void randomize_choice_values(struct symbol *csym)  		else {  			sym->def[S_DEF_USER].tri = no;  		} +		sym->flags |= SYMBOL_DEF_USER; +		/* clear VALID to get value calculated */ +		sym->flags &= ~SYMBOL_VALID;  	}  	csym->flags |= SYMBOL_DEF_USER;  	/* clear VALID to get value calculated */  	csym->flags &= ~(SYMBOL_VALID); + +	return true;  } -static void set_all_choice_values(struct symbol *csym) +void set_all_choice_values(struct symbol *csym)  {  	struct property *prop;  	struct symbol *sym; @@ -1100,10 +1105,10 @@ static void set_all_choice_values(struct symbol *csym)  	}  	csym->flags |= SYMBOL_DEF_USER;  	/* clear VALID to get value calculated */ -	csym->flags &= ~(SYMBOL_VALID); +	csym->flags &= ~(SYMBOL_VALID | SYMBOL_NEED_SET_CHOICE_VALUES);  } -void conf_set_all_new_symbols(enum conf_def_mode mode) +bool conf_set_all_new_symbols(enum conf_def_mode mode)  {  	struct symbol *sym, *csym;  	int i, cnt, pby, pty, ptm;	/* pby: probability of boolean  = y @@ -1151,6 +1156,7 @@ void conf_set_all_new_symbols(enum conf_def_mode mode)  			exit( 1 );  		}  	} +	bool has_changed = false;  	for_all_symbols(i, sym) {  		if (sym_has_value(sym) || (sym->flags & SYMBOL_VALID)) @@ -1158,6 +1164,7 @@ void conf_set_all_new_symbols(enum conf_def_mode mode)  		switch (sym_get_type(sym)) {  		case S_BOOLEAN:  		case S_TRISTATE: +			has_changed = true;  			switch (mode) {  			case def_yes:  				sym->def[S_DEF_USER].tri = yes; @@ -1202,14 +1209,26 @@ void conf_set_all_new_symbols(enum conf_def_mode mode)  	 * selected in a choice block and we set it to yes,  	 * and the rest to no.  	 */ +	if (mode != def_random) { +		for_all_symbols(i, csym) { +			if ((sym_is_choice(csym) && !sym_has_value(csym)) || +			    sym_is_choice_value(csym)) +				csym->flags |= SYMBOL_NEED_SET_CHOICE_VALUES; +		} +	} +  	for_all_symbols(i, csym) {  		if (sym_has_value(csym) || !sym_is_choice(csym))  			continue;  		sym_calc_value(csym);  		if (mode == def_random) -			randomize_choice_values(csym); -		else +			has_changed = randomize_choice_values(csym); +		else {  			set_all_choice_values(csym); +			has_changed = true; +		}  	} + +	return has_changed;  } diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index cdd48600e02a..df198a5f4822 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h @@ -106,6 +106,9 @@ struct symbol {  #define SYMBOL_DEF3       0x40000  /* symbol.def[S_DEF_3] is valid */  #define SYMBOL_DEF4       0x80000  /* symbol.def[S_DEF_4] is valid */ +/* choice values need to be set before calculating this symbol value */ +#define SYMBOL_NEED_SET_CHOICE_VALUES  0x100000 +  #define SYMBOL_MAXLENGTH	256  #define SYMBOL_HASHSIZE		9973 diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index f8aee5fc6d5e..09f4edfdc911 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h @@ -86,7 +86,8 @@ const char *conf_get_autoconfig_name(void);  char *conf_get_default_confname(void);  void sym_set_change_count(int count);  void sym_add_change_count(int count); -void conf_set_all_new_symbols(enum conf_def_mode mode); +bool conf_set_all_new_symbols(enum conf_def_mode mode); +void set_all_choice_values(struct symbol *csym);  struct conf_printer {  	void (*print_symbol)(FILE *, struct symbol *, const char *, void *); diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h index ef1a7381f956..ecdb9659b67d 100644 --- a/scripts/kconfig/lkc_proto.h +++ b/scripts/kconfig/lkc_proto.h @@ -14,6 +14,7 @@ P(conf_set_message_callback, void,(void (*fn)(const char *fmt, va_list ap)));  /* menu.c */  P(rootmenu,struct menu,); +P(menu_is_empty, bool, (struct menu *menu));  P(menu_is_visible, bool, (struct menu *menu));  P(menu_has_prompt, bool, (struct menu *menu));  P(menu_get_prompt,const char *,(struct menu *menu)); diff --git a/scripts/kconfig/lxdialog/checklist.c b/scripts/kconfig/lxdialog/checklist.c index a2eb80fbc896..3b15c08ec1fa 100644 --- a/scripts/kconfig/lxdialog/checklist.c +++ b/scripts/kconfig/lxdialog/checklist.c @@ -132,16 +132,16 @@ int dialog_checklist(const char *title, const char *prompt, int height,  	}  do_resize: -	if (getmaxy(stdscr) < (height + 6)) +	if (getmaxy(stdscr) < (height + CHECKLIST_HEIGTH_MIN))  		return -ERRDISPLAYTOOSMALL; -	if (getmaxx(stdscr) < (width + 6)) +	if (getmaxx(stdscr) < (width + CHECKLIST_WIDTH_MIN))  		return -ERRDISPLAYTOOSMALL;  	max_choice = MIN(list_height, item_count());  	/* center dialog box on screen */ -	x = (COLS - width) / 2; -	y = (LINES - height) / 2; +	x = (getmaxx(stdscr) - width) / 2; +	y = (getmaxy(stdscr) - height) / 2;  	draw_shadow(stdscr, y, x, height, width); diff --git a/scripts/kconfig/lxdialog/dialog.h b/scripts/kconfig/lxdialog/dialog.h index 1099337079b6..b4343d384926 100644 --- a/scripts/kconfig/lxdialog/dialog.h +++ b/scripts/kconfig/lxdialog/dialog.h @@ -200,6 +200,20 @@ int item_is_tag(char tag);  int on_key_esc(WINDOW *win);  int on_key_resize(void); +/* minimum (re)size values */ +#define CHECKLIST_HEIGTH_MIN 6	/* For dialog_checklist() */ +#define CHECKLIST_WIDTH_MIN 6 +#define INPUTBOX_HEIGTH_MIN 2	/* For dialog_inputbox() */ +#define INPUTBOX_WIDTH_MIN 2 +#define MENUBOX_HEIGTH_MIN 15	/* For dialog_menu() */ +#define MENUBOX_WIDTH_MIN 65 +#define TEXTBOX_HEIGTH_MIN 8	/* For dialog_textbox() */ +#define TEXTBOX_WIDTH_MIN 8 +#define YESNO_HEIGTH_MIN 4	/* For dialog_yesno() */ +#define YESNO_WIDTH_MIN 4 +#define WINDOW_HEIGTH_MIN 19	/* For init_dialog() */ +#define WINDOW_WIDTH_MIN 80 +  int init_dialog(const char *backtitle);  void set_dialog_backtitle(const char *backtitle);  void set_dialog_subtitles(struct subtitle_list *subtitles); diff --git a/scripts/kconfig/lxdialog/inputbox.c b/scripts/kconfig/lxdialog/inputbox.c index 21404a04d7c3..447a582198c9 100644 --- a/scripts/kconfig/lxdialog/inputbox.c +++ b/scripts/kconfig/lxdialog/inputbox.c @@ -56,14 +56,14 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width  		strcpy(instr, init);  do_resize: -	if (getmaxy(stdscr) <= (height - 2)) +	if (getmaxy(stdscr) <= (height - INPUTBOX_HEIGTH_MIN))  		return -ERRDISPLAYTOOSMALL; -	if (getmaxx(stdscr) <= (width - 2)) +	if (getmaxx(stdscr) <= (width - INPUTBOX_WIDTH_MIN))  		return -ERRDISPLAYTOOSMALL;  	/* center dialog box on screen */ -	x = (COLS - width) / 2; -	y = (LINES - height) / 2; +	x = (getmaxx(stdscr) - width) / 2; +	y = (getmaxy(stdscr) - height) / 2;  	draw_shadow(stdscr, y, x, height, width); diff --git a/scripts/kconfig/lxdialog/menubox.c b/scripts/kconfig/lxdialog/menubox.c index 38cd69c5660e..c93de0b2faca 100644 --- a/scripts/kconfig/lxdialog/menubox.c +++ b/scripts/kconfig/lxdialog/menubox.c @@ -193,7 +193,7 @@ int dialog_menu(const char *title, const char *prompt,  do_resize:  	height = getmaxy(stdscr);  	width = getmaxx(stdscr); -	if (height < 15 || width < 65) +	if (height < MENUBOX_HEIGTH_MIN || width < MENUBOX_WIDTH_MIN)  		return -ERRDISPLAYTOOSMALL;  	height -= 4; @@ -203,8 +203,8 @@ do_resize:  	max_choice = MIN(menu_height, item_count());  	/* center dialog box on screen */ -	x = (COLS - width) / 2; -	y = (LINES - height) / 2; +	x = (getmaxx(stdscr) - width) / 2; +	y = (getmaxy(stdscr) - height) / 2;  	draw_shadow(stdscr, y, x, height, width); diff --git a/scripts/kconfig/lxdialog/textbox.c b/scripts/kconfig/lxdialog/textbox.c index a48bb93e0907..1773319b95e7 100644 --- a/scripts/kconfig/lxdialog/textbox.c +++ b/scripts/kconfig/lxdialog/textbox.c @@ -80,7 +80,7 @@ int dialog_textbox(const char *title, char *tbuf, int initial_height,  do_resize:  	getmaxyx(stdscr, height, width); -	if (height < 8 || width < 8) +	if (height < TEXTBOX_HEIGTH_MIN || width < TEXTBOX_WIDTH_MIN)  		return -ERRDISPLAYTOOSMALL;  	if (initial_height != 0)  		height = initial_height; @@ -98,8 +98,8 @@ do_resize:  			width = 0;  	/* center dialog box on screen */ -	x = (COLS - width) / 2; -	y = (LINES - height) / 2; +	x = (getmaxx(stdscr) - width) / 2; +	y = (getmaxy(stdscr) - height) / 2;  	draw_shadow(stdscr, y, x, height, width); diff --git a/scripts/kconfig/lxdialog/util.c b/scripts/kconfig/lxdialog/util.c index a0e97c299410..58a8289dd650 100644 --- a/scripts/kconfig/lxdialog/util.c +++ b/scripts/kconfig/lxdialog/util.c @@ -254,7 +254,12 @@ void attr_clear(WINDOW * win, int height, int width, chtype attr)  void dialog_clear(void)  { -	attr_clear(stdscr, LINES, COLS, dlg.screen.atr); +	int lines, columns; + +	lines = getmaxy(stdscr); +	columns = getmaxx(stdscr); + +	attr_clear(stdscr, lines, columns, dlg.screen.atr);  	/* Display background title if it exists ... - SLH */  	if (dlg.backtitle != NULL) {  		int i, len = 0, skip = 0; @@ -269,10 +274,10 @@ void dialog_clear(void)  		}  		wmove(stdscr, 1, 1); -		if (len > COLS - 2) { +		if (len > columns - 2) {  			const char *ellipsis = "[...] ";  			waddstr(stdscr, ellipsis); -			skip = len - (COLS - 2 - strlen(ellipsis)); +			skip = len - (columns - 2 - strlen(ellipsis));  		}  		for (pos = dlg.subtitles; pos != NULL; pos = pos->next) { @@ -298,7 +303,7 @@ void dialog_clear(void)  				skip--;  		} -		for (i = len + 1; i < COLS - 1; i++) +		for (i = len + 1; i < columns - 1; i++)  			waddch(stdscr, ACS_HLINE);  	}  	wnoutrefresh(stdscr); @@ -317,7 +322,7 @@ int init_dialog(const char *backtitle)  	getyx(stdscr, saved_y, saved_x);  	getmaxyx(stdscr, height, width); -	if (height < 19 || width < 80) { +	if (height < WINDOW_HEIGTH_MIN || width < WINDOW_WIDTH_MIN) {  		endwin();  		return -ERRDISPLAYTOOSMALL;  	} @@ -371,27 +376,19 @@ void print_title(WINDOW *dialog, const char *title, int width)  /*   * Print a string of text in a window, automatically wrap around to the   * next line if the string is too long to fit on one line. Newline - * characters '\n' are replaced by spaces.  We start on a new line + * characters '\n' are propperly processed.  We start on a new line   * if there is no room for at least 4 nonblanks following a double-space.   */  void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x)  {  	int newl, cur_x, cur_y; -	int i, prompt_len, room, wlen; -	char tempstr[MAX_LEN + 1], *word, *sp, *sp2; +	int prompt_len, room, wlen; +	char tempstr[MAX_LEN + 1], *word, *sp, *sp2, *newline_separator = 0;  	strcpy(tempstr, prompt);  	prompt_len = strlen(tempstr); -	/* -	 * Remove newlines -	 */ -	for (i = 0; i < prompt_len; i++) { -		if (tempstr[i] == '\n') -			tempstr[i] = ' '; -	} -  	if (prompt_len <= width - x * 2) {	/* If prompt is short */  		wmove(win, y, (width - prompt_len) / 2);  		waddstr(win, tempstr); @@ -401,7 +398,10 @@ void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x)  		newl = 1;  		word = tempstr;  		while (word && *word) { -			sp = strchr(word, ' '); +			sp = strpbrk(word, "\n "); +			if (sp && *sp == '\n') +				newline_separator = sp; +  			if (sp)  				*sp++ = 0; @@ -413,7 +413,7 @@ void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x)  			if (wlen > room ||  			    (newl && wlen < 4 && sp  			     && wlen + 1 + strlen(sp) > room -			     && (!(sp2 = strchr(sp, ' ')) +			     && (!(sp2 = strpbrk(sp, "\n "))  				 || wlen + 1 + (sp2 - sp) > room))) {  				cur_y++;  				cur_x = x; @@ -421,7 +421,15 @@ void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x)  			wmove(win, cur_y, cur_x);  			waddstr(win, word);  			getyx(win, cur_y, cur_x); -			cur_x++; + +			/* Move to the next line if the word separator was a newline */ +			if (newline_separator) { +				cur_y++; +				cur_x = x; +				newline_separator = 0; +			} else +				cur_x++; +  			if (sp && *sp == ' ') {  				cur_x++;	/* double space */  				while (*++sp == ' ') ; diff --git a/scripts/kconfig/lxdialog/yesno.c b/scripts/kconfig/lxdialog/yesno.c index 4e6e8090c20b..676fb2f824a3 100644 --- a/scripts/kconfig/lxdialog/yesno.c +++ b/scripts/kconfig/lxdialog/yesno.c @@ -45,14 +45,14 @@ int dialog_yesno(const char *title, const char *prompt, int height, int width)  	WINDOW *dialog;  do_resize: -	if (getmaxy(stdscr) < (height + 4)) +	if (getmaxy(stdscr) < (height + YESNO_HEIGTH_MIN))  		return -ERRDISPLAYTOOSMALL; -	if (getmaxx(stdscr) < (width + 4)) +	if (getmaxx(stdscr) < (width + YESNO_WIDTH_MIN))  		return -ERRDISPLAYTOOSMALL;  	/* center dialog box on screen */ -	x = (COLS - width) / 2; -	y = (LINES - height) / 2; +	x = (getmaxx(stdscr) - width) / 2; +	y = (getmaxy(stdscr) - height) / 2;  	draw_shadow(stdscr, y, x, height, width); diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index a69cbd78fb38..6c9c45f9fbba 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c @@ -48,7 +48,7 @@ static const char mconf_readme[] = N_(  "----------\n"  "o  Use the Up/Down arrow keys (cursor keys) to highlight the item\n"  "   you wish to change or submenu wish to select and press <Enter>.\n" -"   Submenus are designated by \"--->\".\n" +"   Submenus are designated by \"--->\", empty ones by \"----\".\n"  "\n"  "   Shortcut: Press the option's highlighted letter (hotkey).\n"  "             Pressing a hotkey more than once will sequence\n" @@ -176,7 +176,7 @@ static const char mconf_readme[] = N_(  "\n"),  menu_instructions[] = N_(  	"Arrow keys navigate the menu.  " -	"<Enter> selects submenus --->.  " +	"<Enter> selects submenus ---> (or empty submenus ----).  "  	"Highlighted letters are hotkeys.  "  	"Pressing <Y> includes, <N> excludes, <M> modularizes features.  "  	"Press <Esc><Esc> to exit, <?> for Help, </> for Search.  " @@ -401,7 +401,7 @@ static void search_conf(void)  	struct subtitle_part stpart;  	title = str_new(); -	str_printf( &title, _("Enter %s (sub)string to search for " +	str_printf( &title, _("Enter %s (sub)string or regexp to search for "  			      "(with or without \"%s\")"), CONFIG_, CONFIG_);  again: @@ -498,8 +498,9 @@ static void build_conf(struct menu *menu)  						  menu->data ? "-->" : "++>",  						  indent + 1, ' ', prompt);  				} else -					item_make("   %*c%s  --->", indent + 1, ' ', prompt); - +					item_make("   %*c%s  %s", +						  indent + 1, ' ', prompt, +						  menu_is_empty(menu) ? "----" : "--->");  				item_set_tag('m');  				item_set_data(menu);  				if (single_menu_mode && menu->data) @@ -630,7 +631,7 @@ static void build_conf(struct menu *menu)  			  (sym_has_value(sym) || !sym_is_changable(sym)) ?  			  "" : _(" (NEW)"));  		if (menu->prompt->type == P_MENU) { -			item_add_str("  --->"); +			item_add_str("  %s", menu_is_empty(menu) ? "----" : "--->");  			return;  		}  	} @@ -826,7 +827,9 @@ static void conf_choice(struct menu *menu)  		dialog_clear();  		res = dialog_checklist(prompt ? _(prompt) : _("Main Menu"),  					_(radiolist_instructions), -					 15, 70, 6); +					MENUBOX_HEIGTH_MIN, +					MENUBOX_WIDTH_MIN, +					CHECKLIST_HEIGTH_MIN);  		selected = item_activate_selected();  		switch (res) {  		case 0: @@ -957,8 +960,8 @@ static int handle_exit(void)  	dialog_clear();  	if (conf_get_changed())  		res = dialog_yesno(NULL, -				   _("Do you wish to save your new configuration ?\n" -				     "<ESC><ESC> to continue."), +				   _("Do you wish to save your new configuration?\n" +				     "(Press <ESC><ESC> to continue kernel configuration.)"),  				   6, 60);  	else  		res = -1; diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index fd3f0180e08f..7e233a6ca64e 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -443,6 +443,22 @@ bool menu_has_prompt(struct menu *menu)  	return true;  } +/* + * Determine if a menu is empty. + * A menu is considered empty if it contains no or only + * invisible entries. + */ +bool menu_is_empty(struct menu *menu) +{ +	struct menu *child; + +	for (child = menu->list; child; child = child->next) { +		if (menu_is_visible(child)) +			return(false); +	} +	return(true); +} +  bool menu_is_visible(struct menu *menu)  {  	struct menu *child; diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c index dbf31edd22b2..7975d8d258c3 100644 --- a/scripts/kconfig/nconf.c +++ b/scripts/kconfig/nconf.c @@ -45,8 +45,8 @@ static const char nconf_global_help[] = N_(  "<n> to remove it.  You may press the <Space> key to cycle through the\n"  "available options.\n"  "\n" -"A trailing \"--->\" designates a submenu.\n" -"\n" +"A trailing \"--->\" designates a submenu, a trailing \"----\" an\n" +"empty submenu.\n"  "\n"  "Menu navigation keys\n"  "----------------------------------------------------------------------\n" @@ -131,7 +131,7 @@ static const char nconf_global_help[] = N_(  "\n"),  menu_no_f_instructions[] = N_(  "Legend:  [*] built-in  [ ] excluded  <M> module  < > module capable.\n" -"Submenus are designated by a trailing \"--->\".\n" +"Submenus are designated by a trailing \"--->\", empty ones by \"----\".\n"  "\n"  "Use the following keys to navigate the menus:\n"  "Move up or down with <Up> and <Down>.\n" @@ -148,7 +148,7 @@ menu_no_f_instructions[] = N_(  "For help related to the current menu entry press <?> or <h>.\n"),  menu_instructions[] = N_(  "Legend:  [*] built-in  [ ] excluded  <M> module  < > module capable.\n" -"Submenus are designated by a trailing \"--->\".\n" +"Submenus are designated by a trailing \"--->\", empty ones by \"----\".\n"  "\n"  "Use the following keys to navigate the menus:\n"  "Move up or down with <Up> or <Down>.\n" @@ -365,15 +365,16 @@ static void print_function_line(void)  	int i;  	int offset = 1;  	const int skip = 1; +	int lines = getmaxy(stdscr);  	for (i = 0; i < function_keys_num; i++) {  		(void) wattrset(main_window, attributes[FUNCTION_HIGHLIGHT]); -		mvwprintw(main_window, LINES-3, offset, +		mvwprintw(main_window, lines-3, offset,  				"%s",  				function_keys[i].key_str);  		(void) wattrset(main_window, attributes[FUNCTION_TEXT]);  		offset += strlen(function_keys[i].key_str); -		mvwprintw(main_window, LINES-3, +		mvwprintw(main_window, lines-3,  				offset, "%s",  				function_keys[i].func);  		offset += strlen(function_keys[i].func) + skip; @@ -694,7 +695,7 @@ static void search_conf(void)  	int dres;  	title = str_new(); -	str_printf( &title, _("Enter %s (sub)string to search for " +	str_printf( &title, _("Enter %s (sub)string or regexp to search for "  			      "(with or without \"%s\")"), CONFIG_, CONFIG_);  again: @@ -759,9 +760,9 @@ static void build_conf(struct menu *menu)  						indent + 1, ' ', prompt);  				} else  					item_make(menu, 'm', -						"   %*c%s  --->", -						indent + 1, -						' ', prompt); +						  "   %*c%s  %s", +						  indent + 1, ' ', prompt, +						  menu_is_empty(menu) ? "----" : "--->");  				if (single_menu_mode && menu->data)  					goto conf_childs; @@ -903,7 +904,7 @@ static void build_conf(struct menu *menu)  				(sym_has_value(sym) || !sym_is_changable(sym)) ?  				"" : _(" (NEW)"));  		if (menu->prompt && menu->prompt->type == P_MENU) { -			item_add_str("  --->"); +			item_add_str("  %s", menu_is_empty(menu) ? "----" : "--->");  			return;  		}  	} @@ -954,7 +955,7 @@ static void show_menu(const char *prompt, const char *instructions,  	clear();  	(void) wattrset(main_window, attributes[NORMAL]); -	print_in_middle(stdscr, 1, 0, COLS, +	print_in_middle(stdscr, 1, 0, getmaxx(stdscr),  			menu_backtitle,  			attributes[MAIN_HEADING]); @@ -1455,14 +1456,18 @@ static void conf_save(void)  void setup_windows(void)  { +	int lines, columns; + +	getmaxyx(stdscr, lines, columns); +  	if (main_window != NULL)  		delwin(main_window);  	/* set up the menu and menu window */ -	main_window = newwin(LINES-2, COLS-2, 2, 1); +	main_window = newwin(lines-2, columns-2, 2, 1);  	keypad(main_window, TRUE); -	mwin_max_lines = LINES-7; -	mwin_max_cols = COLS-6; +	mwin_max_lines = lines-7; +	mwin_max_cols = columns-6;  	/* panels order is from bottom to top */  	new_panel(main_window); @@ -1470,6 +1475,7 @@ void setup_windows(void)  int main(int ac, char **av)  { +	int lines, columns;  	char *mode;  	setlocale(LC_ALL, ""); @@ -1495,7 +1501,8 @@ int main(int ac, char **av)  	keypad(stdscr, TRUE);  	curs_set(0); -	if (COLS < 75 || LINES < 20) { +	getmaxyx(stdscr, lines, columns); +	if (columns < 75 || lines < 20) {  		endwin();  		printf("Your terminal should have at "  			"least 20 lines and 75 columns\n"); diff --git a/scripts/kconfig/nconf.gui.c b/scripts/kconfig/nconf.gui.c index 9f8c44ecc703..8275f0e55106 100644 --- a/scripts/kconfig/nconf.gui.c +++ b/scripts/kconfig/nconf.gui.c @@ -276,8 +276,8 @@ int btn_dialog(WINDOW *main_window, const char *msg, int btn_num, ...)  	total_width = max(msg_width, btns_width);  	/* place dialog in middle of screen */ -	y = (LINES-(msg_lines+4))/2; -	x = (COLS-(total_width+4))/2; +	y = (getmaxy(stdscr)-(msg_lines+4))/2; +	x = (getmaxx(stdscr)-(total_width+4))/2;  	/* create the windows */ @@ -387,8 +387,8 @@ int dialog_inputbox(WINDOW *main_window,  		prompt_width = max(prompt_width, strlen(title));  	/* place dialog in middle of screen */ -	y = (LINES-(prompt_lines+4))/2; -	x = (COLS-(prompt_width+4))/2; +	y = (getmaxy(stdscr)-(prompt_lines+4))/2; +	x = (getmaxx(stdscr)-(prompt_width+4))/2;  	strncpy(result, init, *result_len); @@ -545,7 +545,7 @@ void show_scroll_win(WINDOW *main_window,  {  	int res;  	int total_lines = get_line_no(text); -	int x, y; +	int x, y, lines, columns;  	int start_x = 0, start_y = 0;  	int text_lines = 0, text_cols = 0;  	int total_cols = 0; @@ -556,6 +556,8 @@ void show_scroll_win(WINDOW *main_window,  	WINDOW *pad;  	PANEL *panel; +	getmaxyx(stdscr, lines, columns); +  	/* find the widest line of msg: */  	total_lines = get_line_no(text);  	for (i = 0; i < total_lines; i++) { @@ -569,14 +571,14 @@ void show_scroll_win(WINDOW *main_window,  	(void) wattrset(pad, attributes[SCROLLWIN_TEXT]);  	fill_window(pad, text); -	win_lines = min(total_lines+4, LINES-2); -	win_cols = min(total_cols+2, COLS-2); +	win_lines = min(total_lines+4, lines-2); +	win_cols = min(total_cols+2, columns-2);  	text_lines = max(win_lines-4, 0);  	text_cols = max(win_cols-2, 0);  	/* place window in middle of screen */ -	y = (LINES-win_lines)/2; -	x = (COLS-win_cols)/2; +	y = (lines-win_lines)/2; +	x = (columns-win_cols)/2;  	win = newwin(win_lines, win_cols, y, x);  	keypad(win, TRUE); diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index ecc5aa5f865d..d550300ec00c 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c @@ -136,7 +136,7 @@ static struct property *sym_get_range_prop(struct symbol *sym)  	return NULL;  } -static int sym_get_range_val(struct symbol *sym, int base) +static long sym_get_range_val(struct symbol *sym, int base)  {  	sym_calc_value(sym);  	switch (sym->type) { @@ -155,7 +155,7 @@ static int sym_get_range_val(struct symbol *sym, int base)  static void sym_validate_range(struct symbol *sym)  {  	struct property *prop; -	int base, val, val2; +	long base, val, val2;  	char str[64];  	switch (sym->type) { @@ -179,9 +179,9 @@ static void sym_validate_range(struct symbol *sym)  			return;  	}  	if (sym->type == S_INT) -		sprintf(str, "%d", val2); +		sprintf(str, "%ld", val2);  	else -		sprintf(str, "0x%x", val2); +		sprintf(str, "0x%lx", val2);  	sym->curr.val = strdup(str);  } @@ -300,6 +300,14 @@ void sym_calc_value(struct symbol *sym)  	if (sym->flags & SYMBOL_VALID)  		return; + +	if (sym_is_choice_value(sym) && +	    sym->flags & SYMBOL_NEED_SET_CHOICE_VALUES) { +		sym->flags &= ~SYMBOL_NEED_SET_CHOICE_VALUES; +		prop = sym_get_choice_prop(sym); +		sym_calc_value(prop_get_symbol(prop)); +	} +  	sym->flags |= SYMBOL_VALID;  	oldval = sym->curr; @@ -425,6 +433,9 @@ void sym_calc_value(struct symbol *sym)  	if (sym->flags & SYMBOL_AUTO)  		sym->flags &= ~SYMBOL_WRITE; + +	if (sym->flags & SYMBOL_NEED_SET_CHOICE_VALUES) +		set_all_choice_values(sym);  }  void sym_clear_all_valid(void) @@ -583,7 +594,7 @@ bool sym_string_valid(struct symbol *sym, const char *str)  bool sym_string_within_range(struct symbol *sym, const char *str)  {  	struct property *prop; -	int val; +	long val;  	switch (sym->type) {  	case S_STRING: @@ -943,38 +954,98 @@ const char *sym_escape_string_value(const char *in)  	return res;  } +struct sym_match { +	struct symbol	*sym; +	off_t		so, eo; +}; + +/* Compare matched symbols as thus: + * - first, symbols that match exactly + * - then, alphabetical sort + */ +static int sym_rel_comp( const void *sym1, const void *sym2 ) +{ +	struct sym_match *s1 = *(struct sym_match **)sym1; +	struct sym_match *s2 = *(struct sym_match **)sym2; +	int l1, l2; + +	/* Exact match: +	 * - if matched length on symbol s1 is the length of that symbol, +	 *   then this symbol should come first; +	 * - if matched length on symbol s2 is the length of that symbol, +	 *   then this symbol should come first. +	 * Note: since the search can be a regexp, both symbols may match +	 * exactly; if this is the case, we can't decide which comes first, +	 * and we fallback to sorting alphabetically. +	 */ +	l1 = s1->eo - s1->so; +	l2 = s2->eo - s2->so; +	if (l1 == strlen(s1->sym->name) && l2 != strlen(s2->sym->name)) +		return -1; +	if (l1 != strlen(s1->sym->name) && l2 == strlen(s2->sym->name)) +		return 1; + +	/* As a fallback, sort symbols alphabetically */ +	return strcmp(s1->sym->name, s2->sym->name); +} +  struct symbol **sym_re_search(const char *pattern)  {  	struct symbol *sym, **sym_arr = NULL; +	struct sym_match **sym_match_arr = NULL;  	int i, cnt, size;  	regex_t re; +	regmatch_t match[1];  	cnt = size = 0;  	/* Skip if empty */  	if (strlen(pattern) == 0)  		return NULL; -	if (regcomp(&re, pattern, REG_EXTENDED|REG_NOSUB|REG_ICASE)) +	if (regcomp(&re, pattern, REG_EXTENDED|REG_ICASE))  		return NULL;  	for_all_symbols(i, sym) { +		struct sym_match *tmp_sym_match;  		if (sym->flags & SYMBOL_CONST || !sym->name)  			continue; -		if (regexec(&re, sym->name, 0, NULL, 0)) +		if (regexec(&re, sym->name, 1, match, 0))  			continue;  		if (cnt + 1 >= size) { -			void *tmp = sym_arr; +			void *tmp;  			size += 16; -			sym_arr = realloc(sym_arr, size * sizeof(struct symbol *)); -			if (!sym_arr) { -				free(tmp); -				return NULL; +			tmp = realloc(sym_match_arr, size * sizeof(struct sym_match *)); +			if (!tmp) { +				goto sym_re_search_free;  			} +			sym_match_arr = tmp;  		}  		sym_calc_value(sym); -		sym_arr[cnt++] = sym; +		tmp_sym_match = (struct sym_match*)malloc(sizeof(struct sym_match)); +		if (!tmp_sym_match) +			goto sym_re_search_free; +		tmp_sym_match->sym = sym; +		/* As regexec return 0, we know we have a match, so +		 * we can use match[0].rm_[se]o without further checks +		 */ +		tmp_sym_match->so = match[0].rm_so; +		tmp_sym_match->eo = match[0].rm_eo; +		sym_match_arr[cnt++] = tmp_sym_match;  	} -	if (sym_arr) +	if (sym_match_arr) { +		qsort(sym_match_arr, cnt, sizeof(struct sym_match*), sym_rel_comp); +		sym_arr = malloc((cnt+1) * sizeof(struct symbol)); +		if (!sym_arr) +			goto sym_re_search_free; +		for (i = 0; i < cnt; i++) +			sym_arr[i] = sym_match_arr[i]->sym;  		sym_arr[cnt] = NULL; +	} +sym_re_search_free: +	if (sym_match_arr) { +		for (i = 0; i < cnt; i++) +			free(sym_match_arr[i]); +		free(sym_match_arr); +	}  	regfree(&re);  	return sym_arr; diff --git a/scripts/mod/Makefile b/scripts/mod/Makefile index 75d59fcd48b8..c11212ff3510 100644 --- a/scripts/mod/Makefile +++ b/scripts/mod/Makefile @@ -15,8 +15,8 @@ endef  quiet_cmd_offsets = GEN     $@  define cmd_offsets  	(set -e; \ -	 echo "#ifndef __DEVICEVTABLE_OFFSETS_H__"; \ -	 echo "#define __DEVICEVTABLE_OFFSETS_H__"; \ +	 echo "#ifndef __DEVICETABLE_OFFSETS_H__"; \ +	 echo "#define __DEVICETABLE_OFFSETS_H__"; \  	 echo "/*"; \  	 echo " * DO NOT MODIFY."; \  	 echo " *"; \ @@ -29,15 +29,10 @@ define cmd_offsets  	 echo "#endif" ) > $@  endef -# We use internal kbuild rules to avoid the "is up to date" message from make -scripts/mod/devicetable-offsets.s: scripts/mod/devicetable-offsets.c FORCE -	$(Q)mkdir -p $(dir $@) -	$(call if_changed_dep,cc_s_c) +$(obj)/$(devicetable-offsets-file): $(obj)/devicetable-offsets.s +	$(call if_changed,offsets) -$(obj)/$(devicetable-offsets-file): scripts/mod/devicetable-offsets.s -	$(call cmd,offsets) - -targets += $(devicetable-offsets-file) +targets += $(devicetable-offsets-file) devicetable-offsets.s  # dependencies on generated files need to be listed explicitly diff --git a/scripts/mod/devicetable-offsets.c b/scripts/mod/devicetable-offsets.c index e66d4d258e1a..bb5d115ca671 100644 --- a/scripts/mod/devicetable-offsets.c +++ b/scripts/mod/devicetable-offsets.c @@ -177,5 +177,11 @@ int main(void)  	DEVID(mei_cl_device_id);  	DEVID_FIELD(mei_cl_device_id, name); +	DEVID(rio_device_id); +	DEVID_FIELD(rio_device_id, did); +	DEVID_FIELD(rio_device_id, vid); +	DEVID_FIELD(rio_device_id, asm_did); +	DEVID_FIELD(rio_device_id, asm_vid); +  	return 0;  } diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index 45f9a3377dcd..23708636b05c 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c @@ -79,10 +79,12 @@ struct devtable **__start___devtable, **__stop___devtable;  extern struct devtable *__start___devtable[], *__stop___devtable[];  #endif /* __MACH__ */ -#if __GNUC__ == 3 && __GNUC_MINOR__ < 3 -# define __used			__attribute__((__unused__)) -#else -# define __used			__attribute__((__used__)) +#if !defined(__used) +# if __GNUC__ == 3 && __GNUC_MINOR__ < 3 +#  define __used			__attribute__((__unused__)) +# else +#  define __used			__attribute__((__used__)) +# endif  #endif  /* Define a variable f that holds the value of field f of struct devid @@ -1145,6 +1147,26 @@ static int do_mei_entry(const char *filename, void *symval,  }  ADD_TO_DEVTABLE("mei", mei_cl_device_id, do_mei_entry); +/* Looks like: rapidio:vNdNavNadN */ +static int do_rio_entry(const char *filename, +			void *symval, char *alias) +{ +	DEF_FIELD(symval, rio_device_id, did); +	DEF_FIELD(symval, rio_device_id, vid); +	DEF_FIELD(symval, rio_device_id, asm_did); +	DEF_FIELD(symval, rio_device_id, asm_vid); + +	strcpy(alias, "rapidio:"); +	ADD(alias, "v", vid != RIO_ANY_ID, vid); +	ADD(alias, "d", did != RIO_ANY_ID, did); +	ADD(alias, "av", asm_vid != RIO_ANY_ID, asm_vid); +	ADD(alias, "ad", asm_did != RIO_ANY_ID, asm_did); + +	add_wildcard(alias); +	return 1; +} +ADD_TO_DEVTABLE("rapidio", rio_device_id, do_rio_entry); +  /* Does namelen bytes of name exactly match the symbol? */  static bool sym_is(const char *name, unsigned namelen, const char *symbol)  { diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index a4be8e112bb6..62164348ecf7 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -861,37 +861,34 @@ static void check_section(const char *modname, struct elf_info *elf,  #define ALL_INIT_DATA_SECTIONS \ -	".init.setup$", ".init.rodata$", \ -	".cpuinit.rodata$", ".meminit.rodata$", \ -	".init.data$", ".cpuinit.data$", ".meminit.data$" +	".init.setup$", ".init.rodata$", ".meminit.rodata$", \ +	".init.data$", ".meminit.data$"  #define ALL_EXIT_DATA_SECTIONS \ -	".exit.data$", ".cpuexit.data$", ".memexit.data$" +	".exit.data$", ".memexit.data$"  #define ALL_INIT_TEXT_SECTIONS \ -	".init.text$", ".cpuinit.text$", ".meminit.text$" +	".init.text$", ".meminit.text$"  #define ALL_EXIT_TEXT_SECTIONS \ -	".exit.text$", ".cpuexit.text$", ".memexit.text$" +	".exit.text$", ".memexit.text$"  #define ALL_PCI_INIT_SECTIONS	\  	".pci_fixup_early$", ".pci_fixup_header$", ".pci_fixup_final$", \  	".pci_fixup_enable$", ".pci_fixup_resume$", \  	".pci_fixup_resume_early$", ".pci_fixup_suspend$" -#define ALL_XXXINIT_SECTIONS CPU_INIT_SECTIONS, MEM_INIT_SECTIONS -#define ALL_XXXEXIT_SECTIONS CPU_EXIT_SECTIONS, MEM_EXIT_SECTIONS +#define ALL_XXXINIT_SECTIONS MEM_INIT_SECTIONS +#define ALL_XXXEXIT_SECTIONS MEM_EXIT_SECTIONS  #define ALL_INIT_SECTIONS INIT_SECTIONS, ALL_XXXINIT_SECTIONS  #define ALL_EXIT_SECTIONS EXIT_SECTIONS, ALL_XXXEXIT_SECTIONS  #define DATA_SECTIONS ".data$", ".data.rel$" -#define TEXT_SECTIONS ".text$" +#define TEXT_SECTIONS ".text$", ".text.unlikely$"  #define INIT_SECTIONS      ".init.*" -#define CPU_INIT_SECTIONS  ".cpuinit.*"  #define MEM_INIT_SECTIONS  ".meminit.*"  #define EXIT_SECTIONS      ".exit.*" -#define CPU_EXIT_SECTIONS  ".cpuexit.*"  #define MEM_EXIT_SECTIONS  ".memexit.*"  /* init data sections */ @@ -979,48 +976,20 @@ const struct sectioncheck sectioncheck[] = {  	.mismatch = DATA_TO_ANY_EXIT,  	.symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },  }, -/* Do not reference init code/data from cpuinit/meminit code/data */ +/* Do not reference init code/data from meminit code/data */  {  	.fromsec = { ALL_XXXINIT_SECTIONS, NULL },  	.tosec   = { INIT_SECTIONS, NULL },  	.mismatch = XXXINIT_TO_SOME_INIT,  	.symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },  }, -/* Do not reference cpuinit code/data from meminit code/data */ -{ -	.fromsec = { MEM_INIT_SECTIONS, NULL }, -	.tosec   = { CPU_INIT_SECTIONS, NULL }, -	.mismatch = XXXINIT_TO_SOME_INIT, -	.symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL }, -}, -/* Do not reference meminit code/data from cpuinit code/data */ -{ -	.fromsec = { CPU_INIT_SECTIONS, NULL }, -	.tosec   = { MEM_INIT_SECTIONS, NULL }, -	.mismatch = XXXINIT_TO_SOME_INIT, -	.symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL }, -}, -/* Do not reference exit code/data from cpuexit/memexit code/data */ +/* Do not reference exit code/data from memexit code/data */  {  	.fromsec = { ALL_XXXEXIT_SECTIONS, NULL },  	.tosec   = { EXIT_SECTIONS, NULL },  	.mismatch = XXXEXIT_TO_SOME_EXIT,  	.symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },  }, -/* Do not reference cpuexit code/data from memexit code/data */ -{ -	.fromsec = { MEM_EXIT_SECTIONS, NULL }, -	.tosec   = { CPU_EXIT_SECTIONS, NULL }, -	.mismatch = XXXEXIT_TO_SOME_EXIT, -	.symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL }, -}, -/* Do not reference memexit code/data from cpuexit code/data */ -{ -	.fromsec = { CPU_EXIT_SECTIONS, NULL }, -	.tosec   = { MEM_EXIT_SECTIONS, NULL }, -	.mismatch = XXXEXIT_TO_SOME_EXIT, -	.symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL }, -},  /* Do not use exit code/data from init code */  {  	.fromsec = { ALL_INIT_SECTIONS, NULL }, @@ -1089,8 +1058,6 @@ static const struct sectioncheck *section_mismatch(   * Pattern 2:   *   Many drivers utilise a *driver container with references to   *   add, remove, probe functions etc. - *   These functions may often be marked __cpuinit and we do not want to - *   warn here.   *   the pattern is identified by:   *   tosec   = init or exit section   *   fromsec = data section @@ -1249,7 +1216,6 @@ static Elf_Sym *find_elf_symbol2(struct elf_info *elf, Elf_Addr addr,  /*   * Convert a section name to the function/data attribute   * .init.text => __init - * .cpuinit.data => __cpudata   * .memexitconst => __memconst   * etc.   * diff --git a/scripts/package/mkspec b/scripts/package/mkspec index fbbfd08853d3..fdd3fbf4d4a4 100755 --- a/scripts/package/mkspec +++ b/scripts/package/mkspec @@ -74,6 +74,7 @@ echo ""  fi  echo "%install" +echo 'KBUILD_IMAGE=$(make image_name)'  echo "%ifarch ia64"  echo 'mkdir -p $RPM_BUILD_ROOT/boot/efi $RPM_BUILD_ROOT/lib/modules'  echo 'mkdir -p $RPM_BUILD_ROOT/lib/firmware' diff --git a/scripts/setlocalversion b/scripts/setlocalversion index 84b88f109b80..d105a44b68f6 100755 --- a/scripts/setlocalversion +++ b/scripts/setlocalversion @@ -71,9 +71,6 @@ scm_version()  			printf -- '-svn%s' "`git svn find-rev $head`"  		fi -		# Update index only on r/w media -		[ -w . ] && git update-index --refresh --unmerged > /dev/null -  		# Check for uncommitted changes  		if git diff-index --name-only HEAD | grep -qv "^scripts/package"; then  			printf '%s' -dirty diff --git a/scripts/sortextable.c b/scripts/sortextable.c index 1f10e89d15b4..f9ce1160419b 100644 --- a/scripts/sortextable.c +++ b/scripts/sortextable.c @@ -31,6 +31,10 @@  #include <tools/be_byteshift.h>  #include <tools/le_byteshift.h> +#ifndef EM_AARCH64 +#define EM_AARCH64	183 +#endif +  static int fd_map;	/* File descriptor for file being modified. */  static int mmap_failed; /* Boolean flag. */  static void *ehdr_curr; /* current ElfXX_Ehdr *  for resource cleanup */ @@ -249,6 +253,7 @@ do_file(char const *const fname)  		custom_sort = sort_relative_table;  		break;  	case EM_ARM: +	case EM_AARCH64:  	case EM_MIPS:  		break;  	}  /* end switch */ |