]> granicus.if.org Git - curl/commitdiff
build: add picky compiler warning flags for gcc 6 and 7
authorEric Gallager <egall@gwmail.gwu.edu>
Mon, 12 Feb 2018 06:42:47 +0000 (01:42 -0500)
committerDaniel Stenberg <daniel@haxx.se>
Sat, 7 Apr 2018 09:18:58 +0000 (11:18 +0200)
acinclude.m4 [changed mode: 0755->0644]
lib/curl_addrinfo.c
lib/mime.c
lib/tftp.c
lib/timeval.c
m4/curl-compilers.m4

old mode 100755 (executable)
new mode 100644 (file)
index 95a3f1050c742953d33aa8ee5451a4e5282fe532..01775f7042582b0c4e71786e310a052597650404 100644 (file)
@@ -345,7 +345,7 @@ Curl_he2ai(const struct hostent *he, int port)
       addr = (void *)ai->ai_addr; /* storage area for this info */
 
       memcpy(&addr->sin_addr, curr, sizeof(struct in_addr));
-      addr->sin_family = (unsigned short)(he->h_addrtype);
+      addr->sin_family = (sa_family_t)(he->h_addrtype);
       addr->sin_port = htons((unsigned short)port);
       break;
 
@@ -354,7 +354,7 @@ Curl_he2ai(const struct hostent *he, int port)
       addr6 = (void *)ai->ai_addr; /* storage area for this info */
 
       memcpy(&addr6->sin6_addr, curr, sizeof(struct in6_addr));
-      addr6->sin6_family = (unsigned short)(he->h_addrtype);
+      addr6->sin6_family = (sa_family_t)(he->h_addrtype);
       addr6->sin6_port = htons((unsigned short)port);
       break;
 #endif
index 89819a93505860449553a5c2ff30d70cf0e49b92..ce56d7873a56fe7e031a2fdff95403ed76b5a581 100644 (file)
@@ -1193,7 +1193,10 @@ CURLcode Curl_mime_duppart(curl_mimepart *dst, const curl_mimepart *src)
   }
 
   /* Duplicate other fields. */
-  dst->encoder = src->encoder;
+  if(dst != NULL)
+    dst->encoder = src->encoder;
+  else
+    res = CURLE_WRITE_ERROR;
   if(!res)
     res = curl_mime_type(dst, src->mimetype);
   if(!res)
index 20dc600409451f7c5c0ef11ace5fb61cfd0d5392..7fd7b375182bb6cb06468955aba869a47344b2d2 100644 (file)
@@ -1010,7 +1010,7 @@ static CURLcode tftp_connect(struct connectdata *conn, bool *done)
   state->requested_blksize = blksize;
 
   ((struct sockaddr *)&state->local_addr)->sa_family =
-    (unsigned short)(conn->ip_addr->ai_family);
+    (sa_family_t)(conn->ip_addr->ai_family);
 
   tftp_set_timeouts(state);
 
index d11b95197b199e4715c1709f685d7f307f0e70df..f4bf83531f35628749d98718323b3c26da61cb93 100644 (file)
@@ -110,7 +110,7 @@ struct curltime Curl_now(void)
   usecs /= 1000;
 
   cnow.tv_sec = usecs / 1000000;
-  cnow.tv_usec = usecs % 1000000;
+  cnow.tv_usec = (int)(usecs % 1000000);
 
   return cnow;
 }
index 422946e267433c51aa58aab70422bdd2aff51a07..20bdbd706f8e2a5353d7e6a602756c8ce15c4216 100644 (file)
@@ -1044,6 +1044,23 @@ AC_DEFUN([CURL_SET_COMPILER_WARNING_OPTS], [
             tmp_CFLAGS="$tmp_CFLAGS -Wdouble-promotion"
           fi
           #
+          dnl Only gcc 6 or later
+          if test "$compiler_num" -ge "600"; then
+            tmp_CFLAGS="$tmp_CFLAGS -Wshift-negative-value"
+            tmp_CFLAGS="$tmp_CFLAGS -Wshift-overflow=2"
+            tmp_CFLAGS="$tmp_CFLAGS -Wnull-dereference"
+            tmp_CFLAGS="$tmp_CFLAGS -Wduplicated-cond"
+          fi
+          #
+          dnl Only gcc 7 or later
+          if test "$compiler_num" -ge "700"; then
+            tmp_CFLAGS="$tmp_CFLAGS -Wduplicated-branches"
+            tmp_CFLAGS="$tmp_CFLAGS -Wrestrict"
+            tmp_CFLAGS="$tmp_CFLAGS -Walloc-zero"
+            tmp_CFLAGS="$tmp_CFLAGS -Wformat-overflow=2"
+            tmp_CFLAGS="$tmp_CFLAGS -Wformat-truncation=2"
+          fi
+          #
         fi
         #
         dnl Do not issue warnings for code in system include paths.