[REACTOS] Fix MSVC printf format warnings

This commit is contained in:
Timo Kreuzer 2018-08-20 17:42:27 +02:00
parent b8a1a612b2
commit 58588b76e2
17 changed files with 35 additions and 35 deletions

View file

@ -352,7 +352,7 @@ ValidateSizes(ULONG Length, DWORD ProcCount, DWORD BytesRead, DWORD SpecificSize
/* Check whether this covers a specific entry and a generic entry for every processor */ /* Check whether this covers a specific entry and a generic entry for every processor */
if ((sizeof(FILESYSTEM_STATISTICS) + SpecificSize) * ProcCount > BytesRead) if ((sizeof(FILESYSTEM_STATISTICS) + SpecificSize) * ProcCount > BytesRead)
{ {
_ftprintf(stderr, _T("Only performed a partial read: %lu (expected: %lu)\n"), BytesRead, (sizeof(FILESYSTEM_STATISTICS) + SpecificSize)); _ftprintf(stderr, _T("Only performed a partial read: %lu (expected: %Iu)\n"), BytesRead, (sizeof(FILESYSTEM_STATISTICS) + SpecificSize));
return 1; return 1;
} }

View file

@ -28,7 +28,7 @@ VOID DisplayWin32ErrorDbg(DWORD dwErrorCode, const char *file, int line)
VOID DisplayWin32Error(DWORD dwErrorCode) VOID DisplayWin32Error(DWORD dwErrorCode)
#endif #endif
{ {
LPVOID lpMsgBuf; PWSTR lpMsgBuf;
#if DBG #if DBG
WCHAR szMsg[255]; WCHAR szMsg[255];
#endif #endif
@ -44,7 +44,7 @@ VOID DisplayWin32Error(DWORD dwErrorCode)
NULL ); NULL );
#if DBG #if DBG
if (swprintf(szMsg, L"%hs:%d: %s", file, line, lpMsgBuf)) if (swprintf(szMsg, L"%hs:%d: %s", file, line, (PWSTR)lpMsgBuf))
{ {
MessageBoxW(NULL, szMsg, NULL, MB_OK | MB_ICONERROR); MessageBoxW(NULL, szMsg, NULL, MB_OK | MB_ICONERROR);
} }

View file

@ -724,13 +724,13 @@ Return Value:
if((Pdo->Characteristics & FILE_REMOVABLE_MEDIA) == 0) { if((Pdo->Characteristics & FILE_REMOVABLE_MEDIA) == 0) {
if (diskData->PartitionStyle == PARTITION_STYLE_MBR) { if (diskData->PartitionStyle == PARTITION_STYLE_MBR) {
sprintf(string, "S%08lx_O%I64lx_L%I64lx", sprintf(string, "S%08lx_O%I64x_L%I64x",
diskData->Mbr.Signature, diskData->Mbr.Signature,
commonExtension->StartingOffset, commonExtension->StartingOffset.QuadPart,
commonExtension->PartitionLength); commonExtension->PartitionLength.QuadPart);
} else { } else {
sprintf(string, sprintf(string,
"S%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02xS_O%I64lx_L%I64lx", "S%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02xS_O%I64x_L%I64x",
diskData->Efi.DiskId.Data1, diskData->Efi.DiskId.Data1,
diskData->Efi.DiskId.Data2, diskData->Efi.DiskId.Data2,
diskData->Efi.DiskId.Data3, diskData->Efi.DiskId.Data3,
@ -742,8 +742,8 @@ Return Value:
diskData->Efi.DiskId.Data4[5], diskData->Efi.DiskId.Data4[5],
diskData->Efi.DiskId.Data4[6], diskData->Efi.DiskId.Data4[6],
diskData->Efi.DiskId.Data4[7], diskData->Efi.DiskId.Data4[7],
commonExtension->StartingOffset, commonExtension->StartingOffset.QuadPart,
commonExtension->PartitionLength); commonExtension->PartitionLength.QuadPart);
} }
} else { } else {
sprintf(string, "RM"); sprintf(string, "RM");

View file

@ -110,7 +110,7 @@ TestKs()
// Allocate a KS Pin Connection Request Structure // Allocate a KS Pin Connection Request Structure
// //
Length = sizeof(KSPIN_CONNECT) + sizeof(KSDATAFORMAT_WAVEFORMATEX); Length = sizeof(KSPIN_CONNECT) + sizeof(KSDATAFORMAT_WAVEFORMATEX);
printf("Length %ld KSPIN %u DATAFORMAT %u\n", Length, sizeof(KSPIN_CONNECT), sizeof(KSDATAFORMAT_WAVEFORMATEX)); printf("Length %ld KSPIN %Iu DATAFORMAT %Iu\n", Length, sizeof(KSPIN_CONNECT), sizeof(KSDATAFORMAT_WAVEFORMATEX));
PinConnect = (PKSPIN_CONNECT)HeapAlloc(GetProcessHeap(), 0, Length); PinConnect = (PKSPIN_CONNECT)HeapAlloc(GetProcessHeap(), 0, Length);
DataFormat = (PKSDATAFORMAT_WAVEFORMATEX)(PinConnect + 1); DataFormat = (PKSDATAFORMAT_WAVEFORMATEX)(PinConnect + 1);

View file

@ -362,7 +362,7 @@ _tmain(int argc, const TCHAR *argv[])
hFile = CreateFile(argv[3], FILE_READ_DATA, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); hFile = CreateFile(argv[3], FILE_READ_DATA, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile == INVALID_HANDLE_VALUE) if (hFile == INVALID_HANDLE_VALUE)
{ {
_ftprintf(stderr, _T("Failed to open file: %s\n"), GetLastError()); _ftprintf(stderr, _T("Failed to open file: %lu\n"), GetLastError());
return 1; return 1;
} }

View file

@ -164,7 +164,7 @@ static BOOL CALLBACK cb_AddPage(HPROPSHEETPAGE page, LPARAM lParam)
g_Pages.Add(page); g_Pages.Add(page);
if (lParam != (LPARAM)&g_Pages) if (lParam != (LPARAM)&g_Pages)
{ {
wprintf(L"Propsheet failed to pass lParam, got: 0x%x\n", lParam); wprintf(L"Propsheet failed to pass lParam, got: 0x%Ix\n", lParam);
} }
return TRUE; return TRUE;
} }

View file

@ -417,7 +417,7 @@ SOCKET make_listening_socket( int port ) {
fprintf( stderr, "Creating the listener\n" ); fprintf( stderr, "Creating the listener\n" );
SOCKET l = socket( PF_INET, SOCK_STREAM, 0 ); SOCKET l = socket( PF_INET, SOCK_STREAM, 0 );
fprintf( stderr, "Socket %x\n", l ); fprintf( stderr, "Socket %I64x\n", l );
if( l == INVALID_SOCKET ) return l; if( l == INVALID_SOCKET ) return l;
if( bind( l, (struct sockaddr *)&sa, sizeof( sa ) ) < 0 ) { if( bind( l, (struct sockaddr *)&sa, sizeof( sa ) ) < 0 ) {

View file

@ -618,7 +618,7 @@ _tmain(int argc, const TCHAR *argv[])
OutputBuffer = HeapAlloc(GetProcessHeap(), 0, VolumeInfo.BytesPerFileRecordSegment + sizeof(NTFS_FILE_RECORD_OUTPUT_BUFFER)); OutputBuffer = HeapAlloc(GetProcessHeap(), 0, VolumeInfo.BytesPerFileRecordSegment + sizeof(NTFS_FILE_RECORD_OUTPUT_BUFFER));
if (OutputBuffer == NULL) if (OutputBuffer == NULL)
{ {
_ftprintf(stderr, _T("Failed to allocate %x bytes\n"), VolumeInfo.BytesPerFileRecordSegment + sizeof(NTFS_FILE_RECORD_OUTPUT_BUFFER)); _ftprintf(stderr, _T("Failed to allocate %Ix bytes\n"), VolumeInfo.BytesPerFileRecordSegment + sizeof(NTFS_FILE_RECORD_OUTPUT_BUFFER));
CloseHandle(VolumeHandle); CloseHandle(VolumeHandle);
return 1; return 1;
} }

View file

@ -135,7 +135,7 @@ _tmain(int argc, const TCHAR *argv[])
_tprintf(_T("Total sectors\t\t: %I64u\n"), VolumeInfo.NumberSectors.QuadPart); _tprintf(_T("Total sectors\t\t: %I64u\n"), VolumeInfo.NumberSectors.QuadPart);
_tprintf(_T("Total clusters\t\t: %I64u\n"), VolumeInfo.TotalClusters.QuadPart); _tprintf(_T("Total clusters\t\t: %I64u\n"), VolumeInfo.TotalClusters.QuadPart);
_tprintf(_T("Free clusters\t\t: %I64u\n"), VolumeInfo.FreeClusters.QuadPart); _tprintf(_T("Free clusters\t\t: %I64u\n"), VolumeInfo.FreeClusters.QuadPart);
_tprintf(_T("Free space\t\t: %I64u MB (%u%% of drive)\n"), (VolumeInfo.FreeClusters.QuadPart * VolumeInfo.BytesPerCluster) >> 20, (VolumeInfo.FreeClusters.QuadPart * 100) / VolumeInfo.TotalClusters.QuadPart); _tprintf(_T("Free space\t\t: %I64u MB (%I64u%% of drive)\n"), (VolumeInfo.FreeClusters.QuadPart * VolumeInfo.BytesPerCluster) >> 20, (VolumeInfo.FreeClusters.QuadPart * 100) / VolumeInfo.TotalClusters.QuadPart);
_tprintf(_T("\nAllocation Size\n---------------\n")); _tprintf(_T("\nAllocation Size\n---------------\n"));
_tprintf(_T("Bytes per sector\t: %lu\n"), VolumeInfo.BytesPerSector); _tprintf(_T("Bytes per sector\t: %lu\n"), VolumeInfo.BytesPerSector);
@ -144,11 +144,11 @@ _tmain(int argc, const TCHAR *argv[])
_tprintf(_T("Clusters per MFT record\t: %lu\n"), VolumeInfo.ClustersPerFileRecordSegment); _tprintf(_T("Clusters per MFT record\t: %lu\n"), VolumeInfo.ClustersPerFileRecordSegment);
_tprintf(_T("\nMFT Information\n---------------\n")); _tprintf(_T("\nMFT Information\n---------------\n"));
_tprintf(_T("MFT size\t\t: %I64u MB (%u%% of drive)\n"), VolumeInfo.MftValidDataLength.QuadPart >> 20, (VolumeInfo.MftValidDataLength.QuadPart * 100) / VolumeSize); _tprintf(_T("MFT size\t\t: %I64u MB (%I64u%% of drive)\n"), VolumeInfo.MftValidDataLength.QuadPart >> 20, (VolumeInfo.MftValidDataLength.QuadPart * 100) / VolumeSize);
_tprintf(_T("MFT start cluster\t: %I64u\n"), VolumeInfo.MftStartLcn.QuadPart); _tprintf(_T("MFT start cluster\t: %I64u\n"), VolumeInfo.MftStartLcn.QuadPart);
_tprintf(_T("MFT zone clusters\t: %I64u - %I64u\n"), VolumeInfo.MftZoneStart.QuadPart, VolumeInfo.MftZoneEnd.QuadPart); _tprintf(_T("MFT zone clusters\t: %I64u - %I64u\n"), VolumeInfo.MftZoneStart.QuadPart, VolumeInfo.MftZoneEnd.QuadPart);
MftClusters = VolumeInfo.MftZoneEnd.QuadPart - VolumeInfo.MftZoneStart.QuadPart; MftClusters = VolumeInfo.MftZoneEnd.QuadPart - VolumeInfo.MftZoneStart.QuadPart;
_tprintf(_T("MFT zone size\t\t: %I64u MB (%u%% of drive)\n"), (MftClusters * VolumeInfo.BytesPerCluster) >> 20, (MftClusters * 100) / VolumeInfo.TotalClusters.QuadPart); _tprintf(_T("MFT zone size\t\t: %I64u MB (%I64u%% of drive)\n"), (MftClusters * VolumeInfo.BytesPerCluster) >> 20, (MftClusters * 100) / VolumeInfo.TotalClusters.QuadPart);
_tprintf(_T("MFT mirror start\t: %I64u\n"), VolumeInfo.Mft2StartLcn.QuadPart); _tprintf(_T("MFT mirror start\t: %I64u\n"), VolumeInfo.Mft2StartLcn.QuadPart);
_tprintf(_T("\nMeta-Data files\n---------------\n")); _tprintf(_T("\nMeta-Data files\n---------------\n"));

View file

@ -21,7 +21,7 @@ int wmain(int argc, WCHAR * argv[])
wsprintf(ServiceName.Buffer, wsprintf(ServiceName.Buffer,
L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\%S", L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\%S",
argv[1]); argv[1]);
wprintf(L"%s %u %d\n", ServiceName.Buffer, ServiceName.Length, wcslen(ServiceName.Buffer)); wprintf(L"%s %u %Id\n", ServiceName.Buffer, ServiceName.Length, wcslen(ServiceName.Buffer));
Status = NtLoadDriver(&ServiceName); Status = NtLoadDriver(&ServiceName);
free(ServiceName.Buffer); free(ServiceName.Buffer);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))

View file

@ -21,7 +21,7 @@ int wmain(int argc, WCHAR * argv[])
wsprintf(ServiceName.Buffer, wsprintf(ServiceName.Buffer,
L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\%S", L"\\Registry\\Machine\\System\\CurrentControlSet\\Services\\%S",
argv[1]); argv[1]);
wprintf(L"%s %d %d\n", ServiceName.Buffer, ServiceName.Length, wcslen(ServiceName.Buffer)); wprintf(L"%s %d %Ud\n", ServiceName.Buffer, ServiceName.Length, wcslen(ServiceName.Buffer));
Status = NtUnloadDriver(&ServiceName); Status = NtUnloadDriver(&ServiceName);
free(ServiceName.Buffer); free(ServiceName.Buffer);
if (!NT_SUCCESS(Status)) if (!NT_SUCCESS(Status))

View file

@ -46,7 +46,7 @@ PrintWin32Error(
DWORD ErrorCode DWORD ErrorCode
) )
{ {
PVOID lpMsgBuf; LPWSTR lpMsgBuf;
FormatMessageW( FormatMessageW(
(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM), (FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM),

View file

@ -146,8 +146,8 @@ static void test2(LPCWSTR pwsz, LPCWSTR pwszExpected, LPCWSTR pwszExpectedPartNa
if (!bOK) if (!bOK)
{ {
printf("input: : %2Iu chars \"%S\"\n", wcslen(pwsz), pwsz); printf("input: : %2Iu chars \"%S\"\n", wcslen(pwsz), pwsz);
printf("Expected: %2u chars \"%S\"\n", lenExp, pwszExpected); printf("Expected: %2Iu chars \"%S\"\n", lenExp, pwszExpected);
printf("Actual : %2u chars \"%S\"\n", lenAct, lenAct ? pwszActual : L"(null)"); printf("Actual : %2Iu chars \"%S\"\n", lenAct, lenAct ? pwszActual : L"(null)");
return; return;
} }
} else } else
@ -156,8 +156,8 @@ static void test2(LPCWSTR pwsz, LPCWSTR pwszExpected, LPCWSTR pwszExpectedPartNa
PWSTR pwszActual = NtName.Buffer + 4; PWSTR pwszActual = NtName.Buffer + 4;
const size_t lenAct = (NtName.Length - 8) / 2; const size_t lenAct = (NtName.Length - 8) / 2;
check_result(FALSE, "Unexpected NtName (expected NULL)"); check_result(FALSE, "Unexpected NtName (expected NULL)");
printf("input: : %2u chars \"%S\"\n", wcslen(pwsz), pwsz); printf("input: : %2Iu chars \"%S\"\n", wcslen(pwsz), pwsz);
printf("Actual : %2u chars \"%S\"\n", lenAct, pwszActual); printf("Actual : %2Iu chars \"%S\"\n", lenAct, pwszActual);
} }
if (pwszExpectedPartName) { if (pwszExpectedPartName) {
@ -167,17 +167,17 @@ static void test2(LPCWSTR pwsz, LPCWSTR pwszExpected, LPCWSTR pwszExpectedPartNa
wcscmp(PartName, pwszExpectedPartName) == 0; wcscmp(PartName, pwszExpectedPartName) == 0;
check_result(bOK, "PartName does not match expected"); check_result(bOK, "PartName does not match expected");
if (!bOK) { if (!bOK) {
printf("input: : %2u chars \"%S\"\n", wcslen(pwsz), pwsz); printf("input: : %2Iu chars \"%S\"\n", wcslen(pwsz), pwsz);
printf("Expected: %2u chars \"%S\"\n", lenExp, pwszExpectedPartName); printf("Expected: %2Iu chars \"%S\"\n", lenExp, pwszExpectedPartName);
printf("Actual : %2u chars \"%S\"\n", lenAct, lenAct ? PartName : L"(null)"); printf("Actual : %2Iu chars \"%S\"\n", lenAct, lenAct ? PartName : L"(null)");
return; return;
} }
} else } else
if (PartName) if (PartName)
{ {
check_result(FALSE, "Unexpected PartName (expected NULL)."); check_result(FALSE, "Unexpected PartName (expected NULL).");
printf("input: : %2u chars \"%S\"\n", wcslen(pwsz), pwsz); printf("input: : %2Iu chars \"%S\"\n", wcslen(pwsz), pwsz);
printf("Actual : %2u chars %S\n", wcslen(PartName), PartName); printf("Actual : %2Iu chars %S\n", wcslen(PartName), PartName);
} }
} }

View file

@ -60,7 +60,7 @@ void DumpMsgList(const char* lstName, const tagMsgList *ml)
for (i1 = 0; i1 < ml->msgCount; i1++) for (i1 = 0; i1 < ml->msgCount; i1++)
{ {
dlgProcName = (ml->msgList[i1].DlgProc) ? "DlgProc" : "WndProc"; dlgProcName = (ml->msgList[i1].DlgProc) ? "DlgProc" : "WndProc";
printf("#%.3d %s, msg 0x%x, wParam 0x%x, lParam 0x%Ix, result %d\n", printf("#%.3d %s, msg 0x%x, wParam 0x%Ix, lParam 0x%Ix, result %d\n",
i1, i1,
dlgProcName, dlgProcName,
ml->msgList[i1].msg, ml->msgList[i1].msg,

View file

@ -23,7 +23,7 @@ START_TEST(LoadImage)
HDC hdc, hdcScreen; HDC hdc, hdcScreen;
ICONINFO ii; ICONINFO ii;
sscanf (test_argv[2], "%lu", (ULONG_PTR*) &arg); sscanf (test_argv[2], "%Iu", (ULONG_PTR*) &arg);
ok(handle != arg, "Got same handles\n"); ok(handle != arg, "Got same handles\n");
@ -81,7 +81,7 @@ START_TEST(LoadImage)
} }
/* Start child process */ /* Start child process */
sprintf( path, "%s LoadImage %lu", test_argv[0], (ULONG_PTR)handle ); sprintf( path, "%s LoadImage %Iu", test_argv[0], (ULONG_PTR)handle );
memset( &si, 0, sizeof(si) ); memset( &si, 0, sizeof(si) );
si.cb = sizeof(si); si.cb = sizeof(si);
CreateProcessA( NULL, path, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi ); CreateProcessA( NULL, path, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi );

View file

@ -23,9 +23,9 @@ MixerThread(LPVOID Parameter)
while(GetMessage(&msg, NULL, 0, 0)) while(GetMessage(&msg, NULL, 0, 0))
{ {
if (msg.message == MM_MIXM_CONTROL_CHANGE) if (msg.message == MM_MIXM_CONTROL_CHANGE)
printf("got MM_MIXM_CONTROL_CHANGE wParam %x lParam %lx\n", msg.wParam, msg.lParam); printf("got MM_MIXM_CONTROL_CHANGE wParam %Ix lParam %Ix\n", msg.wParam, msg.lParam);
else if (msg.message == MM_MIXM_LINE_CHANGE) else if (msg.message == MM_MIXM_LINE_CHANGE)
printf("got MM_MIXM_LINE_CHANGE wParam %x lParam %lx\n", msg.wParam, msg.lParam); printf("got MM_MIXM_LINE_CHANGE wParam %Ix lParam %Ix\n", msg.wParam, msg.lParam);
} }
return 1; return 1;
} }

View file

@ -3022,7 +3022,7 @@ static NTSTATUS get_manifest_in_pe_file( struct actctx_loader* acl, struct assem
if ((!((ULONG_PTR)resname >> 16))) if ((!((ULONG_PTR)resname >> 16)))
{ {
sprintfW(resnameBuf, L"#%u", (ULONG_PTR)resname); sprintfW(resnameBuf, L"#%u", PtrToUlong(resname));
resptr = resnameBuf; resptr = resnameBuf;
} }