Codebase list libfreefare / 4769392
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
4 changed file(s) with 5 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
316316 int
317317 pn53x_set_tx_bits(struct nfc_device *pnd, const uint8_t ui8Bits)
318318 {
319 int res = 0;
320319 // Test if we need to update the transmission bits register setting
321320 if (CHIP_DATA(pnd)->ui8TxBits != ui8Bits) {
321 int res = 0;
322322 // Set the amount of transmission bits in the PN53X chip register
323323 if ((res = pn53x_write_register(pnd, PN53X_REG_CIU_BitFraming, SYMBOL_TX_LAST_BITS, ui8Bits)) < 0)
324324 return res;
612612 int
613613 pn53x_write_register(struct nfc_device *pnd, const uint16_t ui16RegisterAddress, const uint8_t ui8SymbolMask, const uint8_t ui8Value)
614614 {
615 int res = 0;
616615 if ((ui16RegisterAddress < PN53X_CACHE_REGISTER_MIN_ADDRESS) || (ui16RegisterAddress > PN53X_CACHE_REGISTER_MAX_ADDRESS)) {
616 int res = 0;
617617 // Direct write
618618 if (ui8SymbolMask != 0xff) {
619619 uint8_t ui8CurrentValue;
488488 int
489489 pn532_uart_ack(nfc_device *pnd)
490490 {
491 int res = 0;
492491 if (POWERDOWN == CHIP_DATA(pnd)->power_mode) {
492 int res = 0;
493493 if ((res = pn532_uart_wakeup(pnd)) < 0) {
494494 return res;
495495 }
352352 const struct nfc_driver_list *pndl = nfc_drivers;
353353 while (pndl) {
354354 const struct nfc_driver *ndr = pndl->driver;
355 size_t _device_found = 0;
356355 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));
358357 log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "%ld device(s) found using %s driver", (unsigned long) _device_found, ndr->name);
359358 if (_device_found > 0) {
360359 device_found += _device_found;
174174 {
175175 mifare_cmd mc;
176176 uint32_t uiTrailerBlock;
177 size_t key_index;
178177
179178 // Set the authentication information (uid)
180179 memcpy(mp.mpa.abtAuthUid, nt.nti.nai.abtUid + nt.nti.nai.szUidLen - 4, 4);
199198 return true;
200199 } else {
201200 // 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++) {
203202 memcpy(mp.mpa.abtKey, keys + (key_index * 6), 6);
204203 if (nfc_initiator_mifare_cmd(pnd, mc, uiBlock, &mp)) {
205204 if (bUseKeyA)