cppcheck assigned val never used and reduce var scope

This commit is contained in:
Philippe Teuwen 2021-09-14 23:29:21 +02:00
commit ea12d31a31

View file

@ -175,7 +175,6 @@ static void *crack(void *d) {
struct nRaR *TnRaR; struct nRaR *TnRaR;
unsigned int numnrar; unsigned int numnrar;
Hitag_State hstate;
int i, j; int i, j;
uint64_t klower, kmiddle, klowery; uint64_t klower, kmiddle, klowery;
@ -217,17 +216,15 @@ static void *crack(void *d) {
// store klowery // store klowery
Tk[count].klowery = klowery; Tk[count].klowery = klowery;
// build the initial prng state // build the initial prng state
hstate.shiftreg = (klower << 32) | uid; uint64_t shiftreg = (klower << 32) | uid;
// zero the lfsr so only 0s are inserted
hstate.lfsr = 0;
// insert y into shiftreg and extract keystream, reversed order // insert y into shiftreg and extract keystream, reversed order
b = 0; b = 0;
ytmp = y; ytmp = y;
for (j = 0; j < 2; j++) { for (j = 0; j < 2; j++) {
hstate.shiftreg = hstate.shiftreg | ((ytmp & 0xffff) << 48); shiftreg = shiftreg | ((ytmp & 0xffff) << 48);
for (i = 0; i < 16; i++) { for (i = 0; i < 16; i++) {
hstate.shiftreg = hstate.shiftreg >> 1; shiftreg = shiftreg >> 1;
bit = hitag2_crypt(hstate.shiftreg); bit = hitag2_crypt(shiftreg);
b = (b >> 1) | (bit << 31); b = (b >> 1) | (bit << 31);
} }
ytmp = ytmp >> 16; ytmp = ytmp >> 16;
@ -239,8 +236,8 @@ static void *crack(void *d) {
// get and store inverse of next bit from prng // get and store inverse of next bit from prng
// don't need to worry about shifting in the new bit because // don't need to worry about shifting in the new bit because
// it doesn't affect the filter function anyway // it doesn't affect the filter function anyway
hstate.shiftreg = hstate.shiftreg >> 1; shiftreg = shiftreg >> 1;
Tk[count].notb32 = hitag2_crypt(hstate.shiftreg) ^ 0x1; Tk[count].notb32 = hitag2_crypt(shiftreg) ^ 0x1;
// increase count // increase count
count++; count++;