From 65c2d21d05bc22181206d32e985d2c0920200da1 Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Mon, 25 Jan 2016 20:19:15 +0100 Subject: [PATCH] CHG: Syntax suger --- armsrc/legicrf.c | 11 ++++++----- armsrc/mifarecmd.c | 16 +++++----------- armsrc/mifaresniff.c | 8 ++++---- 3 files changed, 15 insertions(+), 20 deletions(-) diff --git a/armsrc/legicrf.c b/armsrc/legicrf.c index d9c94106..5ad1fdf1 100644 --- a/armsrc/legicrf.c +++ b/armsrc/legicrf.c @@ -276,10 +276,10 @@ static void frame_receive_rwd(struct legic_frame * const f, int bits, int crypt) static void frame_append_bit(struct legic_frame * const f, int bit) { - if(f->bits >= 31) + if (f->bits >= 31) return; /* Overflow, won't happen */ - f->data |= (bit<bits); + f->data |= (bit << f->bits); f->bits++; } @@ -354,9 +354,11 @@ int legic_read_byte(int byte_index, int cmd_sz) { frame_receive_rwd(¤t_frame, 12, 1); byte = current_frame.data & 0xff; + if( LegicCRC(byte_index, byte, cmd_sz) != (current_frame.data >> 8) ) { Dbprintf("!!! crc mismatch: expected %x but got %x !!!", - LegicCRC(byte_index, current_frame.data & 0xff, cmd_sz), current_frame.data >> 8); + LegicCRC(byte_index, current_frame.data & 0xff, cmd_sz), + current_frame.data >> 8); return -1; } @@ -372,9 +374,8 @@ int legic_read_byte(int byte_index, int cmd_sz) { */ int legic_write_byte(int byte, int addr, int addr_sz) { //do not write UID, CRC, DCF - if(addr <= 0x06) { + if(addr <= 0x06) return 0; - } //== send write command ============================== crc_clear(&legic_crc); diff --git a/armsrc/mifarecmd.c b/armsrc/mifarecmd.c index a3ce6acf..7fa3f525 100644 --- a/armsrc/mifarecmd.c +++ b/armsrc/mifarecmd.c @@ -996,32 +996,26 @@ void MifareChkKeys(uint16_t arg0, uint8_t arg1, uint8_t arg2, uint8_t *datain) set_tracing(TRUE); - for (i = 0; i < keyCount; i++) { - if(mifare_classic_halt(pcs, cuid)) { + for (i = 0; i < keyCount; ++i) { + if (mifare_classic_halt(pcs, cuid)) if (MF_DBGLEVEL >= 1) Dbprintf("ChkKeys: Halt error"); - } - if(!iso14443a_select_card(uid, NULL, &cuid, true, 0)) { + if (!iso14443a_select_card(uid, NULL, &cuid, true, 0)) { if (OLD_MF_DBGLEVEL >= 1) Dbprintf("ChkKeys: Can't select card"); break; - }; + } ui64Key = bytes_to_num(datain + i * 6, 6); - if(mifare_classic_auth(pcs, cuid, blockNo, keyType, ui64Key, AUTH_FIRST)) { + if (mifare_classic_auth(pcs, cuid, blockNo, keyType, ui64Key, AUTH_FIRST)) continue; - }; isOK = 1; break; } - - // ----------------------------- crypto1 destroy crypto1_destroy(pcs); LED_B_ON(); cmd_send(CMD_ACK,isOK,0,0,datain + i * 6,6); - LED_B_OFF(); - FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); LEDsoff(); set_tracing(FALSE); diff --git a/armsrc/mifaresniff.c b/armsrc/mifaresniff.c index 3194f8d8..fe57f429 100644 --- a/armsrc/mifaresniff.c +++ b/armsrc/mifaresniff.c @@ -13,11 +13,11 @@ static int sniffState = SNF_INIT; static uint8_t sniffUIDType; -static uint8_t sniffUID[8] = {0x00}; -static uint8_t sniffATQA[2] = {0x00}; +static uint8_t sniffUID[8]; +static uint8_t sniffATQA[2]; static uint8_t sniffSAK; -static uint8_t sniffBuf[16] = {0x00}; -static uint32_t timerData = 0; +static uint8_t sniffBuf[16]; +static uint32_t timerData; bool MfSniffInit(void){ -- 2.39.2