Skip to content

Commit b23abf4

Browse files
committed
src/operators/verify_cc.cc: reduce the scope of variable in a for () loop
In general, it is always preferable to reduce the scope of a variable in a for loop
1 parent 9842b92 commit b23abf4

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/operators/verify_cc.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ int VerifyCC::luhnVerify(const char *ccnumber, int len) {
5959
int sum[2] = { 0, 0 };
6060
int odd = 0;
6161
int digits = 0;
62-
int i;
6362

6463
/* Weighted lookup table which is just a precalculated (i = index):
6564
* i*2 + (( (i*2) > 9 ) ? -9 : 0)
@@ -71,7 +70,7 @@ int VerifyCC::luhnVerify(const char *ccnumber, int len) {
7170
/* Add up only digits (weighted digits via lookup table)
7271
* for both odd and even CC numbers to avoid 2 passes.
7372
*/
74-
for (i = 0; i < len; i++) {
73+
for (int i = 0;i < len;i++) {
7574
if (ccnumber[i] >= (0 + 48) && ccnumber[i] <= (9 + 48)) {
7675
sum[0] += (!odd ? wtable[ccnumber[i] - '0'] : (ccnumber[i] - '0'));
7776
sum[1] += (odd ? wtable[ccnumber[i] - '0'] : (ccnumber[i] - '0'));

0 commit comments

Comments
 (0)