Skip to contentSkip to conversation

checkpatch: ignore deleted lines for comment context

PATCH Superseded Andreas Dilger 1 participant 1 message Jan 9, 2024 Checkpatch

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 checkpatch: ignore deleted lines for comment context

Don't consider lines being removed by a patch as part of the context. Otherwise, false "WARNING: memory barrier without comment" and similar warnings can be reported when a comment exists on the previous line.

For example, a change like below was previously incorrectly flagged:

	/* matched by smp_store_release() in some_function() */

- if (smp_load_acquire(&list->tail) == head))
+ if (smp_load_acquire(&list->tail) == head) && flags == 0)

---
V1 -> V2: don't include extra debugging in 'warn' line

 scripts/checkpatch.pl | 1 +
 1 file changed, 1 insertion(+)
scripts/checkpatch.pl +1 -0
index 25fdb7fda112..316a65354718 100755
@@ -1973,6 +1973,7 @@ sub ctx_locate_comment {
 	for (my $linenr = $first_line; $linenr < $end_line; $linenr++) {
 		my $line = $rawlines[$linenr - 1];
 		#warn "           $line\n";
+		next if ($line =~ /^-/); # ignore lines removed by patch
 		if ($linenr == $first_line and $line =~ m@^.\s*\*@) {
 			$in_comment = 1;
 		}
Signature · 1 line
2.25.1