[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnurl] 161/205: tool_operate: fix MinGW compiler warning
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnurl] 161/205: tool_operate: fix MinGW compiler warning |
Date: |
Thu, 20 Apr 2017 16:21:41 +0200 |
This is an automated email from the git hooks/post-receive script.
ng0 pushed a commit to annotated tag gnurl-7.54.0
in repository gnurl.
commit b547fff566cb7644273716a6e052c5ae6d3f5bef
Author: Marcel Raad <address@hidden>
AuthorDate: Sat Apr 1 11:50:39 2017 +0200
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
---
src/tool_operate.c | 50 +++++++++++++++++++++++++++-----------------------
1 file changed, 27 insertions(+), 23 deletions(-)
diff --git a/src/tool_operate.c b/src/tool_operate.c
index bb698ffec..0e84ac398 100644
--- a/src/tool_operate.c
+++ b/src/tool_operate.c
@@ -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
access to a 64-bit type we can bypass utime and set the times directly. */
#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
Windows FILETIME without overflow: 30827-12-31T23:59:59. */
- 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 {
+ if(filetime > CURL_OFF_T_C(910670515199)) {
+ fprintf(error_stream,
+ "Failed to set filetime %ld on outfile: overflow\n",
+ 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: "
- "CreateFile failed: GetLastError %u\n",
+ "SetFileTime failed: GetLastError %u\n",
filetime, GetLastError());
}
+ CloseHandle(hfile);
}
else {
fprintf(error_stream,
- "Failed to set filetime %ld on outfile: overflow\n",
- filetime);
+ "Failed to set filetime %ld on outfile: "
+ "CreateFile failed: GetLastError %u\n",
+ filetime, GetLastError());
}
#elif defined(HAVE_UTIME)
struct utimbuf times;
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [gnurl] 202/205: nss: fix MinGW compiler warnings, (continued)
- [GNUnet-SVN] [gnurl] 202/205: nss: fix MinGW compiler warnings, gnunet, 2017/04/20
- [GNUnet-SVN] [gnurl] 159/205: configure: prefer 'long long' to int64_t for curl_off_t, gnunet, 2017/04/20
- [GNUnet-SVN] [gnurl] 197/205: code: fix typos and style in comments, gnunet, 2017/04/20
- [GNUnet-SVN] [gnurl] 149/205: docs: minor typo in write-out.d, gnunet, 2017/04/20
- [GNUnet-SVN] [gnurl] 181/205: nss: load CA certificates even with --insecure, gnunet, 2017/04/20
- [GNUnet-SVN] [gnurl] 186/205: Curl_expire_latest: ignore already expired timers, gnunet, 2017/04/20
- [GNUnet-SVN] [gnurl] 155/205: curl_sasl: declare mechtable static, gnunet, 2017/04/20
- [GNUnet-SVN] [gnurl] 150/205: easy: silence compiler warning, gnunet, 2017/04/20
- [GNUnet-SVN] [gnurl] 138/205: dist: add missing files to the tarball, gnunet, 2017/04/20
- [GNUnet-SVN] [gnurl] 204/205: THANKS: add contributors from 7.54.0 release notes, gnunet, 2017/04/20
- [GNUnet-SVN] [gnurl] 161/205: tool_operate: fix MinGW compiler warning,
gnunet <=
- [GNUnet-SVN] [gnurl] 179/205: libcurl-thread.3: fixed a bad macro that caused test 1140 to fail, gnunet, 2017/04/20
- [GNUnet-SVN] [gnurl] 184/205: polarssl: unbreak build with versions < 1.3.8, gnunet, 2017/04/20
- [GNUnet-SVN] [gnurl] 185/205: system.h: fix mingw section, gnunet, 2017/04/20
- [GNUnet-SVN] [gnurl] 137/205: cmake: fix build with cmake 2.8.12.2, gnunet, 2017/04/20
- [GNUnet-SVN] [gnurl] 192/205: RELEASE-NOTES: synced with 1451271e0, gnunet, 2017/04/20
- [GNUnet-SVN] [gnurl] 134/205: curl: fix callback functions to match prototype, gnunet, 2017/04/20
- [GNUnet-SVN] [gnurl] 175/205: INSTALL.md: fix secure transport configure arguments, gnunet, 2017/04/20
- [GNUnet-SVN] [gnurl] 168/205: test1606: verify speedcheck, gnunet, 2017/04/20
- [GNUnet-SVN] [gnurl] 128/205: cmake: add more missing files to the dist, gnunet, 2017/04/20
- [GNUnet-SVN] [gnurl] 97/205: cmake: build manual pages (including curl.1), gnunet, 2017/04/20