From: Viktor Szakats Date: Sat, 26 Jul 2025 13:37:53 +0000 (+0200) Subject: lib517: use `LL` 64-bit literals & re-enable a test case (`time_t`) X-Git-Tag: curl-8_16_0~353 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=975ab36531adf01970814cd81049bcc508c89c61;p=thirdparty%2Fcurl.git lib517: use `LL` 64-bit literals & re-enable a test case (`time_t`) Suffix two 64-bit `time_t` test literals with `LL` to make them compile with mingw-w64 x86_64 in C89 (the default) mode. Possibly other old gcc compilers are affected (e.g. mips gcc 4.9.4, power gcc 15.1.0), but could not pinpoint the exact rules. This also fixes a compiler warning and test failure with MSVC, allowing to re-enable a disabled test case. `LL` is not C89, but used in the code before this patch, which tells it's safe to use. Also display expected / actual timestamp values as `curl_off_t` instead of `long`, making them work with 64-bit timestamps. This was triggered by this issue seen while testing mingw-w64 gcc 4.8.1: ``` tests/libtest/lib517.c:147:5: error: this decimal constant is unsigned only in ISO C90 {"Sun, 06 Nov 2044 08:49:37 GMT", (time_t) 2362034977 }, ^ ``` Ref: https://github.com/curl/curl/actions/runs/16540378828/job/46780712313?pr=18010#step:12:32 Closes #18032 --- diff --git a/tests/libtest/lib517.c b/tests/libtest/lib517.c index cefc42f7fd..5324d6378f 100644 --- a/tests/libtest/lib517.c +++ b/tests/libtest/lib517.c @@ -144,23 +144,20 @@ static CURLcode test_lib517(char *URL) {"Thu, 31-Dec-1969 23:59:58 GMT", -2 }, {"Thu, 31-Dec-1969 23:59:59 GMT", 0 }, /* avoids -1 ! */ #if SIZEOF_TIME_T > 4 - {"Sun, 06 Nov 2044 08:49:37 GMT", (time_t) 2362034977 }, + {"Sun, 06 Nov 2044 08:49:37 GMT", (time_t)2362034977LL }, {"Sun, 06 Nov 3144 08:49:37 GMT", 37074617377 }, #ifndef HAVE_TIME_T_UNSIGNED -#if 0 - /* causes warning on MSVC */ - {"Sun, 06 Nov 1900 08:49:37 GMT", -2182259423 }, -#endif + {"Sun, 06 Nov 1900 08:49:37 GMT", (time_t)-2182259423LL }, {"Sun, 06 Nov 1800 08:49:37 GMT", -5337933023 }, {"Thu, 01-Jan-1583 00:00:00 GMT", -12212553600 }, -#endif +#endif /* HAVE_TIME_T_UNSIGNED */ {"Thu, 01-Jan-1499 00:00:00 GMT", -1 }, #else {"Sun, 06 Nov 2044 08:49:37 GMT", -1 }, -#endif +#endif /* SIZEOF_TIME_T > 4 */ #ifndef HAVE_TIME_T_UNSIGNED {"Sun, 06 Nov 1968 08:49:37 GMT", -36342623 }, -#endif +#endif /* !HAVE_TIME_T_UNSIGNED */ { NULL, 0 } }; @@ -172,8 +169,10 @@ static CURLcode test_lib517(char *URL) for(i = 0; dates[i].input; i++) { time_t out = curl_getdate(dates[i].input, NULL); if(out != dates[i].output) { - curl_mprintf("WRONGLY %s => %ld (instead of %ld)\n", - dates[i].input, (long)out, (long)dates[i].output); + curl_mprintf("WRONGLY %s => %" CURL_FORMAT_CURL_OFF_T + " (instead of %" CURL_FORMAT_CURL_OFF_T ")\n", + dates[i].input, + (curl_off_t)out, (curl_off_t)dates[i].output); error++; } }