From 89cedbefd3197060e630a9751a7720f2a0d78bf5 Mon Sep 17 00:00:00 2001 From: Tobias Weimer Date: Sun, 18 Oct 2015 17:09:17 +0000 Subject: Ping: - Fixed minor compiler warnings git-svn-id: http://svn.miranda-ng.org/main/trunk@15569 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/Ping/src/icmp.cpp | 4 +--- plugins/Ping/src/rawping.cpp | 17 ++++++++--------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/plugins/Ping/src/icmp.cpp b/plugins/Ping/src/icmp.cpp index f54c356998..93bf4febd4 100644 --- a/plugins/Ping/src/icmp.cpp +++ b/plugins/Ping/src/icmp.cpp @@ -5,9 +5,7 @@ ICMP *ICMP::instance = 0; #define BUFFER_SIZE (16 * (sizeof(ICMP_ECHO_REPLY) + sizeof(data))) -ICMP::ICMP() : -timeout(2000), -functions_loaded(false) +ICMP::ICMP() : timeout(2000), functions_loaded(false), hIP(0) { WSAData wsaData; if (WSAStartup(MAKEWORD(1, 1), &wsaData) != 0) { diff --git a/plugins/Ping/src/rawping.cpp b/plugins/Ping/src/rawping.cpp index 2382aa9030..8b7918280a 100644 --- a/plugins/Ping/src/rawping.cpp +++ b/plugins/Ping/src/rawping.cpp @@ -106,11 +106,12 @@ extern int raw_ping(char *host, int timeout) header->checksum = ip_checksum((USHORT*)header, sizeof(ICMPHeader)); bool use_hi_res = false; - LARGE_INTEGER hr_freq, hr_send_time; + LARGE_INTEGER hr_freq = { 0 }, hr_send_time = { 0 }; DWORD send_time; if (QueryPerformanceFrequency(&hr_freq)) { use_hi_res = true; QueryPerformanceCounter(&hr_send_time); + send_time = 0; } else send_time = GetTickCount(); @@ -128,19 +129,17 @@ extern int raw_ping(char *host, int timeout) IPHeader *reply_header = (IPHeader *)recv_buff; ICMPHeader *reply; DWORD start, current_time; - LARGE_INTEGER hr_start, hr_current_time, hr_timeout; + LARGE_INTEGER hr_start = { 0 }, hr_current_time = { 0 }, hr_timeout = { 0 }; if (use_hi_res) { - hr_timeout.QuadPart = (timeout * hr_freq.QuadPart / 1000); + hr_timeout.QuadPart = (timeout * hr_freq.QuadPart / 1000LL); QueryPerformanceCounter(&hr_start); hr_current_time = hr_start; + current_time = start = 0; } - else { - start = GetTickCount(); - current_time = start; - } + else + current_time = start = GetTickCount(); - while (((use_hi_res && (hr_current_time.QuadPart < hr_start.QuadPart + hr_timeout.QuadPart)) - || (!use_hi_res && current_time < start + timeout))) + while (use_hi_res ? (hr_current_time.QuadPart < hr_start.QuadPart + hr_timeout.QuadPart) : (current_time < start + timeout)) { int bread = recvfrom(sd, recv_buff, 1024, 0, (sockaddr*)&source, &fromlen); -- cgit v1.2.3