From 7fd413789aff64a6b9c18d28cd7caaa74d637605 Mon Sep 17 00:00:00 2001 From: Romain Tartiere Date: Fri, 8 Jan 2010 08:29:19 +0000 Subject: [PATCH] Add error checking to mifare_classic_connect(), mifare_classic_disconnect(). Do not assume nfc_initiator_select_tag() and nfc_initiator_deselect_tag() will not return an error if the provided tag is supposed to be ready for the operation (it might have move out of the field), and let the error propagate through libfreefare to the application calling the functions. --- mifare_classic.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mifare_classic.c b/mifare_classic.c index af7630b..844fba8 100644 --- a/mifare_classic.c +++ b/mifare_classic.c @@ -1,5 +1,5 @@ /*- - * Copyright (C) 2009, Romain Tartiere, Romuald Conty. + * Copyright (C) 2009, 2010, Romain Tartiere, Romuald Conty. * * This program is free software: you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published by the @@ -257,6 +257,9 @@ mifare_classic_connect (MifareClassicTag tag) nfc_target_info_t pnti; if (nfc_initiator_select_tag (tag->device, NM_ISO14443A_106, tag->info.abtUid, 4, &pnti)) { tag->active = 1; + } else { + errno = EIO; + return -1; } return 0; } @@ -274,6 +277,9 @@ mifare_classic_disconnect (MifareClassicTag tag) if (nfc_initiator_deselect_tag (tag->device)) { tag->active = 0; + } else { + errno = EIO; + return -1; } return 0; }