From 6b3dde7fe62ea5a557fd1fd323fac2bcd0c2e9be Mon Sep 17 00:00:00 2001 From: Marcel Raad Date: Sat, 11 May 2019 14:51:24 +0200 Subject: build: fix "clarify calculation precedence" warnings Codacy/CppCheck warns about this. Consistently use parentheses as we already do in some places to silence the warning. Closes https://github.com/curl/curl/pull/3866 --- lib/asyn-ares.c | 4 ++-- lib/easy.c | 4 ++-- lib/formdata.c | 2 +- lib/mime.c | 6 ++++-- lib/multi.c | 4 ++-- lib/progress.c | 4 ++-- tests/libtest/lib1156.c | 4 ++-- 7 files changed, 15 insertions(+), 13 deletions(-) diff --git a/lib/asyn-ares.c b/lib/asyn-ares.c index fc107bc6b..2dd64a72a 100644 --- a/lib/asyn-ares.c +++ b/lib/asyn-ares.c @@ -331,9 +331,9 @@ static int waitperform(struct connectdata *conn, int timeout_ms) /* move through the descriptors and ask for processing on them */ for(i = 0; i < num; i++) ares_process_fd((ares_channel)data->state.resolver, - pfd[i].revents & (POLLRDNORM|POLLIN)? + (pfd[i].revents & (POLLRDNORM|POLLIN))? pfd[i].fd:ARES_SOCKET_BAD, - pfd[i].revents & (POLLWRNORM|POLLOUT)? + (pfd[i].revents & (POLLWRNORM|POLLOUT))? pfd[i].fd:ARES_SOCKET_BAD); } return nfds; diff --git a/lib/easy.c b/lib/easy.c index 40be38220..9fc33ccb2 100644 --- a/lib/easy.c +++ b/lib/easy.c @@ -451,8 +451,8 @@ static int events_socket(struct Curl_easy *easy, /* easy handle */ m->socket.revents = 0; ev->list = m; infof(easy, "socket cb: socket %d ADDED as %s%s\n", s, - what&CURL_POLL_IN?"IN":"", - what&CURL_POLL_OUT?"OUT":""); + (what&CURL_POLL_IN)?"IN":"", + (what&CURL_POLL_OUT)?"OUT":""); } else return CURLE_OUT_OF_MEMORY; diff --git a/lib/formdata.c b/lib/formdata.c index 202d930c7..fd0863ef6 100644 --- a/lib/formdata.c +++ b/lib/formdata.c @@ -569,7 +569,7 @@ CURLFORMcode FormAdd(struct curl_httppost **httppost, if(((form->flags & HTTPPOST_FILENAME) || (form->flags & HTTPPOST_BUFFER)) && !form->contenttype) { - char *f = form->flags & HTTPPOST_BUFFER? + char *f = (form->flags & HTTPPOST_BUFFER)? form->showfilename : form->value; char const *type; type = Curl_mime_contenttype(f); diff --git a/lib/mime.c b/lib/mime.c index 48147d4f5..6d4bc4fec 100644 --- a/lib/mime.c +++ b/lib/mime.c @@ -821,8 +821,10 @@ static size_t readback_part(curl_mimepart *part, struct curl_slist *hdr = (struct curl_slist *) part->state.ptr; switch(part->state.state) { case MIMESTATE_BEGIN: - mimesetstate(&part->state, part->flags & MIME_BODY_ONLY? MIMESTATE_BODY: - MIMESTATE_CURLHEADERS, part->curlheaders); + mimesetstate(&part->state, + (part->flags & MIME_BODY_ONLY)? + MIMESTATE_BODY: MIMESTATE_CURLHEADERS, + part->curlheaders); break; case MIMESTATE_USERHEADERS: if(!hdr) { diff --git a/lib/multi.c b/lib/multi.c index 631887bfc..71217989b 100644 --- a/lib/multi.c +++ b/lib/multi.c @@ -3056,8 +3056,8 @@ void Curl_multi_dump(struct Curl_multi *multi) continue; } fprintf(stderr, "[%s %s] ", - entry->action&CURL_POLL_IN?"RECVING":"", - entry->action&CURL_POLL_OUT?"SENDING":""); + (entry->action&CURL_POLL_IN)?"RECVING":"", + (entry->action&CURL_POLL_OUT)?"SENDING":""); } if(data->numsocks) fprintf(stderr, "\n"); diff --git a/lib/progress.c b/lib/progress.c index d37e1d5a6..fe9929bb9 100644 --- a/lib/progress.c +++ b/lib/progress.c @@ -564,9 +564,9 @@ int Curl_pgrsUpdate(struct connectdata *conn) /* Get the total amount of data expected to get transferred */ total_expected_transfer = - (data->progress.flags & PGRS_UL_SIZE_KNOWN? + ((data->progress.flags & PGRS_UL_SIZE_KNOWN)? data->progress.size_ul:data->progress.uploaded)+ - (data->progress.flags & PGRS_DL_SIZE_KNOWN? + ((data->progress.flags & PGRS_DL_SIZE_KNOWN)? data->progress.size_dl:data->progress.downloaded); /* We have transferred this much so far */ diff --git a/tests/libtest/lib1156.c b/tests/libtest/lib1156.c index cb8878c21..f4385b26a 100644 --- a/tests/libtest/lib1156.c +++ b/tests/libtest/lib1156.c @@ -88,7 +88,7 @@ static int onetest(CURL *curl, const char *url, const testparams *p) unsigned int replyselector; char urlbuf[256]; - replyselector = p->flags & F_CONTENTRANGE? 1: 0; + replyselector = (p->flags & F_CONTENTRANGE)? 1: 0; if(p->flags & F_HTTP416) replyselector += 2; msnprintf(urlbuf, sizeof(urlbuf), "%s%04u", url, replyselector); @@ -96,7 +96,7 @@ static int onetest(CURL *curl, const char *url, const testparams *p) test_setopt(curl, CURLOPT_RESUME_FROM, (p->flags & F_RESUME)? 3: 0); test_setopt(curl, CURLOPT_RANGE, !(p->flags & F_RESUME)? "3-1000000": (char *) NULL); - test_setopt(curl, CURLOPT_FAILONERROR, p->flags & F_FAIL? 1: 0); + test_setopt(curl, CURLOPT_FAILONERROR, (p->flags & F_FAIL)? 1: 0); hasbody = 0; res = curl_easy_perform(curl); if(res != p->result) { -- cgit v1.2.3