nbis: Make the extern global bozworth 'y' variable as bz_y

Othewise this could create issues with other 'y' variable definitions
shadowing it.

Add a cocci file that performs the change automatically
This commit is contained in:
Marco Trevisan (Treviño) 2019-12-04 14:22:07 +01:00
parent 70a0d6f0fe
commit 35e9f19c0c
5 changed files with 44 additions and 20 deletions

View file

@ -896,7 +896,7 @@ for ( k = 0; k < np - 1; k++ ) {
for ( i = 0; i < tot; i++ ) { for ( i = 0; i < tot; i++ ) {
int colp_value = colp[ y[i]-1 ][0]; int colp_value = colp[ bz_y[i]-1 ][0];
if ( colp_value < 0 ) { if ( colp_value < 0 ) {
kk += colp_value; kk += colp_value;
n++; n++;
@ -933,7 +933,7 @@ for ( k = 0; k < np - 1; k++ ) {
kk = 0; kk = 0;
for ( i = 0; i < tot; i++ ) { for ( i = 0; i < tot; i++ ) {
int diff = colp[ y[i]-1 ][0] - jj; int diff = colp[ bz_y[i]-1 ][0] - jj;
j = SQUARED( diff ); j = SQUARED( diff );
@ -942,7 +942,7 @@ for ( k = 0; k < np - 1; k++ ) {
if ( j > TXS && j < CTXS ) if ( j > TXS && j < CTXS )
kk++; kk++;
else else
y[i-kk] = y[i]; bz_y[i-kk] = bz_y[i];
} /* END FOR i */ } /* END FOR i */
tot -= kk; /* Adjust the total edge pairs TOT based on # of edge pairs skipped */ tot -= kk; /* Adjust the total edge pairs TOT based on # of edge pairs skipped */
@ -958,7 +958,7 @@ for ( k = 0; k < np - 1; k++ ) {
for ( i = tot-1 ; i >= 0; i-- ) { for ( i = tot-1 ; i >= 0; i-- ) {
int idx = y[i] - 1; int idx = bz_y[i] - 1;
if ( rk[idx] == 0 ) { if ( rk[idx] == 0 ) {
sc[idx] = -1; sc[idx] = -1;
} else { } else {
@ -976,7 +976,7 @@ for ( k = 0; k < np - 1; k++ ) {
int pd = 0; int pd = 0;
for ( i = 0; i < tot; i++ ) { for ( i = 0; i < tot; i++ ) {
int idx = y[i] - 1; int idx = bz_y[i] - 1;
for ( ii = 1; ii < 4; ii++ ) { for ( ii = 1; ii < 4; ii++ ) {
@ -1476,7 +1476,7 @@ return match_score;
/* extern int rk[ RK_SIZE ]; */ /* extern int rk[ RK_SIZE ]; */
/* extern int cp[ CP_SIZE ]; */ /* extern int cp[ CP_SIZE ]; */
/* extern int rp[ RP_SIZE ]; */ /* extern int rp[ RP_SIZE ]; */
/* extern int y[ Y_SIZE ]; */ /* extern int bz_y[ Y_SIZE ]; */
void bz_sift( void bz_sift(
int * ww, /* INPUT and OUTPUT; endpoint groups index; *ww may be bumped by one or by two */ int * ww, /* INPUT and OUTPUT; endpoint groups index; *ww may be bumped by one or by two */
@ -1507,7 +1507,7 @@ if ( n == 0 && t == 0 ) {
if ( sc[kx-1] != ftt ) { if ( sc[kx-1] != ftt ) {
y[ (*tot)++ ] = kx; bz_y[ (*tot)++ ] = kx;
rk[kx-1] = sc[kx-1]; rk[kx-1] = sc[kx-1];
sc[kx-1] = ftt; sc[kx-1] = ftt;
} }
@ -1553,7 +1553,7 @@ if ( n == l ) {
qq[*qh] = kz; qq[*qh] = kz;
zz[kz-1] = (*qh)++; zz[kz-1] = (*qh)++;
} }
y[(*tot)++] = kx; bz_y[(*tot)++] = kx;
rk[kx-1] = sc[kx-1]; rk[kx-1] = sc[kx-1];
sc[kx-1] = ftt; sc[kx-1] = ftt;
} }
@ -1697,12 +1697,12 @@ for ( ii = 0; ii < tp; ii++ ) { /* For each index up to the current value of
} }
t = 0; t = 0;
y[0] = lim; bz_y[0] = lim;
cp[0] = 1; cp[0] = 1;
b = 0; b = 0;
n = 1; n = 1;
do { /* looping until T < 0 ... */ do { /* looping until T < 0 ... */
if ( y[t] - cp[t] > 1 ) { if (bz_y[t] - cp[t] > 1 ) {
k = sct[cp[t]][t]; k = sct[cp[t]][t];
j = ctt[k] + 1; j = ctt[k] + 1;
for ( i = 0; i < j; i++ ) { for ( i = 0; i < j; i++ ) {
@ -1715,25 +1715,25 @@ for ( ii = 0; ii < tp; ii++ ) { /* For each index up to the current value of
do { do {
while ( rp[jj] < sct[kk][t] && jj < j ) while ( rp[jj] < sct[kk][t] && jj < j )
jj++; jj++;
while ( rp[jj] > sct[kk][t] && kk < y[t] ) while ( rp[jj] > sct[kk][t] && kk < bz_y[t] )
kk++; kk++;
while ( rp[jj] == sct[kk][t] && kk < y[t] && jj < j ) { while ( rp[jj] == sct[kk][t] && kk < bz_y[t] && jj < j ) {
sct[k][t+1] = sct[kk][t]; sct[k][t+1] = sct[kk][t];
k++; k++;
kk++; kk++;
jj++; jj++;
} }
} while ( kk < y[t] && jj < j ); } while ( kk < bz_y[t] && jj < j );
t++; t++;
cp[t] = 1; cp[t] = 1;
y[t] = k; bz_y[t] = k;
b = t; b = t;
n = 1; n = 1;
} else { } else {
int tot = 0; int tot = 0;
lim = y[t]; lim = bz_y[t];
for ( i = n-1; i < lim; i++ ) { for ( i = n-1; i < lim; i++ ) {
tot += ct[ sct[i][t] ]; tot += ct[ sct[i][t] ];
} }
@ -1750,7 +1750,7 @@ for ( ii = 0; ii < tp; ii++ ) { /* For each index up to the current value of
{ {
int rk_index = b; int rk_index = b;
lim = y[t]; lim = bz_y[t];
for ( i = n-1; i < lim; ) { for ( i = n-1; i < lim; ) {
rk[ rk_index++ ] = sct[ i++ ][ t ]; rk[ rk_index++ ] = sct[ i++ ][ t ];
} }
@ -1760,7 +1760,7 @@ for ( ii = 0; ii < tp; ii++ ) { /* For each index up to the current value of
t--; t--;
if ( t >= 0 ) { if ( t >= 0 ) {
++cp[t]; ++cp[t];
n = y[t]; n = bz_y[t];
} }
} /* END IF */ } /* END IF */

View file

@ -102,7 +102,7 @@ int yl[ YL_SIZE_1 ][ YL_SIZE_2 ];
int rf[RF_SIZE_1][RF_SIZE_2]; int rf[RF_SIZE_1][RF_SIZE_2];
int cf[CF_SIZE_1][CF_SIZE_2]; int cf[CF_SIZE_1][CF_SIZE_2];
int y[20000]; int bz_y[20000];
#else #else
int rq[ RQ_SIZE ] = {}; int rq[ RQ_SIZE ] = {};
int tq[ TQ_SIZE ] = {}; int tq[ TQ_SIZE ] = {};
@ -122,6 +122,6 @@ int yl[ YL_SIZE_1 ][ YL_SIZE_2 ];
int rf[RF_SIZE_1][RF_SIZE_2] = {}; int rf[RF_SIZE_1][RF_SIZE_2] = {};
int cf[CF_SIZE_1][CF_SIZE_2] = {}; int cf[CF_SIZE_1][CF_SIZE_2] = {};
int y[20000] = {}; int bz_y[20000] = {};
#endif #endif

View file

@ -245,7 +245,7 @@ extern int cp[ CP_SIZE ];
extern int rp[ RP_SIZE ]; extern int rp[ RP_SIZE ];
extern int rf[RF_SIZE_1][RF_SIZE_2]; extern int rf[RF_SIZE_1][RF_SIZE_2];
extern int cf[CF_SIZE_1][CF_SIZE_2]; extern int cf[CF_SIZE_1][CF_SIZE_2];
extern int y[20000]; extern int bz_y[20000];
/**************************************************************************/ /**************************************************************************/
/**************************************************************************/ /**************************************************************************/

View file

@ -0,0 +1,21 @@
@ global_y @
identifier y;
@@
int
- y
+ bz_y
[20000];
@@
identifier global_y.y;
@@
- y
+ bz_y
[...]
@@
@@
int
- y
+ bz_y
[20000] = {};

View file

@ -186,6 +186,9 @@ sed -i 's/^\([[:space:]]*[[:alnum:]_]\+[\*[:space:]]\+'\
# Use GLib memory management # Use GLib memory management
spatch --sp-file glib-memory.cocci --dir . --in-place spatch --sp-file glib-memory.cocci --dir . --in-place
# Rename global "y" variable in "bz_y"
spatch --sp-file remove-global-y.cocci bozorth3/* include/bozorth.h --in-place
# The above leaves an unused variable around, triggering a warning # The above leaves an unused variable around, triggering a warning
# remove it. # remove it.
patch -p0 < glib-mem-warning.patch patch -p0 < glib-mem-warning.patch