1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-23 08:38:49 -05:00

build: add picky compiler warning flags for gcc 6 and 7

This commit is contained in:
Eric Gallager 2018-02-12 01:42:47 -05:00 committed by Daniel Stenberg
parent 4e884615d1
commit a19fefb070
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
6 changed files with 25 additions and 5 deletions

0
acinclude.m4 Executable file → Normal file
View File

View File

@ -345,7 +345,7 @@ Curl_he2ai(const struct hostent *he, int port)
addr = (void *)ai->ai_addr; /* storage area for this info */ addr = (void *)ai->ai_addr; /* storage area for this info */
memcpy(&addr->sin_addr, curr, sizeof(struct in_addr)); 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); addr->sin_port = htons((unsigned short)port);
break; break;
@ -354,7 +354,7 @@ Curl_he2ai(const struct hostent *he, int port)
addr6 = (void *)ai->ai_addr; /* storage area for this info */ addr6 = (void *)ai->ai_addr; /* storage area for this info */
memcpy(&addr6->sin6_addr, curr, sizeof(struct in6_addr)); 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); addr6->sin6_port = htons((unsigned short)port);
break; break;
#endif #endif

View File

@ -1193,7 +1193,10 @@ CURLcode Curl_mime_duppart(curl_mimepart *dst, const curl_mimepart *src)
} }
/* Duplicate other fields. */ /* Duplicate other fields. */
if(dst != NULL)
dst->encoder = src->encoder; dst->encoder = src->encoder;
else
res = CURLE_WRITE_ERROR;
if(!res) if(!res)
res = curl_mime_type(dst, src->mimetype); res = curl_mime_type(dst, src->mimetype);
if(!res) if(!res)

View File

@ -1010,7 +1010,7 @@ static CURLcode tftp_connect(struct connectdata *conn, bool *done)
state->requested_blksize = blksize; state->requested_blksize = blksize;
((struct sockaddr *)&state->local_addr)->sa_family = ((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); tftp_set_timeouts(state);

View File

@ -110,7 +110,7 @@ struct curltime Curl_now(void)
usecs /= 1000; usecs /= 1000;
cnow.tv_sec = usecs / 1000000; cnow.tv_sec = usecs / 1000000;
cnow.tv_usec = usecs % 1000000; cnow.tv_usec = (int)(usecs % 1000000);
return cnow; return cnow;
} }

View File

@ -1044,6 +1044,23 @@ AC_DEFUN([CURL_SET_COMPILER_WARNING_OPTS], [
tmp_CFLAGS="$tmp_CFLAGS -Wdouble-promotion" tmp_CFLAGS="$tmp_CFLAGS -Wdouble-promotion"
fi 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 fi
# #
dnl Do not issue warnings for code in system include paths. dnl Do not issue warnings for code in system include paths.