cppcheck fixes for const

This commit is contained in:
iceman1001 2022-01-06 23:07:47 +01:00
commit 6bb301f4da
9 changed files with 26 additions and 16 deletions

View file

@ -348,7 +348,7 @@ void RunMod(void) {
state = STATE_READ; state = STATE_READ;
DbpString(_YELLOW_("[ ") "Initialized reading mode" _YELLOW_(" ]")); DbpString(_YELLOW_("[ ") "Initialized reading mode" _YELLOW_(" ]"));
DbpString("\n" _YELLOW_("!!") "Waiting for a Visa card..."); DbpString("\n" _YELLOW_("!!") "Waiting for a Visa card...");
break; continue;
} }
// We need to listen to the high-frequency, peak-detected path. // We need to listen to the high-frequency, peak-detected path.

View file

@ -99,7 +99,7 @@ void RunMod() {
// For received Bluetooth package // For received Bluetooth package
uint8_t rpacket[MAX_FRAME_SIZE] = { 0x00 }; uint8_t rpacket[MAX_FRAME_SIZE] = { 0x00 };
uint16_t lenpacket = 0; uint16_t lenpacket;
// For answering the commands // For answering the commands
uint8_t apdubuffer[MAX_FRAME_SIZE] = { 0x00 }; uint8_t apdubuffer[MAX_FRAME_SIZE] = { 0x00 };
@ -268,7 +268,7 @@ void RunMod() {
SpinDelay(500); SpinDelay(500);
state = STATE_READ; state = STATE_READ;
DbpString(_YELLOW_("[ ") "Initialized reading mode" _YELLOW_(" ]")); DbpString(_YELLOW_("[ ") "Initialized reading mode" _YELLOW_(" ]"));
break; continue;
} }
// We need to listen to the high-frequency, peak-detected path. // We need to listen to the high-frequency, peak-detected path.

View file

@ -200,7 +200,7 @@ void RunMod(void) {
state = STATE_READ; state = STATE_READ;
DbpString(_YELLOW_("[ ") "Initialized reading mode" _YELLOW_(" ]")); DbpString(_YELLOW_("[ ") "Initialized reading mode" _YELLOW_(" ]"));
DbpString("\n" _YELLOW_("!!") "Waiting for an ST25TA card..."); DbpString("\n" _YELLOW_("!!") "Waiting for an ST25TA card...");
break; continue;
} }
// We need to listen to the high-frequency, peak-detected path. // We need to listen to the high-frequency, peak-detected path.
@ -378,7 +378,7 @@ void RunMod(void) {
state = STATE_READ; state = STATE_READ;
DbpString(_YELLOW_("[ ") "Initialized reading mode" _YELLOW_(" ]")); DbpString(_YELLOW_("[ ") "Initialized reading mode" _YELLOW_(" ]"));
DbpString("\n" _YELLOW_("!!") "Waiting for an ST25TA card..."); DbpString("\n" _YELLOW_("!!") "Waiting for an ST25TA card...");
break; continue;
} }
// We need to listen to the high-frequency, peak-detected path. // We need to listen to the high-frequency, peak-detected path.

View file

@ -1146,7 +1146,7 @@ void SniffHitag2(bool ledcontrol) {
AT91C_BASE_TCB->TCB_BCR = 1; AT91C_BASE_TCB->TCB_BCR = 1;
int frame_count = 0, response = 0, overflow = 0, lastbit = 1, tag_sof = 4; int frame_count = 0, response = 0, overflow = 0, lastbit = 1, tag_sof = 4;
bool rising_edge = false, reader_frame = false, bSkip = true; bool rising_edge, reader_frame = false, bSkip = true;
uint8_t rx[HITAG_FRAME_LEN]; uint8_t rx[HITAG_FRAME_LEN];
size_t rxlen = 0; size_t rxlen = 0;
@ -1915,6 +1915,11 @@ out:
// release allocated memory from BigBuff. // release allocated memory from BigBuff.
BigBuf_free(); BigBuf_free();
//
if (checked == -1) {
// user interupted
reply_mix(CMD_ACK, false, 0, 0, 0, 0);
}
if (bSuccessful) if (bSuccessful)
reply_mix(CMD_ACK, bSuccessful, 0, 0, (uint8_t *)tag.sectors, tag_size); reply_mix(CMD_ACK, bSuccessful, 0, 0, (uint8_t *)tag.sectors, tag_size);
@ -2233,5 +2238,9 @@ out:
// release allocated memory from BigBuff. // release allocated memory from BigBuff.
BigBuf_free(); BigBuf_free();
reply_mix(CMD_ACK, bSuccessful, 0, 0, (uint8_t *)tag.sectors, tag_size); if (checked == -1) {
reply_mix(CMD_ACK, false, 0, 0, 0, 0);
} else {
reply_mix(CMD_ACK, bSuccessful, 0, 0, (uint8_t *)tag.sectors, tag_size);
}
} }

View file

@ -1268,7 +1268,7 @@ void ReadHitagS(hitag_function htf, hitag_data *htd, bool ledcontrol) {
uint8_t rx[HITAG_FRAME_LEN]; uint8_t rx[HITAG_FRAME_LEN];
size_t rxlen = 0; size_t rxlen = 0;
uint8_t tx[HITAG_FRAME_LEN]; uint8_t tx[HITAG_FRAME_LEN];
size_t txlen = 0; size_t txlen;
int t_wait = HITAG_T_WAIT_MAX; int t_wait = HITAG_T_WAIT_MAX;

View file

@ -210,7 +210,7 @@ void ReadPCF7931(bool ledcontrol) {
uint8_t single_blocks[8][17]; // PFC blocks with unknown position uint8_t single_blocks[8][17]; // PFC blocks with unknown position
int single_blocks_cnt = 0; int single_blocks_cnt = 0;
size_t n = 0; // transmitted blocks size_t n; // transmitted blocks
uint8_t tmp_blocks[4][16]; // temporary read buffer uint8_t tmp_blocks[4][16]; // temporary read buffer
uint8_t found_0_1 = 0; // flag: blocks 0 and 1 were found uint8_t found_0_1 = 0; // flag: blocks 0 and 1 were found

View file

@ -1114,7 +1114,7 @@ typedef struct {
uint8_t mlen; uint8_t mlen;
const char *match; const char *match;
uint32_t (*Pwd)(const uint8_t *uid); uint32_t (*Pwd)(const uint8_t *uid);
uint16_t (*Pack)(uint8_t *uid); uint16_t (*Pack)(const uint8_t *uid);
const char *hint; const char *hint;
} mfu_identify_t; } mfu_identify_t;

View file

@ -157,10 +157,10 @@ uint16_t ul_ev1_packgenA(const uint8_t *uid) {
uint16_t pack = (uid[0] ^ uid[1] ^ uid[2]) << 8 | (uid[2] ^ 8); uint16_t pack = (uid[0] ^ uid[1] ^ uid[2]) << 8 | (uid[2] ^ 8);
return pack; return pack;
} }
uint16_t ul_ev1_packgenB(uint8_t *uid) { uint16_t ul_ev1_packgenB(const uint8_t *uid) {
return 0x8080; return 0x8080;
} }
uint16_t ul_ev1_packgenC(uint8_t *uid) { uint16_t ul_ev1_packgenC(const uint8_t *uid) {
return 0xaa55; return 0xaa55;
} }
uint16_t ul_ev1_packgenD(const uint8_t *uid) { uint16_t ul_ev1_packgenD(const uint8_t *uid) {
@ -182,10 +182,11 @@ uint16_t ul_ev1_packgenD(const uint8_t *uid) {
return BSWAP_16(p & 0xFFFF); return BSWAP_16(p & 0xFFFF);
} }
// default shims
uint32_t ul_ev1_pwdgen_def(const uint8_t *uid) { uint32_t ul_ev1_pwdgen_def(const uint8_t *uid) {
return 0xFFFFFFFF; return 0xFFFFFFFF;
} }
uint16_t ul_ev1_packgen_def(uint8_t *uid) { uint16_t ul_ev1_packgen_def(const uint8_t *uid) {
return 0x0000; return 0x0000;
} }

View file

@ -19,10 +19,10 @@ uint32_t ul_ev1_pwdgenB(const uint8_t *uid);
uint32_t ul_ev1_pwdgenC(const uint8_t *uid); uint32_t ul_ev1_pwdgenC(const uint8_t *uid);
uint32_t ul_ev1_pwdgenD(const uint8_t *uid); uint32_t ul_ev1_pwdgenD(const uint8_t *uid);
uint16_t ul_ev1_packgen_def(uint8_t *uid); uint16_t ul_ev1_packgen_def(const uint8_t *uid);
uint16_t ul_ev1_packgenA(const uint8_t *uid); uint16_t ul_ev1_packgenA(const uint8_t *uid);
uint16_t ul_ev1_packgenB(uint8_t *uid); uint16_t ul_ev1_packgenB(const uint8_t *uid);
uint16_t ul_ev1_packgenC(uint8_t *uid); uint16_t ul_ev1_packgenC(const uint8_t *uid);
uint16_t ul_ev1_packgenD(const uint8_t *uid); uint16_t ul_ev1_packgenD(const uint8_t *uid);
int mfc_algo_ving_one(uint8_t *uid, uint8_t sector, uint8_t keytype, uint64_t *key); int mfc_algo_ving_one(uint8_t *uid, uint8_t sector, uint8_t keytype, uint64_t *key);