fix bad cast done in last revision.
This commit is contained in:
parent
642f9a38f7
commit
601105ef79
6 changed files with 26 additions and 16 deletions
|
@ -62,6 +62,7 @@ int
|
|||
main (int argc, const char *argv[])
|
||||
{
|
||||
uint8_t abtRx[MAX_FRAME_LEN];
|
||||
int res = 0;
|
||||
size_t szRx = sizeof(abtRx);
|
||||
size_t szDeviceFound;
|
||||
uint8_t abtTx[] = "Hello Mars!";
|
||||
|
@ -125,10 +126,11 @@ main (int argc, const char *argv[])
|
|||
}
|
||||
|
||||
printf("Initiator request received. Waiting for data...\n");
|
||||
if (((int) (szRx = (size_t) nfc_target_receive_bytes (pnd, abtRx, 0))) < 0) {
|
||||
if ((res = nfc_target_receive_bytes (pnd, abtRx, 0)) < 0) {
|
||||
nfc_perror(pnd, "nfc_target_receive_bytes");
|
||||
goto error;
|
||||
}
|
||||
szRx = (size_t) res;
|
||||
abtRx[szRx] = '\0';
|
||||
printf ("Received: %s\n", abtRx);
|
||||
|
||||
|
|
|
@ -137,6 +137,7 @@ bool
|
|||
nfc_target_emulate_tag(nfc_device *pnd, nfc_target *pnt)
|
||||
{
|
||||
size_t szTx;
|
||||
int res = 0;
|
||||
uint8_t abtTx[MAX_FRAME_LEN];
|
||||
bool loop = true;
|
||||
|
||||
|
@ -158,10 +159,11 @@ nfc_target_emulate_tag(nfc_device *pnd, nfc_target *pnt)
|
|||
nfc_device_set_property_bool (pnd, NP_HANDLE_CRC, false);
|
||||
init_mfc_auth = false;
|
||||
}
|
||||
if ((int) ((szRx = (size_t) nfc_target_receive_bytes(pnd, abtRx, 0))) < 0) {
|
||||
if ((res = nfc_target_receive_bytes(pnd, abtRx, 0)) < 0) {
|
||||
nfc_perror (pnd, "nfc_target_receive_bytes");
|
||||
return false;
|
||||
}
|
||||
szRx = (size_t) res;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -47,7 +47,7 @@ nfc_emulate_target (nfc_device *pnd, struct nfc_emulator *emulator)
|
|||
}
|
||||
}
|
||||
if (res >= 0) {
|
||||
if ((int) ((szRx = (size_t) nfc_target_receive_bytes(pnd, abtRx, 0))) < 0) {
|
||||
if ((res = nfc_target_receive_bytes(pnd, abtRx, 0)) < 0) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,9 +88,9 @@ target_thread (void *arg)
|
|||
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; }
|
||||
|
||||
szRx = (size_t) nfc_target_receive_bytes (device, abtRx, 500);
|
||||
cut_assert_operator_int (szRx, >, 0, cut_message ("Can't receive bytes from initiator: %s", nfc_strerror (device)));
|
||||
|
||||
res = nfc_target_receive_bytes (device, 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; }
|
||||
|
|
|
@ -87,9 +87,10 @@ target_thread (void *arg)
|
|||
if (res < 0) { thread_res = -1; return (void*) thread_res; }
|
||||
|
||||
// First pass
|
||||
szRx = (size_t) nfc_target_receive_bytes (device, abtRx, 500);
|
||||
cut_assert_operator_int ((int) szRx, >, 0, cut_message ("Can't receive bytes from initiator: %s", nfc_strerror (device)));
|
||||
|
||||
res = nfc_target_receive_bytes (device, 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; }
|
||||
|
@ -100,8 +101,9 @@ target_thread (void *arg)
|
|||
if (res <= 0) { thread_res = -1; return (void*) thread_res; }
|
||||
|
||||
// Second pass
|
||||
szRx = (size_t) nfc_target_receive_bytes (device, abtRx, 500);
|
||||
cut_assert_operator_int ((int) szRx, >, 0, cut_message ("Can't receive bytes from initiator: %s", nfc_strerror (device)));
|
||||
res = nfc_target_receive_bytes (device, abtRx, 500);
|
||||
cut_assert_operator_int (res, >, 0, cut_message ("Can't receive bytes from initiator: %s", nfc_strerror (device)));
|
||||
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; }
|
||||
|
@ -111,8 +113,9 @@ target_thread (void *arg)
|
|||
if (res <= 0) { thread_res = -1; return (void*) thread_res; }
|
||||
|
||||
// Third pass
|
||||
szRx = (size_t) nfc_target_receive_bytes (device, abtRx, 500);
|
||||
cut_assert_operator_int ((int) szRx, >, 0, cut_message ("Can't receive bytes from initiator: %s", nfc_strerror (device)));
|
||||
res = nfc_target_receive_bytes (device, abtRx, 500);
|
||||
cut_assert_operator_int (res, >, 0, cut_message ("Can't receive bytes from initiator: %s", nfc_strerror (device)));
|
||||
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; }
|
||||
|
@ -122,8 +125,9 @@ target_thread (void *arg)
|
|||
if (res <= 0) { thread_res = -1; return (void*) thread_res; }
|
||||
|
||||
// Fourth pass
|
||||
szRx = (size_t) nfc_target_receive_bytes (device, abtRx, 500);
|
||||
cut_assert_operator_int ((int)szRx, >, 0, cut_message ("Can't receive bytes from initiator: %s", nfc_strerror (device)));
|
||||
res = nfc_target_receive_bytes (device, abtRx, 500);
|
||||
cut_assert_operator_int (res, >, 0, cut_message ("Can't receive bytes from initiator: %s", nfc_strerror (device)));
|
||||
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; }
|
||||
|
|
|
@ -368,9 +368,10 @@ main (int argc, char *argv[])
|
|||
|
||||
while (!quitting) {
|
||||
bool ret;
|
||||
int res = 0;
|
||||
if (!initiator_only_mode) {
|
||||
// Receive external reader command through target
|
||||
if ((int) ((szCapduLen = (size_t) nfc_target_receive_bytes(pndTarget, abtCapdu, 0))) < 0) {
|
||||
if ((res = nfc_target_receive_bytes(pndTarget, abtCapdu, 0)) < 0) {
|
||||
nfc_perror (pndTarget, "nfc_target_receive_bytes");
|
||||
if (!target_only_mode) {
|
||||
nfc_disconnect (pndInitiator);
|
||||
|
@ -378,6 +379,7 @@ main (int argc, char *argv[])
|
|||
nfc_disconnect (pndTarget);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
szCapduLen = (size_t) res;
|
||||
if (target_only_mode) {
|
||||
if (print_hex_fd4(abtCapdu, szCapduLen, "C-APDU") != EXIT_SUCCESS) {
|
||||
fprintf (stderr, "Error while printing C-APDU to FD4\n");
|
||||
|
|
Loading…
Reference in a new issue