diff mbox

dim: Avoid false positives with BUG detection

Message ID 1457710012-12589-1-git-send-email-tvrtko.ursulin@linux.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Tvrtko Ursulin March 11, 2016, 3:26 p.m. UTC
From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Makes sure that the diff line adding the BUG is not immediately
preceded by the diff line removing the BUG. Or in other words,
avoids false positives when existing BUG is edited.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 dim | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/dim b/dim
index 1e7622a1e902..e32b24988571 100755
--- a/dim
+++ b/dim
@@ -691,7 +691,8 @@  function shell_checkpatch
 	local cmd=$1
 
 	$cmd | scripts/checkpatch.pl -q --strict - || true
-	if $cmd | grep '^\+.*\WBUG' > /dev/null; then
+	local bug_lines=$("$cmd" | grep -m 1 -B 1 '^\+.*\WBUG' | grep -c '^[+-]')
+	if test "$bug_lines" -eq 1; then
 		warn_or_fail "New BUG macro added"
 	fi
 	$cmd | grep '^\+.*drm_i915_private_t' > /dev/null && echo "WARNING: New drm_i915_private_t added" || true