[Pcsclite-git-commit] [CCID] 05/05: RSA_SecurID_getpasswd.c: fix compiler warnings on OS X

Ludovic Rousseau rousseau at moszumanska.debian.org
Sun Nov 8 21:01:10 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 c2b6e04a9153b198a7f9415847d9dd7273cf11af
Author: Ludovic Rousseau <ludovic.rousseau at free.fr>
Date:   Sun Nov 8 21:58:45 2015 +0100

    RSA_SecurID_getpasswd.c: fix compiler warnings on OS X
    
    Apple defines DWORD as uint32_t so %d is correct
    pcsc-lite defines DWORD as unsigned long so %ld is correct
    
    To get a compilation without warnings on Mac OS X and GNU/Linux you have
    to use "%d" on Mac OS X and "%ld" on GNU/Linux.
    Using the macro LF you can use: "%"LF"d".
    
    This change fixes a lot of compiler warnings like:
    RSA_SecurID_getpasswd.c:54:77: warning: format specifies type 'unsigned long'
          but the argument has type 'LONG' (aka 'int') [-Wformat]
      ...Cannot Connect to Resource Manager %lX\n", rv);
                                            ~~~     ^~
                                            %X
---
 contrib/RSA_SecurID/RSA_SecurID_getpasswd.c | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

diff --git a/contrib/RSA_SecurID/RSA_SecurID_getpasswd.c b/contrib/RSA_SecurID/RSA_SecurID_getpasswd.c
index 00755d9..f23e463 100644
--- a/contrib/RSA_SecurID/RSA_SecurID_getpasswd.c
+++ b/contrib/RSA_SecurID/RSA_SecurID_getpasswd.c
@@ -22,11 +22,20 @@
 #include <string.h>
 #include <winscard.h>
 
+/* DWORD printf(3) format */
+#ifdef __APPLE__
+/* Apple defines DWORD as uint32_t so %d is correct */
+#define LF
+#else
+/* pcsc-lite defines DWORD as unsigned long so %ld is correct */
+#define LF "l"
+#endif
+
 /* PCSC error message pretty print */
 #define PCSC_ERROR_EXIT(rv, text) \
 if (rv != SCARD_S_SUCCESS) \
 { \
-	printf(text ": %s (0x%lX)\n", pcsc_stringify_error(rv), rv); \
+	printf(text ": %s (0x%"LF"X)\n", pcsc_stringify_error(rv), rv); \
 	goto end; \
 }
 
@@ -51,7 +60,7 @@ int main(void)
 	rv = SCardEstablishContext(SCARD_SCOPE_SYSTEM, NULL, NULL, &hContext);
 	if (rv != SCARD_S_SUCCESS)
 	{
-		printf("SCardEstablishContext: Cannot Connect to Resource Manager %lX\n", rv);
+		printf("SCardEstablishContext: Cannot Connect to Resource Manager %"LF"X\n", rv);
 		return 1;
 	}
 
@@ -101,7 +110,7 @@ int main(void)
 	PCSC_ERROR_EXIT(rv, "SCardTransmit")
 	if ((length != 2) || (bRecvBuffer[0] != 0x90) || (bRecvBuffer[1] != 0x00))
 	{
-		printf("cmd1 failed (%ld): %02X%02X\n", length, bRecvBuffer[length-2],
+		printf("cmd1 failed (%"LF"d): %02X%02X\n", length, bRecvBuffer[length-2],
 			bRecvBuffer[length-1]);
 		goto end;
 	}
@@ -113,8 +122,8 @@ int main(void)
 	PCSC_ERROR_EXIT(rv, "SCardTransmit")
 	if ((length != 6) || (bRecvBuffer[4] != 0x90) || (bRecvBuffer[5] != 0x00))
 	{
-		printf("cmd2 failed (%ld) : %02X%02X\n", length, bRecvBuffer[length-2],
-			bRecvBuffer[length-1]);
+		printf("cmd2 failed (%"LF"d) : %02X%02X\n", length,
+			bRecvBuffer[length-2], bRecvBuffer[length-1]);
 		goto end;
 	}
 
@@ -128,7 +137,7 @@ int main(void)
 	PCSC_ERROR_EXIT(rv, "SCardTransmit")
 	if ((length != 2) || (bRecvBuffer[0] != 0x90) || (bRecvBuffer[1] != 0x00))
 	{
-		printf("cmd3 failed (%ld): %02X%02X\n", length, bRecvBuffer[length-2],
+		printf("cmd3 failed (%"LF"d): %02X%02X\n", length, bRecvBuffer[length-2],
 			bRecvBuffer[length-1]);
 		goto end;
 	}
@@ -140,7 +149,7 @@ int main(void)
 	PCSC_ERROR_EXIT(rv, "SCardTransmit")
 	if ((length != 7) || (bRecvBuffer[5] != 0x90) || (bRecvBuffer[6] != 0x00))
 	{
-		printf("cmd4 failed (%ld): %02X%02X\n", length, bRecvBuffer[length-2],
+		printf("cmd4 failed (%"LF"d): %02X%02X\n", length, bRecvBuffer[length-2],
 			bRecvBuffer[length-1]);
 		goto end;
 	}
@@ -151,7 +160,7 @@ end:
 	/* We try to leave things as clean as possible */
     rv = SCardReleaseContext(hContext);
     if (rv != SCARD_S_SUCCESS)
-        printf("SCardReleaseContext: %s (0x%lX)\n", pcsc_stringify_error(rv),
+        printf("SCardReleaseContext: %s (0x%"LF"X)\n", pcsc_stringify_error(rv),
             rv);
 
     /* free allocated memory */

-- 
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