Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: enable -Wsign-conversion warnings and fix/silence them (OpenSSF) #13489

Open
wants to merge 115 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
78379a7
build: enable (non-fatal) `-Wsign-conversion` warnings (OpenSSF)
vszakats Apr 27, 2024
875eb92
build: make `-Wsign-conversion` an error (OpenSSF)
vszakats Apr 27, 2024
21e6d42
lib altsvc
vszakats Apr 24, 2024
39e09fb
lib altsvc switch prio to unsigned int
vszakats Apr 27, 2024
91d725d
lib asyn-ares
vszakats Apr 27, 2024
b40afae
lib asyn-thread win32
vszakats Apr 27, 2024
797cd68
lib bufq
vszakats Apr 25, 2024
cd84212
lib c-hyper
vszakats Apr 28, 2024
d4c227f
lib cf-h2-proxy
vszakats Apr 27, 2024
2490bbf
lib cf-socket
vszakats Apr 25, 2024
df78ea2
lib cfilters
vszakats Apr 25, 2024
223d250
lib content_encoding
vszakats Apr 25, 2024
24a65f7
lib cookie
vszakats Apr 25, 2024
a950186
lib curl_addrinfo mingw
vszakats Apr 28, 2024
4c4e8ec
lib curl_fnmatch
vszakats Apr 27, 2024
d1bc6ef
lib curl_gethostname
vszakats Apr 28, 2024
a1c8d8a
lib curl_gssapi
vszakats Apr 27, 2024
4406dff
lib curl_multibyte
vszakats Apr 27, 2024
1ba1e6b
lib curl_ntlm_core
vszakats Apr 25, 2024
c485c87
lib curl_path
vszakats Apr 27, 2024
a341cd8
lib curl_sspi
vszakats Apr 27, 2024
280a292
lib curl_trc
vszakats Apr 25, 2024
1af9e86
lib doh
vszakats Apr 25, 2024
df6b8cf
lib dynhds
vszakats Apr 25, 2024
aae84ca
lib easy
vszakats Apr 25, 2024
10a056f
lib escape
vszakats Apr 25, 2024
585f711
lib file
vszakats Apr 25, 2024
7be3625
lib formdata
vszakats Apr 26, 2024
8d75ff9
lib ftp
vszakats Apr 26, 2024
d607d5a
lib getinfo
vszakats Apr 26, 2024
ee00c86
lib gopher
vszakats Apr 26, 2024
011f431
lib hash
vszakats Apr 26, 2024
ca76b7d
lib headers
vszakats Apr 26, 2024
06b66b9
lib hostip
vszakats Apr 26, 2024
53d3981
lib http
vszakats Apr 26, 2024
376b0cb
lib http1
vszakats Apr 26, 2024
3109ace
lib http2
vszakats Apr 27, 2024
62b6bef
lib http_aws_sigv4
vszakats Apr 26, 2024
6c3540d
lib http_chunks
vszakats Apr 26, 2024
ed4bf06
lib http_digest
vszakats Apr 26, 2024
35de4da
lib imap
vszakats Apr 26, 2024
a4d31ee
lib inet_ntop
vszakats Apr 28, 2024
4595bc7
lib inet_ntop.h win32
vszakats Apr 28, 2024
3e86829
lib inet_pton
vszakats Apr 28, 2024
15e175a
lib krb5
vszakats Apr 27, 2024
b41be29
lib ldap
vszakats Apr 27, 2024
bf440fb
lib memdebug.h
vszakats Apr 28, 2024
3baea42
lib mime
vszakats Apr 27, 2024
d47f4ed
lib mqtt
vszakats Apr 27, 2024
46c0c5a
lib multi
vszakats Apr 27, 2024
8d765bc
lib multi suppress sign-conversion for FD_SET
vszakats Apr 28, 2024
324a355
lib nonblock
vszakats Apr 28, 2024
2aeb519
lib noproxy
vszakats Apr 27, 2024
c2c31f0
lib openldap
vszakats Apr 27, 2024
6b50a41
lib pingpong
vszakats Apr 26, 2024
b77714e
lib pop3
vszakats Apr 27, 2024
f9fdb22
lib rand
vszakats Apr 27, 2024
b79fa23
lib request
vszakats Apr 25, 2024
345e133
lib rtsp
vszakats Apr 27, 2024
0ee31e0
lib select
vszakats Apr 25, 2024
5255b7f
lib select FD_SET/FD_ISSET workaround
vszakats Apr 28, 2024
1d75517
lib sendf
vszakats Apr 27, 2024
bbece05
lib setopt
vszakats Apr 25, 2024
c87a754
lib smb
vszakats Apr 27, 2024
8aa148b
lib smtp
vszakats Apr 25, 2024
649f543
lib socketpair
vszakats Apr 28, 2024
3e928f4
lib socks
vszakats Apr 27, 2024
228dfe1
lib socks_gssapi
vszakats Apr 28, 2024
fc1164c
lib socks_sspi
vszakats Apr 28, 2024
dde460f
lib strerror
vszakats Apr 28, 2024
edd927d
lib telnet
vszakats Apr 27, 2024
90e93c1
lib tftp
vszakats Apr 27, 2024
1fb7e9c
lib tftp win32
vszakats Apr 28, 2024
d965a82
lib timeval
vszakats Apr 27, 2024
891a77d
lib transfer
vszakats Apr 27, 2024
01ae1a5
lib url
vszakats Apr 27, 2024
81d065c
lib urlapi
vszakats Apr 27, 2024
e760221
lib urlapi bump variable to size_t
vszakats May 14, 2024
1dd189a
lib version
vszakats Apr 27, 2024
cdd49eb
lib ws
vszakats Apr 27, 2024
1d170db
lib vquic curl_msh3
vszakats Apr 27, 2024
a133747
lib vquic curl_ngtcp2 partial
vszakats Apr 27, 2024
83d55af
lib vquic curl_osslq
vszakats Apr 27, 2024
01f0ce2
lib vssh libssh
vszakats Apr 27, 2024
85a11ae
lib vssh libssh2
vszakats Apr 27, 2024
b12bb56
lib vtls bearssl
vszakats Apr 27, 2024
e9666e0
lib vtls cipher_suite
vszakats Apr 27, 2024
3c03dac
lib vtls gtls
vszakats Apr 27, 2024
79ec9e2
lib vtls mbedtls
vszakats Apr 27, 2024
83992fb
lib vtls openssl
vszakats Apr 25, 2024
065b155
lib vtls rustls
vszakats Apr 28, 2024
dcd22ca
lib vtls schannel
vszakats Apr 28, 2024
62914b7
lib vtls schannel_verify
vszakats Apr 28, 2024
b3a76d0
lib vtls sectransp also fix CURLcode/OSStatus mixup
vszakats Apr 28, 2024
5a57914
lib vtls wolfssl
vszakats Apr 27, 2024
63617c3
lib vtls x509asn1
vszakats Apr 27, 2024
386c6a5
lib vtls/vauth/common
vszakats Apr 25, 2024
8d73f27
src PR #13470
vszakats Apr 25, 2024
4fe58c4
src tool_cb_rea suppress sign-conversion for FD_SET
vszakats Apr 28, 2024
26d885e
tests unit
vszakats Apr 24, 2024
12cbfca
tests libtest FD_SET/FD_ISSET workaround
vszakats Apr 28, 2024
00faffa
tests server common
vszakats Apr 24, 2024
a245a85
tests server mqttd FD_SET/FD_ISSET workaround
vszakats Apr 28, 2024
3f2aa31
tests server rtspd
vszakats Apr 24, 2024
cabc050
tests server sockfilt win32
vszakats Apr 28, 2024
d0ad0de
tests server sockfilt FD_SET/FD_ISSET workaround
vszakats Apr 28, 2024
80f222e
tests server socksd FD_SET/FD_ISSET workaround
vszakats Apr 28, 2024
fdce83f
tests server sws
vszakats Apr 24, 2024
e88bc80
tests server sws FD_SET/FD_ISSET workaround
vszakats Apr 28, 2024
b1fa45b
test unit1604 avoid sign conversion
vszakats Jun 2, 2024
6eb0b5b
lib vtls sectransp
vszakats Jun 2, 2024
a67a427
lib krb5 fix type from int to enum
vszakats Jun 2, 2024
6df4f26
tests libtest sethostname add cast
vszakats Jun 2, 2024
63489ce
Revert "lib krb5 fix type from int to enum"
vszakats Jun 2, 2024
9ee6bb4
lib krb5 cast enum to int
vszakats Jun 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ jobs:
- name: openssl3-O3
install_packages: zlib1g-dev valgrind
install_steps: gcc-11 openssl3
configure: CPPFLAGS=-DCURL_WARN_SIGN_CONVERSION CFLAGS=-O3 LDFLAGS="-Wl,-rpath,$HOME/openssl3/lib" --with-openssl=$HOME/openssl3 --enable-debug --enable-websockets
configure: CFLAGS=-O3 LDFLAGS="-Wl,-rpath,$HOME/openssl3/lib" --with-openssl=$HOME/openssl3 --enable-debug --enable-websockets
singleuse: --unit

- name: openssl3-clang
Expand Down
1 change: 0 additions & 1 deletion CMake/PickyWarnings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ if(PICKY_COMPILER)
-Wold-style-definition # clang 2.7 gcc 3.4
-Wredundant-decls # clang 2.7 gcc 4.1
-Wsign-conversion # clang 2.9 gcc 4.3
-Wno-error=sign-conversion # FIXME
-Wstrict-prototypes # clang 1.0 gcc 3.3
# -Wswitch-enum # clang 2.7 gcc 4.1 # Not used because this basically disallows default case
-Wtype-limits # clang 2.7 gcc 4.3
Expand Down
12 changes: 6 additions & 6 deletions lib/altsvc.c
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ static CURLcode altsvc_out(struct altsvc *as, FILE *fp)
"%s %s%s%s %u "
"\"%d%02d%02d "
"%02d:%02d:%02d\" "
"%u %d\n",
"%u %u\n",
Curl_alpnid2str(as->src.alpnid),
src6_pre, as->src.host, src6_post,
as->src.port,
Expand Down Expand Up @@ -409,7 +409,7 @@ static CURLcode getalnum(const char **ptr, char *alpnbuf, size_t buflen)
protop = p;
while(*p && !ISBLANK(*p) && (*p != ';') && (*p != '='))
p++;
len = p - protop;
len = (size_t)(p - protop);
*ptr = p;

if(!len || (len >= buflen))
Expand Down Expand Up @@ -462,7 +462,7 @@ static time_t altsvc_debugtime(void *unused)
char *timestr = getenv("CURL_TIME");
(void)unused;
if(timestr) {
unsigned long val = strtol(timestr, NULL, 10);
long val = strtol(timestr, NULL, 10);
return (time_t)val;
}
return time(NULL);
Expand Down Expand Up @@ -546,7 +546,7 @@ CURLcode Curl_altsvc_parse(struct Curl_easy *data,
else {
while(*p && (ISALNUM(*p) || (*p == '.') || (*p == '-')))
p++;
len = p - hostp;
len = (size_t)(p - hostp);
}
if(!len || (len >= MAX_ALTSVC_HOSTLEN)) {
infof(data, "Excessive alt-svc host name, ignoring.");
Expand Down Expand Up @@ -624,7 +624,7 @@ CURLcode Curl_altsvc_parse(struct Curl_easy *data,
num = strtoul(value_ptr, &end_ptr, 10);
if((end_ptr != value_ptr) && (num < ULONG_MAX)) {
if(strcasecompare("ma", option))
maxage = num;
maxage = (time_t)num;
else if(strcasecompare("persist", option) && (num == 1))
persist = TRUE;
}
Expand Down Expand Up @@ -696,7 +696,7 @@ bool Curl_altsvc_lookup(struct altsvcinfo *asi,
if((as->src.alpnid == srcalpnid) &&
hostcompare(srchost, as->src.host) &&
(as->src.port == srcport) &&
(versions & as->dst.alpnid)) {
(versions & (int)as->dst.alpnid)) {
/* match */
*dstentry = as;
return TRUE;
Expand Down
2 changes: 1 addition & 1 deletion lib/altsvc.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ struct altsvc {
struct althost dst;
time_t expires;
bool persist;
int prio;
unsigned int prio;
struct Curl_llist_element node;
};

Expand Down
2 changes: 1 addition & 1 deletion lib/asyn-ares.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ static int waitperform(struct Curl_easy *data, timediff_t timeout_ms)
}

if(num) {
nfds = Curl_poll(pfd, num, timeout_ms);
nfds = Curl_poll(pfd, (unsigned int)num, timeout_ms);
if(nfds < 0)
return -1;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/asyn-thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ static bool init_resolve_thread(struct Curl_easy *data,
NULL, &td->tsd.w8.overlapped,
&query_complete, &td->tsd.w8.cancel_ev);
if(err != WSA_IO_PENDING)
query_complete(err, 0, &td->tsd.w8.overlapped);
query_complete((DWORD)err, 0, &td->tsd.w8.overlapped);
return TRUE;
}
}
Expand Down
10 changes: 5 additions & 5 deletions lib/bufq.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ static ssize_t chunk_slurpn(struct buf_chunk *chunk, size_t max_len,
nread = reader(reader_ctx, p, n, err);
if(nread > 0) {
DEBUGASSERT((size_t)nread <= n);
chunk->w_offset += nread;
chunk->w_offset += (size_t)nread;
}
return nread;
}
Expand Down Expand Up @@ -405,7 +405,7 @@ ssize_t Curl_bufq_write(struct bufq *q,
n = chunk_append(tail, buf, len);
if(!n)
break;
nwritten += n;
nwritten += (ssize_t)n;
buf += n;
len -= n;
}
Expand Down Expand Up @@ -438,7 +438,7 @@ ssize_t Curl_bufq_read(struct bufq *q, unsigned char *buf, size_t len,
while(len && q->head) {
n = chunk_read(q->head, buf, len);
if(n) {
nread += n;
nread += (ssize_t)n;
buf += n;
len -= n;
}
Expand Down Expand Up @@ -582,7 +582,7 @@ ssize_t Curl_bufq_write_pass(struct bufq *q,
/* Maybe only part of `data` has been added, continue to loop */
buf += (size_t)n;
len -= (size_t)n;
nwritten += (size_t)n;
nwritten += n;
}

if(!nwritten && len) {
Expand Down Expand Up @@ -656,7 +656,7 @@ static ssize_t bufq_slurpn(struct bufq *q, size_t max_len,
*err = CURLE_OK;
break;
}
nread += (size_t)n;
nread += n;
if(max_len) {
DEBUGASSERT((size_t)n <= max_len);
max_len -= (size_t)n;
Expand Down
8 changes: 4 additions & 4 deletions lib/c-hyper.c
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ CURLcode Curl_hyper_header(struct Curl_easy *data, hyper_headers *headers,
if(!p)
/* this is fine if we already added at least one header */
return numh ? CURLE_OK : CURLE_BAD_FUNCTION_ARGUMENT;
nlen = p - n;
nlen = (size_t)(p - n);
p++; /* move past the colon */
while(*p == ' ')
p++;
Expand All @@ -587,8 +587,8 @@ CURLcode Curl_hyper_header(struct Curl_easy *data, hyper_headers *headers,
}
else
linelen = 2; /* CRLF ending */
linelen += (p - n);
vlen = p - v;
linelen += (size_t)(p - n);
vlen = (size_t)(p - v);

if(HYPERE_OK != hyper_headers_add(headers, (uint8_t *)n, nlen,
(uint8_t *)v, vlen)) {
Expand Down Expand Up @@ -670,7 +670,7 @@ static int uploadstreamed(void *userdata, hyper_context *ctx,
}
/* increasing the writebytecount here is a little premature but we
don't know exactly when the body is sent */
data->req.writebytecount += fillcount;
data->req.writebytecount += (curl_off_t)fillcount;
Curl_pgrsSetUploadCounter(data, data->req.writebytecount);
rc = HYPER_POLL_READY;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/cf-h2-proxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -1418,7 +1418,7 @@ static ssize_t cf_h2_proxy_send(struct Curl_cfilter *cf,
/* Unable to send all data, due to connection blocked or H2 window
* exhaustion. Data is left in our stream buffer, or nghttp2's internal
* frame buffer or our network out buffer. */
size_t rwin = nghttp2_session_get_stream_remote_window_size(
size_t rwin = (size_t)nghttp2_session_get_stream_remote_window_size(
ctx->h2, ctx->tunnel.stream_id);
if(rwin == 0) {
/* H2 flow window exhaustion.
Expand All @@ -1433,7 +1433,7 @@ static ssize_t cf_h2_proxy_send(struct Curl_cfilter *cf,
/* Whatever the cause, we need to return CURL_EAGAIN for this call.
* We have unwritten state that needs us being invoked again and EAGAIN
* is the only way to ensure that. */
ctx->tunnel.upload_blocked_len = nwritten;
ctx->tunnel.upload_blocked_len = (size_t)nwritten;
CURL_TRC_CF(data, cf, "[%d] cf_send(len=%zu) BLOCK: win %u/%zu "
"blocked_len=%zu",
ctx->tunnel.stream_id, len,
Expand Down
18 changes: 10 additions & 8 deletions lib/cf-socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,10 @@ tcpkeepalive(struct Curl_easy *data,
vals.onoff = 1;
optval = curlx_sltosi(data->set.tcp_keepidle);
KEEPALIVE_FACTOR(optval);
vals.keepalivetime = optval;
vals.keepalivetime = (u_long)optval;
optval = curlx_sltosi(data->set.tcp_keepintvl);
KEEPALIVE_FACTOR(optval);
vals.keepaliveinterval = optval;
vals.keepaliveinterval = (u_long)optval;
if(WSAIoctl(sockfd, SIO_KEEPALIVE_VALS, (LPVOID) &vals, sizeof(vals),
NULL, 0, &dummy, NULL, NULL) != 0) {
infof(data, "Failed to set SIO_KEEPALIVE_VALS on fd "
Expand Down Expand Up @@ -255,7 +255,7 @@ void Curl_sock_assign_addr(struct Curl_sockaddr_ex *dest,
dest->protocol = IPPROTO_UDP;
break;
}
dest->addrlen = ai->ai_addrlen;
dest->addrlen = (unsigned int)ai->ai_addrlen;

if(dest->addrlen > sizeof(struct Curl_sockaddr_storage))
dest->addrlen = sizeof(struct Curl_sockaddr_storage);
Expand Down Expand Up @@ -959,7 +959,7 @@ static CURLcode set_remote_ip(struct Curl_cfilter *cf,
struct cf_socket_ctx *ctx = cf->ctx;

/* store remote address and port used in this connection attempt */
if(!Curl_addr2string(&ctx->addr.sa_addr, ctx->addr.addrlen,
if(!Curl_addr2string(&ctx->addr.sa_addr, (curl_socklen_t)ctx->addr.addrlen,
ctx->ip.remote_ip, &ctx->ip.remote_port)) {
char buffer[STRERROR_LEN];

Expand Down Expand Up @@ -1124,7 +1124,8 @@ static int do_connect(struct Curl_cfilter *cf, struct Curl_easy *data,
#endif
}
else {
rc = connect(ctx->sock, &ctx->addr.sa_addr, ctx->addr.addrlen);
rc = connect(ctx->sock, &ctx->addr.sa_addr,
(curl_socklen_t)ctx->addr.addrlen);
}
return rc;
}
Expand Down Expand Up @@ -1326,7 +1327,7 @@ static ssize_t cf_socket_send(struct Curl_cfilter *cf, struct Curl_easy *data,
}
}
if(cf->cft != &Curl_cft_udp && ctx->wpartial_percent > 0 && len > 8) {
len = len * ctx->wpartial_percent / 100;
len = len * (size_t)ctx->wpartial_percent / 100;
if(!len)
len = 1;
CURL_TRC_CF(data, cf, "send(len=%zu) SIMULATE partial write of %zu bytes",
Expand Down Expand Up @@ -1662,7 +1663,8 @@ static CURLcode cf_udp_setup_quic(struct Curl_cfilter *cf,
/* On macOS OpenSSL QUIC fails on connected sockets.
* see: <https://github.com/openssl/openssl/issues/23251> */
#else
rc = connect(ctx->sock, &ctx->addr.sa_addr, ctx->addr.addrlen);
rc = connect(ctx->sock, &ctx->addr.sa_addr,
(curl_socklen_t)ctx->addr.addrlen);
if(-1 == rc) {
return socket_connect_result(data, ctx->ip.remote_ip, SOCKERRNO);
}
Expand Down Expand Up @@ -1922,7 +1924,7 @@ static void set_accepted_remote_ip(struct Curl_cfilter *cf,
ctx->ip.remote_ip[0] = 0;
ctx->ip.remote_port = 0;
plen = sizeof(ssrem);
memset(&ssrem, 0, plen);
memset(&ssrem, 0, (size_t)plen);
if(getpeername(ctx->sock, (struct sockaddr*) &ssrem, &plen)) {
int error = SOCKERRNO;
failf(data, "getpeername() failed with errno %d: %s",
Expand Down
2 changes: 1 addition & 1 deletion lib/cfilters.c
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ CURLcode Curl_conn_recv(struct Curl_easy *data, int sockindex,
nread = data->conn->recv[sockindex](data, sockindex, buf, blen, &result);
DEBUGASSERT(nread >= 0 || result);
DEBUGASSERT(nread < 0 || !result);
*n = (nread >= 0)? (size_t)nread : 0;
*n = (nread >= 0)? nread : 0;
return result;
}

Expand Down
11 changes: 6 additions & 5 deletions lib/content_encoding.c
Original file line number Diff line number Diff line change
Expand Up @@ -491,10 +491,11 @@ static CURLcode gzip_do_write(struct Curl_easy *data,
/* Initial call state */
ssize_t hlen;

switch(check_gzip_header((unsigned char *) buf, nbytes, &hlen)) {
/* FIXME: nbytes cast */
switch(check_gzip_header((unsigned char *) buf, (ssize_t)nbytes, &hlen)) {
case GZIP_OK:
z->next_in = (Bytef *) buf + hlen;
z->avail_in = (uInt) (nbytes - hlen);
z->avail_in = (uInt) (nbytes - (size_t)hlen);
zp->zlib_init = ZLIB_GZIP_INFLATING; /* Inflating stream state */
break;

Expand Down Expand Up @@ -536,13 +537,13 @@ static CURLcode gzip_do_write(struct Curl_easy *data,
/* Append the new block of data to the previous one */
memcpy(z->next_in + z->avail_in - nbytes, buf, nbytes);

switch(check_gzip_header(z->next_in, z->avail_in, &hlen)) {
switch(check_gzip_header(z->next_in, (ssize_t)z->avail_in, &hlen)) {
case GZIP_OK:
/* This is the zlib stream data */
free(z->next_in);
/* Don't point into the malloced block since we just freed it */
z->next_in = (Bytef *) buf + hlen + nbytes - z->avail_in;
z->avail_in = (uInt) (z->avail_in - hlen);
z->avail_in = z->avail_in - (uInt)hlen;
zp->zlib_init = ZLIB_GZIP_INFLATING; /* Inflating stream state */
break;

Expand Down Expand Up @@ -988,7 +989,7 @@ CURLcode Curl_build_unencoding_stack(struct Curl_easy *data,

for(namelen = 0; *enclist && *enclist != ','; enclist++)
if(!ISSPACE(*enclist))
namelen = enclist - name + 1;
namelen = (size_t)(enclist - name + 1);

if(namelen) {
const struct Curl_cwtype *cwt;
Expand Down
17 changes: 9 additions & 8 deletions lib/cookie.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,9 @@ static const char *get_top_domain(const char * const domain, size_t *outlen)
len = strlen(domain);
last = memrchr(domain, '.', len);
if(last) {
first = memrchr(domain, '.', (last - domain));
first = memrchr(domain, '.', (size_t)(last - domain));
if(first)
len -= (++first - domain);
len -= (size_t)(++first - domain);
}
}

Expand All @@ -262,8 +262,9 @@ static size_t cookie_hash_domain(const char *domain, const size_t len)
size_t h = 5381;

while(domain < end) {
size_t j = (size_t)Curl_raw_toupper(*domain++);
h += h << 5;
h ^= Curl_raw_toupper(*domain++);
h ^= j;
}

return (h % COOKIE_HASH_SIZE);
Expand Down Expand Up @@ -436,7 +437,7 @@ static bool bad_domain(const char *domain, size_t len)
/* there must be a dot present, but that dot must not be a trailing dot */
char *dot = memchr(domain, '.', len);
if(dot) {
size_t i = dot - domain;
size_t i = (size_t)(dot - domain);
if((len - i) > 1)
/* the dot is not the last byte */
return FALSE;
Expand Down Expand Up @@ -820,9 +821,9 @@ Curl_cookie_add(struct Curl_easy *data,
if(!queryp)
endslash = strrchr(path, '/');
else
endslash = memrchr(path, '/', (queryp - path));
endslash = memrchr(path, '/', (size_t)(queryp - path));
if(endslash) {
size_t pathlen = (endslash-path + 1); /* include end slash */
size_t pathlen = (size_t)(endslash-path + 1); /* include end slash */
co->path = Curl_memdup0(path, pathlen);
if(co->path) {
co->spath = sanitize_cookie_path(co->path);
Expand Down Expand Up @@ -1087,7 +1088,7 @@ Curl_cookie_add(struct Curl_easy *data,
sep = strchr(clist->spath + 1, '/');

if(sep)
cllen = sep - clist->spath;
cllen = (size_t)(sep - clist->spath);
else
cllen = strlen(clist->spath);

Expand Down Expand Up @@ -1646,7 +1647,7 @@ static CURLcode cookie_output(struct Curl_easy *data,
size_t nvalid = 0;
struct Cookie **array;

array = calloc(1, sizeof(struct Cookie *) * c->numcookies);
array = calloc(1, sizeof(struct Cookie *) * (size_t)c->numcookies);
if(!array) {
error = CURLE_OUT_OF_MEMORY;
goto error;
Expand Down
8 changes: 8 additions & 0 deletions lib/curl_addrinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,11 @@ 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));
#ifdef __MINGW32__
addr->sin_family = (short)(he->h_addrtype);
#else
addr->sin_family = (CURL_SA_FAMILY_T)(he->h_addrtype);
#endif
addr->sin_port = htons((unsigned short)port);
break;

Expand All @@ -326,7 +330,11 @@ 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));
#ifdef __MINGW32__
addr6->sin6_family = (short)(he->h_addrtype);
#else
addr6->sin6_family = (CURL_SA_FAMILY_T)(he->h_addrtype);
#endif
addr6->sin6_port = htons((unsigned short)port);
break;
#endif
Expand Down