[pkg-opensc-commit] [opensc] 214/295: Fix minidriver log messages format and parameter issues flagged by GCC

Eric Dorland eric at moszumanska.debian.org
Sat Jun 24 21:11:33 UTC 2017


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

eric pushed a commit to branch master
in repository opensc.

commit 56f880613a1d13b3f6300e2ce3fd314751594240
Author: Maciej S. Szmigiero <mail at maciej.szmigiero.name>
Date:   Tue Mar 14 22:56:39 2017 +0100

    Fix minidriver log messages format and parameter issues flagged by GCC
    
    Since last commit GCC warns us about problems with format strings and their
    arguments in minidriver, so let's fix these warnings just as we did in rest
    of the OpenSC code.
    
    Most of these warnings were about DWORDs being printed as ints, there were
    also some format directives and size_t size specifiers missing and various
    misc format / parameter disagreements.
    
    Attempt was made to keep log strings as-is, only the most obvious typos
    were fixed.
    
    Signed-off-by: Maciej S. Szmigiero <mail at maciej.szmigiero.name>
---
 src/minidriver/minidriver.c | 690 +++++++++++++++++++++++++++++++-------------
 1 file changed, 495 insertions(+), 195 deletions(-)

diff --git a/src/minidriver/minidriver.c b/src/minidriver/minidriver.c
index 846c01c..49f2903 100644
--- a/src/minidriver/minidriver.c
+++ b/src/minidriver/minidriver.c
@@ -297,7 +297,8 @@ static void loghex(PCARD_DATA pCardData, int level, PBYTE data, size_t len)
 	unsigned int i, a;
 	unsigned char * p;
 
-	logprintf(pCardData, level, "--- %p:%d\n", data, len);
+	logprintf(pCardData, level, "--- %p:%"SC_FORMAT_LEN_SIZE_T"u\n",
+		  data, len);
 
 	if (data == NULL || len <= 0) return;
 
@@ -348,10 +349,13 @@ check_reader_status(PCARD_DATA pCardData)
 		return SCARD_E_INVALID_PARAMETER;
 
 	logprintf(pCardData, 7, "pCardData->hSCardCtx:0x%08X hScard:0x%08X\n",
-			pCardData->hSCardCtx, pCardData->hScard);
+		  (unsigned int)pCardData->hSCardCtx,
+		  (unsigned int)pCardData->hScard);
 
 	if (pCardData->hSCardCtx != vs->hSCardCtx || pCardData->hScard != vs->hScard) {
-		logprintf (pCardData, 1, "HANDLES CHANGED from 0x%08X 0x%08X\n", vs->hSCardCtx, vs->hScard);
+		logprintf(pCardData, 1, "HANDLES CHANGED from 0x%08X 0x%08X\n",
+			  (unsigned int)vs->hSCardCtx,
+			  (unsigned int)vs->hScard);
 
 		/* Basically a mini AcquireContext */
 		r = disassociate_card(pCardData);
@@ -367,7 +371,9 @@ check_reader_status(PCARD_DATA pCardData)
 	else if (vs->reader) {
 		/* This should always work, as BaseCSP should be checking for removal too */
 		r = sc_detect_card_presence(vs->reader);
-		logprintf(pCardData, 2, "check_reader_status r=%d flags 0x%08X\n", r, vs->reader->flags);
+		logprintf(pCardData, 2,
+			  "check_reader_status r=%d flags 0x%08X\n", r,
+			  (unsigned int)vs->reader->flags);
 	}
 
 	return r;
@@ -748,7 +754,8 @@ md_fs_find_file(PCARD_DATA pCardData, char *parent, char *name, struct md_file *
 
 	dwret = md_fs_find_directory(pCardData, NULL, parent, &dir);
 	if (dwret != SCARD_S_SUCCESS)   {
-		logprintf(pCardData, 2, "find directory '%s' error: %X\n", parent ? parent : "<null>", dwret);
+		logprintf(pCardData, 2, "find directory '%s' error: %lX\n",
+			  parent ? parent : "<null>", (unsigned long)dwret);
 		return dwret;
 	}
 	else if (!dir)   {
@@ -851,7 +858,8 @@ md_fs_delete_file(PCARD_DATA pCardData, char *parent, char *name)
 
 	dwret = md_fs_find_directory(pCardData, NULL, parent, &dir);
 	if (dwret != SCARD_S_SUCCESS)   {
-		logprintf(pCardData, 2, "find directory '%s' error: %X\n", parent ? parent : "<null>", dwret);
+		logprintf(pCardData, 2, "find directory '%s' error: %lX\n",
+			  parent ? parent : "<null>", (unsigned long)dwret);
 		return dwret;
 	}
 	else if (!dir)   {
@@ -898,7 +906,9 @@ md_fs_delete_file(PCARD_DATA pCardData, char *parent, char *name)
 			dwret = md_pkcs15_delete_object(pCardData, vs->p15_containers[idx].cert_obj);
 			vs->p15_containers[idx].cert_obj = NULL;
 			if(dwret != SCARD_S_SUCCESS)
-				logprintf(pCardData, 2, "Cannot delete certificate PKCS#15 object #%i: dwret 0x%X\n", idx, dwret);
+				logprintf(pCardData, 2,
+					  "Cannot delete certificate PKCS#15 object #%i: dwret 0x%lX\n",
+					  idx, (unsigned long)dwret);
 		}
 	}
 
@@ -1108,7 +1118,8 @@ md_set_cardid(PCARD_DATA pCardData, struct md_file *file)
 			return dwret;
 	}
 
-	logprintf(pCardData, 3, "cardid(%i)\n", file->size);
+	logprintf(pCardData, 3, "cardid(%"SC_FORMAT_LEN_SIZE_T"u)\n",
+		  file->size);
 	loghex(pCardData, 3, file->blob, file->size);
 	return SCARD_S_SUCCESS;
 }
@@ -1152,7 +1163,9 @@ md_fs_read_msroots_file(PCARD_DATA pCardData, char *parent, struct md_file *file
 				CertFreeCertificateContext(wincert);
 			}
 			else {
-				logprintf(pCardData, 2, "unable to load the certificate from windows 0x%08X\n", GetLastError());
+				logprintf(pCardData, 2,
+					  "unable to load the certificate from Windows 0x%08X\n",
+					  (unsigned int)GetLastError());
 			}
 			sc_pkcs15_free_certificate(cert);
 		}
@@ -1208,7 +1221,8 @@ md_fs_read_content(PCARD_DATA pCardData, char *parent, struct md_file *file)
 
 	dwret = md_fs_find_directory(pCardData, NULL, parent, &dir);
 	if (dwret != SCARD_S_SUCCESS)   {
-		logprintf(pCardData, 2, "find directory '%s' error: %X\n", parent ? parent : "<null>", dwret);
+		logprintf(pCardData, 2, "find directory '%s' error: %lX\n",
+			  parent ? parent : "<null>", (unsigned long)dwret);
 		return;
 	}
 	else if (!dir)   {
@@ -1276,7 +1290,8 @@ md_set_cardcf(PCARD_DATA pCardData, struct md_file *file)
 	if (dwret != SCARD_S_SUCCESS)
 		return dwret;
 
-	logprintf(pCardData, 3, "'cardcf' content(%i)\n", file->size);
+	logprintf(pCardData, 3, "'cardcf' content(%"SC_FORMAT_LEN_SIZE_T"u)\n",
+		  file->size);
 	loghex(pCardData, 3, file->blob, file->size);
 	return SCARD_S_SUCCESS;
 }
@@ -1294,7 +1309,7 @@ md_set_cardapps(PCARD_DATA pCardData, struct md_file *file)
 	if (dwret != SCARD_S_SUCCESS)
 		return dwret;
 
-	logprintf(pCardData, 3, "mscp(%i)\n", file->size);
+	logprintf(pCardData, 3, "mscp(%"SC_FORMAT_LEN_SIZE_T"u)\n", file->size);
 	loghex(pCardData, 3, file->blob, file->size);
 	return SCARD_S_SUCCESS;
 }
@@ -1424,7 +1439,9 @@ md_set_cmapfile(PCARD_DATA pCardData, struct md_file *file)
 		}
 
 		logprintf(pCardData, 7, "Container[%i]'s guid=%.*s\n", ii, (int) sizeof cont->guid, cont->guid);
-		logprintf(pCardData, 7, "Container[%i]'s key-exchange:%i, sign:%i\n", ii, cont->size_key_exchange, cont->size_sign);
+		logprintf(pCardData, 7,
+			  "Container[%i]'s key-exchange:%"SC_FORMAT_LEN_SIZE_T"u, sign:%"SC_FORMAT_LEN_SIZE_T"u\n",
+			  ii, cont->size_key_exchange, cont->size_sign);
 
 		cont->id = prkey_info->id;
 		cont->prkey_obj = prkey_objs[ii];
@@ -1529,7 +1546,7 @@ md_set_cmapfile(PCARD_DATA pCardData, struct md_file *file)
 	if (dwret != SCARD_S_SUCCESS)
 		return dwret;
 
-	logprintf(pCardData, 3, "cmap(%i)\n", file->size);
+	logprintf(pCardData, 3, "cmap(%"SC_FORMAT_LEN_SIZE_T"u)\n", file->size);
 	loghex(pCardData, 3, file->blob, file->size);
 	return SCARD_S_SUCCESS;
 }
@@ -1583,9 +1600,12 @@ md_fs_init(PCARD_DATA pCardData)
 		return dwret;
 
 #ifdef OPENSSL_VERSION_NUMBER
-	logprintf(pCardData, 3, "MD virtual file system initialized; OPENSSL_VERSION_NUMBER 0x%Xl\n", OPENSSL_VERSION_NUMBER);
+	logprintf(pCardData, 3,
+		  "MD virtual file system initialized; OPENSSL_VERSION_NUMBER 0x%lX\n",
+		  OPENSSL_VERSION_NUMBER);
 #else
-	logprintf(pCardData, 3, "MD virtual file system initialized; Without OPENSSL\n");
+	logprintf(pCardData, 3,
+		  "MD virtual file system initialized; Without OPENSSL\n");
 #endif
 	return SCARD_S_SUCCESS;
 }
@@ -1690,7 +1710,8 @@ md_check_key_compatibility(PCARD_DATA pCardData, DWORD flags, DWORD key_type,
 			key_algo = SC_ALGORITHM_EC;
 			break;
 		default:
-			logprintf(pCardData, 3, "Unsupported key type: 0x%X\n", key_type);
+			logprintf(pCardData, 3, "Unsupported key type: 0x%lX\n",
+				  (unsigned long)key_type);
 			return SCARD_E_UNSUPPORTED_FEATURE;
 	}
 
@@ -1726,7 +1747,8 @@ md_check_key_compatibility(PCARD_DATA pCardData, DWORD flags, DWORD key_type,
 				return SCARD_E_INVALID_PARAMETER;
 			}
 
-			logprintf(pCardData, 3, "Set key size to %i\n", key_size);
+			logprintf(pCardData, 3, "Set key size to %lu\n",
+				  (unsigned long)key_size);
 		} else if (key_algo == SC_ALGORITHM_EC) {
 			BCRYPT_ECCKEY_BLOB *pub_ecc = (BCRYPT_ECCKEY_BLOB *)pbKeyData;
 			switch(key_type) {
@@ -1774,7 +1796,8 @@ md_check_key_compatibility(PCARD_DATA pCardData, DWORD flags, DWORD key_type,
 					break;
 			}
 		}
-		logprintf(pCardData, 3, "Set key size to %i\n", key_size);
+		logprintf(pCardData, 3, "Set key size to %lu\n",
+			  (unsigned long)key_size);
 	}
 
 	count = vs->p15card->card->algorithm_count;
@@ -1785,7 +1808,9 @@ md_check_key_compatibility(PCARD_DATA pCardData, DWORD flags, DWORD key_type,
 		return SCARD_S_SUCCESS;
 	}
 
-	logprintf(pCardData, 3, "No card support for key(type:0x%X,size:0x%X)\n", key_type, key_size);
+	logprintf(pCardData, 3,
+		  "No card support for key(type:0x%lX,size:0x%lX)\n",
+		  (unsigned long)key_type, (unsigned long)key_size);
 	return SCARD_E_UNSUPPORTED_FEATURE;
 }
 
@@ -1838,7 +1863,9 @@ md_pkcs15_generate_key(PCARD_DATA pCardData, DWORD idx, DWORD key_type, DWORD ke
 		keygen_args.prkey_args.x509_usage = MD_KEY_USAGE_KEYEXCHANGE_ECC;
 	}
 	else    {
-		logprintf(pCardData, 3, "MdGenerateKey(): unsupported key type: 0x%X\n", key_type);
+		logprintf(pCardData, 3,
+			  "MdGenerateKey(): unsupported key type: 0x%lX\n",
+			  (unsigned long)key_type);
 		return SCARD_E_UNSUPPORTED_FEATURE;
 	}
 	if (pub_args.key.algorithm == SC_ALGORITHM_EC) {
@@ -1915,8 +1942,10 @@ md_pkcs15_generate_key(PCARD_DATA pCardData, DWORD idx, DWORD key_type, DWORD ke
 	cont->index = idx;
 	cont->flags = CONTAINER_MAP_VALID_CONTAINER;
 
-	logprintf(pCardData, 3, "MdGenerateKey(): generated key(idx:%i,id:%s,guid:%.*s)\n",
-			idx, sc_pkcs15_print_id(&cont->id),(int) sizeof cont->guid, cont->guid);
+	logprintf(pCardData, 3,
+		  "MdGenerateKey(): generated key(idx:%lu,id:%s,guid:%.*s)\n",
+		  (unsigned long)idx, sc_pkcs15_print_id(&cont->id),
+		  (int) sizeof cont->guid, cont->guid);
 
 done:
 	sc_pkcs15init_unbind(profile);
@@ -1978,7 +2007,9 @@ md_pkcs15_store_key(PCARD_DATA pCardData, DWORD idx, DWORD key_type, BYTE *blob,
 		pubkey_args.x509_usage = MD_KEY_USAGE_KEYEXCHANGE;
 	}
 	else    {
-		logprintf(pCardData, 3, "MdStoreKey(): unsupported key type: 0x%X\n", key_type);
+		logprintf(pCardData, 3,
+			  "MdStoreKey(): unsupported key type: 0x%lX\n",
+			  (unsigned long)key_type);
 		return SCARD_E_INVALID_PARAMETER;
 	}
 
@@ -2048,7 +2079,10 @@ md_pkcs15_store_key(PCARD_DATA pCardData, DWORD idx, DWORD key_type, BYTE *blob,
 	cont->index = idx;
 	cont->flags |= CONTAINER_MAP_VALID_CONTAINER;
 
-	logprintf(pCardData, 3, "MdStoreKey(): stored key(idx:%i,id:%s,guid:%.*s)\n", idx, sc_pkcs15_print_id(&cont->id),(int) sizeof cont->guid,cont->guid);
+	logprintf(pCardData, 3,
+		  "MdStoreKey(): stored key(idx:%lu,id:%s,guid:%.*s)\n",
+		  (unsigned long)idx, sc_pkcs15_print_id(&cont->id),
+		  (int) sizeof cont->guid, cont->guid);
 
 done:
 	sc_pkcs15init_unbind(profile);
@@ -2145,7 +2179,8 @@ md_query_key_sizes(PCARD_DATA pCardData, DWORD dwKeySpec, CARD_KEY_SIZES *pKeySi
 	if (pKeySizes->dwVersion != CARD_KEY_SIZES_CURRENT_VERSION && pKeySizes->dwVersion != 0)
 		return ERROR_REVISION_MISMATCH;
 
-	logprintf(pCardData, 1, "md_query_key_sizes: store dwKeySpec '%u'\n", dwKeySpec);
+	logprintf(pCardData, 1, "md_query_key_sizes: store dwKeySpec '%lu'\n",
+		  (unsigned long)dwKeySpec);
 	vs = (VENDOR_SPECIFIC*)(pCardData->pvVendorSpecific);
 	count = vs->p15card->card->algorithm_count;
 
@@ -2161,7 +2196,6 @@ md_query_key_sizes(PCARD_DATA pCardData, DWORD dwKeySpec, CARD_KEY_SIZES *pKeySi
 		for (i = 0; i < count; i++) {
 			algo_info = vs->p15card->card->algorithms + i;
 			if (algo_info->algorithm == SC_ALGORITHM_RSA) {
-				
 				if (pKeySizes->dwMinimumBitlen == 0 || pKeySizes->dwMinimumBitlen > algo_info->key_length) {
 					pKeySizes->dwMinimumBitlen = algo_info->key_length;
 				}
@@ -2231,17 +2265,23 @@ md_query_key_sizes(PCARD_DATA pCardData, DWORD dwKeySpec, CARD_KEY_SIZES *pKeySi
 				pKeySizes->dwMaximumBitlen = keysize;
 				pKeySizes->dwIncrementalBitlen = 1;
 			} else {
-				logprintf(pCardData, 0, "No ECC key found (keyspec=%u)\n", dwKeySpec);
+				logprintf(pCardData, 0,
+					  "No ECC key found (keyspec=%lu)\n",
+					  (unsigned long)dwKeySpec);
 				return SCARD_E_INVALID_PARAMETER;
 			}
 		}
 	}
-	
+
 	logprintf(pCardData, 3, "Key compatible with the card capabilities\n");
-	logprintf(pCardData, 3, " dwMinimumBitlen: %u\n", pKeySizes->dwMinimumBitlen);
-	logprintf(pCardData, 3, " dwDefaultBitlen: %u\n", pKeySizes->dwDefaultBitlen);
-	logprintf(pCardData, 3, " dwMaximumBitlen: %u\n", pKeySizes->dwMaximumBitlen);
-	logprintf(pCardData, 3, " dwIncrementalBitlen: %u\n", pKeySizes->dwIncrementalBitlen);
+	logprintf(pCardData, 3, " dwMinimumBitlen: %lu\n",
+		  (unsigned long)pKeySizes->dwMinimumBitlen);
+	logprintf(pCardData, 3, " dwDefaultBitlen: %lu\n",
+		  (unsigned long)pKeySizes->dwDefaultBitlen);
+	logprintf(pCardData, 3, " dwMaximumBitlen: %lu\n",
+		  (unsigned long)pKeySizes->dwMaximumBitlen);
+	logprintf(pCardData, 3, " dwIncrementalBitlen: %lu\n",
+		  (unsigned long)pKeySizes->dwIncrementalBitlen);
 	return SCARD_S_SUCCESS;
 }
 
@@ -2468,8 +2508,12 @@ DWORD WINAPI CardDeleteContext(__inout PCARD_DATA  pCardData)
 	if(!pCardData)
 		return SCARD_E_INVALID_PARAMETER;
 
-	logprintf(pCardData, 1, "\nP:%d T:%d pCardData:%p hScard=0x%08X hSCardCtx=0x%08X CardDeleteContext\n",
-			GetCurrentProcessId(), GetCurrentThreadId(), pCardData, pCardData->hScard, pCardData->hSCardCtx);
+	logprintf(pCardData, 1,
+		  "\nP:%lu T:%lu pCardData:%p hScard=0x%08X hSCardCtx=0x%08X CardDeleteContext\n",
+		  (unsigned long)GetCurrentProcessId(),
+		  (unsigned long)GetCurrentThreadId(), pCardData,
+		  (unsigned int)pCardData->hScard,
+		  (unsigned int)pCardData->hSCardCtx);
 
 	vs = (VENDOR_SPECIFIC*)(pCardData->pvVendorSpecific);
 	if(!vs)
@@ -2498,7 +2542,9 @@ DWORD WINAPI CardQueryCapabilities(__in PCARD_DATA pCardData,
 {
 	DWORD dwret;
 
-	logprintf(pCardData, 1, "\nP:%d T:%d pCardData:%p ",GetCurrentProcessId(), GetCurrentThreadId(), pCardData);
+	logprintf(pCardData, 1, "\nP:%lu T:%lu pCardData:%p ",
+		  (unsigned long)GetCurrentProcessId(),
+		  (unsigned long)GetCurrentThreadId(), pCardData);
 	logprintf(pCardData, 1, "pCardCapabilities=%p\n", pCardCapabilities);
 
 	if (!pCardData || !pCardCapabilities)
@@ -2520,8 +2566,11 @@ DWORD WINAPI CardDeleteContainer(__in PCARD_DATA pCardData,
 	VENDOR_SPECIFIC *vs = NULL;
 	DWORD dwret;
 	struct md_pkcs15_container* cont;
-	logprintf(pCardData, 1, "\nP:%d T:%d pCardData:%p ",GetCurrentProcessId(), GetCurrentThreadId(), pCardData);
-	logprintf(pCardData, 1, "CardDeleteContainer(idx:%i)\n", bContainerIndex);
+	logprintf(pCardData, 1, "\nP:%lu T:%lu pCardData:%p ",
+		  (unsigned long)GetCurrentProcessId(),
+		  (unsigned long)GetCurrentThreadId(), pCardData);
+	logprintf(pCardData, 1, "CardDeleteContainer(idx:%u)\n",
+		  (unsigned int)bContainerIndex);
 
 	if (!pCardData)
 		return SCARD_E_INVALID_PARAMETER;
@@ -2571,9 +2620,13 @@ DWORD WINAPI CardCreateContainer(__in PCARD_DATA pCardData,
 	if (!pCardData)
 		return SCARD_E_INVALID_PARAMETER;
 
-	logprintf(pCardData, 1, "\nP:%d T:%d pCardData:%p ",GetCurrentProcessId(), GetCurrentThreadId(), pCardData);
-	logprintf(pCardData, 1, "CardCreateContainer(idx:%i,flags:%X,type:%X,size:%i,data:%p)\n",
-			bContainerIndex, dwFlags, dwKeySpec, dwKeySize, pbKeyData);
+	logprintf(pCardData, 1, "\nP:%lu T:%lu pCardData:%p ",
+		  (unsigned long)GetCurrentProcessId(),
+		  (unsigned long)GetCurrentThreadId(), pCardData);
+	logprintf(pCardData, 1,
+		  "CardCreateContainerEx(idx:%u,flags:%lX,type:%lX,size:%lu,data:%p)\n",
+		  (unsigned int)bContainerIndex, (unsigned long)dwFlags,
+		  (unsigned long)dwKeySpec, (unsigned long)dwKeySize, pbKeyData);
 
 	if (pbKeyData)   {
 		logprintf(pCardData, 7, "Key data\n");
@@ -2618,7 +2671,8 @@ DWORD WINAPI CardCreateContainer(__in PCARD_DATA pCardData,
 		logprintf(pCardData, 1, "key imported\n");
 	}
 	else   {
-		logprintf(pCardData, 1, "Invalid dwFlags value: 0x%X\n", dwFlags);
+		logprintf(pCardData, 1, "Invalid dwFlags value: 0x%lX\n",
+			  (unsigned long)dwFlags);
 		return SCARD_E_INVALID_PARAMETER;
 	}
 
@@ -2647,11 +2701,15 @@ DWORD WINAPI CardGetContainerInfo(__in PCARD_DATA pCardData, __in BYTE bContaine
 	if (!pContainerInfo)
 		return SCARD_E_INVALID_PARAMETER;
 
-	logprintf(pCardData, 1, "\nP:%d T:%d pCardData:%p ",GetCurrentProcessId(), GetCurrentThreadId(), pCardData);
-	logprintf(pCardData, 1, "CardGetContainerInfo bContainerIndex=%u, dwFlags=0x%08X, " \
-		"dwVersion=%u, cbSigPublicKey=%u, cbKeyExPublicKey=%u\n", \
-		bContainerIndex, dwFlags, pContainerInfo->dwVersion, \
-		pContainerInfo->cbSigPublicKey, pContainerInfo->cbKeyExPublicKey);
+	logprintf(pCardData, 1, "\nP:%lu T:%lu pCardData:%p ",
+		  (unsigned long)GetCurrentProcessId(),
+		  (unsigned long)GetCurrentThreadId(), pCardData);
+	logprintf(pCardData, 1,
+		  "CardGetContainerInfo bContainerIndex=%u, dwFlags=0x%08X, dwVersion=%lu, cbSigPublicKey=%lu, cbKeyExPublicKey=%lu\n",
+		  (unsigned int)bContainerIndex, (unsigned int)dwFlags,
+		  (unsigned long)pContainerInfo->dwVersion,
+		  (unsigned long)pContainerInfo->cbSigPublicKey,
+		  (unsigned long)pContainerInfo->cbKeyExPublicKey);
 
 	if (dwFlags)
 		return SCARD_E_INVALID_PARAMETER;
@@ -2666,7 +2724,8 @@ DWORD WINAPI CardGetContainerInfo(__in PCARD_DATA pCardData, __in BYTE bContaine
 	cont = &vs->p15_containers[bContainerIndex];
 
 	if (!cont->prkey_obj)   {
-		logprintf(pCardData, 7, "Container %i is empty\n", bContainerIndex);
+		logprintf(pCardData, 7, "Container %u is empty\n",
+			  (unsigned int)bContainerIndex);
 		return SCARD_E_NO_KEY_CONTAINER;
 	}
 
@@ -2728,7 +2787,9 @@ DWORD WINAPI CardGetContainerInfo(__in PCARD_DATA pCardData, __in BYTE bContaine
 			sc_pkcs15_free_certificate(cert);
 		}
 		else   {
-			logprintf(pCardData, 1, "certificate '%d' read error %d\n", bContainerIndex, rv);
+			logprintf(pCardData, 1,
+				  "certificate '%u' read error %d\n",
+				  (unsigned int)bContainerIndex, rv);
 			ret = SCARD_E_FILE_NOT_FOUND;
 		}
 	}
@@ -2739,7 +2800,9 @@ DWORD WINAPI CardGetContainerInfo(__in PCARD_DATA pCardData, __in BYTE bContaine
 	}
 
 	if (ret != SCARD_S_SUCCESS)   {
-		logprintf(pCardData, 7, "GetContainerInfo(idx:%i) failed; error %X", bContainerIndex, ret);
+		logprintf(pCardData, 7,
+			  "GetContainerInfo(idx:%u) failed; error %lX",
+			  (unsigned int)bContainerIndex, (unsigned long)ret);
 		return ret;
 	}
 
@@ -2765,7 +2828,9 @@ DWORD WINAPI CardGetContainerInfo(__in PCARD_DATA pCardData, __in BYTE bContaine
 				pContainerInfo->cbSigPublicKey = sz;
 				pContainerInfo->pbSigPublicKey = (PBYTE)publicKey;
 
-				logprintf(pCardData, 3, "return info on SIGN_CONTAINER_INDEX %i\n", bContainerIndex);
+				logprintf(pCardData, 3,
+					  "return info on SIGN_CONTAINER_INDEX %u\n",
+					  (unsigned int)bContainerIndex);
 			}
 
 			if (cont->size_key_exchange)   {
@@ -2780,7 +2845,9 @@ DWORD WINAPI CardGetContainerInfo(__in PCARD_DATA pCardData, __in BYTE bContaine
 				pContainerInfo->cbKeyExPublicKey = sz;
 				pContainerInfo->pbKeyExPublicKey = (PBYTE)publicKey;
 
-				logprintf(pCardData, 3, "return info on KEYX_CONTAINER_INDEX %i\n", bContainerIndex);
+				logprintf(pCardData, 3,
+					  "return info on KEYX_CONTAINER_INDEX %u\n",
+					  (unsigned int)bContainerIndex);
 			}
 		}
 	} else if (prkey_info->field_length > 0) {
@@ -2804,7 +2871,9 @@ DWORD WINAPI CardGetContainerInfo(__in PCARD_DATA pCardData, __in BYTE bContaine
 					dwMagic = BCRYPT_ECDSA_PUBLIC_P521_MAGIC;
 					break;
 				default:
-					logprintf(pCardData, 3, "Unable to match the ECC public size to one of Microsoft algorithm %i\n", cont->size_sign);
+					logprintf(pCardData, 3,
+						  "Unable to match the ECC public size to one of Microsoft algorithm %"SC_FORMAT_LEN_SIZE_T"u\n",
+						  cont->size_sign);
 					return SCARD_F_INTERNAL_ERROR;
 				}
 
@@ -2818,8 +2887,10 @@ DWORD WINAPI CardGetContainerInfo(__in PCARD_DATA pCardData, __in BYTE bContaine
 				pContainerInfo->cbSigPublicKey = sz;
 				pContainerInfo->pbSigPublicKey = (PBYTE)publicKey;
 				memcpy(((PBYTE)publicKey) + sizeof(BCRYPT_ECCKEY_BLOB),  pubkey_der.value + 3,  pubkey_der.len -3);
-				
-				logprintf(pCardData, 3, "return info on ECC SIGN_CONTAINER_INDEX %i\n", bContainerIndex);
+
+				logprintf(pCardData, 3,
+					  "return info on ECC SIGN_CONTAINER_INDEX %u\n",
+					  (unsigned int)bContainerIndex);
 			}
 			if (cont->size_key_exchange)   {
 				sz = (DWORD) (sizeof(BCRYPT_ECCKEY_BLOB) +  pubkey_der.len -3);
@@ -2836,7 +2907,9 @@ DWORD WINAPI CardGetContainerInfo(__in PCARD_DATA pCardData, __in BYTE bContaine
 					dwMagic = BCRYPT_ECDH_PUBLIC_P521_MAGIC;
 					break;
 				default:
-					logprintf(pCardData, 3, "Unable to match the ECC public size to one of Microsoft algorithm %i\n", cont->size_key_exchange);
+					logprintf(pCardData, 3,
+						  "Unable to match the ECC public size to one of Microsoft algorithm %"SC_FORMAT_LEN_SIZE_T"u\n",
+						  cont->size_key_exchange);
 					return SCARD_F_INTERNAL_ERROR;
 				}
 
@@ -2850,14 +2923,16 @@ DWORD WINAPI CardGetContainerInfo(__in PCARD_DATA pCardData, __in BYTE bContaine
 				pContainerInfo->cbKeyExPublicKey = sz;
 				pContainerInfo->pbKeyExPublicKey = (PBYTE)publicKey;
 				memcpy(((PBYTE)publicKey) + sizeof(BCRYPT_ECCKEY_BLOB),  pubkey_der.value + 3,  pubkey_der.len -3);
-				
-				logprintf(pCardData, 3, "return info on ECC KEYX_CONTAINER_INDEX %i\n", bContainerIndex);
+
+				logprintf(pCardData, 3,
+					  "return info on ECC KEYX_CONTAINER_INDEX %u\n",
+					  (unsigned int)bContainerIndex);
 			}
-			
 		}
 	}
 
-	logprintf(pCardData, 7, "returns container(idx:%i) info", bContainerIndex);
+	logprintf(pCardData, 7, "returns container(idx:%u) info",
+		  (unsigned int)bContainerIndex);
 	return SCARD_S_SUCCESS;
 }
 
@@ -2868,8 +2943,11 @@ DWORD WINAPI CardAuthenticatePin(__in PCARD_DATA pCardData,
 	__out_opt PDWORD pcAttemptsRemaining)
 {
 	PIN_ID PinId = 0;
-	logprintf(pCardData, 1, "\nP:%d T:%d pCardData:%p ",GetCurrentProcessId(), GetCurrentThreadId(), pCardData);
-	logprintf(pCardData, 1, "CardAuthenticatePin '%S':%d\n", NULLWSTR(pwszUserId), cbPin);
+	logprintf(pCardData, 1, "\nP:%lu T:%lu pCardData:%p ",
+		  (unsigned long)GetCurrentProcessId(),
+		  (unsigned long)GetCurrentThreadId(), pCardData);
+	logprintf(pCardData, 1, "CardAuthenticatePin '%S':%lu\n",
+		  NULLWSTR(pwszUserId), (unsigned long)cbPin);
 
 	if (wcscmp(pwszUserId, wszCARD_USER_USER) == 0)	{
 		PinId = ROLE_USER;
@@ -2894,7 +2972,9 @@ DWORD WINAPI CardGetChallenge(__in PCARD_DATA pCardData,
 	VENDOR_SPECIFIC *vs;
 	int rv;
 
-	logprintf(pCardData, 1, "\nP:%d T:%d pCardData:%p ",GetCurrentProcessId(), GetCurrentThreadId(), pCardData);
+	logprintf(pCardData, 1, "\nP:%lu T:%lu pCardData:%p ",
+		  (unsigned long)GetCurrentProcessId(),
+		  (unsigned long)GetCurrentThreadId(), pCardData);
 	logprintf(pCardData, 1, "CardGetChallenge\n");
 
 	if(!pCardData)
@@ -2902,7 +2982,8 @@ DWORD WINAPI CardGetChallenge(__in PCARD_DATA pCardData,
 	if (!ppbChallengeData || !pcbChallengeData)
 		return SCARD_E_INVALID_PARAMETER;
 
-	logprintf(pCardData, 1, "Asked challenge length %i, buffer %p\n", *pcbChallengeData, *ppbChallengeData);
+	logprintf(pCardData, 1, "Asked challenge length %lu, buffer %p\n",
+		  (unsigned long)*pcbChallengeData, *ppbChallengeData);
 	if (pcbChallengeData == NULL)   {
 		*ppbChallengeData = NULL;
 
@@ -2928,7 +3009,8 @@ DWORD WINAPI CardGetChallenge(__in PCARD_DATA pCardData,
 		return SCARD_E_UNEXPECTED;
 	}
 
-	logprintf(pCardData, 7, "returns %i bytes:\n", *pcbChallengeData);
+	logprintf(pCardData, 7, "returns %lu bytes:\n",
+		  (unsigned long)*pcbChallengeData);
 	loghex(pCardData, 7, *ppbChallengeData, *pcbChallengeData);
 	return SCARD_S_SUCCESS;
 }
@@ -2939,7 +3021,9 @@ DWORD WINAPI CardAuthenticateChallenge(__in PCARD_DATA  pCardData,
 	__in DWORD  cbResponseData,
 	__out_opt PDWORD pcAttemptsRemaining)
 {
-	logprintf(pCardData, 1, "\nP:%d T:%d pCardData:%p ",GetCurrentProcessId(), GetCurrentThreadId(), pCardData);
+	logprintf(pCardData, 1, "\nP:%lu T:%lu pCardData:%p ",
+		  (unsigned long)GetCurrentProcessId(),
+		  (unsigned long)GetCurrentThreadId(), pCardData);
 	logprintf(pCardData, 1, "CardAuthenticateChallenge - unsupported\n");
 	return SCARD_E_UNSUPPORTED_FEATURE;
 }
@@ -2957,7 +3041,9 @@ DWORD WINAPI CardUnblockPin(__in PCARD_DATA  pCardData,
 	if(!pCardData)
 		return SCARD_E_INVALID_PARAMETER;
 
-	logprintf(pCardData, 1, "\nP:%d T:%d pCardData:%p ",GetCurrentProcessId(), GetCurrentThreadId(), pCardData);
+	logprintf(pCardData, 1, "\nP:%lu T:%lu pCardData:%p ",
+		  (unsigned long)GetCurrentProcessId(),
+		  (unsigned long)GetCurrentThreadId(), pCardData);
 	logprintf(pCardData, 1, "CardUnblockPin\n");
 
 	if (pwszUserId == NULL) {
@@ -2985,11 +3071,20 @@ DWORD WINAPI CardUnblockPin(__in PCARD_DATA  pCardData,
 		return SCARD_E_INVALID_PARAMETER;
 	}
 
-	logprintf(pCardData, 1, "UserID('%S'), AuthData(%p, %u), NewPIN(%p, %u), Retry(%u), dwFlags(0x%X)\n",
-			pwszUserId, pbAuthenticationData, cbAuthenticationData, pbNewPinData, cbNewPinData,
-			cRetryCount, dwFlags);
-
-	return CardChangeAuthenticatorEx(pCardData, PIN_CHANGE_FLAG_UNBLOCK | CARD_PIN_SILENT_CONTEXT, ROLE_ADMIN, pbAuthenticationData, cbAuthenticationData, ROLE_USER, pbNewPinData, cbNewPinData, cRetryCount, NULL);
+	logprintf(pCardData, 1,
+		  "UserID('%S'), AuthData(%p, %lu), NewPIN(%p, %lu), Retry(%lu), dwFlags(0x%lX)\n",
+		  pwszUserId, pbAuthenticationData,
+		  (unsigned long)cbAuthenticationData, pbNewPinData,
+		  (unsigned long)cbNewPinData, (unsigned long)cRetryCount,
+		  (unsigned long)dwFlags);
+
+	return CardChangeAuthenticatorEx(pCardData,
+					 PIN_CHANGE_FLAG_UNBLOCK |
+					 CARD_PIN_SILENT_CONTEXT,
+					 ROLE_ADMIN, pbAuthenticationData,
+					 cbAuthenticationData, ROLE_USER,
+					 pbNewPinData, cbNewPinData,
+					 cRetryCount, NULL);
 }
 
 
@@ -3007,7 +3102,9 @@ DWORD WINAPI CardChangeAuthenticator(__in PCARD_DATA  pCardData,
 	if(!pCardData)
 		return SCARD_E_INVALID_PARAMETER;
 
-	logprintf(pCardData, 1, "\nP:%d T:%d pCardData:%p ",GetCurrentProcessId(), GetCurrentThreadId(), pCardData);
+	logprintf(pCardData, 1, "\nP:%lu T:%lu pCardData:%p ",
+		  (unsigned long)GetCurrentProcessId(),
+		  (unsigned long)GetCurrentThreadId(), pCardData);
 	logprintf(pCardData, 1, "CardChangeAuthenticator\n");
 
 	if (pwszUserId == NULL)
@@ -3024,16 +3121,24 @@ DWORD WINAPI CardChangeAuthenticator(__in PCARD_DATA  pCardData,
 	if (wcscmp(wszCARD_USER_USER, pwszUserId) != 0 && wcscmp(wszCARD_USER_ADMIN, pwszUserId) != 0)
 		return SCARD_E_INVALID_PARAMETER;
 
-	logprintf(pCardData, 1, "UserID('%S'), CurrentPIN(%p, %u), NewPIN(%p, %u), Retry(%u), dwFlags(0x%X)\n",
-			pwszUserId, pbCurrentAuthenticator, cbCurrentAuthenticator, pbNewAuthenticator, cbNewAuthenticator,
-			cRetryCount, dwFlags);
+	logprintf(pCardData, 1,
+		  "UserID('%S'), CurrentPIN(%p, %lu), NewPIN(%p, %lu), Retry(%lu), dwFlags(0x%lX)\n",
+		  pwszUserId, pbCurrentAuthenticator,
+		  (unsigned long)cbCurrentAuthenticator, pbNewAuthenticator,
+		  (unsigned long)cbNewAuthenticator, (unsigned long)cRetryCount,
+		  (unsigned long)dwFlags);
 
 	if (wcscmp(wszCARD_USER_USER, pwszUserId) == 0)
 		pinid = ROLE_USER;
 	else
 		pinid = ROLE_ADMIN;
 
-	return CardChangeAuthenticatorEx(pCardData, PIN_CHANGE_FLAG_CHANGEPIN | CARD_PIN_SILENT_CONTEXT, pinid, pbCurrentAuthenticator, cbCurrentAuthenticator, pinid, pbNewAuthenticator, cbNewAuthenticator, cRetryCount, pcAttemptsRemaining);
+	return CardChangeAuthenticatorEx(pCardData, PIN_CHANGE_FLAG_CHANGEPIN |
+					 CARD_PIN_SILENT_CONTEXT, pinid,
+					 pbCurrentAuthenticator,
+					 cbCurrentAuthenticator, pinid,
+					 pbNewAuthenticator, cbNewAuthenticator,
+					 cRetryCount, pcAttemptsRemaining);
 }
 
 /* this function is not called on purpose.
@@ -3046,8 +3151,11 @@ DWORD WINAPI CardDeauthenticate(__in PCARD_DATA pCardData,
 {
 	VENDOR_SPECIFIC* vs = NULL;
 	int rv;
-	logprintf(pCardData, 1, "\nP:%d T:%d pCardData:%p ",GetCurrentProcessId(), GetCurrentThreadId(), pCardData);
-	logprintf(pCardData, 1, "CardDeauthenticate(%S) %d\n", NULLWSTR(pwszUserId), dwFlags);
+	logprintf(pCardData, 1, "\nP:%ld T:%ld pCardData:%p ",
+		  (unsigned long)GetCurrentProcessId(),
+		  (unsigned long)GetCurrentThreadId(), pCardData);
+	logprintf(pCardData, 1, "CardDeauthenticate(%S) %lu\n",
+		  NULLWSTR(pwszUserId), (unsigned long)dwFlags);
 
 	if(!pCardData)
 		return SCARD_E_INVALID_PARAMETER;
@@ -3068,7 +3176,9 @@ DWORD WINAPI CardCreateDirectory(__in PCARD_DATA pCardData,
 	__in LPSTR pszDirectoryName,
 	__in CARD_DIRECTORY_ACCESS_CONDITION AccessCondition)
 {
-	logprintf(pCardData, 1, "\nP:%d T:%d pCardData:%p ",GetCurrentProcessId(), GetCurrentThreadId(), pCardData);
+	logprintf(pCardData, 1, "\nP:%lu T:%lu pCardData:%p ",
+		  (unsigned long)GetCurrentProcessId(),
+		  (unsigned long)GetCurrentThreadId(), pCardData);
 	logprintf(pCardData, 1, "CardCreateDirectory - unsupported\n");
 	return SCARD_E_UNSUPPORTED_FEATURE;
 }
@@ -3076,7 +3186,9 @@ DWORD WINAPI CardCreateDirectory(__in PCARD_DATA pCardData,
 DWORD WINAPI CardDeleteDirectory(__in PCARD_DATA pCardData,
 	__in LPSTR pszDirectoryName)
 {
-	logprintf(pCardData, 1, "\nP:%d T:%d pCardData:%p ",GetCurrentProcessId(), GetCurrentThreadId(), pCardData);
+	logprintf(pCardData, 1, "\nP:%lu T:%lu pCardData:%p ",
+		  (unsigned long)GetCurrentProcessId(),
+		  (unsigned long)GetCurrentThreadId(), pCardData);
 	logprintf(pCardData, 1, "CardDeleteDirectory(%s) - unsupported\n", NULLSTR(pszDirectoryName));
 	return SCARD_E_UNSUPPORTED_FEATURE;
 }
@@ -3090,9 +3202,13 @@ DWORD WINAPI CardCreateFile(__in PCARD_DATA pCardData,
 	struct md_directory *dir = NULL;
 	DWORD dwret;
 
-	logprintf(pCardData, 1, "\nP:%d T:%d pCardData:%p ",GetCurrentProcessId(), GetCurrentThreadId(), pCardData);
-	logprintf(pCardData, 1, "CardCreateFile(%s::%s, size %i, acl:0x%X) called\n",
-			NULLSTR(pszDirectoryName), NULLSTR(pszFileName), cbInitialCreationSize, AccessCondition);
+	logprintf(pCardData, 1, "\nP:%lu T:%lu pCardData:%p ",
+		  (unsigned long)GetCurrentProcessId(),
+		  (unsigned long)GetCurrentThreadId(), pCardData);
+	logprintf(pCardData, 1,
+		  "CardCreateFile(%s::%s, size %lu, acl:0x%X) called\n",
+		  NULLSTR(pszDirectoryName), NULLSTR(pszFileName),
+		  (unsigned long)cbInitialCreationSize, AccessCondition);
 
 	dwret = md_fs_find_directory(pCardData, NULL, pszDirectoryName, &dir);
 	if (dwret != SCARD_S_SUCCESS)   {
@@ -3117,7 +3233,9 @@ DWORD WINAPI CardReadFile(__in PCARD_DATA pCardData,
 {
 	struct md_file *file = NULL;
 
-	logprintf(pCardData, 1, "\nP:%d T:%d pCardData:%p ",GetCurrentProcessId(), GetCurrentThreadId(), pCardData);
+	logprintf(pCardData, 1, "\nP:%lu T:%lu pCardData:%p ",
+		  (unsigned long)GetCurrentProcessId(),
+		  (unsigned long)GetCurrentThreadId(), pCardData);
 	logprintf(pCardData, 1, "CardReadFile\n");
 
 	if(!pCardData)
@@ -3125,8 +3243,10 @@ DWORD WINAPI CardReadFile(__in PCARD_DATA pCardData,
 	if (!ppbData || !pcbData)
 		return SCARD_E_INVALID_PARAMETER;
 
-	logprintf(pCardData, 2, "pszDirectoryName = %s, pszFileName = %s, dwFlags = %X, pcbData=%u, *ppbData=%X\n",
-		NULLSTR(pszDirectoryName), NULLSTR(pszFileName), dwFlags, *pcbData, *ppbData);
+	logprintf(pCardData, 2,
+		  "pszDirectoryName = %s, pszFileName = %s, dwFlags = %lX, pcbData=%lu, ppbData=%p\n",
+		  NULLSTR(pszDirectoryName), NULLSTR(pszFileName),
+		  (unsigned long)dwFlags, (unsigned long)*pcbData, ppbData);
 
 	if (!pszFileName || !strlen(pszFileName))
 		return SCARD_E_INVALID_PARAMETER;
@@ -3169,13 +3289,16 @@ DWORD WINAPI CardWriteFile(__in PCARD_DATA pCardData,
 	if(!pCardData)
 		return SCARD_E_INVALID_PARAMETER;
 
-	logprintf(pCardData, 1, "\nP:%d T:%d pCardData:%p ",GetCurrentProcessId(), GetCurrentThreadId(), pCardData);
+	logprintf(pCardData, 1, "\nP:%lu T:%lu pCardData:%p ",
+		  (unsigned long)GetCurrentProcessId(),
+		  (unsigned long)GetCurrentThreadId(), pCardData);
 	logprintf(pCardData, 1, "CardWriteFile() dirName:'%s', fileName:'%s' \n", NULLSTR(pszDirectoryName), NULLSTR(pszFileName));
 
 	check_reader_status(pCardData);
 
 	if (pbData && cbData)   {
-		logprintf(pCardData, 1, "CardWriteFile try to write (%i):\n", cbData);
+		logprintf(pCardData, 1, "CardWriteFile try to write (%lu):\n",
+			  (unsigned long)cbData);
 		loghex(pCardData, 2, pbData, cbData);
 	}
 
@@ -3190,7 +3313,8 @@ DWORD WINAPI CardWriteFile(__in PCARD_DATA pCardData,
 
 	dwret = md_fs_set_content(pCardData, file, pbData, cbData);
 	if (dwret != SCARD_S_SUCCESS)   {
-		logprintf(pCardData, 1, "cannot set file content: %li\n", dwret);
+		logprintf(pCardData, 1, "cannot set file content: %lu\n",
+			  (unsigned long)dwret);
 		return dwret;
 	}
 
@@ -3214,7 +3338,9 @@ DWORD WINAPI CardDeleteFile(__in PCARD_DATA pCardData,
 {
 	DWORD dwret;
 
-	logprintf(pCardData, 1, "\nP:%d T:%d pCardData:%p ",GetCurrentProcessId(), GetCurrentThreadId(), pCardData);
+	logprintf(pCardData, 1, "\nP:%lu T:%lu pCardData:%p ",
+		  (unsigned long)GetCurrentProcessId(),
+		  (unsigned long)GetCurrentThreadId(), pCardData);
 	logprintf(pCardData, 1, "CardDeleteFile(%s, %s) called\n", NULLSTR(pszDirectoryName), NULLSTR(pszFileName));
 
 	if(!pCardData)
@@ -3224,7 +3350,9 @@ DWORD WINAPI CardDeleteFile(__in PCARD_DATA pCardData,
 
 	dwret = md_fs_delete_file(pCardData, pszDirectoryName, pszFileName);
 	if (dwret != SCARD_S_SUCCESS)   {
-		logprintf(pCardData, 2, "CardDeleteFile(): delete file error: %X\n", dwret);
+		logprintf(pCardData, 2,
+			  "CardDeleteFile(): delete file error: %lX\n",
+			  (unsigned long)dwret);
 		return dwret;
 	}
 
@@ -3244,7 +3372,9 @@ DWORD WINAPI CardEnumFiles(__in PCARD_DATA pCardData,
 	struct md_file *file = NULL;
 	size_t offs;
 
-	logprintf(pCardData, 1, "\nP:%d T:%d pCardData:%p ",GetCurrentProcessId(), GetCurrentThreadId(), pCardData);
+	logprintf(pCardData, 1, "\nP:%lu T:%lu pCardData:%p ",
+		  (unsigned long)GetCurrentProcessId(),
+		  (unsigned long)GetCurrentThreadId(), pCardData);
 	logprintf(pCardData, 1, "CardEnumFiles() directory '%s'\n", NULLSTR(pszDirectoryName));
 
 	if (!pCardData)
@@ -3252,7 +3382,9 @@ DWORD WINAPI CardEnumFiles(__in PCARD_DATA pCardData,
 	if (!pmszFileNames || !pdwcbFileName)
 		return SCARD_E_INVALID_PARAMETER;
 	if (dwFlags)   {
-		logprintf(pCardData, 1, "CardEnumFiles() dwFlags not 'zero' -- %X\n", dwFlags);
+		logprintf(pCardData, 1,
+			  "CardEnumFiles() dwFlags not 'zero' -- %lX\n",
+			  (unsigned long)dwFlags);
 		return SCARD_E_INVALID_PARAMETER;
 	}
 
@@ -3296,7 +3428,9 @@ DWORD WINAPI CardGetFileInfo(__in PCARD_DATA pCardData,
 {
 	struct md_file *file = NULL;
 
-	logprintf(pCardData, 1, "\nP:%d T:%d pCardData:%p ",GetCurrentProcessId(), GetCurrentThreadId(), pCardData);
+	logprintf(pCardData, 1, "\nP:%lu T:%lu pCardData:%p ",
+		  (unsigned long)GetCurrentProcessId(),
+		  (unsigned long)GetCurrentThreadId(), pCardData);
 	logprintf(pCardData, 1, "CardGetFileInfo(dirName:'%s',fileName:'%s', out %p)\n", NULLSTR(pszDirectoryName), NULLSTR(pszFileName), pCardFileInfo);
 
 	md_fs_find_file(pCardData, pszDirectoryName, pszFileName, &file);
@@ -3318,9 +3452,13 @@ DWORD WINAPI CardQueryFreeSpace(__in PCARD_DATA pCardData, __in DWORD dwFlags,
 {
 	DWORD dwret;
 
-	logprintf(pCardData, 1, "\nP:%d T:%d pCardData:%p ",GetCurrentProcessId(), GetCurrentThreadId(), pCardData);
-	logprintf(pCardData, 1, "CardQueryFreeSpace %p, dwFlags=%X, version=%X\n",
-		pCardFreeSpaceInfo, dwFlags, pCardFreeSpaceInfo->dwVersion);
+	logprintf(pCardData, 1, "\nP:%lu T:%lu pCardData:%p ",
+		  (unsigned long)GetCurrentProcessId(),
+		  (unsigned long)GetCurrentThreadId(), pCardData);
+	logprintf(pCardData, 1,
+		  "CardQueryFreeSpace %p, dwFlags=%lX, version=%lX\n",
+		  pCardFreeSpaceInfo, (unsigned long)dwFlags,
+		  (unsigned long)pCardFreeSpaceInfo->dwVersion);
 
 	if (!pCardData)
 		return SCARD_E_INVALID_PARAMETER;
@@ -3346,8 +3484,13 @@ DWORD WINAPI CardQueryKeySizes(__in PCARD_DATA pCardData,
 {
 	DWORD dwret;
 
-	logprintf(pCardData, 1, "\nP:%d T:%d pCardData:%p ",GetCurrentProcessId(), GetCurrentThreadId(), pCardData);
-	logprintf(pCardData, 1, "CardQueryKeySizes dwKeySpec=%X, dwFlags=%X, version=%X\n",  dwKeySpec, dwFlags, (pKeySizes?pKeySizes->dwVersion:0));
+	logprintf(pCardData, 1, "\nP:%lu T:%lu pCardData:%p ",
+		  (unsigned long)GetCurrentProcessId(),
+		  (unsigned long)GetCurrentThreadId(), pCardData);
+	logprintf(pCardData, 1,
+		  "CardQueryKeySizes dwKeySpec=%lX, dwFlags=%lX, version=%lX\n",
+		  (unsigned long)dwKeySpec, (unsigned long)dwFlags,
+		  pKeySizes ? (unsigned long)pKeySizes->dwVersion : 0);
 
 	if (!pCardData)
 		return SCARD_E_INVALID_PARAMETER;
@@ -3378,7 +3521,9 @@ DWORD WINAPI CardRSADecrypt(__in PCARD_DATA pCardData,
 	struct sc_pkcs15_object *pkey = NULL;
 	struct sc_algorithm_info *alg_info = NULL;
 
-	logprintf(pCardData, 1, "\nP:%d T:%d pCardData:%p ",GetCurrentProcessId(), GetCurrentThreadId(), pCardData);
+	logprintf(pCardData, 1, "\nP:%lu T:%lu pCardData:%p ",
+		  (unsigned long)GetCurrentProcessId(),
+		  (unsigned long)GetCurrentThreadId(), pCardData);
 	logprintf(pCardData, 1, "CardRSADecrypt\n");
 	if (!pCardData)
 		return SCARD_E_INVALID_PARAMETER;
@@ -3402,11 +3547,18 @@ DWORD WINAPI CardRSADecrypt(__in PCARD_DATA pCardData,
 
 	check_reader_status(pCardData);
 
-	logprintf(pCardData, 2, "CardRSADecrypt dwVersion=%u, bContainerIndex=%u,dwKeySpec=%u pbData=%p, cbData=%u\n",
-		pInfo->dwVersion,pInfo->bContainerIndex ,pInfo->dwKeySpec, pInfo->pbData,  pInfo->cbData);
+	logprintf(pCardData, 2,
+		  "CardRSADecrypt dwVersion=%lu, bContainerIndex=%u, dwKeySpec=%lu pbData=%p, cbData=%lu\n",
+		  (unsigned long)pInfo->dwVersion,
+		  (unsigned int)pInfo->bContainerIndex,
+		  (unsigned long)pInfo->dwKeySpec, pInfo->pbData,
+		  (unsigned long)pInfo->cbData);
 
 	if (pInfo->dwVersion >= CARD_RSA_KEY_DECRYPT_INFO_VERSION_TWO)
-		logprintf(pCardData, 2, "  pPaddingInfo=%p dwPaddingType=0x%08X\n", pInfo->pPaddingInfo, pInfo->dwPaddingType);
+		logprintf(pCardData, 2,
+			  "  pPaddingInfo=%p dwPaddingType=0x%08X\n",
+			  pInfo->pPaddingInfo,
+			  (unsigned int)pInfo->dwPaddingType);
 
 	pkey = vs->p15_containers[pInfo->bContainerIndex].prkey_obj;
 	if (!pkey)   {
@@ -3434,7 +3586,9 @@ DWORD WINAPI CardRSADecrypt(__in PCARD_DATA pCardData,
 	prkey_info = (struct sc_pkcs15_prkey_info *)(pkey->data);
 	alg_info = sc_card_find_rsa_alg(vs->p15card->card, (unsigned int) prkey_info->modulus_length);
 	if (!alg_info)   {
-		logprintf(pCardData, 2, "Cannot get appropriate RSA card algorithm for key size %i\n", prkey_info->modulus_length);
+		logprintf(pCardData, 2,
+			  "Cannot get appropriate RSA card algorithm for key size %"SC_FORMAT_LEN_SIZE_T"u\n",
+			  prkey_info->modulus_length);
 		pCardData->pfnCspFree(pbuf);
 		pCardData->pfnCspFree(pbuf2);
 		return SCARD_F_INTERNAL_ERROR;
@@ -3458,7 +3612,9 @@ DWORD WINAPI CardRSADecrypt(__in PCARD_DATA pCardData,
 		if (r > 0) {
 			/* Need to handle padding */
 			if (pInfo->dwVersion >= CARD_RSA_KEY_DECRYPT_INFO_VERSION_TWO) {
-				logprintf(pCardData, 2, "sc_pkcs15_decipher: DECRYPT-INFO dwVersion=%u\n", pInfo->dwVersion);
+				logprintf(pCardData, 2,
+					  "sc_pkcs15_decipher: DECRYPT-INFO dwVersion=%lu\n",
+					  (unsigned long)pInfo->dwVersion);
 				if (pInfo->dwPaddingType == CARD_PADDING_PKCS1)   {
 					size_t temp = pInfo->cbData;
 					logprintf(pCardData, 2, "sc_pkcs15_decipher: stripping PKCS1 padding\n");
@@ -3522,7 +3678,8 @@ DWORD WINAPI CardRSADecrypt(__in PCARD_DATA pCardData,
 		return md_translate_OpenSC_to_Windows_error(r, SCARD_E_INVALID_VALUE);
 	}
 
-	logprintf(pCardData, 2, "decrypted data(%i):\n", pInfo->cbData);
+	logprintf(pCardData, 2, "decrypted data(%lu):\n",
+		  (unsigned long)pInfo->cbData);
 	loghex(pCardData, 7, pbuf2, pInfo->cbData);
 
 	/*inversion donnees */
@@ -3545,7 +3702,9 @@ DWORD WINAPI CardSignData(__in PCARD_DATA pCardData, __inout PCARD_SIGNING_INFO
 	size_t dataToSignLen = sizeof(dataToSign);
 	sc_pkcs15_object_t *pkey;
 
-	logprintf(pCardData, 1, "\nP:%d T:%d pCardData:%p ",GetCurrentProcessId(), GetCurrentThreadId(), pCardData);
+	logprintf(pCardData, 1, "\nP:%lu T:%lu pCardData:%p ",
+		  (unsigned long)GetCurrentProcessId(),
+		  (unsigned long)GetCurrentThreadId(), pCardData);
 	logprintf(pCardData, 1, "CardSignData\n");
 
 	if (!pCardData || !pInfo)
@@ -3572,10 +3731,16 @@ DWORD WINAPI CardSignData(__in PCARD_DATA pCardData, __inout PCARD_SIGNING_INFO
 	if (pInfo->dwSigningFlags & ~(CARD_PADDING_INFO_PRESENT | CARD_PADDING_NONE | CARD_BUFFER_SIZE_ONLY | CARD_PADDING_PKCS1 | CARD_PADDING_PSS | CARD_PADDING_OAEP))
 		return SCARD_E_INVALID_PARAMETER;
 
-	logprintf(pCardData, 2, "CardSignData dwVersion=%u, bContainerIndex=%u, dwKeySpec=%u, dwSigningFlags=0x%08X, aiHashAlg=0x%08X\n",
-		pInfo->dwVersion,pInfo->bContainerIndex ,pInfo->dwKeySpec, pInfo->dwSigningFlags, pInfo->aiHashAlg);
+	logprintf(pCardData, 2,
+		  "CardSignData dwVersion=%lu, bContainerIndex=%u, dwKeySpec=%lu, dwSigningFlags=0x%08X, aiHashAlg=0x%08X\n",
+		  (unsigned long)pInfo->dwVersion,
+		  (unsigned int)pInfo->bContainerIndex,
+		  (unsigned long)pInfo->dwKeySpec,
+		  (unsigned int)pInfo->dwSigningFlags,
+		  (unsigned int)pInfo->aiHashAlg);
 
-	logprintf(pCardData, 7, "pInfo->pbData(%i) ", pInfo->cbData);
+	logprintf(pCardData, 7, "pInfo->pbData(%lu) ",
+		  (unsigned long)pInfo->cbData);
 	loghex(pCardData, 7, pInfo->pbData, pInfo->cbData);
 
 	hashAlg = pInfo->aiHashAlg;
@@ -3591,7 +3756,8 @@ DWORD WINAPI CardSignData(__in PCARD_DATA pCardData, __inout PCARD_SIGNING_INFO
 
 	check_reader_status(pCardData);
 
-	logprintf(pCardData, 2, "pInfo->dwVersion = %d\n", pInfo->dwVersion);
+	logprintf(pCardData, 2, "pInfo->dwVersion = %lu\n",
+		  (unsigned long)pInfo->dwVersion);
 
 	if (dataToSignLen < pInfo->cbData)
 		return SCARD_E_INSUFFICIENT_BUFFER;
@@ -3713,7 +3879,9 @@ DWORD WINAPI CardSignData(__in PCARD_DATA pCardData, __inout PCARD_SIGNING_INFO
 				pInfo->cbSignedData = 132;
 				break;
 			default:
-				logprintf(pCardData, 0, "unknown ECC key size %i\n", prkey_info->field_length);
+				logprintf(pCardData, 0,
+					  "unknown ECC key size %"SC_FORMAT_LEN_SIZE_T"u\n",
+					  prkey_info->field_length);
 				return SCARD_E_INVALID_VALUE;
 		}
 	} else {
@@ -3721,7 +3889,8 @@ DWORD WINAPI CardSignData(__in PCARD_DATA pCardData, __inout PCARD_SIGNING_INFO
 		return SCARD_E_INVALID_VALUE;
 	}
 
-	logprintf(pCardData, 3, "pInfo->cbSignedData = %d\n", pInfo->cbSignedData);
+	logprintf(pCardData, 3, "pInfo->cbSignedData = %lu\n",
+		  (unsigned long)pInfo->cbSignedData);
 
 	if(!(pInfo->dwSigningFlags&CARD_BUFFER_SIZE_ONLY))   {
 		int r,i;
@@ -3729,7 +3898,7 @@ DWORD WINAPI CardSignData(__in PCARD_DATA pCardData, __inout PCARD_SIGNING_INFO
 		DWORD lg;
 
 		lg = pInfo->cbSignedData;
-		logprintf(pCardData, 3, "lg = %d\n", lg);
+		logprintf(pCardData, 3, "lg = %lu\n", (unsigned long)lg);
 		pbuf = pCardData->pfnCspAlloc(lg);
 		if (!pbuf)
 			return SCARD_E_NO_MEMORY;
@@ -3769,8 +3938,12 @@ DWORD WINAPI CardSignData(__in PCARD_DATA pCardData, __inout PCARD_SIGNING_INFO
 		loghex(pCardData, 7, pInfo->pbSignedData, pInfo->cbSignedData);
 	}
 
-	logprintf(pCardData, 3, "CardSignData, dwVersion=%u, name=%S, hScard=0x%08X, hSCardCtx=0x%08X\n",
-			pCardData->dwVersion, NULLWSTR(pCardData->pwszCardName),pCardData->hScard, pCardData->hSCardCtx);
+	logprintf(pCardData, 3,
+		  "CardSignData, dwVersion=%lu, name=%S, hScard=0x%08X, hSCardCtx=0x%08X\n",
+		  (unsigned long)pCardData->dwVersion,
+		  NULLWSTR(pCardData->pwszCardName),
+		  (unsigned int)pCardData->hScard,
+		  (unsigned int)pCardData->hSCardCtx);
 
 	return SCARD_S_SUCCESS;
 }
@@ -3789,7 +3962,9 @@ DWORD WINAPI CardConstructDHAgreement(__in PCARD_DATA pCardData,
 	struct md_dh_agreement* temp = NULL;
 	BYTE i;
 
-	logprintf(pCardData, 1, "\nP:%d T:%d pCardData:%p ",GetCurrentProcessId(), GetCurrentThreadId(), pCardData);
+	logprintf(pCardData, 1, "\nP:%lu T:%lu pCardData:%p ",
+		  (unsigned long)GetCurrentProcessId(),
+		  (unsigned long)GetCurrentThreadId(), pCardData);
 	logprintf(pCardData, 1, "CardConstructDHAgreement\n");
 
 	if (!pCardData)
@@ -3812,8 +3987,11 @@ DWORD WINAPI CardConstructDHAgreement(__in PCARD_DATA pCardData,
 
 	check_reader_status(pCardData);
 
-	logprintf(pCardData, 2, "CardConstructDHAgreement dwVersion=%u, dwKeySpec=%u pbData=%p, cbData=%u\n",
-		pAgreementInfo->dwVersion,pAgreementInfo->bContainerIndex , pAgreementInfo->pbPublicKey,  pAgreementInfo->dwPublicKey);
+	logprintf(pCardData, 2, "CardConstructDHAgreement dwVersion=%lu, dwKeySpec=%u pbData=%p, cbData=%lu\n",
+		  (unsigned long)pAgreementInfo->dwVersion,
+		  (unsigned int)pAgreementInfo->bContainerIndex,
+		  pAgreementInfo->pbPublicKey,
+		  (unsigned long)pAgreementInfo->dwPublicKey);
 
 	pkey = vs->p15_containers[pAgreementInfo->bContainerIndex].prkey_obj;
 	if (!pkey)   {
@@ -3909,7 +4087,9 @@ DWORD WINAPI CardDeriveHashOrHMAC(__in PCARD_DATA pCardData,
 
 	dwReturn = BCryptOpenAlgorithmProvider(&hAlgorithm, szAlgorithm, NULL, (pbHmacKey?BCRYPT_ALG_HANDLE_HMAC_FLAG:0));
 	if (dwReturn) {
-		logprintf(pCardData, 0, "CardDeriveKey: unable to find a provider for the algorithm %S 0x%08X\n", szAlgorithm, dwReturn);
+		logprintf(pCardData, 0,
+			  "CardDeriveKey: unable to find a provider for the algorithm %S 0x%08X\n",
+			  szAlgorithm, (unsigned int)dwReturn);
 		goto cleanup;
 	}
 	dwSize = sizeof(DWORD);
@@ -3932,7 +4112,9 @@ DWORD WINAPI CardDeriveHashOrHMAC(__in PCARD_DATA pCardData,
 	dwSize = sizeof(DWORD);
 	dwReturn = BCryptGetProperty(hAlgorithm, BCRYPT_OBJECT_LENGTH, (PUCHAR)&dwBufferSize, dwSize, &dwSize, 0);
 	if (dwReturn) {
-		logprintf(pCardData, 0, "CardDeriveKey: unable to get the buffer length 0x%08X\n", dwReturn);
+		logprintf(pCardData, 0,
+			  "CardDeriveKey: unable to get the buffer length 0x%08X\n",
+			  (unsigned int)dwReturn);
 		goto cleanup;
 	}
 
@@ -3948,7 +4130,9 @@ DWORD WINAPI CardDeriveHashOrHMAC(__in PCARD_DATA pCardData,
 		dwReturn = BCryptCreateHash(hAlgorithm, &hHash, pbBuffer, dwBufferSize, NULL, 0, 0);
 	}
 	if (dwReturn) {
-		logprintf(pCardData, 0, "CardDeriveKey: unable to create the alg object 0x%08X\n", dwReturn);
+		logprintf(pCardData, 0,
+			  "CardDeriveKey: unable to create the alg object 0x%08X\n",
+			  (unsigned int)dwReturn);
 		goto cleanup;
 	}
 
@@ -3959,7 +4143,9 @@ DWORD WINAPI CardDeriveHashOrHMAC(__in PCARD_DATA pCardData,
 			if (buffer->BufferType == KDF_SECRET_PREPEND) {
 				dwReturn = BCryptHashData(hHash, (PUCHAR)buffer->pvBuffer, buffer->cbBuffer, 0);
 				if (dwReturn) {
-					logprintf(pCardData, 0, "CardDeriveKey: unable to hash data 0x%08X\n", dwReturn);
+					logprintf(pCardData, 0,
+						  "CardDeriveKey: unable to hash data 0x%08X\n",
+						  (unsigned int)dwReturn);
 					goto cleanup;
 				}
 			}
@@ -3968,7 +4154,9 @@ DWORD WINAPI CardDeriveHashOrHMAC(__in PCARD_DATA pCardData,
 
 	dwReturn = BCryptHashData(hHash, (PUCHAR)agreement->pbAgreement, agreement->dwSize, 0);
 	if (dwReturn) {
-		logprintf(pCardData, 0, "CardDeriveKey: unable to hash data 0x%08X\n", dwReturn);
+		logprintf(pCardData, 0,
+			  "CardDeriveKey: unable to hash data 0x%08X\n",
+			  (unsigned int)dwReturn);
 		goto cleanup;
 	}
 
@@ -3978,7 +4166,9 @@ DWORD WINAPI CardDeriveHashOrHMAC(__in PCARD_DATA pCardData,
 			if (buffer->BufferType == KDF_SECRET_APPEND) {
 				dwReturn = BCryptHashData(hHash, (PUCHAR)buffer->pvBuffer, buffer->cbBuffer, 0);
 				if (dwReturn) {
-					logprintf(pCardData, 0, "CardDeriveKey: unable to hash data 0x%08X\n", dwReturn);
+					logprintf(pCardData, 0,
+						  "CardDeriveKey: unable to hash data 0x%08X\n",
+						  (unsigned int)dwReturn);
 					goto cleanup;
 				}
 			}
@@ -3987,7 +4177,9 @@ DWORD WINAPI CardDeriveHashOrHMAC(__in PCARD_DATA pCardData,
 
 	dwReturn = BCryptFinishHash(hHash, pAgreementInfo->pbDerivedKey, pAgreementInfo->cbDerivedKey, 0);
 	if (dwReturn) {
-		logprintf(pCardData, 0, "CardDeriveKey: unable to finish hash 0x%08X\n", dwReturn);
+		logprintf(pCardData, 0,
+			  "CardDeriveKey: unable to finish hash 0x%08X\n",
+			  (unsigned int)dwReturn);
 		goto cleanup;
 	}
 
@@ -4014,11 +4206,13 @@ DWORD HashDataWithBCrypt(__in PCARD_DATA pCardData, BCRYPT_ALG_HANDLE hAlgorithm
 	DWORD dwReturn, dwSize, dwBufferSize;
 	BCRYPT_HASH_HANDLE hHash = NULL;
 	PBYTE pbBuffer = NULL;
-	
+
 	dwSize = sizeof(DWORD);
 	dwReturn = BCryptGetProperty(hAlgorithm, BCRYPT_OBJECT_LENGTH, (PUCHAR)&dwBufferSize, dwSize, &dwSize, 0);
 	if (dwReturn) {
-		logprintf(pCardData, 0, "CardDeriveKey: unable to get the buffer length 0x%08X\n", dwReturn);
+		logprintf(pCardData, 0,
+			  "CardDeriveKey: unable to get the buffer length 0x%08X\n",
+			  (unsigned int)dwReturn);
 		goto cleanup;
 	}
 	pbBuffer = (PBYTE)LocalAlloc(0, dwBufferSize);
@@ -4028,33 +4222,43 @@ DWORD HashDataWithBCrypt(__in PCARD_DATA pCardData, BCRYPT_ALG_HANDLE hAlgorithm
 	}
 	dwReturn = BCryptCreateHash(hAlgorithm, &hHash, pbBuffer, dwBufferSize, pbSecret, dwSecretSize, 0);
 	if (dwReturn) {
-		logprintf(pCardData, 0, "CardDeriveKey: unable to create the alg object 0x%08X\n", dwReturn);
+		logprintf(pCardData, 0,
+			  "CardDeriveKey: unable to create the alg object 0x%08X\n",
+			  (unsigned int)dwReturn);
 		goto cleanup;
 	}
 	if (pbData1) {
 		dwReturn = BCryptHashData(hHash, pbData1, dwDataSize1, 0);
 		if (dwReturn) {
-			logprintf(pCardData, 0, "CardDeriveKey: unable to hash data 0x%08X\n", dwReturn);
+			logprintf(pCardData, 0,
+				  "CardDeriveKey: unable to hash data 0x%08X\n",
+				  (unsigned int)dwReturn);
 			goto cleanup;
 		}
 	}
 	if (pbData2) {
 		dwReturn = BCryptHashData(hHash, pbData2, dwDataSize2, 0);
 		if (dwReturn) {
-			logprintf(pCardData, 0, "CardDeriveKey: unable to hash data 0x%08X\n", dwReturn);
+			logprintf(pCardData, 0,
+				  "CardDeriveKey: unable to hash data 0x%08X\n",
+				  (unsigned int)dwReturn);
 			goto cleanup;
 		}
 	}
 	if (pbData3) {
 		dwReturn = BCryptHashData(hHash, pbData3, dwDataSize3, 0);
 		if (dwReturn) {
-			logprintf(pCardData, 0, "CardDeriveKey: unable to hash data 0x%08X\n", dwReturn);
+			logprintf(pCardData, 0,
+				  "CardDeriveKey: unable to hash data 0x%08X\n",
+				  (unsigned int)dwReturn);
 			goto cleanup;
 		}
 	}
 	dwReturn = BCryptFinishHash(hHash, pbOuput, dwOutputSize, 0);
 	if (dwReturn) {
-		logprintf(pCardData, 0, "CardDeriveKey: unable to finish hash 0x%08X\n", dwReturn);
+		logprintf(pCardData, 0,
+			  "CardDeriveKey: unable to finish hash 0x%08X\n",
+			  (unsigned int)dwReturn);
 		goto cleanup;
 	}
 cleanup:
@@ -4082,10 +4286,12 @@ DWORD WINAPI DoTlsPrf(__in PCARD_DATA pCardData,
 	PBYTE pbBuffer = NULL;
 	/* TLS intermediate results */
 	PBYTE pbAx = NULL;
-	
+
 	dwReturn = BCryptOpenAlgorithmProvider(&hAlgorithm, szAlgorithm, NULL, BCRYPT_ALG_HANDLE_HMAC_FLAG);
 	if (dwReturn) {
-		logprintf(pCardData, 0, "CardDeriveKey: unable to find a provider for the algorithm %S 0x%08X\n", szAlgorithm, dwReturn);
+		logprintf(pCardData, 0,
+			  "CardDeriveKey: unable to find a provider for the algorithm %S 0x%08X\n",
+			  szAlgorithm, (unsigned int)dwReturn);
 		goto cleanup;
 	}
 	dwSize = sizeof(DWORD);
@@ -4094,7 +4300,7 @@ DWORD WINAPI DoTlsPrf(__in PCARD_DATA pCardData,
 		logprintf(pCardData, 0, "CardDeriveKey: unable to get the hash length\n");
 		goto cleanup;
 	}
-	
+
 	/* size is always 48 */
 	dwLastRoundSize = TLS_DERIVE_KEY_SIZE % dwHashSize;
 	if (dwLastRoundSize == 0) dwLastRoundSize = dwHashSize;
@@ -4131,7 +4337,9 @@ DWORD WINAPI DoTlsPrf(__in PCARD_DATA pCardData,
 					NULL, 0);
 		}
 		if (dwReturn) {
-			logprintf(pCardData, 0, "CardDeriveKey: unable to hash Ax 0x%08X\n", szAlgorithm, dwReturn);
+			logprintf(pCardData, 0,
+				  "CardDeriveKey: unable to hash %S 0x%08X\n",
+				  szAlgorithm, (unsigned int)dwReturn);
 			goto cleanup;
 		}
 		if (dwNumberOfRounds -1 == i) {
@@ -4150,11 +4358,12 @@ DWORD WINAPI DoTlsPrf(__in PCARD_DATA pCardData,
 					pbSeed, 64);
 		}
 		if (dwReturn) {
-			logprintf(pCardData, 0, "CardDeriveKey: unable to hash Ax 0x%08X\n", szAlgorithm, dwReturn);
+			logprintf(pCardData, 0,
+				  "CardDeriveKey: unable to hash %S 0x%08X\n",
+				  szAlgorithm, (unsigned int)dwReturn);
 			goto cleanup;
 		}
 	}
-	
 
 cleanup:
 	if (pbBuffer)
@@ -4190,7 +4399,9 @@ DWORD WINAPI CardDeriveTlsPrf(__in PCARD_DATA pCardData,
 			return SCARD_E_INVALID_PARAMETER;
 		}
 	} else {
-		logprintf(pCardData, 0, "CardDeriveTlsPrf: TLS protocol unknwon 0x%08X\n", dwReturn);
+		logprintf(pCardData, 0,
+			  "CardDeriveTlsPrf: TLS protocol unknown 0x%08X\n",
+			  (unsigned int)dwReturn);
 		return SCARD_E_INVALID_PARAMETER;
 	}
 	/* size is always 48 according to msdn */
@@ -4215,7 +4426,9 @@ DWORD WINAPI CardDeriveTlsPrf(__in PCARD_DATA pCardData,
 						pbLabel, dwLabelSize,
 						pbSeed);
 		if (dwReturn) {
-			logprintf(pCardData, 0, "CardDeriveTlsPrf: unable to DoTlsPrf with %S 0x%08X\n", szAlgorithm, dwReturn);
+			logprintf(pCardData, 0,
+				  "CardDeriveTlsPrf: unable to DoTlsPrf with %S 0x%08X\n",
+				  szAlgorithm, (unsigned int)dwReturn);
 			pCardData->pfnCspFree(pAgreementInfo->pbDerivedKey );
 			pAgreementInfo->pbDerivedKey  = NULL;
 			return dwReturn;
@@ -4234,7 +4447,9 @@ DWORD WINAPI CardDeriveTlsPrf(__in PCARD_DATA pCardData,
 						pbLabel, dwLabelSize,
 						pbSeed);
 		if (dwReturn) {
-			logprintf(pCardData, 0, "CardDeriveTlsPrf: unable to DoTlsPrf with %S 0x%08X\n", szAlgorithm, dwReturn);
+			logprintf(pCardData, 0,
+				  "CardDeriveTlsPrf: unable to DoTlsPrf with %S 0x%08X\n",
+				  szAlgorithm, (unsigned int)dwReturn);
 			LocalFree(pbBuffer);
 			pCardData->pfnCspFree(pAgreementInfo->pbDerivedKey );
 			pAgreementInfo->pbDerivedKey  = NULL;
@@ -4254,7 +4469,9 @@ DWORD WINAPI CardDeriveTlsPrf(__in PCARD_DATA pCardData,
 						pbLabel, dwLabelSize,
 						pbSeed);
 		if (dwReturn) {
-			logprintf(pCardData, 0, "CardDeriveTlsPrf: unable to DoTlsPrf with %S 0x%08X\n", szAlgorithm, dwReturn);
+			logprintf(pCardData, 0,
+				  "CardDeriveTlsPrf: unable to DoTlsPrf with %S 0x%08X\n",
+				  szAlgorithm, (unsigned int)dwReturn);
 			pCardData->pfnCspFree(pAgreementInfo->pbDerivedKey );
 			pAgreementInfo->pbDerivedKey  = NULL;
 			return dwReturn;
@@ -4279,9 +4496,10 @@ DWORD WINAPI CardDeriveKey(__in PCARD_DATA pCardData,
 	DWORD dwLabelSize = 0;
 	PBYTE pbSeed = NULL;
 	DWORD dwProtocol = 0;
-	
 
-	logprintf(pCardData, 1, "\nP:%d T:%d pCardData:%p ",GetCurrentProcessId(), GetCurrentThreadId(), pCardData);
+	logprintf(pCardData, 1, "\nP:%lu T:%lu pCardData:%p ",
+		  (unsigned long)GetCurrentProcessId(),
+		  (unsigned long)GetCurrentThreadId(), pCardData);
 	logprintf(pCardData, 1, "CardDeriveKey\n");
 	if (!pCardData)
 		return SCARD_E_INVALID_PARAMETER;
@@ -4343,7 +4561,9 @@ DWORD WINAPI CardDeriveKey(__in PCARD_DATA pCardData,
 					} else if (wcscmp((PWSTR) buffer->pvBuffer, BCRYPT_MD5_ALGORITHM) == 0) {
 						szAlgorithm = BCRYPT_MD5_ALGORITHM;
 					} else {
-						logprintf(pCardData, 0, "CardDeriveKey: unsupported algorithm %S\n", buffer->pvBuffer);
+						logprintf(pCardData, 0,
+							  "CardDeriveKey: unsupported algorithm %S\n",
+							  (PWSTR)buffer->pvBuffer);
 						return SCARD_E_INVALID_PARAMETER;
 					}
 					break;
@@ -4374,7 +4594,9 @@ DWORD WINAPI CardDeriveKey(__in PCARD_DATA pCardData,
 					}
 					if (buffer->cbBuffer != 64)
 					{
-						logprintf(pCardData, 0, "CardDeriveKey: invalid seed size %u\n", buffer->cbBuffer);
+						logprintf(pCardData, 0,
+							  "CardDeriveKey: invalid seed size %lu\n",
+							  buffer->cbBuffer);
 						return SCARD_E_INVALID_PARAMETER;
 					}
 					pbSeed = (PBYTE)buffer->pvBuffer;
@@ -4389,7 +4611,9 @@ DWORD WINAPI CardDeriveKey(__in PCARD_DATA pCardData,
 				case KDF_SUPPPRIVINFO:
 					break;*/
 				default:
-					logprintf(pCardData, 0, "CardDeriveKey: unknown buffer type %u\n", (parameters->pBuffers + i)->BufferType);
+					logprintf(pCardData, 0,
+						  "CardDeriveKey: unknown buffer type %lu\n",
+						  (parameters->pBuffers + i)->BufferType);
 					return SCARD_E_INVALID_PARAMETER;
 			}
 		}
@@ -4398,7 +4622,7 @@ DWORD WINAPI CardDeriveKey(__in PCARD_DATA pCardData,
 	if (szAlgorithm == NULL && wcscmp(pAgreementInfo->pwszKDF, BCRYPT_KDF_TLS_PRF) != 0) {
 		szAlgorithm = BCRYPT_SHA1_ALGORITHM;
 	}
-	
+
 	/* check the values with the KDF choosen */
 	if (wcscmp(pAgreementInfo->pwszKDF, BCRYPT_KDF_HASH) == 0) {
 	}
@@ -4425,17 +4649,21 @@ DWORD WINAPI CardDeriveKey(__in PCARD_DATA pCardData,
 	/* do the job for the KDF Hash & Hmac */
 	if (wcscmp(pAgreementInfo->pwszKDF, BCRYPT_KDF_HASH) == 0 ||
 		wcscmp(pAgreementInfo->pwszKDF, BCRYPT_KDF_HMAC) == 0 ) {
-		
+
 		dwReturn = CardDeriveHashOrHMAC(pCardData, pAgreementInfo, agreement, szAlgorithm, pbHmacKey, dwHmacKeySize);
 		if (dwReturn) {
-			logprintf(pCardData, 0, "CardDeriveKey: got an error while deriving the Key (hash or HMAC) 0x%08X\n", dwReturn);
+			logprintf(pCardData, 0,
+				  "CardDeriveKey: got an error while deriving the Key (hash or HMAC) 0x%08X\n",
+				  (unsigned int)dwReturn);
 			return dwReturn;
 		}
 
 	} else if (wcscmp(pAgreementInfo->pwszKDF, BCRYPT_KDF_TLS_PRF) == 0) {
 		dwReturn = CardDeriveTlsPrf(pCardData, pAgreementInfo, agreement, dwProtocol, szAlgorithm, pbLabel, dwLabelSize, pbSeed);
 		if (dwReturn) {
-			logprintf(pCardData, 0, "CardDeriveKey: got an error while deriving the Key (TlsPrf) 0x%08X\n", dwReturn);
+			logprintf(pCardData, 0,
+				  "CardDeriveKey: got an error while deriving the Key (TlsPrf) 0x%08X\n",
+				  (unsigned int)dwReturn);
 			return dwReturn;
 		}
 	}
@@ -4455,7 +4683,9 @@ DWORD WINAPI CardDestroyDHAgreement(
 	VENDOR_SPECIFIC *vs;
 	struct md_dh_agreement* agreement = NULL;
 
-	logprintf(pCardData, 1, "\nP:%d T:%d pCardData:%p ",GetCurrentProcessId(), GetCurrentThreadId(), pCardData);
+	logprintf(pCardData, 1, "\nP:%lu T:%lu pCardData:%p ",
+		  (unsigned long)GetCurrentProcessId(),
+		  (unsigned long)GetCurrentThreadId(), pCardData);
 	logprintf(pCardData, 1, "CardDestroyDHAgreement\n");
 	if (!pCardData)
 		return SCARD_E_INVALID_PARAMETER;
@@ -4484,7 +4714,9 @@ DWORD WINAPI CardGetChallengeEx(__in PCARD_DATA pCardData,
 	__out PDWORD pcbChallengeData,
 	__in DWORD dwFlags)
 {
-	logprintf(pCardData, 1, "\nP:%d T:%d pCardData:%p ",GetCurrentProcessId(), GetCurrentThreadId(), pCardData);
+	logprintf(pCardData, 1, "\nP:%lu T:%lu pCardData:%p ",
+		  (unsigned long)GetCurrentProcessId(),
+		  (unsigned long)GetCurrentThreadId(), pCardData);
 	logprintf(pCardData, 1, "CardGetChallengeEx - unsupported\n");
 	return SCARD_E_UNSUPPORTED_FEATURE;
 }
@@ -4504,14 +4736,18 @@ DWORD WINAPI CardAuthenticateEx(__in PCARD_DATA pCardData,
 	int r;
 	BOOL DisplayPinpadUI = FALSE;
 
-	logprintf(pCardData, 1, "\nP:%d T:%d pCardData:%p ",GetCurrentProcessId(), GetCurrentThreadId(), pCardData);
+	logprintf(pCardData, 1, "\nP:%lu T:%lu pCardData:%p ",
+		  (unsigned long)GetCurrentProcessId(),
+		  (unsigned long)GetCurrentThreadId(), pCardData);
 	logprintf(pCardData, 1, "CardAuthenticateEx\n");
 
 	if (!pCardData)
 		return SCARD_E_INVALID_PARAMETER;
 
-	logprintf(pCardData, 2, "CardAuthenticateEx: PinId=%u, dwFlags=0x%08X, cbPinData=%u, Attempts %s\n",
-		PinId, dwFlags, cbPinData, pcAttemptsRemaining ? "YES" : "NO");
+	logprintf(pCardData, 2,
+		  "CardAuthenticateEx: PinId=%u, dwFlags=0x%08X, cbPinData=%lu, Attempts %s\n",
+		  (unsigned int)PinId, (unsigned int)dwFlags,
+		  (unsigned long)cbPinData, pcAttemptsRemaining ? "YES" : "NO");
 
 	vs = (VENDOR_SPECIFIC*)(pCardData->pvVendorSpecific);
 
@@ -4617,7 +4853,9 @@ DWORD WINAPI CardChangeAuthenticatorEx(__in PCARD_DATA pCardData,
 	struct sc_pkcs15_auth_info *auth_info;
 	BOOL DisplayPinpadUI = FALSE;
 
-	logprintf(pCardData, 1, "\nP:%d T:%d pCardData:%p ",GetCurrentProcessId(), GetCurrentThreadId(), pCardData);
+	logprintf(pCardData, 1, "\nP:%lu T:%lu pCardData:%p ",
+		  (unsigned long)GetCurrentProcessId(),
+		  (unsigned long)GetCurrentThreadId(), pCardData);
 	logprintf(pCardData, 1, "CardChangeAuthenticatorEx\n");
 
 	if (!pCardData)
@@ -4640,8 +4878,12 @@ DWORD WINAPI CardChangeAuthenticatorEx(__in PCARD_DATA pCardData,
 	if (cRetryCount)
 		return SCARD_E_INVALID_PARAMETER;
 
-	logprintf(pCardData, 2, "CardChangeAuthenticatorEx: AuthenticatingPinId=%u, dwFlags=0x%08X, cbAuthenticatingPinData=%u, TargetPinId=%u, cbTargetData=%u, Attempts %s\n",
-		dwAuthenticatingPinId, dwFlags, cbAuthenticatingPinData, dwTargetPinId, cbTargetData, pcAttemptsRemaining ? "YES" : "NO");
+	logprintf(pCardData, 2,
+		  "CardChangeAuthenticatorEx: AuthenticatingPinId=%u, dwFlags=0x%08X, cbAuthenticatingPinData=%lu, TargetPinId=%u, cbTargetData=%lu, Attempts %s\n",
+		  (unsigned int)dwAuthenticatingPinId, (unsigned int)dwFlags,
+		  (unsigned long)cbAuthenticatingPinData,
+		  (unsigned int)dwTargetPinId, (unsigned long)cbTargetData,
+		  pcAttemptsRemaining ? "YES" : "NO");
 
 
 	check_reader_status(pCardData);
@@ -4706,8 +4948,12 @@ DWORD WINAPI CardDeauthenticateEx(__in PCARD_DATA pCardData,
 	__in DWORD dwFlags)
 {
 
-	logprintf(pCardData, 1, "\nP:%d T:%d pCardData:%p ",GetCurrentProcessId(), GetCurrentThreadId(), pCardData);
-	logprintf(pCardData, 1, "CardDeauthenticateEx PinId=%d dwFlags=0x%08X\n",PinId, dwFlags);
+	logprintf(pCardData, 1, "\nP:%lu T:%lu pCardData:%p ",
+		  (unsigned long)GetCurrentProcessId(),
+		  (unsigned long)GetCurrentThreadId(), pCardData);
+	logprintf(pCardData, 1,
+		  "CardDeauthenticateEx PinId=%u dwFlags=0x%08X\n",
+		  (unsigned int)PinId, (unsigned int)dwFlags);
 
 	return CardDeauthenticate(pCardData, wszCARD_USER_USER, 0);
 }
@@ -4723,14 +4969,18 @@ DWORD WINAPI CardGetContainerProperty(__in PCARD_DATA pCardData,
 	VENDOR_SPECIFIC *vs = NULL;
 	struct md_pkcs15_container *cont = NULL;
 
-	logprintf(pCardData, 1, "\nP:%d T:%d pCardData:%p ",GetCurrentProcessId(), GetCurrentThreadId(), pCardData);
+	logprintf(pCardData, 1, "\nP:%lu T:%lu pCardData:%p ",
+		  (unsigned long)GetCurrentProcessId(),
+		  (unsigned long)GetCurrentThreadId(), pCardData);
 	logprintf(pCardData, 1, "CardGetContainerProperty\n");
 
 	check_reader_status(pCardData);
 
 	if (!pCardData) return SCARD_E_INVALID_PARAMETER;
-	logprintf(pCardData, 2, "CardGetContainerProperty bContainerIndex=%u, wszProperty=%S," \
-		"cbData=%u, dwFlags=0x%08X\n",bContainerIndex,NULLWSTR(wszProperty),cbData,dwFlags);
+	logprintf(pCardData, 2,
+		  "CardGetContainerProperty bContainerIndex=%u, wszProperty=%S, cbData=%lu, dwFlags=0x%08X\n",
+		  (unsigned int)bContainerIndex, NULLWSTR(wszProperty),
+		  (unsigned long)cbData, (unsigned int)dwFlags);
 	if (!wszProperty)
 		return SCARD_E_INVALID_PARAMETER;
 	if (dwFlags)
@@ -4745,7 +4995,8 @@ DWORD WINAPI CardGetContainerProperty(__in PCARD_DATA pCardData,
 	cont = &vs->p15_containers[bContainerIndex];
 
 	if (!cont->prkey_obj)   {
-		logprintf(pCardData, 7, "Container %i is empty\n", bContainerIndex);
+		logprintf(pCardData, 7, "Container %u is empty\n",
+			  (unsigned int)bContainerIndex);
 		return SCARD_E_NO_KEY_CONTAINER;
 	}
 
@@ -4767,7 +5018,8 @@ DWORD WINAPI CardGetContainerProperty(__in PCARD_DATA pCardData,
 		if (cbData < sizeof(*p))
 			return ERROR_INSUFFICIENT_BUFFER;
 		*p = ROLE_USER;
-		logprintf(pCardData, 2,"Return Pin id %u\n",*p);
+		logprintf(pCardData, 2, "Return Pin id %u\n",
+			  (unsigned int)*p);
 		return SCARD_S_SUCCESS;
 	}
 
@@ -4781,7 +5033,9 @@ DWORD WINAPI CardSetContainerProperty(__in PCARD_DATA pCardData,
 	__in DWORD cbDataLen,
 	__in DWORD dwFlags)
 {
-	logprintf(pCardData, 1, "\nP:%d T:%d pCardData:%p ",GetCurrentProcessId(), GetCurrentThreadId(), pCardData);
+	logprintf(pCardData, 1, "\nP:%lu T:%lu pCardData:%p ",
+		  (unsigned long)GetCurrentProcessId(),
+		  (unsigned long)GetCurrentThreadId(), pCardData);
 	logprintf(pCardData, 1, "CardSetContainerProperty - unsupported\n");
 	return SCARD_E_UNSUPPORTED_FEATURE;
 }
@@ -4797,8 +5051,13 @@ DWORD WINAPI CardGetProperty(__in PCARD_DATA pCardData,
 	VENDOR_SPECIFIC *vs;
 	DWORD dwret;
 
-	logprintf(pCardData, 1, "\nP:%d T:%d pCardData:%p ",GetCurrentProcessId(), GetCurrentThreadId(), pCardData);
-	logprintf(pCardData, 2, "CardGetProperty('%S',cbData=%u,dwFlags=%u) called\n", NULLWSTR(wszProperty),cbData,dwFlags);
+	logprintf(pCardData, 1, "\nP:%lu T:%lu pCardData:%p ",
+		  (unsigned long)GetCurrentProcessId(),
+		  (unsigned long)GetCurrentThreadId(), pCardData);
+	logprintf(pCardData, 2,
+		  "CardGetProperty('%S',cbData=%lu,dwFlags=%lu) called\n",
+		  NULLWSTR(wszProperty), (unsigned long)cbData,
+		  (unsigned long)dwFlags);
 
 	if (!pCardData || !wszProperty)
 		return SCARD_E_INVALID_PARAMETER;
@@ -4920,7 +5179,9 @@ DWORD WINAPI CardGetProperty(__in PCARD_DATA pCardData,
 		p->dwFlags = 0;
 		switch (dwFlags)   {
 			case ROLE_USER:
-				logprintf(pCardData, 2,"returning info on PIN ROLE_USER ( Auth ) [%u]\n",dwFlags);
+				logprintf(pCardData, 2,
+					  "returning info on PIN ROLE_USER ( Auth ) [%lu]\n",
+					  (unsigned long)dwFlags);
 				p->PinPurpose = DigitalSignaturePin;
 				p->PinCachePolicy.dwVersion = PIN_CACHE_POLICY_CURRENT_VERSION;
 				p->PinCachePolicy.dwPinCachePolicyInfo = 0;
@@ -4929,7 +5190,9 @@ DWORD WINAPI CardGetProperty(__in PCARD_DATA pCardData,
 				p->dwUnblockPermission = CREATE_PIN_SET(ROLE_ADMIN);
 				break;
 			case ROLE_ADMIN:
-				logprintf(pCardData, 2,"returning info on PIN ROLE_ADMIN ( Unblock ) [%u]\n",dwFlags);
+				logprintf(pCardData, 2,
+					  "returning info on PIN ROLE_ADMIN ( Unblock ) [%lu]\n",
+					  (unsigned long)dwFlags);
 				p->PinPurpose = UnblockOnlyPin;
 				p->PinCachePolicy.dwVersion = PIN_CACHE_POLICY_CURRENT_VERSION;
 				p->PinCachePolicy.dwPinCachePolicyInfo = 0;
@@ -4938,7 +5201,9 @@ DWORD WINAPI CardGetProperty(__in PCARD_DATA pCardData,
 				p->dwUnblockPermission = 0;
 				break;
 			default:
-				logprintf(pCardData, 0,"Invalid Pin number %u requested\n",dwFlags);
+				logprintf(pCardData, 0,
+					  "Invalid Pin number %lu requested\n",
+					  (unsigned long)dwFlags);
 				return SCARD_E_INVALID_PARAMETER;
 		}
 	}
@@ -5013,14 +5278,18 @@ DWORD WINAPI CardSetProperty(__in   PCARD_DATA pCardData,
 {
 	VENDOR_SPECIFIC *vs;
 
-	logprintf(pCardData, 1, "\nP:%d T:%d pCardData:%p ",GetCurrentProcessId(), GetCurrentThreadId(), pCardData);
+	logprintf(pCardData, 1, "\nP:%lu T:%lu pCardData:%p ",
+		  (unsigned long)GetCurrentProcessId(),
+		  (unsigned long)GetCurrentThreadId(), pCardData);
 	logprintf(pCardData, 1, "CardSetProperty\n");
 
 	if (!pCardData)
 		return SCARD_E_INVALID_PARAMETER;
 
-	logprintf(pCardData, 2, "CardSetProperty wszProperty=%S, pbData=%p, cbDataLen=%u, dwFlags=%u",\
-		NULLWSTR(wszProperty),pbData,cbDataLen,dwFlags);
+	logprintf(pCardData, 2,
+		  "CardSetProperty wszProperty=%S, pbData=%p, cbDataLen=%lu, dwFlags=%lu",
+		  NULLWSTR(wszProperty), pbData, (unsigned long)cbDataLen,
+		  (unsigned long)dwFlags);
 
 	vs = (VENDOR_SPECIFIC*)(pCardData->pvVendorSpecific);
 
@@ -5113,7 +5382,9 @@ DWORD WINAPI CardImportSessionKey(
 	UNREFERENCED_PARAMETER(pbInput);
 	UNREFERENCED_PARAMETER(cbInput);
 	UNREFERENCED_PARAMETER(dwFlags);
-	logprintf(pCardData, 1, "\nP:%d T:%d pCardData:%p ",GetCurrentProcessId(), GetCurrentThreadId(), pCardData);
+	logprintf(pCardData, 1, "\nP:%lu T:%lu pCardData:%p ",
+		  (unsigned long)GetCurrentProcessId(),
+		  (unsigned long)GetCurrentThreadId(), pCardData);
 	logprintf(pCardData, 1, "CardImportSessionKey - unsupported\n");
 	return SCARD_E_UNSUPPORTED_FEATURE;
 }
@@ -5136,7 +5407,9 @@ DWORD WINAPI MDImportSessionKey(
 	UNREFERENCED_PARAMETER(phKey);
 	UNREFERENCED_PARAMETER(pbInput);
 	UNREFERENCED_PARAMETER(cbInput);
-	logprintf(pCardData, 1, "\nP:%d T:%d pCardData:%p ",GetCurrentProcessId(), GetCurrentThreadId(), pCardData);
+	logprintf(pCardData, 1, "\nP:%lu T:%lu pCardData:%p ",
+		  (unsigned long)GetCurrentProcessId(),
+		  (unsigned long)GetCurrentThreadId(), pCardData);
 	logprintf(pCardData, 1, "MDImportSessionKey - unsupported\n");
 	return SCARD_E_UNSUPPORTED_FEATURE;
 }
@@ -5164,7 +5437,9 @@ DWORD WINAPI MDEncryptData(
 	UNREFERENCED_PARAMETER(dwFlags);
 	UNREFERENCED_PARAMETER(ppEncryptedData);
 	UNREFERENCED_PARAMETER(pcEncryptedData);
-	logprintf(pCardData, 1, "\nP:%d T:%d pCardData:%p ",GetCurrentProcessId(), GetCurrentThreadId(), pCardData);
+	logprintf(pCardData, 1, "\nP:%lu T:%lu pCardData:%p ",
+		  (unsigned long)GetCurrentProcessId(),
+		  (unsigned long)GetCurrentThreadId(), pCardData);
 	logprintf(pCardData, 1, "MDEncryptData - unsupported\n");
 	return SCARD_E_UNSUPPORTED_FEATURE;
 }
@@ -5192,7 +5467,9 @@ DWORD WINAPI CardGetSharedKeyHandle(
 	UNREFERENCED_PARAMETER(ppbOutput);
 	UNREFERENCED_PARAMETER(pcbOutput);
 	UNREFERENCED_PARAMETER(phKey);
-	logprintf(pCardData, 1, "\nP:%d T:%d pCardData:%p ",GetCurrentProcessId(), GetCurrentThreadId(), pCardData);
+	logprintf(pCardData, 1, "\nP:%lu T:%lu pCardData:%p ",
+		  (unsigned long)GetCurrentProcessId(),
+		  (unsigned long)GetCurrentThreadId(), pCardData);
 	logprintf(pCardData, 1, "CardGetSharedKeyHandle - unsupported\n");
 	return SCARD_E_UNSUPPORTED_FEATURE;
 }
@@ -5207,7 +5484,9 @@ DWORD WINAPI CardDestroyKey(
 {
 	UNREFERENCED_PARAMETER(pCardData);
 	UNREFERENCED_PARAMETER(hKey);
-	logprintf(pCardData, 1, "\nP:%d T:%d pCardData:%p ",GetCurrentProcessId(), GetCurrentThreadId(), pCardData);
+	logprintf(pCardData, 1, "\nP:%lu T:%lu pCardData:%p ",
+		  (unsigned long)GetCurrentProcessId(),
+		  (unsigned long)GetCurrentThreadId(), pCardData);
 	logprintf(pCardData, 1, "CardDestroyKey - unsupported\n");
 	return SCARD_E_UNSUPPORTED_FEATURE;
 }
@@ -5231,7 +5510,9 @@ DWORD WINAPI CardGetAlgorithmProperty (
 	UNREFERENCED_PARAMETER(cbData);
 	UNREFERENCED_PARAMETER(pdwDataLen);
 	UNREFERENCED_PARAMETER(dwFlags);
-	logprintf(pCardData, 1, "\nP:%d T:%d pCardData:%p ",GetCurrentProcessId(), GetCurrentThreadId(), pCardData);
+	logprintf(pCardData, 1, "\nP:%lu T:%lu pCardData:%p ",
+		  (unsigned long)GetCurrentProcessId(),
+		  (unsigned long)GetCurrentThreadId(), pCardData);
 	logprintf(pCardData, 1, "CardGetAlgorithmProperty - unsupported\n");
 	return SCARD_E_UNSUPPORTED_FEATURE;
 }
@@ -5254,7 +5535,9 @@ DWORD WINAPI CardGetKeyProperty(
 	UNREFERENCED_PARAMETER(cbData);
 	UNREFERENCED_PARAMETER(pdwDataLen);
 	UNREFERENCED_PARAMETER(dwFlags);
-	logprintf(pCardData, 1, "\nP:%d T:%d pCardData:%p ",GetCurrentProcessId(), GetCurrentThreadId(), pCardData);
+	logprintf(pCardData, 1, "\nP:%lu T:%lu pCardData:%p ",
+		  (unsigned long)GetCurrentProcessId(),
+		  (unsigned long)GetCurrentThreadId(), pCardData);
 	logprintf(pCardData, 1, "CardGetKeyProperty - unsupported\n");
 	return SCARD_E_UNSUPPORTED_FEATURE;
 }
@@ -5276,7 +5559,9 @@ DWORD WINAPI CardSetKeyProperty(
 	UNREFERENCED_PARAMETER(pbInput);
 	UNREFERENCED_PARAMETER(cbInput);
 	UNREFERENCED_PARAMETER(dwFlags);
-	logprintf(pCardData, 1, "\nP:%d T:%d pCardData:%p ",GetCurrentProcessId(), GetCurrentThreadId(), pCardData);
+	logprintf(pCardData, 1, "\nP:%lu T:%lu pCardData:%p ",
+		  (unsigned long)GetCurrentProcessId(),
+		  (unsigned long)GetCurrentThreadId(), pCardData);
 	logprintf(pCardData, 1, "CardSetKeyProperty - unsupported\n");
 	return SCARD_E_UNSUPPORTED_FEATURE;
 }
@@ -5307,7 +5592,9 @@ DWORD WINAPI CardProcessEncryptedData(
 	UNREFERENCED_PARAMETER(cbOutput);
 	UNREFERENCED_PARAMETER(pdwOutputLen);
 	UNREFERENCED_PARAMETER(dwFlags);
-	logprintf(pCardData, 1, "\nP:%d T:%d pCardData:%p ",GetCurrentProcessId(), GetCurrentThreadId(), pCardData);
+	logprintf(pCardData, 1, "\nP:%lu T:%lu pCardData:%p ",
+		  (unsigned long)GetCurrentProcessId(),
+		  (unsigned long)GetCurrentThreadId(), pCardData);
 	logprintf(pCardData, 1, "CardProcessEncryptedData - unsupported\n");
 	return SCARD_E_UNSUPPORTED_FEATURE;
 }
@@ -5387,22 +5674,30 @@ DWORD WINAPI CardAcquireContext(__inout PCARD_DATA pCardData, __in DWORD dwFlags
 		return (DWORD) ERROR_REVISION_MISMATCH;
 
 	suppliedVersion = pCardData->dwVersion;
-	
+
 	/* VENDOR SPECIFIC */
 	vs = pCardData->pvVendorSpecific = pCardData->pfnCspAlloc(sizeof(VENDOR_SPECIFIC));
 	memset(vs, 0, sizeof(VENDOR_SPECIFIC));
 
 	logprintf(pCardData, 1, "==================================================================\n");
-	logprintf(pCardData, 1, "\nP:%d T:%d pCardData:%p ",GetCurrentProcessId(), GetCurrentThreadId(), pCardData);
-	logprintf(pCardData, 1, "CardAcquireContext, dwVersion=%u, name=%S,hScard=0x%08X, hSCardCtx=0x%08X\n",
-			pCardData->dwVersion, NULLWSTR(pCardData->pwszCardName),pCardData->hScard, pCardData->hSCardCtx);
+	logprintf(pCardData, 1, "\nP:%lu T:%lu pCardData:%p ",
+		  (unsigned long)GetCurrentProcessId(),
+		  (unsigned long)GetCurrentThreadId(), pCardData);
+	logprintf(pCardData, 1,
+		  "CardAcquireContext, dwVersion=%lu, name=%S,hScard=0x%08X, hSCardCtx=0x%08X\n",
+		  (unsigned long)pCardData->dwVersion,
+		  NULLWSTR(pCardData->pwszCardName),
+		  (unsigned int)pCardData->hScard,
+		  (unsigned int)pCardData->hSCardCtx);
 
 	vs->hScard = pCardData->hScard;
 	vs->hSCardCtx = pCardData->hSCardCtx;
 
-	logprintf(pCardData, 2, "request version pCardData->dwVersion = %d\n", pCardData->dwVersion);
+	logprintf(pCardData, 2, "request version pCardData->dwVersion = %lu\n",
+		  (unsigned long)pCardData->dwVersion);
 	pCardData->dwVersion = min(pCardData->dwVersion, MD_CURRENT_VERSION_SUPPORTED);
-	logprintf(pCardData, 2, "pCardData->dwVersion = %d\n", pCardData->dwVersion);
+	logprintf(pCardData, 2, "pCardData->dwVersion = %lu\n",
+		  (unsigned long)pCardData->dwVersion);
 
 	dwret = md_create_context(pCardData, vs);
 	if (dwret != SCARD_S_SUCCESS) {
@@ -5454,7 +5749,9 @@ DWORD WINAPI CardAcquireContext(__inout PCARD_DATA pCardData, __in DWORD dwFlags
 	}
 
 	logprintf(pCardData, 1, "OpenSC init done.\n");
-	logprintf(pCardData, 1, "Supplied version %u - version used %u.\n", suppliedVersion, pCardData->dwVersion);
+	logprintf(pCardData, 1, "Supplied version %lu - version used %lu.\n",
+		  (unsigned long)suppliedVersion,
+		  (unsigned long)pCardData->dwVersion);
 
 	if (pCardData->dwVersion >= CARD_DATA_VERSION_FIVE) {
 		pCardData->pfnCardDeriveKey = CardDeriveKey;
@@ -5624,8 +5921,11 @@ BOOL APIENTRY DllMain( HINSTANCE hinstDLL,
 		break;
 	}
 
-	logprintf(NULL,8,"\n********** DllMain Module(handle:0x%p) '%s'; reason='%s'; Reserved=%p; P:%d; T:%d\n",
-			hinstDLL, name, reason, lpReserved, GetCurrentProcessId(), GetCurrentThreadId());
+	logprintf(NULL, 8,
+		  "\n********** DllMain Module(handle:0x%p) '%s'; reason='%s'; Reserved=%p; P:%lu; T:%lu\n",
+		  hinstDLL, name, reason, lpReserved,
+		  (unsigned long)GetCurrentProcessId(),
+		  (unsigned long)GetCurrentThreadId());
 	switch (ul_reason_for_call)
 	{
 	case DLL_PROCESS_ATTACH:

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



More information about the pkg-opensc-commit mailing list