Blame SOURCES/0076-nbis-Make-the-extern-global-bozworth-y-variable-as-b.patch

73b847
From 9c3af4498e7e5898744c4598fe89a5b34e639b92 Mon Sep 17 00:00:00 2001
73b847
From: =?UTF-8?q?Marco=20Trevisan=20=28Trevi=C3=B1o=29?= <mail@3v1n0.net>
73b847
Date: Wed, 4 Dec 2019 14:22:07 +0100
73b847
Subject: [PATCH 076/181] nbis: Make the extern global bozworth 'y' variable as
73b847
 bz_y
73b847
73b847
Othewise this could create issues with other 'y' variable definitions
73b847
shadowing it.
73b847
73b847
Add a cocci file that performs the change automatically
73b847
---
73b847
 libfprint/nbis/bozorth3/bozorth3.c   | 34 ++++++++++++++--------------
73b847
 libfprint/nbis/bozorth3/bz_gbls.c    |  4 ++--
73b847
 libfprint/nbis/include/bozorth.h     |  2 +-
73b847
 libfprint/nbis/remove-global-y.cocci | 21 +++++++++++++++++
73b847
 libfprint/nbis/update-from-nbis.sh   |  3 +++
73b847
 5 files changed, 44 insertions(+), 20 deletions(-)
73b847
 create mode 100644 libfprint/nbis/remove-global-y.cocci
73b847
73b847
diff --git a/libfprint/nbis/bozorth3/bozorth3.c b/libfprint/nbis/bozorth3/bozorth3.c
73b847
index 0a8b0ff..e2e668f 100644
73b847
--- a/libfprint/nbis/bozorth3/bozorth3.c
73b847
+++ b/libfprint/nbis/bozorth3/bozorth3.c
73b847
@@ -896,7 +896,7 @@ for ( k = 0; k < np - 1; k++ ) {
73b847
 			for ( i = 0; i < tot; i++ ) {
73b847
 
73b847
 
73b847
-				int colp_value = colp[ y[i]-1 ][0];
73b847
+				int colp_value = colp[ bz_y[i]-1 ][0];
73b847
 				if ( colp_value < 0 ) {
73b847
 					kk += colp_value;
73b847
 					n++;
73b847
@@ -933,7 +933,7 @@ for ( k = 0; k < np - 1; k++ ) {
73b847
 
73b847
 			kk = 0;
73b847
 			for ( i = 0; i < tot; i++ ) {
73b847
-				int diff = colp[ y[i]-1 ][0] - jj;
73b847
+				int diff = colp[ bz_y[i]-1 ][0] - jj;
73b847
 				j = SQUARED( diff );
73b847
 
73b847
 
73b847
@@ -942,7 +942,7 @@ for ( k = 0; k < np - 1; k++ ) {
73b847
 				if ( j > TXS && j < CTXS )
73b847
 					kk++;
73b847
 				else
73b847
-					y[i-kk] = y[i];
73b847
+					bz_y[i-kk] = bz_y[i];
73b847
 			} /* END FOR i */
73b847
 
73b847
 			tot -= kk;				/* Adjust the total edge pairs TOT based on # of edge pairs skipped */
73b847
@@ -958,7 +958,7 @@ for ( k = 0; k < np - 1; k++ ) {
73b847
 
73b847
 
73b847
 			for ( i = tot-1 ; i >= 0; i-- ) {
73b847
-				int idx = y[i] - 1;
73b847
+				int idx = bz_y[i] - 1;
73b847
 				if ( rk[idx] == 0 ) {
73b847
 					sc[idx] = -1;
73b847
 				} else {
73b847
@@ -976,7 +976,7 @@ for ( k = 0; k < np - 1; k++ ) {
73b847
 			int pd = 0;
73b847
 
73b847
 			for ( i = 0; i < tot; i++ ) {
73b847
-				int idx = y[i] - 1;
73b847
+				int idx = bz_y[i] - 1;
73b847
 				for ( ii = 1; ii < 4; ii++ ) {
73b847
 
73b847
 
73b847
@@ -1476,7 +1476,7 @@ return match_score;
73b847
 /* extern int rk[ RK_SIZE ]; */
73b847
 /* extern int cp[ CP_SIZE ]; */
73b847
 /* extern int rp[ RP_SIZE ]; */
73b847
-/* extern int y[ Y_SIZE ]; */
73b847
+/* extern int bz_y[ Y_SIZE ]; */
73b847
 
73b847
 void bz_sift(
73b847
 	int * ww,		/* INPUT and OUTPUT; endpoint groups index; *ww may be bumped by one or by two */
73b847
@@ -1507,7 +1507,7 @@ if ( n == 0 && t == 0 ) {
73b847
 
73b847
 
73b847
 	if ( sc[kx-1] != ftt ) {
73b847
-		y[ (*tot)++ ] = kx;
73b847
+		bz_y[ (*tot)++ ] = kx;
73b847
 		rk[kx-1] = sc[kx-1];
73b847
 		sc[kx-1] = ftt;
73b847
 	}
73b847
@@ -1553,7 +1553,7 @@ if ( n == l ) {
73b847
 			qq[*qh]  = kz;
73b847
 			zz[kz-1] = (*qh)++;
73b847
 		}
73b847
-		y[(*tot)++] = kx;
73b847
+		bz_y[(*tot)++] = kx;
73b847
 		rk[kx-1] = sc[kx-1];
73b847
 		sc[kx-1] = ftt;
73b847
 	}
73b847
@@ -1697,12 +1697,12 @@ for ( ii = 0; ii < tp; ii++ ) {				/* For each index up to the current value of
73b847
 		}
73b847
 
73b847
 		t     = 0;
73b847
-		y[0]  = lim;
73b847
+		bz_y[0]  = lim;
73b847
 		cp[0] = 1;
73b847
 		b     = 0;
73b847
 		n     = 1;
73b847
 		do {					/* looping until T < 0 ... */
73b847
-			if ( y[t] - cp[t] > 1 ) {
73b847
+			if (bz_y[t] - cp[t] > 1 ) {
73b847
 				k = sct[cp[t]][t];
73b847
 				j = ctt[k] + 1;
73b847
 				for ( i = 0; i < j; i++ ) {
73b847
@@ -1715,25 +1715,25 @@ for ( ii = 0; ii < tp; ii++ ) {				/* For each index up to the current value of
73b847
 				do {
73b847
 					while ( rp[jj] < sct[kk][t] && jj < j )
73b847
 						jj++;
73b847
-					while ( rp[jj] > sct[kk][t] && kk < y[t] )
73b847
+					while ( rp[jj] > sct[kk][t] && kk < bz_y[t] )
73b847
 						kk++;
73b847
-					while ( rp[jj] == sct[kk][t] && kk < y[t] && jj < j ) {
73b847
+					while ( rp[jj] == sct[kk][t] && kk < bz_y[t] && jj < j ) {
73b847
 						sct[k][t+1] = sct[kk][t];
73b847
 						k++;
73b847
 						kk++;
73b847
 						jj++;
73b847
 					}
73b847
-				} while ( kk < y[t] && jj < j );
73b847
+				} while ( kk < bz_y[t] && jj < j );
73b847
 
73b847
 				t++;
73b847
 				cp[t] = 1;
73b847
-				y[t]  = k;
73b847
+				bz_y[t]  = k;
73b847
 				b     = t;
73b847
 				n     = 1;
73b847
 			} else {
73b847
 				int tot = 0;
73b847
 
73b847
-				lim = y[t];
73b847
+				lim = bz_y[t];
73b847
 				for ( i = n-1; i < lim; i++ ) {
73b847
 					tot += ct[ sct[i][t] ];
73b847
 				}
73b847
@@ -1750,7 +1750,7 @@ for ( ii = 0; ii < tp; ii++ ) {				/* For each index up to the current value of
73b847
 
73b847
 					{
73b847
 					int rk_index = b;
73b847
-					lim = y[t];
73b847
+					lim = bz_y[t];
73b847
 					for ( i = n-1; i < lim; ) {
73b847
 						rk[ rk_index++ ] = sct[ i++ ][ t ];
73b847
 					}
73b847
@@ -1760,7 +1760,7 @@ for ( ii = 0; ii < tp; ii++ ) {				/* For each index up to the current value of
73b847
 				t--;
73b847
 				if ( t >= 0 ) {
73b847
 					++cp[t];
73b847
-					n = y[t];
73b847
+					n = bz_y[t];
73b847
 				}
73b847
 			} /* END IF */
73b847
 
73b847
diff --git a/libfprint/nbis/bozorth3/bz_gbls.c b/libfprint/nbis/bozorth3/bz_gbls.c
73b847
index dd828dc..ea283d8 100644
73b847
--- a/libfprint/nbis/bozorth3/bz_gbls.c
73b847
+++ b/libfprint/nbis/bozorth3/bz_gbls.c
73b847
@@ -102,7 +102,7 @@ int yl[ YL_SIZE_1 ][ YL_SIZE_2 ];
73b847
    int rf[RF_SIZE_1][RF_SIZE_2];
73b847
    int cf[CF_SIZE_1][CF_SIZE_2];
73b847
 
73b847
-   int y[20000];
73b847
+   int bz_y[20000];
73b847
 #else
73b847
    int rq[ RQ_SIZE ] = {};
73b847
    int tq[ TQ_SIZE ] = {};
73b847
@@ -122,6 +122,6 @@ int yl[ YL_SIZE_1 ][ YL_SIZE_2 ];
73b847
    int rf[RF_SIZE_1][RF_SIZE_2] = {};
73b847
    int cf[CF_SIZE_1][CF_SIZE_2] = {};
73b847
 
73b847
-   int y[20000] = {};
73b847
+   int bz_y[20000] = {};
73b847
 #endif
73b847
 
73b847
diff --git a/libfprint/nbis/include/bozorth.h b/libfprint/nbis/include/bozorth.h
73b847
index 08ec4b1..a705da9 100644
73b847
--- a/libfprint/nbis/include/bozorth.h
73b847
+++ b/libfprint/nbis/include/bozorth.h
73b847
@@ -245,7 +245,7 @@ extern int cp[ CP_SIZE ];
73b847
 extern int rp[ RP_SIZE ];
73b847
 extern int rf[RF_SIZE_1][RF_SIZE_2];
73b847
 extern int cf[CF_SIZE_1][CF_SIZE_2];
73b847
-extern int y[20000];
73b847
+extern int bz_y[20000];
73b847
 
73b847
 /**************************************************************************/
73b847
 /**************************************************************************/
73b847
diff --git a/libfprint/nbis/remove-global-y.cocci b/libfprint/nbis/remove-global-y.cocci
73b847
new file mode 100644
73b847
index 0000000..3b740af
73b847
--- /dev/null
73b847
+++ b/libfprint/nbis/remove-global-y.cocci
73b847
@@ -0,0 +1,21 @@
73b847
+@ global_y @
73b847
+identifier y;
73b847
+@@
73b847
+int
73b847
+- y
73b847
++ bz_y
73b847
+[20000];
73b847
+
73b847
+@@
73b847
+identifier global_y.y;
73b847
+@@
73b847
+- y
73b847
++ bz_y
73b847
+[...]
73b847
+
73b847
+@@
73b847
+@@
73b847
+int
73b847
+- y
73b847
++ bz_y
73b847
+[20000] = {};
73b847
diff --git a/libfprint/nbis/update-from-nbis.sh b/libfprint/nbis/update-from-nbis.sh
73b847
index 742c8cb..75e82ba 100755
73b847
--- a/libfprint/nbis/update-from-nbis.sh
73b847
+++ b/libfprint/nbis/update-from-nbis.sh
73b847
@@ -186,6 +186,9 @@ sed -i 's/^\([[:space:]]*[[:alnum:]_]\+[\*[:space:]]\+'\
73b847
 # Use GLib memory management
73b847
 spatch --sp-file glib-memory.cocci --dir . --in-place
73b847
 
73b847
+# Rename global "y" variable in "bz_y"
73b847
+spatch --sp-file remove-global-y.cocci bozorth3/* include/bozorth.h --in-place
73b847
+
73b847
 # The above leaves an unused variable around, triggering a warning
73b847
 # remove it.
73b847
 patch -p0 < glib-mem-warning.patch
73b847
-- 
73b847
2.24.1
73b847