From c1d670fd752b96abac09b919d7ca1bff4ebafcbc Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Mon, 10 Feb 2020 00:21:15 +0100 Subject: Windows: Fix warnings reported by Coverity static code analyzer --- src/Common/Dlgcode.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/Common') diff --git a/src/Common/Dlgcode.c b/src/Common/Dlgcode.c index 7640b59e..5a2ed526 100644 --- a/src/Common/Dlgcode.c +++ b/src/Common/Dlgcode.c @@ -5529,11 +5529,11 @@ static void DisplayBenchmarkResults (HWND hwndDlg) SendMessageW (hList, LVM_SETITEMW, 0, (LPARAM)&LvItem); break; case BENCHMARK_TYPE_PRF: - swprintf_s (item1, sizeof(item1) / sizeof(item1[0]), L"%d ms", benchmarkTable[i].meanBytesPerSec); + swprintf_s (item1, sizeof(item1) / sizeof(item1[0]), L"%d ms", (int) benchmarkTable[i].meanBytesPerSec); LvItem.iSubItem = 1; LvItem.pszText = item1; SendMessageW (hList, LVM_SETITEMW, 0, (LPARAM)&LvItem); - swprintf_s (item1, sizeof(item1) / sizeof(item1[0]), L"%d", benchmarkTable[i].decSpeed); + swprintf_s (item1, sizeof(item1) / sizeof(item1[0]), L"%d", (int) benchmarkTable[i].decSpeed); LvItem.iSubItem = 2; LvItem.pszText = item1; SendMessageW (hList, LVM_SETITEMW, 0, (LPARAM)&LvItem); @@ -7530,7 +7530,10 @@ int GetLastAvailableDrive () BOOL IsDriveAvailable (int driveNo) { - return (GetUsedLogicalDrives() & (1 << driveNo)) == 0; + if (driveNo >= 0 && driveNo < 26) + return (GetUsedLogicalDrives() & (1 << driveNo)) == 0; + else + return FALSE; } @@ -13057,7 +13060,7 @@ BOOL IsApplicationInstalled (const wchar_t *appName, BOOL b32bitApp) } wchar_t regName[1024]; - DWORD regNameSize = sizeof (regName); + DWORD regNameSize = ARRAYSIZE (regName); DWORD index = 0; while (RegEnumKeyEx (unistallKey, index++, regName, ®NameSize, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) { -- cgit v1.2.3