Fix a couple warnings.

This commit is contained in:
Romain Tartiere 2012-03-01 13:33:13 +00:00
parent 3eba0e9b54
commit 05789e5a68
8 changed files with 28 additions and 22 deletions

View file

@ -288,13 +288,13 @@ select:
} }
// Read time-out // Read time-out
if (res == 0) { if (res == 0) {
log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "Timeout!"); log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "%s", "Timeout!");
return NFC_ETIMEOUT; return NFC_ETIMEOUT;
} }
if (FD_ISSET (iAbortFd, &rfds)) { if (FD_ISSET (iAbortFd, &rfds)) {
// Abort requested // Abort requested
log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "Abort!"); log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "%s", "Abort!");
close (iAbortFd); close (iAbortFd);
return NFC_EOPABORTED; return NFC_EOPABORTED;
} }

View file

@ -150,7 +150,7 @@ pn53x_transceive (struct nfc_device *pnd, const uint8_t *pbtTx, const size_t szT
if (timeout > 0) { if (timeout > 0) {
log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "Timeout values: %d", timeout); log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "Timeout values: %d", timeout);
} else if (timeout == 0) { } else if (timeout == 0) {
log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "No timeout"); log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "%s", "No timeout");
} else if (timeout == -1) { } else if (timeout == -1) {
timeout = CHIP_DATA (pnd)->timeout_command; timeout = CHIP_DATA (pnd)->timeout_command;
} else { } else {
@ -2547,12 +2547,12 @@ pn53x_check_ack_frame (struct nfc_device *pnd, const uint8_t *pbtRxFrame, const
{ {
if (szRxFrameLen >= sizeof (pn53x_ack_frame)) { if (szRxFrameLen >= sizeof (pn53x_ack_frame)) {
if (0 == memcmp (pbtRxFrame, pn53x_ack_frame, sizeof (pn53x_ack_frame))) { if (0 == memcmp (pbtRxFrame, pn53x_ack_frame, sizeof (pn53x_ack_frame))) {
log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "PN53x ACKed"); log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "%s", "PN53x ACKed");
return NFC_SUCCESS; return NFC_SUCCESS;
} }
} }
pnd->last_error = NFC_EIO; pnd->last_error = NFC_EIO;
log_put (LOG_CATEGORY, NFC_PRIORITY_ERROR, "Unexpected PN53x reply!"); log_put (LOG_CATEGORY, NFC_PRIORITY_ERROR, "%s", "Unexpected PN53x reply!");
return pnd->last_error; return pnd->last_error;
} }
@ -2561,7 +2561,7 @@ pn53x_check_error_frame (struct nfc_device *pnd, const uint8_t *pbtRxFrame, cons
{ {
if (szRxFrameLen >= sizeof (pn53x_error_frame)) { if (szRxFrameLen >= sizeof (pn53x_error_frame)) {
if (0 == memcmp (pbtRxFrame, pn53x_error_frame, sizeof (pn53x_error_frame))) { if (0 == memcmp (pbtRxFrame, pn53x_error_frame, sizeof (pn53x_error_frame))) {
log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "PN53x sent an error frame"); log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "%s", "PN53x sent an error frame");
pnd->last_error = NFC_EIO; pnd->last_error = NFC_EIO;
return pnd->last_error; return pnd->last_error;
} }
@ -2831,6 +2831,7 @@ pn53x_get_supported_baud_rate (nfc_device *pnd, const nfc_modulation_type nmt, n
case NMT_DEP: case NMT_DEP:
*supported_br = (nfc_baud_rate*)pn53x_dep_supported_baud_rates; *supported_br = (nfc_baud_rate*)pn53x_dep_supported_baud_rates;
break; break;
default:
return NFC_EINVARG; return NFC_EINVARG;
} }
return NFC_SUCCESS; return NFC_SUCCESS;

View file

@ -476,7 +476,7 @@ acr122s_probe(nfc_connstring connstrings[], size_t connstrings_len, size_t *pszD
(void) connstrings; (void) connstrings;
(void) connstrings_len; (void) connstrings_len;
*pszDeviceFound = 0; *pszDeviceFound = 0;
log_put(LOG_CATEGORY, NFC_PRIORITY_INFO, "Serial auto-probing have been disabled at compile time. Skipping autoprobe."); log_put(LOG_CATEGORY, NFC_PRIORITY_INFO, "%s", "Serial auto-probing have been disabled at compile time. Skipping autoprobe.");
return false; return false;
#else /* SERIAL_AUTOPROBE_ENABLED */ #else /* SERIAL_AUTOPROBE_ENABLED */
*pszDeviceFound = 0; *pszDeviceFound = 0;

View file

@ -101,7 +101,7 @@ arygon_probe (nfc_connstring connstrings[], size_t connstrings_len, size_t *pszD
(void) connstrings; (void) connstrings;
(void) connstrings_len; (void) connstrings_len;
*pszDeviceFound = 0; *pszDeviceFound = 0;
log_put (LOG_CATEGORY, NFC_PRIORITY_INFO, "Serial auto-probing have been disabled at compile time. Skipping autoprobe."); log_put (LOG_CATEGORY, NFC_PRIORITY_INFO, "%s", "Serial auto-probing have been disabled at compile time. Skipping autoprobe.");
return false; return false;
#else /* SERIAL_AUTOPROBE_ENABLED */ #else /* SERIAL_AUTOPROBE_ENABLED */
*pszDeviceFound = 0; *pszDeviceFound = 0;
@ -113,7 +113,7 @@ arygon_probe (nfc_connstring connstrings[], size_t connstrings_len, size_t *pszD
while ((acPort = acPorts[iDevice++])) { while ((acPort = acPorts[iDevice++])) {
sp = uart_open (acPort); sp = uart_open (acPort);
log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "Trying to find ARYGON device on serial port: %s at %d bauds.", acPort, ARYGON_DEFAULT_SPEED); log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "%s", "Trying to find ARYGON device on serial port: %s at %d bauds.", acPort, ARYGON_DEFAULT_SPEED);
if ((sp != INVALID_SERIAL_PORT) && (sp != CLAIMED_SERIAL_PORT)) { if ((sp != INVALID_SERIAL_PORT) && (sp != CLAIMED_SERIAL_PORT)) {
// We need to flush input to be sure first reply does not comes from older byte transceive // We need to flush input to be sure first reply does not comes from older byte transceive
@ -344,7 +344,7 @@ arygon_tama_send (nfc_device *pnd, const uint8_t *pbtData, const size_t szData,
if (pn53x_check_ack_frame (pnd, abtRxBuf, sizeof(abtRxBuf)) == 0) { if (pn53x_check_ack_frame (pnd, abtRxBuf, sizeof(abtRxBuf)) == 0) {
// The PN53x is running the sent command // The PN53x is running the sent command
} else if (0 == memcmp(arygon_error_unknown_mode, abtRxBuf, sizeof(abtRxBuf))) { } else if (0 == memcmp(arygon_error_unknown_mode, abtRxBuf, sizeof(abtRxBuf))) {
log_put (LOG_CATEGORY, NFC_PRIORITY_ERROR, "Bad frame format." ); log_put (LOG_CATEGORY, NFC_PRIORITY_ERROR, "%s", "Bad frame format.");
// We have already read 6 bytes and arygon_error_unknown_mode is 10 bytes long // We have already read 6 bytes and arygon_error_unknown_mode is 10 bytes long
// so we have to read 4 remaining bytes to be synchronized at the next receiving pass. // so we have to read 4 remaining bytes to be synchronized at the next receiving pass.
pnd->last_error = uart_receive (DRIVER_DATA (pnd)->port, abtRxBuf, 4, 0, timeout); pnd->last_error = uart_receive (DRIVER_DATA (pnd)->port, abtRxBuf, 4, 0, timeout);
@ -495,12 +495,12 @@ arygon_firmware (nfc_device *pnd, char *str)
int res = uart_send (DRIVER_DATA (pnd)->port, arygon_firmware_version_cmd, sizeof (arygon_firmware_version_cmd), 0); int res = uart_send (DRIVER_DATA (pnd)->port, arygon_firmware_version_cmd, sizeof (arygon_firmware_version_cmd), 0);
if (res != 0) { if (res != 0) {
log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "Unable to send ARYGON firmware command."); log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "%s", "Unable to send ARYGON firmware command.");
return; return;
} }
res = uart_receive (DRIVER_DATA (pnd)->port, abtRx, szRx, 0, 0); res = uart_receive (DRIVER_DATA (pnd)->port, abtRx, szRx, 0, 0);
if (res != 0) { if (res != 0) {
log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "Unable to retrieve ARYGON firmware version."); log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "%s", "Unable to retrieve ARYGON firmware version.");
return; return;
} }
@ -527,7 +527,7 @@ arygon_reset_tama (nfc_device *pnd)
// or arygon_error_unknown_mode (ie. in case of the first byte was bad-transmitted) // or arygon_error_unknown_mode (ie. in case of the first byte was bad-transmitted)
res = uart_receive (DRIVER_DATA (pnd)->port, abtRx, szRx, 0, 1000); res = uart_receive (DRIVER_DATA (pnd)->port, abtRx, szRx, 0, 1000);
if (res != 0) { if (res != 0) {
log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "No reply to 'reset TAMA' command."); log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "%s", "No reply to 'reset TAMA' command.");
pnd->last_error = res; pnd->last_error = res;
return pnd->last_error; return pnd->last_error;
} }

View file

@ -660,7 +660,7 @@ pn53x_usb_init (nfc_device *pnd)
// ...and we don't care about error // ...and we don't care about error
pnd->last_error = 0; pnd->last_error = 0;
if (SONY_RCS360 == DRIVER_DATA (pnd)->model) { if (SONY_RCS360 == DRIVER_DATA (pnd)->model) {
log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "SONY RC-S360 initialization."); log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "%s", "SONY RC-S360 initialization.");
const uint8_t abtCmd2[] = { 0x18, 0x01 }; const uint8_t abtCmd2[] = { 0x18, 0x01 };
pn53x_transceive (pnd, abtCmd2, sizeof (abtCmd2), NULL, 0, 0); pn53x_transceive (pnd, abtCmd2, sizeof (abtCmd2), NULL, 0, 0);
pn53x_usb_ack (pnd); pn53x_usb_ack (pnd);
@ -670,7 +670,7 @@ pn53x_usb_init (nfc_device *pnd)
return res; return res;
if (ASK_LOGO == DRIVER_DATA (pnd)->model) { if (ASK_LOGO == DRIVER_DATA (pnd)->model) {
log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "ASK LoGO initialization."); log_put (LOG_CATEGORY, NFC_PRIORITY_TRACE, "%s", "ASK LoGO initialization.");
/* Internal registers */ /* Internal registers */
/* Disable 100mA current limit, Power on Secure IC (SVDD) */ /* Disable 100mA current limit, Power on Secure IC (SVDD) */
pn53x_write_register (pnd, PN53X_REG_Control_switch_rng, 0xFF, SYMBOL_CURLIMOFF | SYMBOL_SIC_SWITCH_EN | SYMBOL_RANDOM_DATAREADY); pn53x_write_register (pnd, PN53X_REG_Control_switch_rng, 0xFF, SYMBOL_CURLIMOFF | SYMBOL_SIC_SWITCH_EN | SYMBOL_RANDOM_DATAREADY);

View file

@ -40,8 +40,8 @@
#define NFC_PRIORITY_TRACE "trace" #define NFC_PRIORITY_TRACE "trace"
#else #else
// No logging // No logging
#define log_init() (0) #define log_init() ((void) 0)
#define log_fini() (0) #define log_fini() ((void) 0)
#define log_msg(category, priority, message) do {} while (0) #define log_msg(category, priority, message) do {} while (0)
#define log_set_appender(category, appender) do {} while (0) #define log_set_appender(category, appender) do {} while (0)
#define log_put(category, priority, format, ...) do {} while (0) #define log_put(category, priority, format, ...) do {} while (0)

View file

@ -109,6 +109,7 @@ const struct nfc_driver *nfc_drivers[] = {
void void
nfc_init(nfc_context *context) nfc_init(nfc_context *context)
{ {
(void) context;
log_init (); log_init ();
} }
@ -120,6 +121,7 @@ nfc_init(nfc_context *context)
void void
nfc_exit(nfc_context *context) nfc_exit(nfc_context *context)
{ {
(void) context;
log_fini (); log_fini ();
} }
@ -176,6 +178,7 @@ nfc_get_default_device (nfc_connstring *connstring)
nfc_device * nfc_device *
nfc_open (nfc_context *context, const nfc_connstring connstring) nfc_open (nfc_context *context, const nfc_connstring connstring)
{ {
(void) context;
nfc_device *pnd = NULL; nfc_device *pnd = NULL;
nfc_connstring ncs; nfc_connstring ncs;
@ -251,6 +254,8 @@ nfc_list_devices (nfc_context *context, nfc_connstring connstrings[] , size_t sz
const struct nfc_driver *ndr; const struct nfc_driver *ndr;
const struct nfc_driver **pndr = nfc_drivers; const struct nfc_driver **pndr = nfc_drivers;
(void) context;
while ((ndr = *pndr)) { while ((ndr = *pndr)) {
szN = 0; szN = 0;
if (ndr->probe (connstrings + (szDeviceFound), szDevices - (szDeviceFound), &szN)) { if (ndr->probe (connstrings + (szDeviceFound), szDevices - (szDeviceFound), &szN)) {

View file

@ -101,7 +101,7 @@ main (int argc, const char *argv[])
printf ("No NFC device found.\n"); printf ("No NFC device found.\n");
} }
printf ("%d NFC device(s) found:\n", szDeviceFound); printf ("%d NFC device(s) found:\n", (int) szDeviceFound);
for (i = 0; i < szDeviceFound; i++) { for (i = 0; i < szDeviceFound; i++) {
pnd = nfc_open (NULL, connstrings[i]); pnd = nfc_open (NULL, connstrings[i]);
if (pnd != NULL) { if (pnd != NULL) {