diff --git a/libnfc/chips/pn53x.c b/libnfc/chips/pn53x.c index 362cb4a..c961b46 100644 --- a/libnfc/chips/pn53x.c +++ b/libnfc/chips/pn53x.c @@ -317,9 +317,9 @@ pn53x_set_parameters(struct nfc_device *pnd, const uint8_t ui8Parameter, const b int pn53x_set_tx_bits(struct nfc_device *pnd, const uint8_t ui8Bits) { - int res = 0; // Test if we need to update the transmission bits register setting if (CHIP_DATA(pnd)->ui8TxBits != ui8Bits) { + int res = 0; // Set the amount of transmission bits in the PN53X chip register if ((res = pn53x_write_register(pnd, PN53X_REG_CIU_BitFraming, SYMBOL_TX_LAST_BITS, ui8Bits)) < 0) return res; @@ -613,8 +613,8 @@ pn53x_WriteRegister(struct nfc_device *pnd, const uint16_t ui16RegisterAddress, int pn53x_write_register(struct nfc_device *pnd, const uint16_t ui16RegisterAddress, const uint8_t ui8SymbolMask, const uint8_t ui8Value) { - int res = 0; if ((ui16RegisterAddress < PN53X_CACHE_REGISTER_MIN_ADDRESS) || (ui16RegisterAddress > PN53X_CACHE_REGISTER_MAX_ADDRESS)) { + int res = 0; // Direct write if (ui8SymbolMask != 0xff) { uint8_t ui8CurrentValue; diff --git a/libnfc/drivers/pn532_uart.c b/libnfc/drivers/pn532_uart.c index 4cbb9a5..f7b8867 100644 --- a/libnfc/drivers/pn532_uart.c +++ b/libnfc/drivers/pn532_uart.c @@ -489,8 +489,8 @@ error: int pn532_uart_ack(nfc_device *pnd) { - int res = 0; if (POWERDOWN == CHIP_DATA(pnd)->power_mode) { + int res = 0; if ((res = pn532_uart_wakeup(pnd)) < 0) { return res; } diff --git a/libnfc/nfc.c b/libnfc/nfc.c index 6fabdf9..dd511a1 100644 --- a/libnfc/nfc.c +++ b/libnfc/nfc.c @@ -353,9 +353,8 @@ nfc_list_devices(nfc_context *context, nfc_connstring connstrings[], const size_ const struct nfc_driver_list *pndl = nfc_drivers; while (pndl) { const struct nfc_driver *ndr = pndl->driver; - size_t _device_found = 0; if ((ndr->scan_type == NOT_INTRUSIVE) || ((context->allow_intrusive_scan) && (ndr->scan_type == INTRUSIVE))) { - _device_found = ndr->scan(context, connstrings + (device_found), connstrings_len - (device_found)); + size_t _device_found = ndr->scan(context, connstrings + (device_found), connstrings_len - (device_found)); log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "%ld device(s) found using %s driver", (unsigned long) _device_found, ndr->name); if (_device_found > 0) { device_found += _device_found; diff --git a/utils/nfc-mfclassic.c b/utils/nfc-mfclassic.c index 081be3b..a5ebfe4 100644 --- a/utils/nfc-mfclassic.c +++ b/utils/nfc-mfclassic.c @@ -175,7 +175,6 @@ authenticate(uint32_t uiBlock) { mifare_cmd mc; uint32_t uiTrailerBlock; - size_t key_index; // Set the authentication information (uid) memcpy(mp.mpa.abtAuthUid, nt.nti.nai.abtUid + nt.nti.nai.szUidLen - 4, 4); @@ -200,7 +199,7 @@ authenticate(uint32_t uiBlock) return true; } else { // Try to guess the right key - for (key_index = 0; key_index < num_keys; key_index++) { + for (size_t key_index = 0; key_index < num_keys; key_index++) { memcpy(mp.mpa.abtKey, keys + (key_index * 6), 6); if (nfc_initiator_mifare_cmd(pnd, mc, uiBlock, &mp)) { if (bUseKeyA)