From: Martin Ling Date: Fri, 24 Jan 2020 04:55:32 +0000 (+0000) Subject: windows: Fix warnings for conversions in time_as_timeval(). X-Git-Tag: libserialport-0.1.2~40 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=528e8c0002cf71b6f00602022dacd4996a213522;p=libserialport.git windows: Fix warnings for conversions in time_as_timeval(). Building with MSVC gave: warning C4244: '=': conversion from 'LONGLONG' to 'long', possible loss of data when assigning the results of these calculation to the long fields of struct timeval. The result should be OK, but put an explicit cast in to make the change clear and suppress the warning. --- diff --git a/timing.c b/timing.c index 8817e48..3a5f5c7 100644 --- a/timing.c +++ b/timing.c @@ -89,9 +89,9 @@ SP_PRIV void time_as_timeval(const struct time *time, struct timeval *tv) #ifdef _WIN32 LARGE_INTEGER frequency; QueryPerformanceFrequency(&frequency); - tv->tv_sec = time->ticks / frequency.QuadPart; - tv->tv_usec = (time->ticks % frequency.QuadPart) / - (frequency.QuadPart / 1000000); + tv->tv_sec = (long) (time->ticks / frequency.QuadPart); + tv->tv_usec = (long) ((time->ticks % frequency.QuadPart) / + (frequency.QuadPart / 1000000)); #else *tv = time->tv; #endif