From 5876e33e49213138660072a8fa48a2e5da1b125c Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Tue, 22 Jan 2013 00:56:34 +0100 Subject: [PATCH] Fix returned value ((res=f()<0)) => ((res=f())<0); this solves a bug in nfc-relay-picc --- libnfc/chips/pn53x.c | 4 ++-- libnfc/drivers/acr122_usb.c | 8 ++++---- libnfc/drivers/pn53x_usb.c | 8 ++++---- utils/nfc-relay-picc.c | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/libnfc/chips/pn53x.c b/libnfc/chips/pn53x.c index 18aec8c..cd7c9d5 100644 --- a/libnfc/chips/pn53x.c +++ b/libnfc/chips/pn53x.c @@ -1087,7 +1087,7 @@ pn53x_initiator_select_passive_target_ext(struct nfc_device *pnd, if (szTargetsData != 2) return 0; // Target is not ISO14443B2CT uint8_t abtRead[] = { 0xC4 }; // Reading UID_MSB (Read address 4) - if ((res = pn53x_initiator_transceive_bytes(pnd, abtRead, sizeof(abtRead), abtTargetsData + 4, sizeof(abtTargetsData) - 4, timeout) < 0)) { + if ((res = pn53x_initiator_transceive_bytes(pnd, abtRead, sizeof(abtRead), abtTargetsData + 4, sizeof(abtTargetsData) - 4, timeout)) < 0) { return res; } szTargetsData = 6; // u16 UID_LSB, u8 prod code, u8 fab code, u16 UID_MSB @@ -1125,7 +1125,7 @@ pn53x_initiator_select_passive_target_ext(struct nfc_device *pnd, if (pnt) { pnt->nm = nm; // Fill the tag info struct with the values corresponding to this init modulation - if ((res = pn53x_decode_target_data(abtTargetsData + 1, szTargetsData - 1, CHIP_DATA(pnd)->type, nm.nmt, &(pnt->nti)) < 0)) { + if ((res = pn53x_decode_target_data(abtTargetsData + 1, szTargetsData - 1, CHIP_DATA(pnd)->type, nm.nmt, &(pnt->nti))) < 0) { return res; } pn53x_current_target_new(pnd, pnt); diff --git a/libnfc/drivers/acr122_usb.c b/libnfc/drivers/acr122_usb.c index 75fe8ce..e469aba 100644 --- a/libnfc/drivers/acr122_usb.c +++ b/libnfc/drivers/acr122_usb.c @@ -315,14 +315,14 @@ acr122_usb_scan(const nfc_context *context, nfc_connstring connstrings[], const // usb_find_busses will find all of the busses on the system. Returns the // number of changes since previous call to this function (total of new // busses and busses removed). - if ((res = usb_find_busses() < 0)) { + if ((res = usb_find_busses()) < 0) { log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "Unable to find USB busses (%s)", _usb_strerror(res)); return 0; } // usb_find_devices will find all of the devices on each bus. This should be // called after usb_find_busses. Returns the number of changes since the // previous call to this function (total of new device and devices removed). - if ((res = usb_find_devices() < 0)) { + if ((res = usb_find_devices()) < 0) { log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "Unable to find USB devices (%s)", _usb_strerror(res)); return 0; } @@ -452,14 +452,14 @@ acr122_usb_open(const nfc_context *context, const nfc_connstring connstring) // usb_find_busses will find all of the busses on the system. Returns the // number of changes since previous call to this function (total of new // busses and busses removed). - if ((res = usb_find_busses() < 0)) { + if ((res = usb_find_busses()) < 0) { log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "Unable to find USB busses (%s)", _usb_strerror(res)); goto free_mem; } // usb_find_devices will find all of the devices on each bus. This should be // called after usb_find_busses. Returns the number of changes since the // previous call to this function (total of new device and devices removed). - if ((res = usb_find_devices() < 0)) { + if ((res = usb_find_devices()) < 0) { log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "Unable to find USB devices (%s)", _usb_strerror(res)); goto free_mem; } diff --git a/libnfc/drivers/pn53x_usb.c b/libnfc/drivers/pn53x_usb.c index 6098427..11f3164 100644 --- a/libnfc/drivers/pn53x_usb.c +++ b/libnfc/drivers/pn53x_usb.c @@ -191,14 +191,14 @@ pn53x_usb_scan(const nfc_context *context, nfc_connstring connstrings[], const s // usb_find_busses will find all of the busses on the system. Returns the // number of changes since previous call to this function (total of new // busses and busses removed). - if ((res = usb_find_busses() < 0)) { + if ((res = usb_find_busses()) < 0) { log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "Unable to find USB busses (%s)", _usb_strerror(res)); return 0; } // usb_find_devices will find all of the devices on each bus. This should be // called after usb_find_busses. Returns the number of changes since the // previous call to this function (total of new device and devices removed). - if ((res = usb_find_devices() < 0)) { + if ((res = usb_find_devices()) < 0) { log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "Unable to find USB devices (%s)", _usb_strerror(res)); return 0; } @@ -336,14 +336,14 @@ pn53x_usb_open(const nfc_context *context, const nfc_connstring connstring) // usb_find_busses will find all of the busses on the system. Returns the // number of changes since previous call to this function (total of new // busses and busses removed). - if ((res = usb_find_busses() < 0)) { + if ((res = usb_find_busses()) < 0) { log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "Unable to find USB busses (%s)", _usb_strerror(res)); goto free_mem; } // usb_find_devices will find all of the devices on each bus. This should be // called after usb_find_busses. Returns the number of changes since the // previous call to this function (total of new device and devices removed). - if ((res = usb_find_devices() < 0)) { + if ((res = usb_find_devices()) < 0) { log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR, "Unable to find USB devices (%s)", _usb_strerror(res)); goto free_mem; } diff --git a/utils/nfc-relay-picc.c b/utils/nfc-relay-picc.c index 411f144..2798487 100644 --- a/utils/nfc-relay-picc.c +++ b/utils/nfc-relay-picc.c @@ -425,7 +425,7 @@ main(int argc, char *argv[]) if (!target_only_mode) { // Forward the frame to the original tag - if ((res = nfc_initiator_transceive_bytes(pndInitiator, abtCapdu, szCapduLen, abtRapdu, sizeof(abtRapdu), -1) < 0)) { + if ((res = nfc_initiator_transceive_bytes(pndInitiator, abtCapdu, szCapduLen, abtRapdu, sizeof(abtRapdu), -1)) < 0) { ret = false; } else { szRapduLen = (size_t) res;