mirror of
https://github.com/moparisthebest/curl
synced 2025-02-28 09:21:50 -05:00
tool_operate: fix MinGW compiler warning
MinGW complains: tool_operate.c:197:15: error: comparison is always true due to limited range of data type [-Werror=type-limits] Fix this by only doing the comparison if 'long' is large enough to hold the constant it is compared with. Closes https://github.com/curl/curl/pull/1378
This commit is contained in:
parent
446eaa941d
commit
b547fff566
@ -194,38 +194,42 @@ static void setfiletime(long filetime, const char *filename,
|
|||||||
saving time offset and since it's GMT that is bad behavior. When we have
|
saving time offset and since it's GMT that is bad behavior. When we have
|
||||||
access to a 64-bit type we can bypass utime and set the times directly. */
|
access to a 64-bit type we can bypass utime and set the times directly. */
|
||||||
#if defined(WIN32) && (CURL_SIZEOF_CURL_OFF_T >= 8)
|
#if defined(WIN32) && (CURL_SIZEOF_CURL_OFF_T >= 8)
|
||||||
|
HANDLE hfile;
|
||||||
|
|
||||||
|
#if (CURL_SIZEOF_LONG >= 8)
|
||||||
/* 910670515199 is the maximum unix filetime that can be used as a
|
/* 910670515199 is the maximum unix filetime that can be used as a
|
||||||
Windows FILETIME without overflow: 30827-12-31T23:59:59. */
|
Windows FILETIME without overflow: 30827-12-31T23:59:59. */
|
||||||
if(filetime <= CURL_OFF_T_C(910670515199)) {
|
if(filetime > CURL_OFF_T_C(910670515199)) {
|
||||||
HANDLE hfile = CreateFileA(filename, FILE_WRITE_ATTRIBUTES,
|
|
||||||
(FILE_SHARE_READ | FILE_SHARE_WRITE |
|
|
||||||
FILE_SHARE_DELETE),
|
|
||||||
NULL, OPEN_EXISTING, 0, NULL);
|
|
||||||
if(hfile != INVALID_HANDLE_VALUE) {
|
|
||||||
curl_off_t converted = ((curl_off_t)filetime * 10000000) +
|
|
||||||
CURL_OFF_T_C(116444736000000000);
|
|
||||||
FILETIME ft;
|
|
||||||
ft.dwLowDateTime = (DWORD)(converted & 0xFFFFFFFF);
|
|
||||||
ft.dwHighDateTime = (DWORD)(converted >> 32);
|
|
||||||
if(!SetFileTime(hfile, NULL, &ft, &ft)) {
|
|
||||||
fprintf(error_stream,
|
|
||||||
"Failed to set filetime %ld on outfile: "
|
|
||||||
"SetFileTime failed: GetLastError %u\n",
|
|
||||||
filetime, GetLastError());
|
|
||||||
}
|
|
||||||
CloseHandle(hfile);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
fprintf(error_stream,
|
|
||||||
"Failed to set filetime %ld on outfile: "
|
|
||||||
"CreateFile failed: GetLastError %u\n",
|
|
||||||
filetime, GetLastError());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
fprintf(error_stream,
|
fprintf(error_stream,
|
||||||
"Failed to set filetime %ld on outfile: overflow\n",
|
"Failed to set filetime %ld on outfile: overflow\n",
|
||||||
filetime);
|
filetime);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif /* CURL_SIZEOF_LONG >= 8 */
|
||||||
|
|
||||||
|
hfile = CreateFileA(filename, FILE_WRITE_ATTRIBUTES,
|
||||||
|
(FILE_SHARE_READ | FILE_SHARE_WRITE |
|
||||||
|
FILE_SHARE_DELETE),
|
||||||
|
NULL, OPEN_EXISTING, 0, NULL);
|
||||||
|
if(hfile != INVALID_HANDLE_VALUE) {
|
||||||
|
curl_off_t converted = ((curl_off_t)filetime * 10000000) +
|
||||||
|
CURL_OFF_T_C(116444736000000000);
|
||||||
|
FILETIME ft;
|
||||||
|
ft.dwLowDateTime = (DWORD)(converted & 0xFFFFFFFF);
|
||||||
|
ft.dwHighDateTime = (DWORD)(converted >> 32);
|
||||||
|
if(!SetFileTime(hfile, NULL, &ft, &ft)) {
|
||||||
|
fprintf(error_stream,
|
||||||
|
"Failed to set filetime %ld on outfile: "
|
||||||
|
"SetFileTime failed: GetLastError %u\n",
|
||||||
|
filetime, GetLastError());
|
||||||
|
}
|
||||||
|
CloseHandle(hfile);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
fprintf(error_stream,
|
||||||
|
"Failed to set filetime %ld on outfile: "
|
||||||
|
"CreateFile failed: GetLastError %u\n",
|
||||||
|
filetime, GetLastError());
|
||||||
}
|
}
|
||||||
#elif defined(HAVE_UTIME)
|
#elif defined(HAVE_UTIME)
|
||||||
struct utimbuf times;
|
struct utimbuf times;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user