Skip to contentSkip to conversation

dim: Avoid false positives with BUG detection

PATCH Superseded Tvrtko Ursulin 3 participants 5 messages Mar 11, 2016 – Mar 18, 2016

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dim: Avoid false positives with BUG detection

From: Tvrtko Ursulin <[email protected]>

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.

---
 dim | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
dim +2 -1
index 1e7622a1e902..e32b24988571 100755
@@ -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
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

PATCH v2 1/1 dim: Avoid false positives with BUG detection

From: Tvrtko Ursulin <[email protected]>

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.

v2: Sent the incomplete version out...

---
 dim | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
dim +2 -1
index 1e7622a1e902..5392c64bf5b4 100755
@@ -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 '^[+-].*\WBUG')
+	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
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw
Quoted 19 lines · Tvrtko Ursulin

From: Tvrtko Ursulin <[email protected]>

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.

v2: Sent the incomplete version out...

---
  dim | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
dim +0 -0
index 1e7622a1e902..5392c64bf5b4 100755

dim function shell_checkpatch · line 698

Quoted 9 lines
dim +2 -1
@@ -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 '^[+-].*\WBUG')
+	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

Are we interested in this?

Regards,

Tvrtko
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#3 lore raw
Quoted 24 lines · Tvrtko Ursulin

[ text/plain ]

Quoted 20 lines · Tvrtko Ursulin

From: Tvrtko Ursulin <[email protected]>

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.

v2: Sent the incomplete version out...

---
  dim | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
dim +0 -0
index 1e7622a1e902..5392c64bf5b4 100755
@@ -691,7 +691,8 @@ function shell_checkpatch
  	local cmd=$1
 
Quoted 10 lines

dim function shell_checkpatch · line 698

Quoted 8 lines
dim +2 -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 '^[+-].*\WBUG')
+	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

Are we interested in this?

Yes. Sorry, I've updated these lines so you'll need to rebase, I'm afraid.

I'd also be fine with comparing the results of $(grep -c '^\+.*\WBUG) and $(grep -c '^\-.*\WBUG) and complaining if there are more +'s than -'s. But your stricter version is fine too.

BR,
Jani.

Quoted 4 lines

Regards,

Tvrtko

Signature · 5 lines
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#4 lore raw
Quoted 39 lines · Jani Nikula
Quoted 24 lines · Tvrtko Ursulin

[ text/plain ]

Quoted 20 lines · Tvrtko Ursulin

From: Tvrtko Ursulin <[email protected]>

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.

v2: Sent the incomplete version out...

---
   dim | 3 ++-
   1 file changed, 2 insertions(+), 1 deletion(-)
dim +0 -0
index 1e7622a1e902..5392c64bf5b4 100755
@@ -691,7 +691,8 @@ function shell_checkpatch
   	local cmd=$1
 
Quoted 10 lines

dim function shell_checkpatch · line 698

Quoted 8 lines
dim +2 -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 '^[+-].*\WBUG')
+	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

Are we interested in this?

Yes. Sorry, I've updated these lines so you'll need to rebase, I'm afraid.

Quoted 6 lines

I'd also be fine with comparing the results of $(grep -c '^\+.*\WBUG) and $(grep -c '^\-.*\WBUG) and complaining if there are more +'s than -'s. But your stricter version is fine too.

BR,
Jani.

The version above doesn't really avoid all the issues, though; for example if the edited BUG spans multiple lines, or if the pattern spotted (first added line containing a word beginning with BUG) is in a comment or string, or what's actually happened is that some code has been moved from before an existing BUG() to after or vice-versa, but diff thinks you've deleted the old BUG() and added a new one :(

.Dave.
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx