[Pcsclite-git-commit] [CCID] 02/04: IFDHCloseChannel(): use FreeChannel()

Ludovic Rousseau rousseau at moszumanska.debian.org
Fri Nov 13 15:35:19 UTC 2015


This is an automated email from the git hooks/post-receive script.

rousseau pushed a commit to branch master
in repository CCID.

commit eda850192dbd6b5d8dca3a6355174ed9649bad38
Author: Ludovic Rousseau <ludovic.rousseau at free.fr>
Date:   Fri Nov 13 11:18:10 2015 +0100

    IFDHCloseChannel(): use FreeChannel()
    
    Move part of the code of IFDHCloseChannel() into a new function
    FreeChannel().
    Call the new function FreeChannel() from IFDHCloseChannel().
    
    No code semantic change.
---
 src/ifdhandler.c | 30 +++++++++++++++++-------------
 1 file changed, 17 insertions(+), 13 deletions(-)

diff --git a/src/ifdhandler.c b/src/ifdhandler.c
index aef79db..c06e9fb 100644
--- a/src/ifdhandler.c
+++ b/src/ifdhandler.c
@@ -78,6 +78,22 @@ static unsigned int T1_card_timeout(double f, double d, int TC1, int BWI,
 	int CWI, int clock_frequency);
 static int get_IFSC(ATR_t *atr, int *i);
 
+static void FreeChannel(int reader_index)
+{
+#ifdef HAVE_PTHREAD
+	(void)pthread_mutex_lock(&ifdh_context_mutex);
+#endif
+
+	(void)ClosePort(reader_index);
+	ReleaseReaderIndex(reader_index);
+
+	free(CcidSlots[reader_index].readerName);
+	memset(&CcidSlots[reader_index], 0, sizeof(CcidSlots[reader_index]));
+
+#ifdef HAVE_PTHREAD
+	(void)pthread_mutex_unlock(&ifdh_context_mutex);
+#endif
+}
 
 static RESPONSECODE CreateChannelByNameOrChannel(DWORD Lun,
 	LPSTR lpcDevice, DWORD Channel)
@@ -269,19 +285,7 @@ EXTERNAL RESPONSECODE IFDHCloseChannel(DWORD Lun)
 	(void)CmdPowerOff(reader_index);
 	/* No reader status check, if it failed, what can you do ? :) */
 
-#ifdef HAVE_PTHREAD
-	(void)pthread_mutex_lock(&ifdh_context_mutex);
-#endif
-
-	(void)ClosePort(reader_index);
-	ReleaseReaderIndex(reader_index);
-
-	free(CcidSlots[reader_index].readerName);
-	memset(&CcidSlots[reader_index], 0, sizeof(CcidSlots[reader_index]));
-
-#ifdef HAVE_PTHREAD
-	(void)pthread_mutex_unlock(&ifdh_context_mutex);
-#endif
+	FreeChannel(reader_index);
 
 	return IFD_SUCCESS;
 } /* IFDHCloseChannel */

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pcsclite/CCID.git



More information about the Pcsclite-cvs-commit mailing list