summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2018-05-11 23:40:58 +0200
committerDaniel Stenberg <daniel@haxx.se>2018-05-14 10:59:11 +0200
commiteaf3200f7f08cd7ee5afede3b5576cdac0266665 (patch)
treee961f65ad27632ddb6e3fd2e38cdaacef808e047
parent07b9826541ec429433495d237301d59a5d8bfd22 (diff)
downloadcurl-bagder/unify-sizeof.tar.gz
checksrc: make sure sizeof() is used *with* parenthesesbagder/unify-sizeof
... and unify the source code to adhere.
-rw-r--r--docs/examples/cacertinmem.c4
-rw-r--r--docs/examples/multi-uv.c4
-rwxr-xr-xlib/checksrc.pl12
-rw-r--r--lib/formdata.c2
-rw-r--r--lib/hmac.c4
-rw-r--r--lib/http.c2
-rw-r--r--lib/http2.c2
-rw-r--r--lib/inet_ntop.c2
-rw-r--r--lib/md5.c4
-rw-r--r--lib/mime.c12
-rw-r--r--lib/telnet.c10
-rw-r--r--lib/version.c2
-rw-r--r--lib/vtls/cyassl.c2
-rw-r--r--lib/vtls/gskit.c32
-rw-r--r--lib/vtls/nss.c11
-rw-r--r--lib/vtls/schannel.c2
-rw-r--r--lib/x509asn1.c4
-rw-r--r--src/tool_formparse.c8
-rw-r--r--src/tool_metalink.c6
-rw-r--r--tests/libtest/lib544.c2
-rw-r--r--tests/libtest/lib552.c4
-rw-r--r--tests/libtest/lib650.c4
-rw-r--r--tests/libtest/lib652.c4
-rw-r--r--tests/unit/unit1604.c4
-rw-r--r--tests/unit/unit1607.c2
25 files changed, 79 insertions, 66 deletions
diff --git a/docs/examples/cacertinmem.c b/docs/examples/cacertinmem.c
index cf7c76e14..6f4c61cbf 100644
--- a/docs/examples/cacertinmem.c
+++ b/docs/examples/cacertinmem.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -111,7 +111,7 @@ err:
fprintf(stderr, "error adding certificate\n");
if(error) {
- ERR_error_string_n(error, errbuf, sizeof errbuf);
+ ERR_error_string_n(error, errbuf, sizeof(errbuf));
fprintf(stderr, "%s\n", errbuf);
}
}
diff --git a/docs/examples/multi-uv.c b/docs/examples/multi-uv.c
index ceddad04a..1d8c96f58 100644
--- a/docs/examples/multi-uv.c
+++ b/docs/examples/multi-uv.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -50,7 +50,7 @@ static curl_context_t* create_curl_context(curl_socket_t sockfd)
{
curl_context_t *context;
- context = (curl_context_t *) malloc(sizeof *context);
+ context = (curl_context_t *) malloc(sizeof(*context));
context->sockfd = sockfd;
diff --git a/lib/checksrc.pl b/lib/checksrc.pl
index c90e245ee..daff07bf5 100755
--- a/lib/checksrc.pl
+++ b/lib/checksrc.pl
@@ -63,6 +63,7 @@ my %warnings = (
'NOSPACEEQUALS' => 'equals sign without preceding space',
'SEMINOSPACE' => 'semicolon without following space',
'MULTISPACE' => 'multiple spaces used when not suitable',
+ 'SIZEOFNOPAREN' => 'use of sizeof without parentheses',
);
sub readwhitelist {
@@ -417,6 +418,17 @@ sub scanfile {
}
}
+ # check for "sizeof" without parenthesis
+ if(($l =~ /^(.*)sizeof *([ (])/) && ($2 ne "(")) {
+ if($1 =~ / *\#/) {
+ # this is a #if, treat it differently
+ }
+ else {
+ checkwarn("SIZEOFNOPAREN", $line, length($1)+6, $file, $l,
+ "sizeof without parenthesis");
+ }
+ }
+
# check for comma without space
if($l =~ /^(.*),[^ \n]/) {
my $pref=$1;
diff --git a/lib/formdata.c b/lib/formdata.c
index f91241052..53fe2cf06 100644
--- a/lib/formdata.c
+++ b/lib/formdata.c
@@ -725,7 +725,7 @@ int curl_formget(struct curl_httppost *form, void *arg,
while(!result) {
char buffer[8192];
- size_t nread = Curl_mime_read(buffer, 1, sizeof buffer, &toppart);
+ size_t nread = Curl_mime_read(buffer, 1, sizeof(buffer), &toppart);
if(!nread)
break;
diff --git a/lib/hmac.c b/lib/hmac.c
index dae95054b..bf49ebec5 100644
--- a/lib/hmac.c
+++ b/lib/hmac.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -58,7 +58,7 @@ Curl_HMAC_init(const HMAC_params * hashparams,
unsigned char b;
/* Create HMAC context. */
- i = sizeof *ctxt + 2 * hashparams->hmac_ctxtsize +
+ i = sizeof(*ctxt) + 2 * hashparams->hmac_ctxtsize +
hashparams->hmac_resultlen;
ctxt = malloc(i);
diff --git a/lib/http.c b/lib/http.c
index ff1d6813a..d4854013d 100644
--- a/lib/http.c
+++ b/lib/http.c
@@ -1406,7 +1406,7 @@ static CURLcode add_haproxy_protocol_header(struct connectdata *conn)
}
snprintf(proxy_header,
- sizeof proxy_header,
+ sizeof(proxy_header),
"PROXY %s %s %s %li %li\r\n",
tcp_version,
conn->data->info.conn_local_ip,
diff --git a/lib/http2.c b/lib/http2.c
index 62b109293..6c7eb33a6 100644
--- a/lib/http2.c
+++ b/lib/http2.c
@@ -345,7 +345,7 @@ const char *Curl_http2_strerror(uint32_t err)
"INADEQUATE_SECURITY", /* 0xC */
"HTTP_1_1_REQUIRED" /* 0xD */
};
- return (err < sizeof str / sizeof str[0]) ? str[err] : "unknown";
+ return (err < sizeof(str) / sizeof(str[0])) ? str[err] : "unknown";
#else
return nghttp2_http2_strerror(err);
#endif
diff --git a/lib/inet_ntop.c b/lib/inet_ntop.c
index fb91a505d..ac5d2d4d6 100644
--- a/lib/inet_ntop.c
+++ b/lib/inet_ntop.c
@@ -49,7 +49,7 @@
*/
static char *inet_ntop4 (const unsigned char *src, char *dst, size_t size)
{
- char tmp[sizeof "255.255.255.255"];
+ char tmp[sizeof("255.255.255.255")];
size_t len;
DEBUGASSERT(size >= 16);
diff --git a/lib/md5.c b/lib/md5.c
index 80301a141..c96dc4bda 100644
--- a/lib/md5.c
+++ b/lib/md5.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -522,7 +522,7 @@ MD5_context *Curl_MD5_init(const MD5_params *md5params)
MD5_context *ctxt;
/* Create MD5 context */
- ctxt = malloc(sizeof *ctxt);
+ ctxt = malloc(sizeof(*ctxt));
if(!ctxt)
return ctxt;
diff --git a/lib/mime.c b/lib/mime.c
index 4c0d2eeba..7319b7caa 100644
--- a/lib/mime.c
+++ b/lib/mime.c
@@ -787,10 +787,10 @@ static size_t read_encoded_part_content(curl_mimepart *part,
st->bufbeg = 0;
st->bufend = len;
}
- if(st->bufend >= sizeof st->buf)
+ if(st->bufend >= sizeof(st->buf))
return cursize? cursize: READ_ERROR; /* Buffer full. */
sz = read_part_content(part, st->buf + st->bufend,
- sizeof st->buf - st->bufend);
+ sizeof(st->buf) - st->bufend);
switch(sz) {
case 0:
ateof = TRUE;
@@ -1220,7 +1220,7 @@ curl_mime *curl_mime_init(struct Curl_easy *easy)
{
curl_mime *mime;
- mime = (curl_mime *) malloc(sizeof *mime);
+ mime = (curl_mime *) malloc(sizeof(*mime));
if(mime) {
mime->easy = easy;
@@ -1247,7 +1247,7 @@ curl_mime *curl_mime_init(struct Curl_easy *easy)
/* Initialize a mime part. */
void Curl_mime_initpart(curl_mimepart *part, struct Curl_easy *easy)
{
- memset((char *) part, 0, sizeof *part);
+ memset((char *) part, 0, sizeof(*part));
part->easy = easy;
mimesetstate(&part->state, MIMESTATE_BEGIN, NULL);
}
@@ -1260,7 +1260,7 @@ curl_mimepart *curl_mime_addpart(curl_mime *mime)
if(!mime)
return NULL;
- part = (curl_mimepart *) malloc(sizeof *part);
+ part = (curl_mimepart *) malloc(sizeof(*part));
if(part) {
Curl_mime_initpart(part, mime->easy);
@@ -1670,7 +1670,7 @@ const char *Curl_mime_contenttype(const char *filename)
size_t len1 = strlen(filename);
const char *nameend = filename + len1;
- for(i = 0; i < sizeof ctts / sizeof ctts[0]; i++) {
+ for(i = 0; i < sizeof(ctts) / sizeof(ctts[0]); i++) {
size_t len2 = strlen(ctts[i].extension);
if(len1 >= len2 && strcasecompare(nameend - len2, ctts[i].extension))
diff --git a/lib/telnet.c b/lib/telnet.c
index d71c8e067..8f5ee57ab 100644
--- a/lib/telnet.c
+++ b/lib/telnet.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -74,10 +74,10 @@
x->subend = x->subpointer; \
CURL_SB_CLEAR(x); \
} WHILE_FALSE
-#define CURL_SB_ACCUM(x,c) \
- do { \
- if(x->subpointer < (x->subbuffer + sizeof x->subbuffer)) \
- *x->subpointer++ = (c); \
+#define CURL_SB_ACCUM(x,c) \
+ do { \
+ if(x->subpointer < (x->subbuffer + sizeof(x->subbuffer))) \
+ *x->subpointer++ = (c); \
} WHILE_FALSE
#define CURL_SB_GET(x) ((*x->subpointer++)&0xff)
diff --git a/lib/version.c b/lib/version.c
index 5b0d05a15..05c2cd8b0 100644
--- a/lib/version.c
+++ b/lib/version.c
@@ -445,7 +445,7 @@ curl_version_info_data *curl_version_info(CURLversion stamp)
#ifdef HAVE_BROTLI
version_info.brotli_ver_num = BrotliDecoderVersion();
- brotli_version(brotli_buffer, sizeof brotli_buffer);
+ brotli_version(brotli_buffer, sizeof(brotli_buffer));
version_info.brotli_version = brotli_buffer;
#endif
diff --git a/lib/vtls/cyassl.c b/lib/vtls/cyassl.c
index 20ce460e8..0e940487a 100644
--- a/lib/vtls/cyassl.c
+++ b/lib/vtls/cyassl.c
@@ -569,7 +569,7 @@ cyassl_connect_step2(struct connectdata *conn,
return CURLE_SSL_PINNEDPUBKEYNOTMATCH;
}
- memset(&x509_parsed, 0, sizeof x509_parsed);
+ memset(&x509_parsed, 0, sizeof(x509_parsed));
if(Curl_parseX509(&x509_parsed, x509_der, x509_der + x509_der_len))
return CURLE_SSL_PINNEDPUBKEYNOTMATCH;
diff --git a/lib/vtls/gskit.c b/lib/vtls/gskit.c
index b0856cdf4..a0b49601f 100644
--- a/lib/vtls/gskit.c
+++ b/lib/vtls/gskit.c
@@ -328,7 +328,7 @@ static CURLcode set_ciphers(struct connectdata *conn,
GSKit tokens are always shorter than their cipher names, allocated buffers
will always be large enough to accommodate the result. */
l = strlen(cipherlist) + 1;
- memset((char *) ciphers, 0, sizeof ciphers);
+ memset((char *) ciphers, 0, sizeof(ciphers));
for(i = 0; i < CURL_GSKPROTO_LAST; i++) {
ciphers[i].buf = malloc(l);
if(!ciphers[i].buf) {
@@ -536,18 +536,18 @@ inetsocketpair(int sv[2])
lfd = socket(AF_INET, SOCK_STREAM, 0);
if(lfd < 0)
return -1;
- memset((char *) &addr1, 0, sizeof addr1);
+ memset((char *) &addr1, 0, sizeof(addr1));
addr1.sin_family = AF_INET;
addr1.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
addr1.sin_port = 0;
- if(bind(lfd, (struct sockaddr *) &addr1, sizeof addr1) ||
+ if(bind(lfd, (struct sockaddr *) &addr1, sizeof(addr1)) ||
listen(lfd, 2) < 0) {
close(lfd);
return -1;
}
/* Get the allocated port. */
- len = sizeof addr1;
+ len = sizeof(addr1);
if(getsockname(lfd, (struct sockaddr *) &addr1, &len) < 0) {
close(lfd);
return -1;
@@ -562,7 +562,7 @@ inetsocketpair(int sv[2])
/* Request unblocking connection to the listening socket. */
curlx_nonblock(cfd, TRUE);
- if(connect(cfd, (struct sockaddr *) &addr1, sizeof addr1) < 0 &&
+ if(connect(cfd, (struct sockaddr *) &addr1, sizeof(addr1)) < 0 &&
errno != EINPROGRESS) {
close(lfd);
close(cfd);
@@ -570,7 +570,7 @@ inetsocketpair(int sv[2])
}
/* Get the client dynamic port for intrusion check below. */
- len = sizeof addr2;
+ len = sizeof(addr2);
if(getsockname(cfd, (struct sockaddr *) &addr2, &len) < 0) {
close(lfd);
close(cfd);
@@ -580,7 +580,7 @@ inetsocketpair(int sv[2])
/* Accept the incoming connection and get the server socket. */
curlx_nonblock(lfd, TRUE);
for(;;) {
- len = sizeof addr1;
+ len = sizeof(addr1);
sfd = accept(lfd, (struct sockaddr *) &addr1, &len);
if(sfd < 0) {
close(lfd);
@@ -644,7 +644,7 @@ static int pipe_ssloverssl(struct connectdata *conn, int sockindex,
/* Try getting data from HTTPS proxy and pipe it upstream. */
n = 0;
i = gsk_secure_soc_read(connproxyssl->backend->handle,
- buf, sizeof buf, &n);
+ buf, sizeof(buf), &n);
switch(i) {
case GSK_OK:
if(n) {
@@ -665,7 +665,7 @@ static int pipe_ssloverssl(struct connectdata *conn, int sockindex,
if(FD_ISSET(BACKEND->remotefd, &fds_read) &&
FD_ISSET(conn->sock[sockindex], &fds_write)) {
/* Pipe data to HTTPS proxy. */
- n = read(BACKEND->remotefd, buf, sizeof buf);
+ n = read(BACKEND->remotefd, buf, sizeof(buf));
if(n < 0)
return -1;
if(n) {
@@ -864,13 +864,13 @@ static CURLcode gskit_connect_step1(struct connectdata *conn, int sockindex)
BACKEND->localfd = sockpair[0];
BACKEND->remotefd = sockpair[1];
setsockopt(BACKEND->localfd, SOL_SOCKET, SO_RCVBUF,
- (void *) sobufsize, sizeof sobufsize);
+ (void *) sobufsize, sizeof(sobufsize));
setsockopt(BACKEND->remotefd, SOL_SOCKET, SO_RCVBUF,
- (void *) sobufsize, sizeof sobufsize);
+ (void *) sobufsize, sizeof(sobufsize));
setsockopt(BACKEND->localfd, SOL_SOCKET, SO_SNDBUF,
- (void *) sobufsize, sizeof sobufsize);
+ (void *) sobufsize, sizeof(sobufsize));
setsockopt(BACKEND->remotefd, SOL_SOCKET, SO_SNDBUF,
- (void *) sobufsize, sizeof sobufsize);
+ (void *) sobufsize, sizeof(sobufsize));
curlx_nonblock(BACKEND->localfd, TRUE);
curlx_nonblock(BACKEND->remotefd, TRUE);
}
@@ -977,7 +977,7 @@ static CURLcode gskit_connect_step1(struct connectdata *conn, int sockindex)
if(!result) {
/* Start handshake. Try asynchronous first. */
- memset(&commarea, 0, sizeof commarea);
+ memset(&commarea, 0, sizeof(commarea));
BACKEND->iocport = QsoCreateIOCompletionPort();
if(BACKEND->iocport != -1) {
result = gskit_status(data,
@@ -1333,11 +1333,11 @@ static int Curl_gskit_check_cxn(struct connectdata *cxn)
return 0; /* connection has been closed */
err = 0;
- errlen = sizeof err;
+ errlen = sizeof(err);
if(getsockopt(cxn->sock[FIRSTSOCKET], SOL_SOCKET, SO_ERROR,
(unsigned char *) &err, &errlen) ||
- errlen != sizeof err || err)
+ errlen != sizeof(err) || err)
return 0; /* connection has been closed */
return -1; /* connection status unknown */
diff --git a/lib/vtls/nss.c b/lib/vtls/nss.c
index 7cd450cda..89f818397 100644
--- a/lib/vtls/nss.c
+++ b/lib/vtls/nss.c
@@ -394,7 +394,7 @@ static PK11SlotInfo* nss_find_slot_by_name(const char *slot_name)
/* wrap 'ptr' as list node and tail-insert into 'list' */
static CURLcode insert_wrapped_ptr(struct curl_llist *list, void *ptr)
{
- struct ptr_list_wrap *wrap = malloc(sizeof *wrap);
+ struct ptr_list_wrap *wrap = malloc(sizeof(*wrap));
if(!wrap)
return CURLE_OUT_OF_MEMORY;
@@ -914,11 +914,11 @@ static CURLcode display_conn_info(struct connectdata *conn, PRFileDesc *sock)
PRTime now;
int i;
- if(SSL_GetChannelInfo(sock, &channel, sizeof channel) ==
- SECSuccess && channel.length == sizeof channel &&
+ if(SSL_GetChannelInfo(sock, &channel, sizeof(channel)) ==
+ SECSuccess && channel.length == sizeof(channel) &&
channel.cipherSuite) {
if(SSL_GetCipherSuiteInfo(channel.cipherSuite,
- &suite, sizeof suite) == SECSuccess) {
+ &suite, sizeof(suite)) == SECSuccess) {
infof(conn->data, "SSL connection using %s\n", suite.cipherSuiteName);
}
}
@@ -1345,7 +1345,8 @@ static CURLcode nss_init(struct Curl_easy *data)
return CURLE_OUT_OF_MEMORY;
/* the default methods just call down to the lower I/O layer */
- memcpy(&nspr_io_methods, PR_GetDefaultIOMethods(), sizeof nspr_io_methods);
+ memcpy(&nspr_io_methods, PR_GetDefaultIOMethods(),
+ sizeof(nspr_io_methods));
/* override certain methods in the table by our wrappers */
nspr_io_methods.recv = nspr_io_recv;
diff --git a/lib/vtls/schannel.c b/lib/vtls/schannel.c
index 2cfd5c19f..5a3ca1123 100644
--- a/lib/vtls/schannel.c
+++ b/lib/vtls/schannel.c
@@ -1819,7 +1819,7 @@ static CURLcode pkp_pin_peer_pubkey(struct connectdata *conn, int sockindex,
x509_der = (const char *)pCertContextServer->pbCertEncoded;
x509_der_len = pCertContextServer->cbCertEncoded;
- memset(&x509_parsed, 0, sizeof x509_parsed);
+ memset(&x509_parsed, 0, sizeof(x509_parsed));
if(Curl_parseX509(&x509_parsed, x509_der, x509_der + x509_der_len))
break;
diff --git a/lib/x509asn1.c b/lib/x509asn1.c
index bba20233f..052bcad7e 100644
--- a/lib/x509asn1.c
+++ b/lib/x509asn1.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -712,7 +712,7 @@ int Curl_parseX509(curl_X509certificate *cert,
/* Get optional version, get serialNumber. */
cert->version.header = NULL;
cert->version.beg = &defaultVersion;
- cert->version.end = &defaultVersion + sizeof defaultVersion;;
+ cert->version.end = &defaultVersion + sizeof(defaultVersion);
beg = Curl_getASN1Element(&elem, beg, end);
if(elem.tag == 0) {
Curl_getASN1Element(&cert->version, elem.beg, elem.end);
diff --git a/src/tool_formparse.c b/src/tool_formparse.c
index 5313b3441..9fcf014b8 100644
--- a/src/tool_formparse.c
+++ b/src/tool_formparse.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -168,12 +168,12 @@ static int read_field_headers(struct OperationConfig *config,
pos++;
if(!incomment) {
- if(hdrlen == sizeof hdrbuf - 1) {
+ if(hdrlen == sizeof(hdrbuf) - 1) {
warnf(config->global, "File %s line %d: header too long (truncated)\n",
filename, lineno);
c = ' ';
}
- if(hdrlen <= sizeof hdrbuf - 1)
+ if(hdrlen <= sizeof(hdrbuf) - 1)
hdrbuf[hdrlen++] = (char) c;
}
}
@@ -451,7 +451,7 @@ static CURLcode file_or_stdin(curl_mimepart *part, const char *file)
if(strcmp(file, "-"))
return curl_mime_filedata(part, file);
- sip = (standard_input *) calloc(1, sizeof *sip);
+ sip = (standard_input *) calloc(1, sizeof(*sip));
if(!sip)
return CURLE_OUT_OF_MEMORY;
diff --git a/src/tool_metalink.c b/src/tool_metalink.c
index 91c5878c9..3dcf99006 100644
--- a/src/tool_metalink.c
+++ b/src/tool_metalink.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -246,7 +246,7 @@ static int nss_hash_init(void **pctx, SECOidTag hash_alg)
/* we have to initialize NSS if not initialized already */
if(!NSS_IsInitialized() && !nss_context) {
static NSSInitParameters params;
- params.length = sizeof params;
+ params.length = sizeof(params);
nss_context = NSS_InitContext("", "", "", "", &params, NSS_INIT_READONLY
| NSS_INIT_NOCERTDB | NSS_INIT_NOMODDB | NSS_INIT_FORCEOPEN
| NSS_INIT_NOROOTINIT | NSS_INIT_OPTIMIZESPACE | NSS_INIT_PK11RELOAD);
@@ -524,7 +524,7 @@ digest_context *Curl_digest_init(const digest_params *dparams)
digest_context *ctxt;
/* Create digest context */
- ctxt = malloc(sizeof *ctxt);
+ ctxt = malloc(sizeof(*ctxt));
if(!ctxt)
return ctxt;
diff --git a/tests/libtest/lib544.c b/tests/libtest/lib544.c
index cb1aefc87..60de7fc67 100644
--- a/tests/libtest/lib544.c
+++ b/tests/libtest/lib544.c
@@ -61,7 +61,7 @@ int test(char *URL)
test_setopt(curl, CURLOPT_URL, URL);
#ifdef LIB545
- test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long) sizeof teststring);
+ test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long) sizeof(teststring));
#endif
test_setopt(curl, CURLOPT_COPYPOSTFIELDS, teststring);
diff --git a/tests/libtest/lib552.c b/tests/libtest/lib552.c
index 83797f3c2..7a960417d 100644
--- a/tests/libtest/lib552.c
+++ b/tests/libtest/lib552.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -185,7 +185,7 @@ int test(char *URL)
/* setup repeated data string */
for(i = 0; i < sizeof(databuf); ++i)
- databuf[i] = fill[i % sizeof fill];
+ databuf[i] = fill[i % sizeof(fill)];
/* Post */
test_setopt(curl, CURLOPT_POST, 1L);
diff --git a/tests/libtest/lib650.c b/tests/libtest/lib650.c
index da1fd5672..056270cfb 100644
--- a/tests/libtest/lib650.c
+++ b/tests/libtest/lib650.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -153,7 +153,7 @@ int test(char *URL)
curl_formget(formpost, (void *) &formlength, count_chars);
/* Include length in data for external check. */
- curl_msnprintf(flbuf, sizeof flbuf, "%lu", (unsigned long) formlength);
+ curl_msnprintf(flbuf, sizeof(flbuf), "%lu", (unsigned long) formlength);
formrc = curl_formadd(&formpost,
&lastptr,
CURLFORM_COPYNAME, "formlength",
diff --git a/tests/libtest/lib652.c b/tests/libtest/lib652.c
index d60390b2f..5c9cba5fb 100644
--- a/tests/libtest/lib652.c
+++ b/tests/libtest/lib652.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -75,7 +75,7 @@ int test(char *URL)
fprintf(stderr, "curl_mime_type() failed\n");
goto test_cleanup;
}
- res = curl_mime_data(part, buffer, sizeof buffer);
+ res = curl_mime_data(part, buffer, sizeof(buffer));
if(res) {
fprintf(stderr, "curl_mime_data() failed\n");
goto test_cleanup;
diff --git a/tests/unit/unit1604.c b/tests/unit/unit1604.c
index b414e03e5..fbfd2c423 100644
--- a/tests/unit/unit1604.c
+++ b/tests/unit/unit1604.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -295,7 +295,7 @@ UNITTEST_START
size_t i;
- for(i = 0; i < sizeof data / sizeof data[0]; ++i) {
+ for(i = 0; i < sizeof(data) / sizeof(data[0]); ++i) {
char *output = NULL;
char *flagstr = NULL;
char *received_ccstr = NULL;
diff --git a/tests/unit/unit1607.c b/tests/unit/unit1607.c
index 71c59939b..697b8b5c4 100644
--- a/tests/unit/unit1607.c
+++ b/tests/unit/unit1607.c
@@ -120,7 +120,7 @@ UNITTEST_START
for(i = 0; i < testnum; ++i, curl_easy_reset(easy)) {
int j;
- int addressnum = sizeof tests[i].address / sizeof *tests[i].address;
+ int addressnum = sizeof(tests[i].address) / sizeof(*tests[i].address);
struct Curl_addrinfo *addr;
struct Curl_dns_entry *dns;
struct curl_slist *list;