- Fixed the suppression of the auto-fixup for linking against MS built libs
- Fixed all the formatting warnings by shifting to inttypes.h specifiers
- shifted to %lu for DWORD printf
This becomes more consistent with all other pass by pointer of most structures.
Additionally, this should lessen stack memory usage, as building strings with str_nfc_target would push the target (283 bytes) plus then a copy of the info objects (up to 275) onto the stack as it dives into the sprintf functions.
Lastly, this makes my attempt at a .NET wrapper easier, as I can make passing by pointer work, but passing by value seems to bomb on the interop right now.
Still a few todo according to cppcheck:
[examples/pn53x-tamashell.c:165]:
(style) Found obsolete function 'usleep'. It is recommended that new applications use the 'nanosleep' or 'setitimer' function
[libnfc/buses/uart_posix.c:343]:
(portability) Found non reentrant function 'readdir'. For threadsafe applications it is recommended to use the reentrant replacement function 'readdir_r'
[libnfc/drivers/acr122_pcsc.c:206]:
[libnfc/drivers/acr122_pcsc.c:219]:
[libnfc/drivers/acr122s.c:412]:
[libnfc/drivers/acr122s.c:425]:
[libnfc/drivers/acr122s.c:434]:
[libnfc/drivers/arygon.c:181]:
[libnfc/drivers/arygon.c:194]:
[libnfc/drivers/arygon.c:203]:
[libnfc/drivers/pn532_uart.c:158]:
[libnfc/drivers/pn532_uart.c:171]:
[libnfc/drivers/pn532_uart.c:180]:
(portability) Found non reentrant function 'strtok'. For threadsafe applications it is recommended to use the reentrant replacement function 'strtok_r'
Fix following warnings:
[examples/pn53x-tamashell.c:162]: (warning) scanf without field width limits can crash with huge input data
[libnfc/drivers/acr122_pcsc.c:261]: (warning) scanf without field width limits can crash with huge input data
[libnfc/drivers/acr122s.c:441]: (warning) scanf without field width limits can crash with huge input data
[libnfc/drivers/arygon.c:210]: (warning) scanf without field width limits can crash with huge input data
[libnfc/drivers/arygon.c:522]: (warning) scanf without field width limits can crash with huge input data
[libnfc/drivers/pn532_uart.c:187]: (warning) scanf without field width limits can crash with huge input data
[utils/nfc-relay-picc.c:176]: (warning) scanf without field width limits can crash with huge input data
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
Fix cppcheck warnings
[utils/nfc-read-forum-tag3.c:281]: (style) Variable 'len' is assigned a value that is never used
[utils/nfc-relay-picc.c:392]: (style) Variable 'res' is assigned a value that is never used
Not a good idea to call exit() from a library...
Problem is now moved to
void nfc_init() calling exit()
This requires a change in API to return error rather than exiting...
* in main():
** errx()/err()/return -> exit()
** return values -> EXIT_SUCCESS & EXIT_FAILURE
* out of main:
** err()/errx()/exit() -> return
** change retval from size_t to int to allow returning errors
** don't use EXIT_SUCCESS / EXIT_FAILURE as retvals
* add nfc_close() & nfc_exit() to exit() on errors
* add missing fclose() on errors
* add missing test if (pnd == NULL)
* unify style if (pnd == / != NULL)
* remove goto's
* few related fixes
* remove if(pnd!=NULL) test on nfc_close() calls
Fixes:
pn53x.c:523:11: warning: Value stored to 'pbtRawData' is never read
pbtRawData += szRawData - 8;
^ ~~~~~~~~~~~~~
pn53x.c:544:7: warning: Value stored to 'pbtRawData' is never read
pbtRawData += 2;
^ ~
pn53x.c:532:7: warning: Value stored to 'pbtRawData' is never read
pbtRawData += 8;
^ ~
pn53x.c:3085:3: warning: Value stored to 'buflen' is never read
buflen -= res;
^ ~~~
pn53x.c:3080:3: warning: Value stored to 'buf' is never read
buf += res;
^ ~~~
target-subr.c:466:7: warning: Value stored to 'dst' is never read
dst += sprintf(dst, "* Unknown card, sorry\n");
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
target-subr.c:480:3: warning: Value stored to 'dst' is never read
dst += sprint_hex(dst, nfi.abtSysCode, 2);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
target-subr.c:490:3: warning: Value stored to 'dst' is never read
dst += sprint_hex(dst, nji.btId, 4);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
target-subr.c:546:7: warning: Value stored to 'dst' is never read
dst += sprintf(dst, "\n");
^ ~~~~~~~~~~~~~~~~~~
target-subr.c:571:5: warning: Value stored to 'dst' is never read
dst += sprint_hex(dst, nii.abtAtr, nii.szAtrLen);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
target-subr.c:580:3: warning: Value stored to 'dst' is never read
dst += sprint_hex(dst, nsi.abtUID, 8);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
target-subr.c:593:3: warning: Value stored to 'dst' is never read
dst += sprintf(dst, " Fab Code: %02X\n", nci.btFabCode);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
target-subr.c:608:5: warning: Value stored to 'dst' is never read
dst += sprint_hex(dst, ndi.abtGB, ndi.szGB);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
acr122_usb.c:570:3: warning: Null pointer passed as an argument to a 'nonnull' parameter
memcpy(DRIVER_DATA(pnd)->apdu_frame.apdu_payload, data, data_len);
^ ~~~~
acr122_usb.c:738:3: warning: Value stored to 'offset' is never read
offset += len;
^ ~~~
acr122_usb.c:753:3: warning: Value stored to 'res' is never read
res = acr122_usb_bulk_write(DRIVER_DATA(pnd), (unsigned char *) & (DRIVER_DATA(pnd)->tama_frame), res, 1000);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~