[PATCH] blame - fix some issues identified by coverage report.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Michael Platings <michael@xxxxxxxxx>

Thanks to Derrick Stolee for highlighting missing coverage.

In the case of "certainties[i] = CERTAINTY_NOT_CALCULATED" this was
defeating an optimization that preserved results of calculations
between line-matching passes. This had caused other code to never
be executed - that code is now executed and only discards calculation
results that are no longer valid.

In the case of "max_search_distance_b = 0" this was never executed
because another statement was added earlier in the function to return
early in such a case.

Signed-off-by: Michael Platings <michael@xxxxxxxxx>
---
 blame.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/blame.c b/blame.c
index c059063688..2b47c942db 100644
--- a/blame.c
+++ b/blame.c
@@ -825,10 +825,6 @@ static void fuzzy_find_matching_lines_recurse(
 		*get_similarity(similarities, most_certain_line_a - start_a,
 				i, closest_local_line_a,
 				max_search_distance_a) = -1;
-
-		if (certainties[i] >= 0) {
-			certainties[i] = CERTAINTY_NOT_CALCULATED;
-		}
 	}
 
 	/* More invalidating of results that may be affected by the choice of
@@ -947,12 +943,8 @@ static int *fuzzy_find_matching_lines(struct blame_origin *parent,
 	if (max_search_distance_a >= length_a)
 		max_search_distance_a = length_a ? length_a - 1 : 0;
 
-	if (length_a == 0) {
-		max_search_distance_b = 0;
-	} else {
-		max_search_distance_b = ((2 * max_search_distance_a + 1) *
-			length_b - 1) / length_a;
-	}
+	max_search_distance_b = ((2 * max_search_distance_a + 1) *
+		length_b - 1) / length_a;
 
 	result = xcalloc(sizeof(int), length_b);
 	second_best_result = xcalloc(sizeof(int), length_b);
-- 
2.21.0




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux