From e545a06c3004359029b8dd8d5a1e3aedc6fb5cc0 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Wed, 26 Feb 2025 17:12:12 +0100 Subject: [PATCH] server: sync timediff_t type across modules fix unused timediff warning with clang-cl ``` C:/projects/curl/tests/server/util.c(463,13): error : unused function 'timediff' [-Werror,-Wunused-function] ``` https://ci.appveyor.com/project/curlorg/curl/builds/51606010/job/p1e4tmsahj0p043r#L208 --- tests/server/util.c | 25 ++++++++++++++----------- tests/server/util.h | 1 - 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/tests/server/util.c b/tests/server/util.c index b8a47b1fbb..c36f8eade3 100644 --- a/tests/server/util.c +++ b/tests/server/util.c @@ -54,6 +54,7 @@ #include "getpart.h" #include "util.h" #include "timeval.h" +#include "timediff.h" #ifdef USE_WINSOCK #undef EINTR @@ -221,6 +222,19 @@ FILE *test2fopen(long testno, const char *logdir2) return stream; } +#if !defined(MSDOS) && !defined(USE_WINSOCK) +static long timediff(struct timeval newer, struct timeval older) +{ + timediff_t diff = newer.tv_sec-older.tv_sec; + if(diff >= (LONG_MAX/1000)) + return LONG_MAX; + else if(diff <= (LONG_MIN/1000)) + return LONG_MIN; + return (long)(newer.tv_sec-older.tv_sec)*1000+ + (long)(newer.tv_usec-older.tv_usec)/1000; +} +#endif + /* * Portable function used for waiting a specific amount of ms. * Waiting indefinitely with this function is not allowed, a @@ -457,17 +471,6 @@ static struct timeval tvnow(void) #endif -long timediff(struct timeval newer, struct timeval older) -{ - timediff_t diff = newer.tv_sec-older.tv_sec; - if(diff >= (LONG_MAX/1000)) - return LONG_MAX; - else if(diff <= (LONG_MIN/1000)) - return LONG_MIN; - return (long)(newer.tv_sec-older.tv_sec)*1000+ - (long)(newer.tv_usec-older.tv_usec)/1000; -} - /* vars used to keep around previous signal handlers */ typedef void (*SIGHANDLER_T)(int); diff --git a/tests/server/util.h b/tests/server/util.h index 69121c587f..105e4f73c1 100644 --- a/tests/server/util.h +++ b/tests/server/util.h @@ -37,7 +37,6 @@ enum { char *data_to_hex(char *data, size_t len); void logmsg(const char *msg, ...) CURL_PRINTF(1, 2); -long timediff(struct timeval newer, struct timeval older); #define SERVERLOGS_LOCKDIR "lock" /* within logdir */