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
Philippe Teuwen
11 years ago
316 | 316 |
int
|
317 | 317 |
pn53x_set_tx_bits(struct nfc_device *pnd, const uint8_t ui8Bits)
|
318 | 318 |
{
|
319 | |
int res = 0;
|
320 | 319 |
// Test if we need to update the transmission bits register setting
|
321 | 320 |
if (CHIP_DATA(pnd)->ui8TxBits != ui8Bits) {
|
|
321 |
int res = 0;
|
322 | 322 |
// Set the amount of transmission bits in the PN53X chip register
|
323 | 323 |
if ((res = pn53x_write_register(pnd, PN53X_REG_CIU_BitFraming, SYMBOL_TX_LAST_BITS, ui8Bits)) < 0)
|
324 | 324 |
return res;
|
|
612 | 612 |
int
|
613 | 613 |
pn53x_write_register(struct nfc_device *pnd, const uint16_t ui16RegisterAddress, const uint8_t ui8SymbolMask, const uint8_t ui8Value)
|
614 | 614 |
{
|
615 | |
int res = 0;
|
616 | 615 |
if ((ui16RegisterAddress < PN53X_CACHE_REGISTER_MIN_ADDRESS) || (ui16RegisterAddress > PN53X_CACHE_REGISTER_MAX_ADDRESS)) {
|
|
616 |
int res = 0;
|
617 | 617 |
// Direct write
|
618 | 618 |
if (ui8SymbolMask != 0xff) {
|
619 | 619 |
uint8_t ui8CurrentValue;
|
352 | 352 |
const struct nfc_driver_list *pndl = nfc_drivers;
|
353 | 353 |
while (pndl) {
|
354 | 354 |
const struct nfc_driver *ndr = pndl->driver;
|
355 | |
size_t _device_found = 0;
|
356 | 355 |
if ((ndr->scan_type == NOT_INTRUSIVE) || ((context->allow_intrusive_scan) && (ndr->scan_type == INTRUSIVE))) {
|
357 | |
_device_found = ndr->scan(context, connstrings + (device_found), connstrings_len - (device_found));
|
|
356 |
size_t _device_found = ndr->scan(context, connstrings + (device_found), connstrings_len - (device_found));
|
358 | 357 |
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "%ld device(s) found using %s driver", (unsigned long) _device_found, ndr->name);
|
359 | 358 |
if (_device_found > 0) {
|
360 | 359 |
device_found += _device_found;
|
174 | 174 |
{
|
175 | 175 |
mifare_cmd mc;
|
176 | 176 |
uint32_t uiTrailerBlock;
|
177 | |
size_t key_index;
|
178 | 177 |
|
179 | 178 |
// Set the authentication information (uid)
|
180 | 179 |
memcpy(mp.mpa.abtAuthUid, nt.nti.nai.abtUid + nt.nti.nai.szUidLen - 4, 4);
|
|
199 | 198 |
return true;
|
200 | 199 |
} else {
|
201 | 200 |
// Try to guess the right key
|
202 | |
for (key_index = 0; key_index < num_keys; key_index++) {
|
|
201 |
for (size_t key_index = 0; key_index < num_keys; key_index++) {
|
203 | 202 |
memcpy(mp.mpa.abtKey, keys + (key_index * 6), 6);
|
204 | 203 |
if (nfc_initiator_mifare_cmd(pnd, mc, uiBlock, &mp)) {
|
205 | 204 |
if (bUseKeyA)
|