Skip to content
Snippets Groups Projects
checkpatch.pl 112 KiB
Newer Older
  • Learn to ignore specific revisions
  • 			    $realfile !~ m@^drivers/base/core@) {
    
    				ERROR("LOCKDEP",
    				      "lockdep_no_validate class is reserved for device->mutex.\n" . $herecurr);
    
    
    		if ($line =~ /debugfs_create_file.*S_IWUGO/ ||
    		    $line =~ /DEVICE_ATTR.*S_IWUGO/ ) {
    
    			WARN("EXPORTED_WORLD_WRITABLE",
    			     "Exporting world writable files is usually an error. Consider more restrictive permissions.\n" . $herecurr);
    
    	}
    
    	# If we have no input at all, then there is nothing to report on
    	# so just keep quiet.
    	if ($#rawlines == -1) {
    		exit(0);
    
    	# In mailback mode only produce a report in the negative, for
    	# things that appear to be patches.
    	if ($mailback && ($clean == 1 || !$is_patch)) {
    		exit(0);
    	}
    
    	# This is not a patch, and we are are in 'no-patch' mode so
    	# just keep quiet.
    	if (!$chk_patch && !$is_patch) {
    		exit(0);
    	}
    
    	if (!$is_patch) {
    
    		ERROR("NOT_UNIFIED_DIFF",
    		      "Does not appear to be a unified-diff format patch\n");
    
    	}
    	if ($is_patch && $chk_signoff && $signoff == 0) {
    
    		ERROR("MISSING_SIGN_OFF",
    		      "Missing Signed-off-by: line(s)\n");
    
    	print report_dump();
    
    	if ($summary && !($clean == 1 && $quiet == 1)) {
    		print "$filename " if ($summary_file);
    
    		print "total: $cnt_error errors, $cnt_warn warnings, " .
    			(($check)? "$cnt_chk checks, " : "") .
    			"$cnt_lines lines checked\n";
    		print "\n" if ($quiet == 0);
    
    
    		if ($^V lt 5.10.0) {
    			print("NOTE: perl $^V is not modern enough to detect all possible issues.\n");
    			print("An upgrade to at least perl v5.10.0 is suggested.\n\n");
    		}
    
    
    		# If there were whitespace errors which cleanpatch can fix
    		# then suggest that.
    		if ($rpt_cleaners) {
    			print "NOTE: whitespace errors detected, you may wish to use scripts/cleanpatch or\n";
    			print "      scripts/cleanfile\n\n";
    
    	if ($quiet == 0 && keys %ignore_type) {
    
    	    print "NOTE: Ignored message types:";
    	    foreach my $ignore (sort keys %ignore_type) {
    		print " $ignore";
    	    }
    
    	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"
    
    	}
    	if ($clean == 0 && $quiet == 0) {
    
    		print << "EOM";
    $vname has style problems, please review.
    
    If any of these errors are false positives, please report
    them to the maintainer, see CHECKPATCH in MAINTAINERS.
    EOM
    
    	return $clean;
    }