[Pcsclite-cvs-commit] r2768 - /trunk/PCSC/src/winscard_clnt.c
rousseau at users.alioth.debian.org
rousseau at users.alioth.debian.org
Tue Jan 29 08:52:20 UTC 2008
Author: rousseau
Date: Tue Jan 29 08:52:19 2008
New Revision: 2768
URL: http://svn.debian.org/wsvn/pcsclite/?sc=1&rev=2768
Log:
SCardListReaders(): factorize code
Modified:
trunk/PCSC/src/winscard_clnt.c
Modified: trunk/PCSC/src/winscard_clnt.c
URL: http://svn.debian.org/wsvn/pcsclite/trunk/PCSC/src/winscard_clnt.c?rev=2768&op=diff
==============================================================================
--- trunk/PCSC/src/winscard_clnt.c (original)
+++ trunk/PCSC/src/winscard_clnt.c Tue Jan 29 08:52:19 2008
@@ -2998,6 +2998,7 @@
DWORD dwReadersLen;
int i, lastChrPtr;
LONG dwContextIndex;
+ LONG rv = SCARD_S_SUCCESS;
PROFILE_START
@@ -3026,22 +3027,18 @@
/* for the last NULL byte */
dwReadersLen += 1;
+ *pcchReaders = dwReadersLen;
if ((mszReaders == NULL) /* text array not allocated */
|| (*pcchReaders == 0)) /* size == 0 */
{
- *pcchReaders = dwReadersLen;
- SYS_MutexUnLock(psContextMap[dwContextIndex].mMutex);
- PROFILE_END(SCARD_S_SUCCESS)
- return SCARD_S_SUCCESS;
+ goto end;
}
if (*pcchReaders < dwReadersLen)
{
- *pcchReaders = dwReadersLen;
- SYS_MutexUnLock(psContextMap[dwContextIndex].mMutex);
- PROFILE_END(SCARD_E_INSUFFICIENT_BUFFER)
- return SCARD_E_INSUFFICIENT_BUFFER;
+ rv = SCARD_E_INSUFFICIENT_BUFFER;
+ goto end;
}
lastChrPtr = 0;
@@ -3058,13 +3055,12 @@
}
mszReaders[lastChrPtr] = '\0'; /* Add the last null */
- *pcchReaders = dwReadersLen;
-
+end:
SYS_MutexUnLock(psContextMap[dwContextIndex].mMutex);
- PROFILE_END(SCARD_S_SUCCESS)
-
- return SCARD_S_SUCCESS;
+ PROFILE_END(rv)
+
+ return rv;
}
/**
More information about the Pcsclite-cvs-commit
mailing list