Fix compiler warnings in Windows plugins

This fixes a bunch of compiler warnings in the Windows plugins.
This commit is contained in:
Michael Insel 2019-04-30 10:32:44 +02:00
parent b878086565
commit 25c2a2bb53
5 changed files with 79 additions and 81 deletions

View File

@ -317,7 +317,7 @@ bool QueryPerfData(printInfoStruct& pI)
pI.dValue = pDisplayValues[0].FmtValue.longValue;
break;
case (PDH_FMT_LARGE):
pI.dValue = pDisplayValues[0].FmtValue.largeValue;
pI.dValue = (double) pDisplayValues[0].FmtValue.largeValue;
break;
default:
pI.dValue = pDisplayValues[0].FmtValue.doubleValue;

View File

@ -345,7 +345,7 @@ static int check_ping4(const printInfoStruct& pi, response& response)
QueryPerformanceCounter(&timer2);
if (((timer2.QuadPart - timer1.QuadPart) * 1000 / frequency.QuadPart) < pi.timeout)
Sleep(pi.timeout - ((timer2.QuadPart - timer1.QuadPart) * 1000 / frequency.QuadPart));
Sleep((DWORD) (pi.timeout - ((timer2.QuadPart - timer1.QuadPart) * 1000 / frequency.QuadPart)));
} while (--num);
if (l_Debug)
@ -400,9 +400,16 @@ static int check_ping6(const printInfoStruct& pi, response& response)
HANDLE hIcmp = Icmp6CreateFile();
if (hIcmp == INVALID_HANDLE_VALUE) {
goto die;
}
printErrorInfo(GetLastError());
if (hIcmp)
IcmpCloseHandle(hIcmp);
if (repBuf)
delete reinterpret_cast<BYTE *>(repBuf);
return 3;
} else {
IP_OPTION_INFORMATION ipInfo = { 30, 0, 0, 0, NULL };
LARGE_INTEGER frequency;
@ -451,7 +458,7 @@ static int check_ping6(const printInfoStruct& pi, response& response)
QueryPerformanceCounter(&timer2);
if (((timer2.QuadPart - timer1.QuadPart) * 1000 / frequency.QuadPart) < pi.timeout)
Sleep(pi.timeout - ((timer2.QuadPart - timer1.QuadPart) * 1000 / frequency.QuadPart));
Sleep((DWORD) (pi.timeout - ((timer2.QuadPart - timer1.QuadPart) * 1000 / frequency.QuadPart)));
} while (--num);
if (l_Debug)
@ -466,16 +473,7 @@ static int check_ping6(const printInfoStruct& pi, response& response)
response.avg = ((double)rtt / pi.num);
return -1;
die:
printErrorInfo(GetLastError());
if (hIcmp)
IcmpCloseHandle(hIcmp);
if (repBuf)
delete reinterpret_cast<BYTE *>(repBuf);
return 3;
}
}
int wmain(int argc, WCHAR **argv)

View File

@ -167,7 +167,7 @@ static std::wstring getServiceByDescription(const std::wstring& description)
EnumServicesStatus(hSCM, SERVICE_WIN32 | SERVICE_DRIVER, SERVICE_STATE_ALL, lpServices, pcbBytesNeeded,
&pcbBytesNeeded, &lpServicesReturned, &lpResumeHandle);
for (int index = 0; index < lpServicesReturned; index++) {
for (decltype(lpServicesReturned) index = 0; index < lpServicesReturned; index++) {
LPWSTR lpCurrent = lpServices[index].lpServiceName;
if (l_Debug) {

View File

@ -87,7 +87,7 @@ static int parseArguments(int ac, WCHAR **av, po::variables_map& vm, printInfoSt
L"threshold will be set to one greater than the set warning threshold.\n\n"
L"The \"possible-reboot\" option is not recommended since this true for nearly\n"
L"every update."
, progName, progName);
, progName);
std::cout << '\n';
return 0;
} if (vm.count("version")) {

View File

@ -143,9 +143,9 @@ static int printOutput(printInfoStruct& printInfo)
state state = OK;
if (printInfo.warn.rend(printInfo.time))
if (printInfo.warn.rend((double) printInfo.time))
state = WARNING;
if (printInfo.crit.rend(printInfo.time))
if (printInfo.crit.rend((double) printInfo.time))
state = CRITICAL;
switch (state) {