Tweak some static analysis suppressions
A follow-up to commit 4c5a1df0cc06b3b101786454070544641a44cebb.
If whitespace changes are ignored, there are only two changes to
third_party/fastfeat/nonmax.c in that commit, and we tweak them as
follows.
1. Change:
if(pos.y > 0)
if (row_start[pos.y - 1] != -1)
to:
if(pos.y > 0 && row_start[pos.y - 1] != -1)
This is closer to the original code, which is:
if(pos.y != 0 && row_start[pos.y - 1] != -1)
2. Remove the "if(pos.y >= 0)" check after the comment
"Check below (if there is anything below)". The scan-build in LLVM 14
does not need this check. Again this is closer to the original code.
After these tweaks, the description of
commit 06540eb9ad297a93b413c38041a95cceb6524c06 in
third_party/fastfeat/README.libaom also covers change #1, so I just
change the word "comparison" to "comparisons" (plural).
Change-Id: Ic6299a95f284dcb84379caf663518e6ab34faa02
diff --git a/third_party/fastfeat/README.libaom b/third_party/fastfeat/README.libaom
index 6c227c9..8aaee12 100644
--- a/third_party/fastfeat/README.libaom
+++ b/third_party/fastfeat/README.libaom
@@ -40,4 +40,4 @@
Prefix global functions with "aom_"
Add error checking
Add output argument to hold the scores of the detected features
-Add assertion and rewrite comparison to appease the scan-build static analyzer
+Add assertion and rewrite comparisons to appease the scan-build static analyzer
diff --git a/third_party/fastfeat/nonmax.c b/third_party/fastfeat/nonmax.c
index 18d627e..cc0ada7 100644
--- a/third_party/fastfeat/nonmax.c
+++ b/third_party/fastfeat/nonmax.c
@@ -116,48 +116,46 @@
continue;
/*Check above (if there is a valid row above)*/
- if(pos.y > 0)
- if (row_start[pos.y - 1] != -1)
+ if(pos.y > 0 && row_start[pos.y - 1] != -1)
+ {
+ /*Make sure that current point_above is one
+ row above.*/
+ if(corners[point_above].y < pos.y - 1)
+ point_above = row_start[pos.y-1];
+
+ /*Make point_above point to the first of the pixels above the current point,
+ if it exists.*/
+ for(; corners[point_above].y < pos.y && corners[point_above].x < pos.x - 1; point_above++)
+ {}
+
+
+ for(j=point_above; corners[j].y < pos.y && corners[j].x <= pos.x + 1; j++)
{
- /*Make sure that current point_above is one
- row above.*/
- if(corners[point_above].y < pos.y - 1)
- point_above = row_start[pos.y-1];
-
- /*Make point_above point to the first of the pixels above the current point,
- if it exists.*/
- for(; corners[point_above].y < pos.y && corners[point_above].x < pos.x - 1; point_above++)
- {}
-
-
- for(j=point_above; corners[j].y < pos.y && corners[j].x <= pos.x + 1; j++)
- {
- int x = corners[j].x;
- if( (x == pos.x - 1 || x ==pos.x || x == pos.x+1) && Compare(scores[j], score))
- goto cont;
- }
-
+ int x = corners[j].x;
+ if( (x == pos.x - 1 || x ==pos.x || x == pos.x+1) && Compare(scores[j], score))
+ goto cont;
}
+ }
+
/*Check below (if there is anything below)*/
- if(pos.y >= 0)
- if (pos.y + 1 < last_row+1 && row_start[pos.y + 1] != -1 && point_below < sz) /*Nothing below*/
+ if (pos.y + 1 < last_row+1 && row_start[pos.y + 1] != -1 && point_below < sz) /*Nothing below*/
+ {
+ if(corners[point_below].y < pos.y + 1)
+ point_below = row_start[pos.y+1];
+
+ /* Make point below point to one of the pixels belowthe current point, if it
+ exists.*/
+ for(; point_below < sz && corners[point_below].y == pos.y+1 && corners[point_below].x < pos.x - 1; point_below++)
+ {}
+
+ for(j=point_below; j < sz && corners[j].y == pos.y+1 && corners[j].x <= pos.x + 1; j++)
{
- if(corners[point_below].y < pos.y + 1)
- point_below = row_start[pos.y+1];
-
- /* Make point below point to one of the pixels belowthe current point, if it
- exists.*/
- for(; point_below < sz && corners[point_below].y == pos.y+1 && corners[point_below].x < pos.x - 1; point_below++)
- {}
-
- for(j=point_below; j < sz && corners[j].y == pos.y+1 && corners[j].x <= pos.x + 1; j++)
- {
- int x = corners[j].x;
- if( (x == pos.x - 1 || x ==pos.x || x == pos.x+1) && Compare(scores[j],score))
- goto cont;
- }
+ int x = corners[j].x;
+ if( (x == pos.x - 1 || x ==pos.x || x == pos.x+1) && Compare(scores[j],score))
+ goto cont;
}
+ }
ret_nonmax[num_nonmax] = corners[i];
nonmax_scores[num_nonmax] = scores[i];