diff --git a/examples/nfc-emulate-tag.c b/examples/nfc-emulate-tag.c index 6239145..3df6999 100644 --- a/examples/nfc-emulate-tag.c +++ b/examples/nfc-emulate-tag.c @@ -88,7 +88,7 @@ case 0x30: // Mifare read // block address is in pbtInput[1] *pszOutput = 15; - strcpy((char*)pbtOutput, "You read block "); + strcpy((char *)pbtOutput, "You read block "); pbtOutput[15] = pbtInput[1]; break; case 0x50: // HLTA (ISO14443-3) diff --git a/examples/nfc-poll.c b/examples/nfc-poll.c index 3de18ba..2f09759 100644 --- a/examples/nfc-poll.c +++ b/examples/nfc-poll.c @@ -63,7 +63,7 @@ } static void -print_usage(const char* progname) +print_usage(const char *progname) { printf("usage: %s [-v]\n", progname); printf(" -v\t verbose display\n"); diff --git a/examples/pn53x-tamashell.c b/examples/pn53x-tamashell.c index 7691a59..f594eb4 100644 --- a/examples/pn53x-tamashell.c +++ b/examples/pn53x-tamashell.c @@ -67,14 +67,14 @@ #define MAX_FRAME_LEN 264 -int main(int argc, const char* argv[]) +int main(int argc, const char *argv[]) { nfc_device *pnd; uint8_t abtRx[MAX_FRAME_LEN]; uint8_t abtTx[MAX_FRAME_LEN]; size_t szRx = sizeof(abtRx); size_t szTx; - FILE* input = NULL; + FILE *input = NULL; if (argc >= 2) { if ((input = fopen(argv[1], "r")) == NULL) { diff --git a/include/nfc/nfc-emulation.h b/include/nfc/nfc-emulation.h index f672ae8..70ea375 100644 --- a/include/nfc/nfc-emulation.h +++ b/include/nfc/nfc-emulation.h @@ -54,7 +54,7 @@ void *data; }; - NFC_EXPORT int nfc_emulate_target(nfc_device* pnd, struct nfc_emulator *emulator); + NFC_EXPORT int nfc_emulate_target(nfc_device *pnd, struct nfc_emulator *emulator); #ifdef __cplusplus } diff --git a/include/nfc/nfc.h b/include/nfc/nfc.h index c48de82..04eed54 100644 --- a/include/nfc/nfc.h +++ b/include/nfc/nfc.h @@ -120,8 +120,8 @@ NFC_EXPORT int nfc_device_get_information_about(nfc_device *pnd, char *buf, size_t buflen); /* String converter functions */ - NFC_EXPORT const char * str_nfc_modulation_type(const nfc_modulation_type nmt); - NFC_EXPORT const char * str_nfc_baud_rate(const nfc_baud_rate nbr); + NFC_EXPORT const char *str_nfc_modulation_type(const nfc_modulation_type nmt); + NFC_EXPORT const char *str_nfc_baud_rate(const nfc_baud_rate nbr); /* Error codes */ diff --git a/libnfc/buses/uart_posix.c b/libnfc/buses/uart_posix.c index 50f8e28..54b2bda 100644 --- a/libnfc/buses/uart_posix.c +++ b/libnfc/buses/uart_posix.c @@ -127,7 +127,7 @@ if (available_bytes_count == 0) { return; } - char* rx = malloc(available_bytes_count); + char *rx = malloc(available_bytes_count); // There is something available, read the data res = read(UART_DATA(sp)->fd, rx, available_bytes_count); log_put(LOG_CATEGORY, NFC_PRIORITY_TRACE, "%d bytes have eatten.", available_bytes_count); @@ -250,7 +250,7 @@ int uart_receive(serial_port sp, uint8_t *pbtRx, const size_t szRx, void *abort_p, int timeout) { - int iAbortFd = abort_p ? *((int*)abort_p) : 0; + int iAbortFd = abort_p ? *((int *)abort_p) : 0; int received_bytes_count = 0; int available_bytes_count = 0; const int expected_bytes_count = (int)szRx; diff --git a/libnfc/buses/uart_win32.c b/libnfc/buses/uart_win32.c index 612d244..0052e82 100644 --- a/libnfc/buses/uart_win32.c +++ b/libnfc/buses/uart_win32.c @@ -139,7 +139,7 @@ } int -uart_receive(serial_port sp, uint8_t * pbtRx, const size_t szRx, void * abort_p, int timeout) +uart_receive(serial_port sp, uint8_t *pbtRx, const size_t szRx, void *abort_p, int timeout) { DWORD dwBytesToGet = (DWORD)szRx; DWORD dwBytesReceived = 0; @@ -163,7 +163,7 @@ // TODO Enhance the reception method // - According to MSDN, it could be better to implement nfc_abort_command() mecanism using Cancello() - volatile bool * abort_flag_p = (volatile bool *)abort_p; + volatile bool *abort_flag_p = (volatile bool *)abort_p; do { log_put(LOG_CATEGORY, NFC_PRIORITY_TRACE, "ReadFile"); res = ReadFile(((struct serial_port_windows *) sp)->hPort, pbtRx + dwTotalBytesReceived, @@ -194,7 +194,7 @@ } int -uart_send(serial_port sp, const uint8_t * pbtTx, const size_t szTx, int timeout) +uart_send(serial_port sp, const uint8_t *pbtTx, const size_t szTx, int timeout) { DWORD dwTxLen = 0; @@ -238,12 +238,12 @@ char ** uart_list_ports(void) { - char **availablePorts = malloc((1 + MAX_SERIAL_PORT_WIN) * sizeof(char*)); + char **availablePorts = malloc((1 + MAX_SERIAL_PORT_WIN) * sizeof(char *)); int curIndex = 0; int i; for (i = 1; i <= MAX_SERIAL_PORT_WIN; i++) { if (is_port_available(i)) { - availablePorts[curIndex] = (char*)malloc(10); + availablePorts[curIndex] = (char *)malloc(10); sprintf(availablePorts[curIndex], "COM%d", i); // printf("found candidate port: %s\n", availablePorts[curIndex]); curIndex++; diff --git a/libnfc/chips/pn53x.c b/libnfc/chips/pn53x.c index ac1f8f1..1ef696a 100644 --- a/libnfc/chips/pn53x.c +++ b/libnfc/chips/pn53x.c @@ -95,7 +95,7 @@ } if (!CHIP_DATA(pnd)->supported_modulation_as_target) { - CHIP_DATA(pnd)->supported_modulation_as_target = (nfc_modulation_type*) pn53x_supported_modulation_as_target; + CHIP_DATA(pnd)->supported_modulation_as_target = (nfc_modulation_type *) pn53x_supported_modulation_as_target; } // CRC handling should be enabled by default as declared in nfc_device_new @@ -1189,7 +1189,7 @@ const int timeout) { const uint8_t abtPassiveInitiatorData[] = { 0x00, 0xff, 0xff, 0x00, 0x0f }; // Only for 212/424 kpbs: First 4 bytes shall be set like this according to NFCIP-1, last byte is TSN (Time Slot Number) - const uint8_t * pbtPassiveInitiatorData = NULL; + const uint8_t *pbtPassiveInitiatorData = NULL; switch (nbr) { case NBR_212: @@ -2345,7 +2345,7 @@ int pn53x_InAutoPoll(struct nfc_device *pnd, const pn53x_target_type *ppttTargetTypes, const size_t szTargetTypes, - const uint8_t btPollNr, const uint8_t btPeriod, nfc_target * pntTargets, const int timeout) + const uint8_t btPollNr, const uint8_t btPeriod, nfc_target *pntTargets, const int timeout) { size_t szTargetFound = 0; if (CHIP_DATA(pnd)->type != PN532) { @@ -2849,27 +2849,27 @@ { switch (nmt) { case NMT_FELICA: - *supported_br = (nfc_baud_rate*)pn53x_felica_supported_baud_rates; + *supported_br = (nfc_baud_rate *)pn53x_felica_supported_baud_rates; break; case NMT_ISO14443A: - *supported_br = (nfc_baud_rate*)pn53x_iso14443a_supported_baud_rates; + *supported_br = (nfc_baud_rate *)pn53x_iso14443a_supported_baud_rates; break; case NMT_ISO14443B: case NMT_ISO14443BI: case NMT_ISO14443B2SR: case NMT_ISO14443B2CT: { if ((CHIP_DATA(pnd)->type != PN533)) { - *supported_br = (nfc_baud_rate*)pn532_iso14443b_supported_baud_rates; + *supported_br = (nfc_baud_rate *)pn532_iso14443b_supported_baud_rates; } else { - *supported_br = (nfc_baud_rate*)pn533_iso14443b_supported_baud_rates; + *supported_br = (nfc_baud_rate *)pn533_iso14443b_supported_baud_rates; } } break; case NMT_JEWEL: - *supported_br = (nfc_baud_rate*)pn53x_jewel_supported_baud_rates; + *supported_br = (nfc_baud_rate *)pn53x_jewel_supported_baud_rates; break; case NMT_DEP: - *supported_br = (nfc_baud_rate*)pn53x_dep_supported_baud_rates; + *supported_br = (nfc_baud_rate *)pn53x_dep_supported_baud_rates; break; default: return NFC_EINVARG; diff --git a/libnfc/drivers/acr122s.c b/libnfc/drivers/acr122s.c index 12c91a0..1a4b3fe 100644 --- a/libnfc/drivers/acr122s.c +++ b/libnfc/drivers/acr122s.c @@ -538,7 +538,7 @@ } iDevice = 0; while ((acPort = acPorts[iDevice++])) { - free((void*)acPort); + free((void *)acPort); } free(acPorts); #endif /* SERIAL_AUTOPROBE_ENABLED */ diff --git a/libnfc/drivers/arygon.c b/libnfc/drivers/arygon.c index e380eca..8231c6e 100644 --- a/libnfc/drivers/arygon.c +++ b/libnfc/drivers/arygon.c @@ -156,7 +156,7 @@ } iDevice = 0; while ((acPort = acPorts[iDevice++])) { - free((void*)acPort); + free((void *)acPort); } free(acPorts); #endif /* SERIAL_AUTOPROBE_ENABLED */ @@ -378,7 +378,7 @@ #ifndef WIN32 abort_p = &(DRIVER_DATA(pnd)->iAbortFds[1]); #else - abort_p = (void*) & (DRIVER_DATA(pnd)->abort_flag); + abort_p = (void *) & (DRIVER_DATA(pnd)->abort_flag); #endif pnd->last_error = uart_receive(DRIVER_DATA(pnd)->port, abtRxBuf, 5, abort_p, timeout); @@ -508,7 +508,7 @@ if (0 == memcmp(abtRx, arygon_error_none, 6)) { uint8_t *p = abtRx + 6; unsigned int szData; - sscanf((const char*)p, "%02x%s", &szData, p); + sscanf((const char *)p, "%02x%s", &szData, p); memcpy(str, p, szData); *(str + szData) = '\0'; } diff --git a/libnfc/drivers/pn532_uart.c b/libnfc/drivers/pn532_uart.c index f8c9068..8f6924b 100644 --- a/libnfc/drivers/pn532_uart.c +++ b/libnfc/drivers/pn532_uart.c @@ -134,7 +134,7 @@ } iDevice = 0; while ((acPort = acPorts[iDevice++])) { - free((void*)acPort); + free((void *)acPort); } free(acPorts); #endif /* SERIAL_AUTOPROBE_ENABLED */ @@ -358,7 +358,7 @@ #ifndef WIN32 abort_p = &(DRIVER_DATA(pnd)->iAbortFds[1]); #else - abort_p = (void*) & (DRIVER_DATA(pnd)->abort_flag); + abort_p = (void *) & (DRIVER_DATA(pnd)->abort_flag); #endif pnd->last_error = uart_receive(DRIVER_DATA(pnd)->port, abtRxBuf, 5, abort_p, timeout); diff --git a/libnfc/nfc-internal.c b/libnfc/nfc-internal.c index b5ae0d4..260c1eb 100644 --- a/libnfc/nfc-internal.c +++ b/libnfc/nfc-internal.c @@ -26,7 +26,7 @@ #include "nfc-internal.h" void -prepare_initiator_data(const nfc_modulation nm, uint8_t **ppbtInitiatorData, size_t * pszInitiatorData) +prepare_initiator_data(const nfc_modulation nm, uint8_t **ppbtInitiatorData, size_t *pszInitiatorData) { switch (nm.nmt) { case NMT_ISO14443B: { diff --git a/libnfc/nfc-internal.h b/libnfc/nfc-internal.h index 1e41d2c..df095c4 100644 --- a/libnfc/nfc-internal.h +++ b/libnfc/nfc-internal.h @@ -135,27 +135,27 @@ struct nfc_driver { const char *name; - bool (*probe)(nfc_connstring connstrings[], size_t connstrings_len, size_t * pszDeviceFound); + bool (*probe)(nfc_connstring connstrings[], size_t connstrings_len, size_t *pszDeviceFound); struct nfc_device *(*open)(const nfc_connstring connstring); void (*close)(struct nfc_device *pnd); const char *(*strerror)(const struct nfc_device *pnd); int (*initiator_init)(struct nfc_device *pnd); - int (*initiator_select_passive_target)(struct nfc_device *pnd, const nfc_modulation nm, const uint8_t * pbtInitData, const size_t szInitData, nfc_target * pnt); - int (*initiator_poll_target)(struct nfc_device *pnd, const nfc_modulation * pnmModulations, const size_t szModulations, const uint8_t uiPollNr, const uint8_t btPeriod, nfc_target * pnt); - int (*initiator_select_dep_target)(struct nfc_device *pnd, const nfc_dep_mode ndm, const nfc_baud_rate nbr, const nfc_dep_info * pndiInitiator, nfc_target * pnt, const int timeout); + int (*initiator_select_passive_target)(struct nfc_device *pnd, const nfc_modulation nm, const uint8_t *pbtInitData, const size_t szInitData, nfc_target *pnt); + int (*initiator_poll_target)(struct nfc_device *pnd, const nfc_modulation *pnmModulations, const size_t szModulations, const uint8_t uiPollNr, const uint8_t btPeriod, nfc_target *pnt); + int (*initiator_select_dep_target)(struct nfc_device *pnd, const nfc_dep_mode ndm, const nfc_baud_rate nbr, const nfc_dep_info *pndiInitiator, nfc_target *pnt, const int timeout); int (*initiator_deselect_target)(struct nfc_device *pnd); - int (*initiator_transceive_bytes)(struct nfc_device *pnd, const uint8_t * pbtTx, const size_t szTx, uint8_t * pbtRx, const size_t szRx, int timeout); - int (*initiator_transceive_bits)(struct nfc_device *pnd, const uint8_t * pbtTx, const size_t szTxBits, const uint8_t * pbtTxPar, uint8_t * pbtRx, uint8_t * pbtRxPar); - int (*initiator_transceive_bytes_timed)(struct nfc_device *pnd, const uint8_t * pbtTx, const size_t szTx, uint8_t * pbtRx, uint32_t * cycles); - int (*initiator_transceive_bits_timed)(struct nfc_device *pnd, const uint8_t * pbtTx, const size_t szTxBits, const uint8_t * pbtTxPar, uint8_t * pbtRx, uint8_t * pbtRxPar, uint32_t * cycles); + int (*initiator_transceive_bytes)(struct nfc_device *pnd, const uint8_t *pbtTx, const size_t szTx, uint8_t *pbtRx, const size_t szRx, int timeout); + int (*initiator_transceive_bits)(struct nfc_device *pnd, const uint8_t *pbtTx, const size_t szTxBits, const uint8_t *pbtTxPar, uint8_t *pbtRx, uint8_t *pbtRxPar); + int (*initiator_transceive_bytes_timed)(struct nfc_device *pnd, const uint8_t *pbtTx, const size_t szTx, uint8_t *pbtRx, uint32_t *cycles); + int (*initiator_transceive_bits_timed)(struct nfc_device *pnd, const uint8_t *pbtTx, const size_t szTxBits, const uint8_t *pbtTxPar, uint8_t *pbtRx, uint8_t *pbtRxPar, uint32_t *cycles); int (*initiator_target_is_present)(struct nfc_device *pnd, const nfc_target nt); - int (*target_init)(struct nfc_device *pnd, nfc_target * pnt, uint8_t * pbtRx, const size_t szRx, int timeout); - int (*target_send_bytes)(struct nfc_device *pnd, const uint8_t * pbtTx, const size_t szTx, int timeout); - int (*target_receive_bytes)(struct nfc_device *pnd, uint8_t * pbtRx, const size_t szRxLen, int timeout); - int (*target_send_bits)(struct nfc_device *pnd, const uint8_t * pbtTx, const size_t szTxBits, const uint8_t * pbtTxPar); - int (*target_receive_bits)(struct nfc_device *pnd, uint8_t * pbtRx, const size_t szRxLen, uint8_t * pbtRxPar); + int (*target_init)(struct nfc_device *pnd, nfc_target *pnt, uint8_t *pbtRx, const size_t szRx, int timeout); + int (*target_send_bytes)(struct nfc_device *pnd, const uint8_t *pbtTx, const size_t szTx, int timeout); + int (*target_receive_bytes)(struct nfc_device *pnd, uint8_t *pbtRx, const size_t szRxLen, int timeout); + int (*target_send_bits)(struct nfc_device *pnd, const uint8_t *pbtTx, const size_t szTxBits, const uint8_t *pbtTxPar); + int (*target_receive_bits)(struct nfc_device *pnd, uint8_t *pbtRx, const size_t szRxLen, uint8_t *pbtRxPar); int (*device_set_property_bool)(struct nfc_device *pnd, const nfc_property property, const bool bEnable); int (*device_set_property_int)(struct nfc_device *pnd, const nfc_property property, const int value); @@ -201,8 +201,8 @@ nfc_device *nfc_device_new(const nfc_connstring connstring); void nfc_device_free(nfc_device *dev); -void iso14443_cascade_uid(const uint8_t abtUID[], const size_t szUID, uint8_t * pbtCascadedUID, size_t * pszCascadedUID); - -void prepare_initiator_data(const nfc_modulation nm, uint8_t **ppbtInitiatorData, size_t * pszInitiatorData); +void iso14443_cascade_uid(const uint8_t abtUID[], const size_t szUID, uint8_t *pbtCascadedUID, size_t *pszCascadedUID); + +void prepare_initiator_data(const nfc_modulation nm, uint8_t **ppbtInitiatorData, size_t *pszInitiatorData); #endif // __NFC_INTERNAL_H__ diff --git a/test/test_dep_active.c b/test/test_dep_active.c index 2ae8f88..8948678 100644 --- a/test/test_dep_active.c +++ b/test/test_dep_active.c @@ -85,19 +85,19 @@ size_t szRx = sizeof(abtRx); int res = nfc_target_init(device, &nt, abtRx, sizeof(abtRx), 0); cut_assert_operator_int(res, > , 0, cut_message("Can't initialize NFC device as target: %s", nfc_strerror(device))); - if (res < 0) { thread_res = -1; return (void*) thread_res; } + if (res < 0) { thread_res = -1; return (void *) thread_res; } res = nfc_target_receive_bytes(device, abtRx, sizeof(abtRx), 500); cut_assert_operator_int(res, > , 0, cut_message("Can't receive bytes from initiator: %s", nfc_strerror(device))); szRx = (size_t) res; const uint8_t abtAttRx[] = "Hello DEP target!"; cut_assert_equal_memory(abtAttRx, sizeof(abtAttRx), abtRx, szRx, cut_message("Invalid received data")); - if (res <= 0) { thread_res = -1; return (void*) thread_res; } + if (res <= 0) { thread_res = -1; return (void *) thread_res; } const uint8_t abtTx[] = "Hello DEP initiator!"; res = nfc_target_send_bytes(device, abtTx, sizeof(abtTx), 500); cut_assert_operator_int(res, > , 0, cut_message("Can't send bytes to initiator: %s", nfc_strerror(device))); - if (res <= 0) { thread_res = -1; return (void*) thread_res; } + if (res <= 0) { thread_res = -1; return (void *) thread_res; } return (void *) thread_res; } @@ -117,7 +117,7 @@ printf("=========== INITIATOR %s =========\n", nfc_device_get_name(device)); int res = nfc_initiator_init(device); cut_assert_equal_int(0, res, cut_message("Can't initialize NFC device as initiator: %s", nfc_strerror(device))); - if (res < 0) { thread_res = -1; return (void*) thread_res; } + if (res < 0) { thread_res = -1; return (void *) thread_res; } nfc_target nt; @@ -130,7 +130,7 @@ cut_assert_equal_memory("\x11\x22\x33\x44\x55\x66\x77\x88\x99\xAA", 10, nt.nti.ndi.abtNFCID3, 10, cut_message("Invalid target NFCID3")); cut_assert_equal_int(NDM_ACTIVE, nt.nti.ndi.ndm, cut_message("Invalid target DEP mode")); cut_assert_equal_memory("\x12\x34\x56\x78", 4, nt.nti.ndi.abtGB, nt.nti.ndi.szGB, cut_message("Invalid target general bytes")); - if (res <= 0) { thread_res = -1; return (void*) thread_res; } + if (res <= 0) { thread_res = -1; return (void *) thread_res; } const uint8_t abtTx[] = "Hello DEP target!"; uint8_t abtRx[1024]; @@ -140,10 +140,10 @@ const uint8_t abtAttRx[] = "Hello DEP initiator!"; cut_assert_equal_memory(abtAttRx, sizeof(abtAttRx), abtRx, szRx, cut_message("Invalid received data")); - if (res < 0) { thread_res = -1; return (void*) thread_res; } + if (res < 0) { thread_res = -1; return (void *) thread_res; } res = nfc_initiator_deselect_target(device); cut_assert_operator_int(res, >= , 0, cut_message("Can't deselect target: %s", nfc_strerror(device))); - if (res < 0) { thread_res = -1; return (void*) thread_res; } + if (res < 0) { thread_res = -1; return (void *) thread_res; } return (void *) thread_res; } diff --git a/test/test_dep_passive.c b/test/test_dep_passive.c index d241418..933233d 100644 --- a/test/test_dep_passive.c +++ b/test/test_dep_passive.c @@ -84,7 +84,7 @@ size_t szRx = sizeof(abtRx); int res = nfc_target_init(device, &nt, abtRx, szRx, 0); cut_assert_operator_int(res, > , 0, cut_message("Can't initialize NFC device as target: %s", nfc_strerror(device))); - if (res < 0) { thread_res = -1; return (void*) thread_res; } + if (res < 0) { thread_res = -1; return (void *) thread_res; } // First pass res = nfc_target_receive_bytes(device, abtRx, sizeof(abtRx), 500); @@ -93,12 +93,12 @@ const uint8_t abtAttRx[] = "Hello DEP target!"; cut_assert_equal_memory(abtAttRx, sizeof(abtAttRx), abtRx, szRx, cut_message("Invalid received data")); - if (res <= 0) { thread_res = -1; return (void*) thread_res; } + if (res <= 0) { thread_res = -1; return (void *) thread_res; } const uint8_t abtTx[] = "Hello DEP initiator!"; res = nfc_target_send_bytes(device, abtTx, sizeof(abtTx), 500); cut_assert_operator_int(res, > , 0, cut_message("Can't send bytes to initiator: %s", nfc_strerror(device))); - if (res <= 0) { thread_res = -1; return (void*) thread_res; } + if (res <= 0) { thread_res = -1; return (void *) thread_res; } // Second pass res = nfc_target_receive_bytes(device, abtRx, sizeof(abtRx), 500); @@ -106,11 +106,11 @@ szRx = (size_t) res; cut_assert_equal_memory(abtAttRx, sizeof(abtAttRx), abtRx, szRx, cut_message("Invalid received data")); - if (res <= 0) { thread_res = -1; return (void*) thread_res; } - - res = nfc_target_send_bytes(device, abtTx, sizeof(abtTx), 500); - cut_assert_operator_int(res, > , 0, cut_message("Can't send bytes to initiator: %s", nfc_strerror(device))); - if (res <= 0) { thread_res = -1; return (void*) thread_res; } + if (res <= 0) { thread_res = -1; return (void *) thread_res; } + + res = nfc_target_send_bytes(device, abtTx, sizeof(abtTx), 500); + cut_assert_operator_int(res, > , 0, cut_message("Can't send bytes to initiator: %s", nfc_strerror(device))); + if (res <= 0) { thread_res = -1; return (void *) thread_res; } // Third pass res = nfc_target_receive_bytes(device, abtRx, sizeof(abtRx), 500); @@ -118,11 +118,11 @@ szRx = (size_t) res; cut_assert_equal_memory(abtAttRx, sizeof(abtAttRx), abtRx, szRx, cut_message("Invalid received data")); - if (res <= 0) { thread_res = -1; return (void*) thread_res; } - - res = nfc_target_send_bytes(device, abtTx, sizeof(abtTx), 500); - cut_assert_operator_int(res, > , 0, cut_message("Can't send bytes to initiator: %s", nfc_strerror(device))); - if (res <= 0) { thread_res = -1; return (void*) thread_res; } + if (res <= 0) { thread_res = -1; return (void *) thread_res; } + + res = nfc_target_send_bytes(device, abtTx, sizeof(abtTx), 500); + cut_assert_operator_int(res, > , 0, cut_message("Can't send bytes to initiator: %s", nfc_strerror(device))); + if (res <= 0) { thread_res = -1; return (void *) thread_res; } // Fourth pass res = nfc_target_receive_bytes(device, abtRx, sizeof(abtRx), 500); @@ -130,11 +130,11 @@ szRx = (size_t) res; cut_assert_equal_memory(abtAttRx, sizeof(abtAttRx), abtRx, szRx, cut_message("Invalid received data")); - if (res <= 0) { thread_res = -1; return (void*) thread_res; } - - res = nfc_target_send_bytes(device, abtTx, sizeof(abtTx), 500); - cut_assert_operator_int(res, > , 0, cut_message("Can't send bytes to initiator: %s", nfc_strerror(device))); - if (res <= 0) { thread_res = -1; return (void*) thread_res; } + if (res <= 0) { thread_res = -1; return (void *) thread_res; } + + res = nfc_target_send_bytes(device, abtTx, sizeof(abtTx), 500); + cut_assert_operator_int(res, > , 0, cut_message("Can't send bytes to initiator: %s", nfc_strerror(device))); + if (res <= 0) { thread_res = -1; return (void *) thread_res; } return (void *) thread_res; } @@ -154,7 +154,7 @@ int res = nfc_initiator_init(device); cut_assert_equal_int(0, res, cut_message("Can't initialize NFC device as initiator: %s", nfc_strerror(device))); - if (res < 0) { thread_res = -1; return (void*) thread_res; } + if (res < 0) { thread_res = -1; return (void *) thread_res; } nfc_target nt; @@ -167,7 +167,7 @@ cut_assert_equal_memory("\x11\x22\x33\x44\x55\x66\x77\x88\x99\xAA", 10, nt.nti.ndi.abtNFCID3, 10, cut_message("Invalid target NFCID3")); cut_assert_equal_int(NDM_PASSIVE, nt.nti.ndi.ndm, cut_message("Invalid target DEP mode")); cut_assert_equal_memory("\x12\x34\x56\x78", 4, nt.nti.ndi.abtGB, nt.nti.ndi.szGB, cut_message("Invalid target general bytes")); - if (res <= 0) { thread_res = -1; return (void*) thread_res; } + if (res <= 0) { thread_res = -1; return (void *) thread_res; } const uint8_t abtTx[] = "Hello DEP target!"; uint8_t abtRx[1024]; @@ -177,11 +177,11 @@ const uint8_t abtAttRx[] = "Hello DEP initiator!"; cut_assert_equal_memory(abtAttRx, sizeof(abtAttRx), abtRx, szRx, cut_message("Invalid received data")); - if (res < 0) { thread_res = -1; return (void*) thread_res; } - - res = nfc_initiator_deselect_target(device); - cut_assert_operator_int(res, >= , 0, cut_message("Can't deselect target: %s", nfc_strerror(device))); - if (res < 0) { thread_res = -1; return (void*) thread_res; } + if (res < 0) { thread_res = -1; return (void *) thread_res; } + + res = nfc_initiator_deselect_target(device); + cut_assert_operator_int(res, >= , 0, cut_message("Can't deselect target: %s", nfc_strerror(device))); + if (res < 0) { thread_res = -1; return (void *) thread_res; } // Passive mode / 212Kbps (second pass) printf("=========== INITIATOR %s (Passive mode / 212Kbps) =========\n", nfc_device_get_name(device)); @@ -192,18 +192,18 @@ cut_assert_equal_memory("\x11\x22\x33\x44\x55\x66\x77\x88\x99\xAA", 10, nt.nti.ndi.abtNFCID3, 10, cut_message("Invalid target NFCID3")); cut_assert_equal_int(NDM_PASSIVE, nt.nti.ndi.ndm, cut_message("Invalid target DEP mode")); cut_assert_equal_memory("\x12\x34\x56\x78", 4, nt.nti.ndi.abtGB, nt.nti.ndi.szGB, cut_message("Invalid target general bytes")); - if (res <= 0) { thread_res = -1; return (void*) thread_res; } + if (res <= 0) { thread_res = -1; return (void *) thread_res; } szRx = sizeof(abtRx); res = nfc_initiator_transceive_bytes(device, abtTx, sizeof(abtTx), abtRx, &szRx, 1000); cut_assert_operator_int(res, >= , 0, cut_message("Can't transceive bytes to target: %s", nfc_strerror(device))); cut_assert_equal_memory(abtAttRx, sizeof(abtAttRx), abtRx, szRx, cut_message("Invalid received data")); - if (res < 0) { thread_res = -1; return (void*) thread_res; } - - res = nfc_initiator_deselect_target(device); - cut_assert_operator_int(res, >= , 0, cut_message("Can't deselect target: %s", nfc_strerror(device))); - if (res < 0) { thread_res = -1; return (void*) thread_res; } + if (res < 0) { thread_res = -1; return (void *) thread_res; } + + res = nfc_initiator_deselect_target(device); + cut_assert_operator_int(res, >= , 0, cut_message("Can't deselect target: %s", nfc_strerror(device))); + if (res < 0) { thread_res = -1; return (void *) thread_res; } // Passive mode / 212Kbps printf("=========== INITIATOR %s (Passive mode / 212Kbps, second pass) =========\n", nfc_device_get_name(device)); @@ -214,18 +214,18 @@ cut_assert_equal_memory("\x11\x22\x33\x44\x55\x66\x77\x88\x99\xAA", 10, nt.nti.ndi.abtNFCID3, 10, cut_message("Invalid target NFCID3")); cut_assert_equal_int(NDM_PASSIVE, nt.nti.ndi.ndm, cut_message("Invalid target DEP mode")); cut_assert_equal_memory("\x12\x34\x56\x78", 4, nt.nti.ndi.abtGB, nt.nti.ndi.szGB, cut_message("Invalid target general bytes")); - if (res <= 0) { thread_res = -1; return (void*) thread_res; } + if (res <= 0) { thread_res = -1; return (void *) thread_res; } szRx = sizeof(abtRx); res = nfc_initiator_transceive_bytes(device, abtTx, sizeof(abtTx), abtRx, &szRx, 5000); cut_assert_operator_int(res, >= , 0, cut_message("Can't transceive bytes to target: %s", nfc_strerror(device))); cut_assert_equal_memory(abtAttRx, sizeof(abtAttRx), abtRx, szRx, cut_message("Invalid received data")); - if (res < 0) { thread_res = -1; return (void*) thread_res; } - - res = nfc_initiator_deselect_target(device); - cut_assert_operator_int(res, >= , 0, cut_message("Can't deselect target: %s", nfc_strerror(device))); - if (res < 0) { thread_res = -1; return (void*) thread_res; } + if (res < 0) { thread_res = -1; return (void *) thread_res; } + + res = nfc_initiator_deselect_target(device); + cut_assert_operator_int(res, >= , 0, cut_message("Can't deselect target: %s", nfc_strerror(device))); + if (res < 0) { thread_res = -1; return (void *) thread_res; } // Passive mode / 424Kbps printf("=========== INITIATOR %s (Passive mode / 424Kbps) =========\n", nfc_device_get_name(device)); @@ -236,18 +236,18 @@ cut_assert_equal_memory("\x11\x22\x33\x44\x55\x66\x77\x88\x99\xAA", 10, nt.nti.ndi.abtNFCID3, 10, cut_message("Invalid target NFCID3")); cut_assert_equal_int(NDM_PASSIVE, nt.nti.ndi.ndm, cut_message("Invalid target DEP mode")); cut_assert_equal_memory("\x12\x34\x56\x78", 4, nt.nti.ndi.abtGB, nt.nti.ndi.szGB, cut_message("Invalid target general bytes")); - if (res <= 0) { thread_res = -1; return (void*) thread_res; } + if (res <= 0) { thread_res = -1; return (void *) thread_res; } szRx = sizeof(abtRx); res = nfc_initiator_transceive_bytes(device, abtTx, sizeof(abtTx), abtRx, &szRx, 5000); cut_assert_operator_int(res, >= , 0, cut_message("Can't transceive bytes to target: %s", nfc_strerror(device))); cut_assert_equal_memory(abtAttRx, sizeof(abtAttRx), abtRx, szRx, cut_message("Invalid received data")); - if (res < 0) { thread_res = -1; return (void*) thread_res; } - - res = nfc_initiator_deselect_target(device); - cut_assert_operator_int(res, >= , 0, cut_message("Can't deselect target: %s", nfc_strerror(device))); - if (res < 0) { thread_res = -1; return (void*) thread_res; } + if (res < 0) { thread_res = -1; return (void *) thread_res; } + + res = nfc_initiator_deselect_target(device); + cut_assert_operator_int(res, >= , 0, cut_message("Can't deselect target: %s", nfc_strerror(device))); + if (res < 0) { thread_res = -1; return (void *) thread_res; } return (void *) thread_res; } diff --git a/test/test_device_modes_as_dep.c b/test/test_device_modes_as_dep.c index c08a7bc..3ad250f 100644 --- a/test/test_device_modes_as_dep.c +++ b/test/test_device_modes_as_dep.c @@ -65,7 +65,7 @@ // 1) nfc_target_init should take target in idle mode int res = nfc_target_init(device, &nt, abtRx, szRx, 500); cut_assert_operator_int(res, >= , 0, cut_message("Can't initialize NFC device as target: %s", nfc_strerror(device))); - if (res < 0) { thread_res = -1; return (void*) thread_res; } + if (res < 0) { thread_res = -1; return (void *) thread_res; } // 2) act as target nfc_target nt1 = { @@ -91,7 +91,7 @@ sleep(6); res = nfc_target_init(device, &nt1, abtRx, szRx, 0); cut_assert_operator_int(res, > , 0, cut_message("Can't initialize NFC device as target: %s", nfc_strerror(device))); - if (res < 0) { thread_res = -1; return (void*) thread_res; } + if (res < 0) { thread_res = -1; return (void *) thread_res; } res = nfc_target_receive_bytes(device, abtRx, sizeof(abtRx), 500); cut_assert_operator_int(res, > , 0, cut_message("Can't receive bytes from initiator: %s", nfc_strerror(device))); @@ -99,12 +99,12 @@ const uint8_t abtAttRx[] = "Hello DEP target!"; cut_assert_equal_memory(abtAttRx, sizeof(abtAttRx), abtRx, szRx, cut_message("Invalid received data")); - if (res <= 0) { thread_res = -1; return (void*) thread_res; } + if (res <= 0) { thread_res = -1; return (void *) thread_res; } const uint8_t abtTx[] = "Hello DEP initiator!"; res = nfc_target_send_bytes(device, abtTx, sizeof(abtTx), 500); cut_assert_operator_int(res, > , 0, cut_message("Can't send bytes to initiator: %s", nfc_strerror(device))); - if (res <= 0) { thread_res = -1; return (void*) thread_res; } + if (res <= 0) { thread_res = -1; return (void *) thread_res; } // 3) idle mode sleep(1); @@ -128,13 +128,13 @@ int res = nfc_initiator_init(device); cut_assert_equal_int(0, res, cut_message("Can't initialize NFC device as initiator: %s", nfc_strerror(device))); - if (res < 0) { thread_res = -1; return (void*) thread_res; } + if (res < 0) { thread_res = -1; return (void *) thread_res; } // 1) As other device should be in idle mode, nfc_initiator_poll_dep_target should return 0 nfc_target nt; res = nfc_initiator_poll_dep_target(device, NDM_PASSIVE, NBR_106, NULL, &nt, 1000); cut_assert_equal_int(0, res, cut_message("Problem with nfc_idle")); - if (res != 0) { thread_res = -1; return (void*) thread_res; } + if (res != 0) { thread_res = -1; return (void *) thread_res; } // 2 As other device should be in target mode, nfc_initiator_poll_dep_target should be positive. @@ -149,7 +149,7 @@ cut_assert_equal_memory("\x11\x22\x33\x44\x55\x66\x77\x88\x99\xAA", 10, nt1.nti.ndi.abtNFCID3, 10, cut_message("Invalid target NFCID3")); cut_assert_equal_int(NDM_PASSIVE, nt1.nti.ndi.ndm, cut_message("Invalid target DEP mode")); cut_assert_equal_memory("\x12\x34\x56\x78", 4, nt1.nti.ndi.abtGB, nt1.nti.ndi.szGB, cut_message("Invalid target general bytes")); - if (res <= 0) { thread_res = -1; return (void*) thread_res; } + if (res <= 0) { thread_res = -1; return (void *) thread_res; } const uint8_t abtTx[] = "Hello DEP target!"; uint8_t abtRx[1024]; @@ -159,17 +159,17 @@ const uint8_t abtAttRx[] = "Hello DEP initiator!"; cut_assert_equal_memory(abtAttRx, sizeof(abtAttRx), abtRx, szRx, cut_message("Invalid received data")); - if (res < 0) { thread_res = -1; return (void*) thread_res; } + if (res < 0) { thread_res = -1; return (void *) thread_res; } res = nfc_initiator_deselect_target(device); cut_assert_operator_int(res, >= , 0, cut_message("Can't deselect target: %s", nfc_strerror(device))); - if (res < 0) { thread_res = -1; return (void*) thread_res; } + if (res < 0) { thread_res = -1; return (void *) thread_res; } // 3) As other device should be in idle mode, nfc_initiator_poll_dep_target should return 0 nfc_target nt2; res = nfc_initiator_poll_dep_target(device, NDM_PASSIVE, NBR_106, NULL, &nt2, 1000); cut_assert_equal_int(0, res, cut_message("Problem with nfc_idle")); - if (res != 0) { thread_res = -1; return (void*) thread_res; } + if (res != 0) { thread_res = -1; return (void *) thread_res; } return (void *) thread_res; } diff --git a/utils/nfc-list.c b/utils/nfc-list.c index 6a22a82..806ef18 100644 --- a/utils/nfc-list.c +++ b/utils/nfc-list.c @@ -59,7 +59,7 @@ static nfc_device *pnd; static void -print_usage(const char* progname) +print_usage(const char *progname) { printf("usage: %s [-v]\n", progname); printf(" -v\t verbose display\n"); diff --git a/utils/nfc-mfultralight.c b/utils/nfc-mfultralight.c index 6aebe14..d3cc571 100644 --- a/utils/nfc-mfultralight.c +++ b/utils/nfc-mfultralight.c @@ -63,7 +63,7 @@ }; static void -print_success_or_failure(bool bFailure, uint32_t * uiCounter) +print_success_or_failure(bool bFailure, uint32_t *uiCounter) { printf("%c", (bFailure) ? 'x' : '.'); if (uiCounter) diff --git a/utils/nfc-probe.c b/utils/nfc-probe.c index 69cdc06..0c9a6fe 100644 --- a/utils/nfc-probe.c +++ b/utils/nfc-probe.c @@ -60,7 +60,7 @@ static nfc_device *pnd; static void -print_usage(const char* progname) +print_usage(const char *progname) { printf("usage: %s [-v]\n", progname); printf(" -v\t verbose display\n"); diff --git a/utils/nfc-read-forum-tag3.c b/utils/nfc-read-forum-tag3.c index 5800abe..2f48d19 100644 --- a/utils/nfc-read-forum-tag3.c +++ b/utils/nfc-read-forum-tag3.c @@ -177,8 +177,8 @@ print_usage(argv[0]); exit(EXIT_FAILURE); } - FILE* message_stream = NULL; - FILE* ndef_stream = NULL; + FILE *message_stream = NULL; + FILE *ndef_stream = NULL; if ((strlen(ndef_output) == 1) && (ndef_output[0] == '-')) { message_stream = stderr; @@ -220,7 +220,7 @@ int error = EXIT_SUCCESS; // Polling payload (SENSF_REQ) must be present (see NFC Digital Protol) - const uint8_t *pbtSensfReq = (uint8_t*)"\x00\xff\xff\x01\x00"; + const uint8_t *pbtSensfReq = (uint8_t *)"\x00\xff\xff\x01\x00"; if (nfc_initiator_select_passive_target(pnd, nm, pbtSensfReq, 5, &nt) < 0) { nfc_perror(pnd, "nfc_initiator_select_passive_target"); error = EXIT_FAILURE; @@ -231,7 +231,7 @@ const uint8_t abtNfcForumSysCode[] = { 0x12, 0xfc }; if (0 != memcmp(nt.nti.nfi.abtSysCode, abtNfcForumSysCode, 2)) { // Retry with special polling - const uint8_t *pbtSensfReqNfcForum = (uint8_t*)"\x00\x12\xfc\x01\x00"; + const uint8_t *pbtSensfReqNfcForum = (uint8_t *)"\x00\x12\xfc\x01\x00"; if (nfc_initiator_select_passive_target(pnd, nm, pbtSensfReqNfcForum, 5, &nt) < 0) { nfc_perror(pnd, "nfc_initiator_select_passive_target"); error = EXIT_FAILURE; diff --git a/utils/nfc-relay-picc.c b/utils/nfc-relay-picc.c index dac663c..cd73c78 100644 --- a/utils/nfc-relay-picc.c +++ b/utils/nfc-relay-picc.c @@ -68,8 +68,8 @@ static bool initiator_only_mode = false; static bool target_only_mode = false; static int waiting_time = 0; -FILE * fd3; -FILE * fd4; +FILE *fd3; +FILE *fd4; static void intr_hdlr(int sig) @@ -336,7 +336,7 @@ // PC/SC pseudo-ATR = 3B 80 80 01 01 if there is no historical bytes // Creates ATS and copy max 48 bytes of Tk: - uint8_t * pbtTk; + uint8_t *pbtTk; size_t szTk; pbtTk = iso14443a_locate_historical_bytes(ntEmulatedTarget.nti.nai.abtAts, ntEmulatedTarget.nti.nai.szAtsLen, &szTk); szTk = (szTk > 48) ? 48 : szTk;