libnfc/HACKING
Philippe Teuwen 9632f3ef35 Edit HACKING & introduce cppcheck
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'
2013-03-06 01:09:57 +01:00

54 lines
2.1 KiB
Text

Hello hackers!
General remarks about contributing
----------------------------------
Contributions to the libnfc are welcome!
Here are some directions to get you started:
1. Follow style conventions
The source code of the library trend to follow some conventions so that it
is consistent in style and thus easier to read.
Look around and respect the same style.
Don't use tabs. Increment unit is two spaces.
Don't leave dandling spaces or tabs at EOL.
Helper script to get some uniformity in the style:
$ make style
If you use vim see the "Vim: How to prevent trailing whitespaces"
http://www.carbon-project.org/Vim__How_to_prevent_trailing_whitespaces.html
2. Chase warnings: no warning should be introduced by your changes
Depending what you touch, you can check with:
2.1 When using autotools
$ autoreconf -Wall -vis
2.2 When compiling
$ export CFLAGS="-Wall -g -O2 -Wextra -pipe -funsigned-char -fstrict-aliasing \
-Wchar-subscripts -Wundef -Wshadow -Wcast-align -Wwrite-strings -Wunused \
-Wuninitialized -Wpointer-arith -Wredundant-decls -Winline -Wformat \
-Wformat-security -Wswitch-enum -Winit-self -Wmissing-include-dirs \
-Wmissing-prototypes -Wstrict-prototypes -Wold-style-definition \
-Wbad-function-cast -Wnested-externs -Wmissing-declarations"
$ ./configure
$ make clean
$ make
You can chase even more issues by using clang:
$ scan-build ./configure
$ make clean
$ scan-build make
And by using cppcheck:
$ cppcheck --quiet --enable=all --std=c99 --std=posix \
-I include -I libnfc -I libnfc/buses .
2.3 When Debianizing
$ lintian --info --display-info --display-experimental *deb
or (shorter version)
$ lintian -iIE *deb
3. Preserve cross-platform compatility
The source code should remain compilable across various platforms,
including some you probably cannot test alone so keep it in mind.
Supported platforms:
- Linux
- FreeBSD
- Mac OS X
- Windows with Mingw