Commit graph

931 commits

Author SHA1 Message Date
Philippe Teuwen
09ef2e3927 nfc_device_new(): replace err() by return
Not a good idea to call exit() from a library...
2013-03-05 19:58:32 +01:00
Philippe Teuwen
b0f216b3b2 spi driver: remove compilation warnings
spi_posix.c:141:1: warning: no previous prototype for 'bit_reversal' [-Wmissing-prototypes]
=> set bit_reversal() static

pn532_spi.c:258:48: warning: unused parameter 'timeout' [-Wunused-parameter]
=> remove timeout in pn532_spi_read_spi_status() params
2013-03-03 16:24:10 +01:00
Philippe Teuwen
cd98a4ac87 make style 2013-03-03 16:14:58 +01:00
Philippe Teuwen
2ac7963076 Merge branch 'master' into pn532_spi 2013-03-03 16:10:11 +01:00
Philippe Teuwen
b68a37b835 Replace usb_set_debug() in utils by new group in LIBNFC_LOG_LEVEL
To use it: (NFC_LOG_PRIORITY_DEBUG * 2 ^ NFC_LOG_GROUP_LIBUSB)
LIBUSB_LOG_LEVEL=12288
2013-03-02 23:43:37 +01:00
Philippe Teuwen
2334adc8bd Fix compilation warnings: values never read
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);
    ^      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2013-03-02 19:39:20 +01:00
Philippe Teuwen
70b0dffca7 acr122_usb: fix compiler warnings & check return value
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);
  ^     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2013-03-02 19:25:36 +01:00
Philippe Teuwen
f07d784b8b make style 2013-03-02 13:17:57 +01:00
Ludovic Rousseau
999631588d closedir() only if opendir() succeeds
Fix compiler warning:
conf.c:186:3: warning: Null pointer passed as an argument to a 'nonnull' parameter
  closedir(d);
  ^        ~
2013-03-02 13:11:30 +01:00
Ludovic Rousseau
aee56b9255 Initialize variables
Fix compiler warnings and potential bug

pn53x.c:1526:19: warning: The right operand of '<' is a garbage value
    for (i = 0; i < sz; i++) {
                  ^ ~~
pn53x.c:1621:19: warning: The right operand of '<' is a garbage value
    for (i = 0; i < sz; i++) {
                  ^ ~~
2013-03-02 13:09:23 +01:00
Philippe Teuwen
ae571941c5 usbbus: make usb_initialized static 2013-03-02 12:43:15 +01:00
Philippe Teuwen
1f0b0e5b81 Fix zealous double free 2013-03-02 12:26:24 +01:00
Ludovic Rousseau
e7290de83b Fix compiler warning
nfc.c:121: warning: function declaration isn't a prototype
nfc.c: In function 'nfc_drivers_init':
nfc.c:121: warning: old-style function definition
2013-03-02 11:30:24 +01:00
Romuald Conty
3aadb45988 Ease diff between both libusb based drivers: acr122_usb and pn53x_usb 2013-03-02 10:59:37 +01:00
Philippe Teuwen
b2b1d2a2a2 make style 2013-03-02 02:52:07 +01:00
Philippe Teuwen
a6c405a5d5 malloc/free: some more cleaning & checking malloc errors 2013-03-02 02:51:33 +01:00
Philippe Teuwen
0708279215 malloc/free: some cleaning & checking malloc errors 2013-03-02 02:25:13 +01:00
Philippe Teuwen
d7e7abb061 Fix mem leak in config file parser (opendir)
This fixes the following leaks:

==30517== 32,808 bytes in 1 blocks are definitely lost in loss record 11 of 12
==30517==    at 0x4C28BED: malloc (vg_replace_malloc.c:263)
==30517==    by 0x50F4B2A: __alloc_dir (opendir.c:186)
==30517==    by 0x4E34998: conf_devices_load.constprop.1 (in /usr/lib/x86_64-linux-gnu/libnfc.so.4.0.0)
==30517==    by 0x4E36350: nfc_context_new (in /usr/lib/x86_64-linux-gnu/libnfc.so.4.0.0)
==30517==    by 0x4E34D98: nfc_init (in /usr/lib/x86_64-linux-gnu/libnfc.so.4.0.0)
2013-03-02 01:21:13 +01:00
Philippe Teuwen
3d9ebb5044 Fix mem leak in config file parser
This fixes the following leaks:

==18690== 256 bytes in 1 blocks are definitely lost in loss record 75 of 100
==18690==    at 0x4C28BED: malloc (vg_replace_malloc.c:263)
==18690==    by 0x511613F: regcomp (regcomp.c:487)
==18690==    by 0x4E34313: conf_parse_file (in /usr/lib/x86_64-linux-gnu/libnfc.so.4.0.0)
==18690==    by 0x4E349F5: conf_devices_load.constprop.1 (in /usr/lib/x86_64-linux-gnu/libnfc.so.4.0.0)
==18690==    by 0x4E362C0: nfc_context_new (in /usr/lib/x86_64-linux-gnu/libnfc.so.4.0.0)
==18690==    by 0x4E34D08: nfc_init (in /usr/lib/x86_64-linux-gnu/libnfc.so.4.0.0)
==18690==
==18690== 32,068 (224 direct, 31,844 indirect) bytes in 1 blocks are definitely lost in loss record 98 of 100
==18690==    at 0x4C28BED: malloc (vg_replace_malloc.c:263)
==18690==    by 0x4C28D6F: realloc (vg_replace_malloc.c:632)
==18690==    by 0x5115DF3: re_compile_internal (regcomp.c:760)
==18690==    by 0x51161AB: regcomp (regcomp.c:506)
==18690==    by 0x4E34313: conf_parse_file (in /usr/lib/x86_64-linux-gnu/libnfc.so.4.0.0)
==18690==    by 0x4E349F5: conf_devices_load.constprop.1 (in /usr/lib/x86_64-linux-gnu/libnfc.so.4.0.0)
==18690==    by 0x4E362C0: nfc_context_new (in /usr/lib/x86_64-linux-gnu/libnfc.so.4.0.0)
==18690==    by 0x4E34D08: nfc_init (in /usr/lib/x86_64-linux-gnu/libnfc.so.4.0.0)
2013-03-02 01:09:47 +01:00
Philippe Teuwen
9dcf7378b6 Fix mem leak with libusb by introducing buses/usbbus.c
Now call only once usb_init(); usb_find_busses(); usb_find_devices()
instead of multiple calls in several scan() then open()

This fixes the following leaks:

==1159== 8 bytes in 1 blocks are definitely lost in loss record 9 of 102
==1159==    at 0x4C28BED: malloc (vg_replace_malloc.c:263)
==1159==    by 0x53D9931: usb_parse_configuration (in /lib/x86_64-linux-gnu/libusb-0.1.so.4.4.4)
==1159==    by 0x53DB8B1: usb_os_find_devices (in /lib/x86_64-linux-gnu/libusb-0.1.so.4.4.4)
==1159==    by 0x53D8FDC: usb_find_devices (in /lib/x86_64-linux-gnu/libusb-0.1.so.4.4.4)
==1159==    by 0x4E41D79: pn53x_usb_scan (in /usr/lib/x86_64-linux-gnu/libnfc.so.4.0.0)
==1159==
==1159== 8 bytes in 1 blocks are definitely lost in loss record 10 of 102
==1159==    at 0x4C28BED: malloc (vg_replace_malloc.c:263)
==1159==    by 0x53D9931: usb_parse_configuration (in /lib/x86_64-linux-gnu/libusb-0.1.so.4.4.4)
==1159==    by 0x53DB8B1: usb_os_find_devices (in /lib/x86_64-linux-gnu/libusb-0.1.so.4.4.4)
==1159==    by 0x53D8FDC: usb_find_devices (in /lib/x86_64-linux-gnu/libusb-0.1.so.4.4.4)
==1159==    by 0x4E42CC7: pn53x_usb_open (in /usr/lib/x86_64-linux-gnu/libnfc.so.4.0.0)
==1159==    by 0x4E351E6: nfc_open (in /usr/lib/x86_64-linux-gnu/libnfc.so.4.0.0)
2013-03-02 01:08:07 +01:00
Eugeny Boger
d9fd9155ea Adding a SPI driver for pn532
The driver seems to work well.
I tested it on Linux with i.mx233-based board using hardware SPI.
I tried to modify the build files as well, but it's probably a little messy.
I'm not sure whether it will work on other *nix OSes,
so it's probably better to limit the driver to Linux only using build system.
2013-02-28 23:24:42 +01:00
Philippe Teuwen
7e3549819e Split --disable-conf into --disable-conffiles & --disable-envvars 2013-02-22 21:53:16 +01:00
Ahti Legonkov
fd6d4db5b7 Make it possible to disable conf.
Now the configure script has --disable-conf command-line argument
that can be used to turn off environment variables and use of
configuration files.
2013-02-22 21:09:46 +01:00
Philippe Teuwen
72b10c5d9b Fix warnings: ignoring return value of 'pipe' & discarding const qualifier 2013-02-21 23:20:28 +01:00
Philippe Teuwen
24e1edd858 make style 2013-02-21 22:39:39 +01:00
Philippe Teuwen
5ced93fcbf Makefile.am: move header files from noinst_HEADERS to _SOURCES
Ensures proper recompilation when a header file is edited.
cf https://www.gnu.org/software/automake/manual/html_node/Headers.html
2013-02-21 22:37:20 +01:00
Philippe Teuwen
9935095a36 Fix stack smash bug in LOG_HEX() macro
Fixes issue 232
2013-02-21 22:31:19 +01:00
Romuald Conty
7e26869b68 Fixes nfc_drivers memory leak 2013-02-21 19:58:40 +01:00
Romuald Conty
1e16795341 'make style' and align some #preprocessor directives 2013-02-19 00:43:20 +01:00
Philippe Teuwen
09ce0e822c nfc_free(): fix related doc 2013-02-16 22:18:00 +01:00
Romuald Conty
f8601886fd Adds nfc_free() function to freed allocated buffers
Fixes issue 228 (Thanks to Alex Lian)
2013-02-16 14:20:37 +01:00
Romuald Conty
360365ca84 Preserves error code while setting parameters
It now returns a more precise error code while using pn53x_set_property_bool() with NP_AUTO_ISO14443_4 flag.
2013-02-15 09:38:26 +01:00
Alex Lian
4487fd768e Windows: Shift files from libnfc/windows to libnfc/contrib/win32
- Fixes the fact files were missed in package
2013-02-14 15:33:47 +01:00
Philippe Teuwen
73992041b4 Merge remote-tracking branch 'ahti/issue-137' into master
* ahti/issue-137:
  Add nfc_register_driver.

Fixes issue 225
Helps issue 137
2013-02-06 15:07:18 +01:00
Romuald Conty
d5b6a7c4d1 Resolves conflict between Alex Lian and master branch 2013-02-04 10:14:34 +01:00
Alex Lian
54e0bdb62f Windows: Build updates
- Generate rc files from version.rc.in + CMake variable information in CMakeLists files
- Add step to generate .lib file for windows developers
- Re-structure tool flag usage, apparently ADD_DEFINTIONS adds them to _ALL_ tools. This is bad for rc files with the windres tool.

Needs other platform testing, as the flags have changed to fix Windows rc file generation.
2013-02-01 10:19:02 -05:00
lego
225094e2c8 Add nfc_register_driver. Issue 137.
The nfc_register_driver allows users of the library to write their
own device drivers without needing to resort to hacking libnfc itself.
2013-02-01 14:40:40 +02:00
Romuald Conty
8127a2ca63 Merge branch 'master' of https://code.google.com/p/libnfc 2013-02-01 11:46:26 +01:00
Romuald Conty
b5f8ce91c7 Uses configurable path for libnfc's configuration files 2013-02-01 11:11:39 +01:00
Romuald Conty
cf9e02879a Enables logging by default when using CMake 2013-02-01 10:32:44 +01:00
Philippe Teuwen
06bfed11b9 Various typos 2013-01-31 21:58:29 +01:00
Romuald Conty
519dd8f8e2 make style 2013-01-31 16:12:14 +01:00
Romuald Conty
acdde1088c Renames contrib/win32/nfc_win32.c to contrib/win32/stdlib.c 2013-01-31 16:09:41 +01:00
Alex Lian
ef33827f04 Fix setenv/unsetenv link errors by implementing a local version using Windows SetEnvironmentVariable.
Untested, and does not comply with the error returns per setenv.
2013-01-31 15:52:39 +01:00
Alex Lian
9f682cc52b Fix enabling of LIBNFC_DEBUG_OUTPUT
- inclusion of log-printf.c didn't align with needed preprocessor definitions
- Added extra #error as well as preprocessor protection
- fixed CMakeList to specify -DLOG as appropriate per the header log.h usage
2013-01-31 15:52:39 +01:00
Alex Lian
eb90c5a8db Add CMake options for Win32 to require PCRE 2013-01-31 15:52:39 +01:00
Philippe Teuwen
8bc7a1c291 call idle() from driver-dependent close() rather than from nfc_close() as some driver still need to do an ack() before 2013-01-31 01:18:23 +01:00
Philippe Teuwen
683505f39b pn53x_idle: call driver-dependent PowerDown & do InRelease first, skip redundant InDeselect 2013-01-31 01:16:37 +01:00
Philippe Teuwen
1682a86166 Add driver-dependent PowerDown 2013-01-31 01:15:03 +01:00
Philippe Teuwen
db8033622a acr122_pcsc: fix log category 2013-01-31 01:08:23 +01:00