[Pcsclite-git-commit] [PCSC] 02/02: pcsc_stringify_error() now returns a const char *

Ludovic Rousseau rousseau at moszumanska.debian.org
Wed Jan 18 16:12:56 UTC 2017


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

rousseau pushed a commit to branch master
in repository PCSC.

commit b27f0e54194dcfb4db8179dceede8a649141fea4
Author: Ludovic Rousseau <ludovic.rousseau at free.fr>
Date:   Wed Jan 18 17:10:51 2017 +0100

    pcsc_stringify_error() now returns a const char *
    
    The pcsc_stringify_error() function returns a C-string stored in a
    static buffer. The buffer should NOT be modified outside of
    pcsc_stringify_error().
    
    Thanks to Nikos Mavrogiannopoulos for the idea
    "[Pcsclite-muscle] pcsc_stringify_error thread safety"
    https://lists.alioth.debian.org/pipermail/pcsclite-muscle/Week-of-Mon-20170116/000785.html
---
 src/PCSC/pcsclite.h.in | 2 +-
 src/error.c            | 4 ++--
 src/spy/libpcscspy.c   | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/PCSC/pcsclite.h.in b/src/PCSC/pcsclite.h.in
index 5b3547e..83a17dd 100644
--- a/src/PCSC/pcsclite.h.in
+++ b/src/PCSC/pcsclite.h.in
@@ -300,7 +300,7 @@ extern const SCARD_IO_REQUEST g_rgSCardT0Pci, g_rgSCardT1Pci, g_rgSCardRawPci;
 /*
  * Gets a stringified error response
  */
-char *pcsc_stringify_error(const LONG);
+const char *pcsc_stringify_error(const LONG);
 
 #ifdef __cplusplus
 }
diff --git a/src/error.c b/src/error.c
index a261768..5acac5d 100644
--- a/src/error.c
+++ b/src/error.c
@@ -48,7 +48,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include "string.h"
 
 #ifdef NO_LOG
-PCSC_API char* pcsc_stringify_error(const LONG pcscError)
+PCSC_API const char* pcsc_stringify_error(const LONG pcscError)
 {
 	static char strError[] = "0x12345678";
 
@@ -74,7 +74,7 @@ PCSC_API char* pcsc_stringify_error(const LONG pcscError)
  *         pcsc_stringify_error(rv), rv);
  * @endcode
  */
-PCSC_API char* pcsc_stringify_error(const LONG pcscError)
+PCSC_API const char* pcsc_stringify_error(const LONG pcscError)
 {
 	/* Use a Thread-local storage so that the returned buffer
 	 * is thread safe */
diff --git a/src/spy/libpcscspy.c b/src/spy/libpcscspy.c
index 80f9009..525150a 100644
--- a/src/spy/libpcscspy.c
+++ b/src/spy/libpcscspy.c
@@ -78,7 +78,7 @@ PCSC_API int32_t SCardControl132(SCARDHANDLE hCard, uint32_t dwControlCode,
 
 #define p_SCardSetAttrib(fct) LONG(fct) (SCARDHANDLE hCard, DWORD dwAttrId, LPCBYTE pbAttr, DWORD cbAttrLen)
 
-#define p_pcsc_stringify_error(fct) char *(fct)(const LONG pcscError)
+#define p_pcsc_stringify_error(fct) const char *(fct)(const LONG pcscError)
 
 /* fake function to just return en error code */
 static LONG internal_error(void)

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



More information about the Pcsclite-cvs-commit mailing list