mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 02:30:34 +02:00 
			
		
		
		
	checkpatch: trailing statement indent: fix end of statement location
Fix end of statement location. Where the last line of the statement is replaced we are miss reporting the newly added replacement an incorrectly indented trailing statement for the negative context. We are also incorrectly reporting negative statements generally. Signed-off-by: Andy Whitcroft <apw@shadowen.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
		
							parent
							
								
									a3bb97a7ab
								
							
						
					
					
						commit
						548596d523
					
				
					 1 changed files with 10 additions and 5 deletions
				
			
		| 
						 | 
					@ -1249,17 +1249,22 @@ sub process {
 | 
				
			||||||
			my $pre_ctx = "$1$2";
 | 
								my $pre_ctx = "$1$2";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			my ($level, @ctx) = ctx_statement_level($linenr, $realcnt, 0);
 | 
								my ($level, @ctx) = ctx_statement_level($linenr, $realcnt, 0);
 | 
				
			||||||
			my $ctx_ln = $linenr + $#ctx + 1;
 | 
					 | 
				
			||||||
			my $ctx_cnt = $realcnt - $#ctx - 1;
 | 
								my $ctx_cnt = $realcnt - $#ctx - 1;
 | 
				
			||||||
			my $ctx = join("\n", @ctx);
 | 
								my $ctx = join("\n", @ctx);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			##warn "realcnt<$realcnt> ctx_cnt<$ctx_cnt>\n";
 | 
								my $ctx_ln = $linenr;
 | 
				
			||||||
 | 
								my $ctx_skip = $realcnt;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			# Skip over any removed lines in the context following statement.
 | 
								while ($ctx_skip > $ctx_cnt || ($ctx_skip == $ctx_cnt &&
 | 
				
			||||||
			while (defined($lines[$ctx_ln - 1]) && $lines[$ctx_ln - 1] =~ /^-/) {
 | 
										defined $lines[$ctx_ln - 1] &&
 | 
				
			||||||
 | 
										$lines[$ctx_ln - 1] =~ /^-/)) {
 | 
				
			||||||
 | 
									##print "SKIP<$ctx_skip> CNT<$ctx_cnt>\n";
 | 
				
			||||||
 | 
									$ctx_skip-- if (!defined $lines[$ctx_ln - 1] || $lines[$ctx_ln - 1] !~ /^-/);
 | 
				
			||||||
				$ctx_ln++;
 | 
									$ctx_ln++;
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			##warn "pre<$pre_ctx>\nline<$line>\nctx<$ctx>\nnext<$lines[$ctx_ln - 1]>\n";
 | 
					
 | 
				
			||||||
 | 
								##print "realcnt<$realcnt> ctx_cnt<$ctx_cnt>\n";
 | 
				
			||||||
 | 
								##print "pre<$pre_ctx>\nline<$line>\nctx<$ctx>\nnext<$lines[$ctx_ln - 1]>\n";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if ($ctx !~ /{\s*/ && defined($lines[$ctx_ln -1]) && $lines[$ctx_ln - 1] =~ /^\+\s*{/) {
 | 
								if ($ctx !~ /{\s*/ && defined($lines[$ctx_ln -1]) && $lines[$ctx_ln - 1] =~ /^\+\s*{/) {
 | 
				
			||||||
				ERROR("that open brace { should be on the previous line\n" .
 | 
									ERROR("that open brace { should be on the previous line\n" .
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue