Fix cppcheck style: scope of variable can be reduced
Fix the following cppcheck warnings: [libnfc/drivers/pn532_uart.c:492]: (style) The scope of the variable 'res' can be reduced [libnfc/chips/pn53x.c:320]: (style) The scope of the variable 'res' can be reduced [libnfc/chips/pn53x.c:616]: (style) The scope of the variable 'res' can be reduced [libnfc/nfc.c:356]: (style) The scope of the variable '_device_found' can be reduced [utils/nfc-mfclassic.c:178]: (style) The scope of the variable 'key_index' can be reduced
This commit is contained in:
parent
3f5a3fd58f
commit
4769392157
4 changed files with 5 additions and 7 deletions
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue