Commit 7b917f9a authored by Alex Lian's avatar Alex Lian Committed by Philippe Teuwen

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
parent bd961222
......@@ -79,9 +79,9 @@ ADD_DEFINITIONS(-Du_int8_t=uint8_t -Du_int16_t=uint16_t)
IF(MINGW)
# force MinGW-w64 in 32bit mode
SET(CMAKE_C_FLAGS "-m32 ${CMAKE_C_FLAGS}")
SET(CMAKE_MODULE_LINKER_FLAGS "-m32 --enable-stdcall-fixup ${CMAKE_SHARED_LINKER_FLAGS}")
SET(CMAKE_SHARED_LINKER_FLAGS "-m32 --enable-stdcall-fixup ${CMAKE_SHARED_LINKER_FLAGS}")
SET(CMAKE_EXE_LINKER_FLAGS "-m32 --enable-stdcall-fixup ${CMAKE_EXE_LINKER_FLAGS}")
SET(CMAKE_MODULE_LINKER_FLAGS "-m32 -Wl,--enable-stdcall-fixup ${CMAKE_SHARED_LINKER_FLAGS}")
SET(CMAKE_SHARED_LINKER_FLAGS "-m32 -Wl,--enable-stdcall-fixup ${CMAKE_SHARED_LINKER_FLAGS}")
SET(CMAKE_EXE_LINKER_FLAGS "-m32 -Wl,--enable-stdcall-fixup ${CMAKE_EXE_LINKER_FLAGS}")
SET(CMAKE_RC_FLAGS "--target=pe-i386 --output-format=coff ${CMAKE_RC_FLAGS}")
ENDIF(MINGW)
......
......@@ -38,6 +38,7 @@
#endif // HAVE_CONFIG_H
#include <err.h>
#include <inttypes.h>
#include <signal.h>
#include <stdio.h>
#include <stddef.h>
......@@ -128,7 +129,7 @@ main(int argc, const char *argv[])
}
printf("NFC reader: %s opened\n", nfc_device_get_name(pnd));
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);
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);
if ((res = nfc_initiator_poll_target(pnd, nmModulations, szModulations, uiPollNr, uiPeriod, &nt)) < 0) {
nfc_perror(pnd, "nfc_initiator_poll_target");
nfc_close(pnd);
......
......@@ -37,6 +37,7 @@
# include "config.h"
#endif /* HAVE_CONFIG_H */
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
......@@ -119,7 +120,7 @@ main(int argc, char *argv[])
size_t szFound = nfc_list_devices(context, connstrings, MAX_DEVICE_COUNT);
if (szFound < 2) {
ERR("%zd device found but two opened devices are needed to relay NFC.", szFound);
ERR("%" PRIdPTR " device found but two opened devices are needed to relay NFC.", szFound);
nfc_exit(context);
exit(EXIT_FAILURE);
}
......
......@@ -24,6 +24,7 @@
* @brief Windows UART driver
*/
#include <inttypes.h>
#include "log.h"
#define LOG_GROUP NFC_LOG_GROUP_COM
......@@ -164,7 +165,7 @@ uart_receive(serial_port sp, uint8_t *pbtRx, const size_t szRx, void *abort_p, i
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "Unable to apply new timeout settings.");
return NFC_EIO;
}
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "Timeouts are set to %u ms", timeout_ms);
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "Timeouts are set to %lu ms", timeout_ms);
// TODO Enhance the reception method
// - According to MSDN, it could be better to implement nfc_abort_command() mecanism using Cancello()
......@@ -179,7 +180,7 @@ uart_receive(serial_port sp, uint8_t *pbtRx, const size_t szRx, void *abort_p, i
if (!res) {
DWORD err = GetLastError();
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "ReadFile error: %u", err);
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "ReadFile error: %lu", err);
return NFC_EIO;
} else if (dwBytesReceived == 0) {
return NFC_ETIMEOUT;
......
......@@ -28,6 +28,7 @@
# include "config.h"
#endif // HAVE_CONFIG_H
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
......@@ -1354,7 +1355,7 @@ pn53x_initiator_transceive_bytes(struct nfc_device *pnd, const uint8_t *pbtTx, c
const size_t szRxLen = (size_t)res - 1;
if (pbtRx != NULL) {
if (szRxLen > szRx) {
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "Buffer size is too short: %zuo available(s), %zuo needed", szRx, szRxLen);
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "Buffer size is too short: %" PRIuPTR " available(s), %" PRIuPTR " needed", szRx, szRxLen);
return NFC_EOVFLOW;
}
// Copy the received bytes
......@@ -1629,7 +1630,7 @@ pn53x_initiator_transceive_bytes_timed(struct nfc_device *pnd, const uint8_t *pb
}
if (pbtRx != NULL) {
if ((szRxLen + sz) > szRx) {
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "Buffer size is too short: %zuo available(s), %zuo needed", szRx, szRxLen + sz);
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "Buffer size is too short: %" PRIuPTR " available(s), %" PRIuPTR " needed", szRx, szRxLen + sz);
return NFC_EOVFLOW;
}
// Copy the received bytes
......@@ -2711,7 +2712,7 @@ pn53x_build_frame(uint8_t *pbtFrame, size_t *pszFrame, const uint8_t *pbtData, c
(*pszFrame) = szData + PN53x_EXTENDED_FRAME__OVERHEAD;
} else {
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);
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);
return NFC_ECHIP;
}
return NFC_SUCCESS;
......
......@@ -255,7 +255,7 @@ acr122_pcsc_open(const nfc_context *context, const nfc_connstring connstring)
if (strlen(ndd.pcsc_device_name) < 5) { // We can assume it's a reader ID as pcsc_name always ends with "NN NN"
// Device was not specified, only ID, retrieve it
size_t index;
if (sscanf(ndd.pcsc_device_name, "%4lu", &index) != 1)
if (sscanf(ndd.pcsc_device_name, "%4" SCNuPTR, &index) != 1)
return NULL;
nfc_connstring *ncs = malloc(sizeof(nfc_connstring) * (index + 1));
if (!ncs) {
......
......@@ -718,7 +718,7 @@ read:
len -= 4; // We skip 2 bytes for PN532 direction byte (D5) and command byte (CMD+1), then 2 bytes for APDU status (90 00).
if (len > szDataLen) {
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "Unable to receive data: buffer too small. (szDataLen: %zu, len: %zu)", szDataLen, len);
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "Unable to receive data: buffer too small. (szDataLen: %" PRIuPTR ", len: %" PRIuPTR ")", szDataLen, len);
pnd->last_error = NFC_EOVFLOW;
return pnd->last_error;
}
......
......@@ -684,7 +684,7 @@ acr122s_receive(nfc_device *pnd, uint8_t *buf, size_t buf_len, int timeout)
size_t data_len = FRAME_SIZE(tmp) - 17;
if (data_len > buf_len) {
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "Receive buffer too small. (buf_len: %zu, data_len: %zu)", buf_len, data_len);
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "Receive buffer too small. (buf_len: %" PRIuPTR ", data_len: %" PRIuPTR ")", buf_len, data_len);
pnd->last_error = NFC_EIO;
return pnd->last_error;
}
......
......@@ -330,7 +330,7 @@ arygon_tama_send(nfc_device *pnd, const uint8_t *pbtData, const size_t szData, i
size_t szFrame = 0;
if (szData > PN53x_NORMAL_FRAME__DATA_MAX_LEN) {
// ARYGON Reader with PN532 equipped does not support extended frame (bug in ARYGON firmware?)
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);
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);
pnd->last_error = NFC_EDEVNOTSUPP;
return pnd->last_error;
}
......@@ -438,7 +438,7 @@ arygon_tama_receive(nfc_device *pnd, uint8_t *pbtData, const size_t szDataLen, i
}
if (len > szDataLen) {
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "Unable to receive data: buffer too small. (szDataLen: %zu, len: %zu)", szDataLen, len);
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "Unable to receive data: buffer too small. (szDataLen: %" PRIuPTR ", len: %" PRIuPTR ")", szDataLen, len);
pnd->last_error = NFC_EIO;
return pnd->last_error;
}
......
......@@ -424,7 +424,7 @@ pn532_uart_receive(nfc_device *pnd, uint8_t *pbtData, const size_t szDataLen, in
}
if (len > szDataLen) {
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "Unable to receive data: buffer too small. (szDataLen: %zu, len: %zu)", szDataLen, len);
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "Unable to receive data: buffer too small. (szDataLen: %" PRIuPTR ", len: %" PRIuPTR ")", szDataLen, len);
pnd->last_error = NFC_EIO;
goto error;
}
......
......@@ -588,7 +588,7 @@ read:
}
if (len > szDataLen) {
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "Unable to receive data: buffer too small. (szDataLen: %zu, len: %zu)", szDataLen, len);
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "Unable to receive data: buffer too small. (szDataLen: %" PRIuPTR ", len: %" PRIuPTR ")", szDataLen, len);
pnd->last_error = NFC_EIO;
return pnd->last_error;
}
......
......@@ -23,6 +23,7 @@
* @file target-subr.c
* @brief Target-related subroutines. (ie. determine target type, print target, etc.)
*/
#include <inttypes.h>
#include <nfc/nfc.h>
#include "target-subr.h"
......@@ -248,9 +249,9 @@ snprint_nfc_iso14443a_info(char *dst, size_t size, const nfc_iso14443a_info *pna
uint8_t TC = pnai->abtAts[offset];
offset++;
if (TC & 0x1) {
off += snprintf(dst + off, size - off, "* Node ADdress supported\n");
off += snprintf(dst + off, size - off, "* Node Address supported\n");
} else {
off += snprintf(dst + off, size - off, "* Node ADdress not supported\n");
off += snprintf(dst + off, size - off, "* Node Address not supported\n");
}
if (TC & 0x2) {
off += snprintf(dst + off, size - off, "* Card IDentifier supported\n");
......@@ -271,7 +272,7 @@ snprint_nfc_iso14443a_info(char *dst, size_t size, const nfc_iso14443a_info *pna
offset++;
if (L != (pnai->szAtsLen - offset)) {
off += snprintf(dst + off, size - off, " * Warning: Type Identification Coding length (%i)", L);
off += snprintf(dst + off, size - off, " not matching Tk length (%zi)\n", (pnai->szAtsLen - offset));
off += snprintf(dst + off, size - off, " not matching Tk length (%" PRIdPTR ")\n", (pnai->szAtsLen - offset));
}
if ((pnai->szAtsLen - offset - 2) > 0) { // Omit 2 CRC bytes
uint8_t CTC = pnai->abtAts[offset];
......
......@@ -42,6 +42,7 @@
# include "config.h"
#endif /* HAVE_CONFIG_H */
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
......@@ -100,7 +101,7 @@ static int print_hex_fd4(const uint8_t *pbtData, const size_t szBytes, const cha
if (szBytes > MAX_FRAME_LEN) {
return -1;
}
if (fprintf(fd4, "#%s %04zx: ", pchPrefix, szBytes) < 0) {
if (fprintf(fd4, "#%s %04" PRIxPTR ": ", pchPrefix, szBytes) < 0) {
return -1;
}
......@@ -225,7 +226,7 @@ main(int argc, char *argv[])
}
} else {
if (szFound < 2) {
ERR("%zd device found but two opened devices are needed to relay NFC.", szFound);
ERR("%" PRIdPTR " device found but two opened devices are needed to relay NFC.", szFound);
nfc_exit(context);
exit(EXIT_FAILURE);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment