]> granicus.if.org Git - curl/commitdiff
build: fix "clarify calculation precedence" warnings
authorMarcel Raad <Marcel.Raad@teamviewer.com>
Sat, 11 May 2019 12:51:24 +0000 (14:51 +0200)
committerMarcel Raad <Marcel.Raad@teamviewer.com>
Sun, 12 May 2019 07:31:09 +0000 (09:31 +0200)
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
lib/easy.c
lib/formdata.c
lib/mime.c
lib/multi.c
lib/progress.c
tests/libtest/lib1156.c

index fc107bc6baab90f0f9bdd203416d38274ec41078..2dd64a72a2a067f7284ca5e46bd754c42d48f5b3 100644 (file)
@@ -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;
index 40be38220a6a97af1b9ab6ca7c5f7ff5ab700749..9fc33ccb2fd92bf6b891d220db150f80c5e2d391 100644 (file)
@@ -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;
index 202d930c70c936b829e6c05d0c3fd82bbdc4277f..fd0863ef6be6572aa9f18d31a9b15686e6e08fc7 100644 (file)
@@ -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);
index 48147d4f59f88721d3b3f647f3f01556e5e16f64..6d4bc4fec63be6a8ad21c80ee0f77d47a0ec256a 100644 (file)
@@ -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) {
index 631887bfcc2d12fd9729cfae26e96f620b2f5c0b..71217989bead8ba0c54c74f7b55d3ef009d61377 100644 (file)
@@ -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");
index d37e1d5a63412bfd9f3f8c40d52cd09de4cd7e08..fe9929bb9094cc0ea193347d19d3e41ee6cf2a9e 100644 (file)
@@ -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 */
index cb8878c21bf1da54f11c99f4ff567a8140e33cad..f4385b26ae6af78e528a41a1bdb73b3d8a84d17b 100644 (file)
@@ -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) {