From dc5b122f236895dabd049bf342910a0b40e2dfe1 Mon Sep 17 00:00:00 2001 From: skal Date: Mon, 26 May 2014 18:19:43 +0200 Subject: [PATCH] try to remove the spurious warning for static analysis Change-Id: Ib81f16c70a0bfad05021401c1cf6788c974b63bd --- examples/stopwatch.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/examples/stopwatch.h b/examples/stopwatch.h index 70eba9f6..28518387 100644 --- a/examples/stopwatch.h +++ b/examples/stopwatch.h @@ -46,10 +46,13 @@ static WEBP_INLINE void StopwatchReset(Stopwatch* watch) { } static WEBP_INLINE double StopwatchReadAndReset(Stopwatch* watch) { - const struct timeval old_value = *watch; + struct timeval old_value; + double delta_sec, delta_usec; + memcpy(&old_value, watch, sizeof(old_value)); gettimeofday(watch, NULL); - return watch->tv_sec - old_value.tv_sec + - (watch->tv_usec - old_value.tv_usec) / 1000000.0; + delta_sec = (double)watch->tv_sec - old_value.tv_sec; + delta_usec = (double)watch->tv_usec - old_value.tv_usec; + return delta_sec + delta_usec / 1000000.0; } #endif /* _WIN32 */