Codebase list libfreefare / 7b917f9
Windows: Clean up all compiler warnings and link warnings - 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 Alex Lian authored 11 years ago Philippe Teuwen committed 11 years ago
13 changed file(s) with 28 addition(s) and 22 deletion(s). Raw diff Collapse all Expand all
7878 IF(MINGW)
7979 # force MinGW-w64 in 32bit mode
8080 SET(CMAKE_C_FLAGS "-m32 ${CMAKE_C_FLAGS}")
81 SET(CMAKE_MODULE_LINKER_FLAGS "-m32 --enable-stdcall-fixup ${CMAKE_SHARED_LINKER_FLAGS}")
82 SET(CMAKE_SHARED_LINKER_FLAGS "-m32 --enable-stdcall-fixup ${CMAKE_SHARED_LINKER_FLAGS}")
83 SET(CMAKE_EXE_LINKER_FLAGS "-m32 --enable-stdcall-fixup ${CMAKE_EXE_LINKER_FLAGS}")
81 SET(CMAKE_MODULE_LINKER_FLAGS "-m32 -Wl,--enable-stdcall-fixup ${CMAKE_SHARED_LINKER_FLAGS}")
82 SET(CMAKE_SHARED_LINKER_FLAGS "-m32 -Wl,--enable-stdcall-fixup ${CMAKE_SHARED_LINKER_FLAGS}")
83 SET(CMAKE_EXE_LINKER_FLAGS "-m32 -Wl,--enable-stdcall-fixup ${CMAKE_EXE_LINKER_FLAGS}")
8484 SET(CMAKE_RC_FLAGS "--target=pe-i386 --output-format=coff ${CMAKE_RC_FLAGS}")
8585 ENDIF(MINGW)
8686
3737 #endif // HAVE_CONFIG_H
3838
3939 #include <err.h>
40 #include <inttypes.h>
4041 #include <signal.h>
4142 #include <stdio.h>
4243 #include <stddef.h>
127128 }
128129
129130 printf("NFC reader: %s opened\n", nfc_device_get_name(pnd));
130 printf("NFC device will poll during %ld ms (%u pollings of %lu ms for %zd modulations)\n", (unsigned long) uiPollNr * szModulations * uiPeriod * 150, uiPollNr, (unsigned long) uiPeriod * 150, szModulations);
131 printf("NFC device will poll during %ld ms (%u pollings of %lu ms for %" PRIdPTR " modulations)\n", (unsigned long) uiPollNr * szModulations * uiPeriod * 150, uiPollNr, (unsigned long) uiPeriod * 150, szModulations);
131132 if ((res = nfc_initiator_poll_target(pnd, nmModulations, szModulations, uiPollNr, uiPeriod, &nt)) < 0) {
132133 nfc_perror(pnd, "nfc_initiator_poll_target");
133134 nfc_close(pnd);
3636 # include "config.h"
3737 #endif /* HAVE_CONFIG_H */
3838
39 #include <inttypes.h>
3940 #include <stdio.h>
4041 #include <stdlib.h>
4142 #include <stdint.h>
118119 size_t szFound = nfc_list_devices(context, connstrings, MAX_DEVICE_COUNT);
119120
120121 if (szFound < 2) {
121 ERR("%zd device found but two opened devices are needed to relay NFC.", szFound);
122 ERR("%" PRIdPTR " device found but two opened devices are needed to relay NFC.", szFound);
122123 nfc_exit(context);
123124 exit(EXIT_FAILURE);
124125 }
2323 * @brief Windows UART driver
2424 */
2525
26 #include <inttypes.h>
2627 #include "log.h"
2728
2829 #define LOG_GROUP NFC_LOG_GROUP_COM
163164 log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "Unable to apply new timeout settings.");
164165 return NFC_EIO;
165166 }
166 log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "Timeouts are set to %u ms", timeout_ms);
167 log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "Timeouts are set to %lu ms", timeout_ms);
167168
168169 // TODO Enhance the reception method
169170 // - According to MSDN, it could be better to implement nfc_abort_command() mecanism using Cancello()
178179
179180 if (!res) {
180181 DWORD err = GetLastError();
181 log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "ReadFile error: %u", err);
182 log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "ReadFile error: %lu", err);
182183 return NFC_EIO;
183184 } else if (dwBytesReceived == 0) {
184185 return NFC_ETIMEOUT;
2727 # include "config.h"
2828 #endif // HAVE_CONFIG_H
2929
30 #include <inttypes.h>
3031 #include <stdio.h>
3132 #include <stdlib.h>
3233 #include <string.h>
13531354 const size_t szRxLen = (size_t)res - 1;
13541355 if (pbtRx != NULL) {
13551356 if (szRxLen > szRx) {
1356 log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "Buffer size is too short: %zuo available(s), %zuo needed", szRx, szRxLen);
1357 log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "Buffer size is too short: %" PRIuPTR " available(s), %" PRIuPTR " needed", szRx, szRxLen);
13571358 return NFC_EOVFLOW;
13581359 }
13591360 // Copy the received bytes
16281629 }
16291630 if (pbtRx != NULL) {
16301631 if ((szRxLen + sz) > szRx) {
1631 log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "Buffer size is too short: %zuo available(s), %zuo needed", szRx, szRxLen + sz);
1632 log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "Buffer size is too short: %" PRIuPTR " available(s), %" PRIuPTR " needed", szRx, szRxLen + sz);
16321633 return NFC_EOVFLOW;
16331634 }
16341635 // Copy the received bytes
27102711
27112712 (*pszFrame) = szData + PN53x_EXTENDED_FRAME__OVERHEAD;
27122713 } else {
2713 log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "We can't send more than %d bytes in a raw (requested: %zd)", PN53x_EXTENDED_FRAME__DATA_MAX_LEN, szData);
2714 log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "We can't send more than %d bytes in a raw (requested: %" PRIdPTR ")", PN53x_EXTENDED_FRAME__DATA_MAX_LEN, szData);
27142715 return NFC_ECHIP;
27152716 }
27162717 return NFC_SUCCESS;
254254 if (strlen(ndd.pcsc_device_name) < 5) { // We can assume it's a reader ID as pcsc_name always ends with "NN NN"
255255 // Device was not specified, only ID, retrieve it
256256 size_t index;
257 if (sscanf(ndd.pcsc_device_name, "%4lu", &index) != 1)
257 if (sscanf(ndd.pcsc_device_name, "%4" SCNuPTR, &index) != 1)
258258 return NULL;
259259 nfc_connstring *ncs = malloc(sizeof(nfc_connstring) * (index + 1));
260260 if (!ncs) {
717717 len -= 4; // We skip 2 bytes for PN532 direction byte (D5) and command byte (CMD+1), then 2 bytes for APDU status (90 00).
718718
719719 if (len > szDataLen) {
720 log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "Unable to receive data: buffer too small. (szDataLen: %zu, len: %zu)", szDataLen, len);
720 log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "Unable to receive data: buffer too small. (szDataLen: %" PRIuPTR ", len: %" PRIuPTR ")", szDataLen, len);
721721 pnd->last_error = NFC_EOVFLOW;
722722 return pnd->last_error;
723723 }
683683
684684 size_t data_len = FRAME_SIZE(tmp) - 17;
685685 if (data_len > buf_len) {
686 log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "Receive buffer too small. (buf_len: %zu, data_len: %zu)", buf_len, data_len);
686 log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "Receive buffer too small. (buf_len: %" PRIuPTR ", data_len: %" PRIuPTR ")", buf_len, data_len);
687687 pnd->last_error = NFC_EIO;
688688 return pnd->last_error;
689689 }
329329 size_t szFrame = 0;
330330 if (szData > PN53x_NORMAL_FRAME__DATA_MAX_LEN) {
331331 // ARYGON Reader with PN532 equipped does not support extended frame (bug in ARYGON firmware?)
332 log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "ARYGON device does not support more than %d bytes as payload (requested: %zd)", PN53x_NORMAL_FRAME__DATA_MAX_LEN, szData);
332 log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "ARYGON device does not support more than %d bytes as payload (requested: %" PRIdPTR ")", PN53x_NORMAL_FRAME__DATA_MAX_LEN, szData);
333333 pnd->last_error = NFC_EDEVNOTSUPP;
334334 return pnd->last_error;
335335 }
437437 }
438438
439439 if (len > szDataLen) {
440 log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "Unable to receive data: buffer too small. (szDataLen: %zu, len: %zu)", szDataLen, len);
440 log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "Unable to receive data: buffer too small. (szDataLen: %" PRIuPTR ", len: %" PRIuPTR ")", szDataLen, len);
441441 pnd->last_error = NFC_EIO;
442442 return pnd->last_error;
443443 }
423423 }
424424
425425 if (len > szDataLen) {
426 log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "Unable to receive data: buffer too small. (szDataLen: %zu, len: %zu)", szDataLen, len);
426 log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "Unable to receive data: buffer too small. (szDataLen: %" PRIuPTR ", len: %" PRIuPTR ")", szDataLen, len);
427427 pnd->last_error = NFC_EIO;
428428 goto error;
429429 }
587587 }
588588
589589 if (len > szDataLen) {
590 log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "Unable to receive data: buffer too small. (szDataLen: %zu, len: %zu)", szDataLen, len);
590 log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "Unable to receive data: buffer too small. (szDataLen: %" PRIuPTR ", len: %" PRIuPTR ")", szDataLen, len);
591591 pnd->last_error = NFC_EIO;
592592 return pnd->last_error;
593593 }
2222 * @file target-subr.c
2323 * @brief Target-related subroutines. (ie. determine target type, print target, etc.)
2424 */
25 #include <inttypes.h>
2526 #include <nfc/nfc.h>
2627
2728 #include "target-subr.h"
247248 uint8_t TC = pnai->abtAts[offset];
248249 offset++;
249250 if (TC & 0x1) {
250 off += snprintf(dst + off, size - off, "* Node ADdress supported\n");
251 off += snprintf(dst + off, size - off, "* Node Address supported\n");
251252 } else {
252 off += snprintf(dst + off, size - off, "* Node ADdress not supported\n");
253 off += snprintf(dst + off, size - off, "* Node Address not supported\n");
253254 }
254255 if (TC & 0x2) {
255256 off += snprintf(dst + off, size - off, "* Card IDentifier supported\n");
270271 offset++;
271272 if (L != (pnai->szAtsLen - offset)) {
272273 off += snprintf(dst + off, size - off, " * Warning: Type Identification Coding length (%i)", L);
273 off += snprintf(dst + off, size - off, " not matching Tk length (%zi)\n", (pnai->szAtsLen - offset));
274 off += snprintf(dst + off, size - off, " not matching Tk length (%" PRIdPTR ")\n", (pnai->szAtsLen - offset));
274275 }
275276 if ((pnai->szAtsLen - offset - 2) > 0) { // Omit 2 CRC bytes
276277 uint8_t CTC = pnai->abtAts[offset];
4141 # include "config.h"
4242 #endif /* HAVE_CONFIG_H */
4343
44 #include <inttypes.h>
4445 #include <stdio.h>
4546 #include <stdlib.h>
4647 #include <stdint.h>
99100 if (szBytes > MAX_FRAME_LEN) {
100101 return -1;
101102 }
102 if (fprintf(fd4, "#%s %04zx: ", pchPrefix, szBytes) < 0) {
103 if (fprintf(fd4, "#%s %04" PRIxPTR ": ", pchPrefix, szBytes) < 0) {
103104 return -1;
104105 }
105106
224225 }
225226 } else {
226227 if (szFound < 2) {
227 ERR("%zd device found but two opened devices are needed to relay NFC.", szFound);
228 ERR("%" PRIdPTR " device found but two opened devices are needed to relay NFC.", szFound);
228229 nfc_exit(context);
229230 exit(EXIT_FAILURE);
230231 }