mirror of
https://github.com/curl/curl.git
synced 2026-08-24 16:33:33 +03:00
tidy-up: move literals to right-side of if expressions (where missing)
Closes #20535
This commit is contained in:
parent
c6ac2de5b3
commit
85de995208
57 changed files with 115 additions and 115 deletions
|
|
@ -183,17 +183,17 @@ int main(int argc, const char *argv[])
|
|||
/* get it! */
|
||||
result = curl_easy_perform(curl);
|
||||
|
||||
if(CURLE_OK == result) {
|
||||
if(result == CURLE_OK) {
|
||||
curl_off_t val;
|
||||
|
||||
/* check for bytes downloaded */
|
||||
result = curl_easy_getinfo(curl, CURLINFO_SIZE_DOWNLOAD_T, &val);
|
||||
if((CURLE_OK == result) && (val > 0))
|
||||
if((result == CURLE_OK) && (val > 0))
|
||||
printf("Data downloaded: %" CURL_FORMAT_CURL_OFF_T " bytes.\n", val);
|
||||
|
||||
/* check for total download time */
|
||||
result = curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME_T, &val);
|
||||
if((CURLE_OK == result) && (val > 0))
|
||||
if((result == CURLE_OK) && (val > 0))
|
||||
printf("Total download time: %" CURL_FORMAT_CURL_OFF_T
|
||||
".%06" CURL_FORMAT_CURL_OFF_T " sec.\n",
|
||||
val / 1000000,
|
||||
|
|
@ -201,7 +201,7 @@ int main(int argc, const char *argv[])
|
|||
|
||||
/* check for average download speed */
|
||||
result = curl_easy_getinfo(curl, CURLINFO_SPEED_DOWNLOAD_T, &val);
|
||||
if((CURLE_OK == result) && (val > 0))
|
||||
if((result == CURLE_OK) && (val > 0))
|
||||
printf("Average download speed: "
|
||||
"%" CURL_FORMAT_CURL_OFF_T " kbyte/sec.\n",
|
||||
val / 1024);
|
||||
|
|
@ -209,7 +209,7 @@ int main(int argc, const char *argv[])
|
|||
if(prtall) {
|
||||
/* check for name resolution time */
|
||||
result = curl_easy_getinfo(curl, CURLINFO_NAMELOOKUP_TIME_T, &val);
|
||||
if((CURLE_OK == result) && (val > 0))
|
||||
if((result == CURLE_OK) && (val > 0))
|
||||
printf("Name lookup time: %" CURL_FORMAT_CURL_OFF_T
|
||||
".%06" CURL_FORMAT_CURL_OFF_T " sec.\n",
|
||||
val / 1000000,
|
||||
|
|
@ -217,7 +217,7 @@ int main(int argc, const char *argv[])
|
|||
|
||||
/* check for connect time */
|
||||
result = curl_easy_getinfo(curl, CURLINFO_CONNECT_TIME_T, &val);
|
||||
if((CURLE_OK == result) && (val > 0))
|
||||
if((result == CURLE_OK) && (val > 0))
|
||||
printf("Connect time: %" CURL_FORMAT_CURL_OFF_T
|
||||
".%06" CURL_FORMAT_CURL_OFF_T " sec.\n",
|
||||
val / 1000000,
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ int main(void)
|
|||
/* clean up the FTP commands list */
|
||||
curl_slist_free_all(headerlist);
|
||||
|
||||
if(CURLE_OK != result) {
|
||||
if(result != CURLE_OK) {
|
||||
/* we failed */
|
||||
fprintf(stderr, "curl told us %d\n", result);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ int main(void)
|
|||
/* always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
|
||||
if(CURLE_OK != result) {
|
||||
if(result != CURLE_OK) {
|
||||
/* we failed */
|
||||
fprintf(stderr, "curl told us %d\n", result);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,16 +75,16 @@ int main(void)
|
|||
|
||||
result = curl_easy_perform(curl);
|
||||
|
||||
if(CURLE_OK == result) {
|
||||
if(result == CURLE_OK) {
|
||||
/* https://curl.se/libcurl/c/curl_easy_getinfo.html */
|
||||
result = curl_easy_getinfo(curl, CURLINFO_FILETIME, &filetime);
|
||||
if((CURLE_OK == result) && (filetime >= 0)) {
|
||||
if((result == CURLE_OK) && (filetime >= 0)) {
|
||||
time_t file_time = (time_t)filetime;
|
||||
printf("filetime %s: %s", filename, ctime(&file_time));
|
||||
}
|
||||
result = curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD_T,
|
||||
&filesize);
|
||||
if((CURLE_OK == result) && (filesize > 0))
|
||||
if((result == CURLE_OK) && (filesize > 0))
|
||||
printf("filesize %s: %" CURL_FORMAT_CURL_OFF_T " bytes\n",
|
||||
filename, filesize);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ int main(void)
|
|||
/* always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
|
||||
if(CURLE_OK != result) {
|
||||
if(result != CURLE_OK) {
|
||||
/* we failed */
|
||||
fprintf(stderr, "curl told us %d\n", result);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,12 +42,12 @@ int main(void)
|
|||
curl_easy_setopt(curl, CURLOPT_URL, "https://www.example.com/");
|
||||
result = curl_easy_perform(curl);
|
||||
|
||||
if(CURLE_OK == result) {
|
||||
if(result == CURLE_OK) {
|
||||
const char *ct;
|
||||
/* ask for the content-type */
|
||||
result = curl_easy_getinfo(curl, CURLINFO_CONTENT_TYPE, &ct);
|
||||
|
||||
if((CURLE_OK == result) && ct)
|
||||
if((result == CURLE_OK) && ct)
|
||||
printf("We received Content-Type: %s\n", ct);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ int main(void)
|
|||
/* always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
|
||||
if(CURLE_OK != result) {
|
||||
if(result != CURLE_OK) {
|
||||
/* we failed */
|
||||
fprintf(stderr, "curl told us %d\n", result);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ static curl_off_t sftpGetRemoteFileSize(const char *i_remoteFile)
|
|||
curl_easy_setopt(curl, CURLOPT_FILETIME, 1L);
|
||||
|
||||
result = curl_easy_perform(curl);
|
||||
if(CURLE_OK == result) {
|
||||
if(result == CURLE_OK) {
|
||||
result = curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD_T,
|
||||
&remoteFileSizeByte);
|
||||
if(result)
|
||||
|
|
|
|||
|
|
@ -417,12 +417,12 @@ int main(void)
|
|||
curl_easy_setopt(curl, CURLOPT_URL, "https://www.example.com/");
|
||||
result = curl_easy_perform(curl);
|
||||
|
||||
if(CURLE_OK == result) {
|
||||
if(result == CURLE_OK) {
|
||||
char *ct;
|
||||
/* ask for the content-type */
|
||||
result = curl_easy_getinfo(curl, CURLINFO_CONTENT_TYPE, &ct);
|
||||
|
||||
if((CURLE_OK == result) && ct)
|
||||
if((result == CURLE_OK) && ct)
|
||||
printf("We received Content-Type: %s\n", ct);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -51,9 +51,9 @@ int main(void)
|
|||
double connect;
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
|
||||
result = curl_easy_perform(curl);
|
||||
if(CURLE_OK == result) {
|
||||
if(result == CURLE_OK) {
|
||||
result = curl_easy_getinfo(curl, CURLINFO_APPCONNECT_TIME, &connect);
|
||||
if(CURLE_OK == result) {
|
||||
if(result == CURLE_OK) {
|
||||
printf("Time: %.1f", connect);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,9 +51,9 @@ int main(void)
|
|||
curl_off_t connect;
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
|
||||
result = curl_easy_perform(curl);
|
||||
if(CURLE_OK == result) {
|
||||
if(result == CURLE_OK) {
|
||||
result = curl_easy_getinfo(curl, CURLINFO_APPCONNECT_TIME_T, &connect);
|
||||
if(CURLE_OK == result) {
|
||||
if(result == CURLE_OK) {
|
||||
printf("Time: %" CURL_FORMAT_CURL_OFF_T ".%06ld", connect / 1000000,
|
||||
(long)(connect % 1000000));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,9 +47,9 @@ int main(void)
|
|||
double connect;
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
|
||||
result = curl_easy_perform(curl);
|
||||
if(CURLE_OK == result) {
|
||||
if(result == CURLE_OK) {
|
||||
result = curl_easy_getinfo(curl, CURLINFO_CONNECT_TIME, &connect);
|
||||
if(CURLE_OK == result) {
|
||||
if(result == CURLE_OK) {
|
||||
printf("Time: %.1f", connect);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,9 +49,9 @@ int main(void)
|
|||
curl_off_t connect;
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
|
||||
result = curl_easy_perform(curl);
|
||||
if(CURLE_OK == result) {
|
||||
if(result == CURLE_OK) {
|
||||
result = curl_easy_getinfo(curl, CURLINFO_CONNECT_TIME_T, &connect);
|
||||
if(CURLE_OK == result) {
|
||||
if(result == CURLE_OK) {
|
||||
printf("Time: %" CURL_FORMAT_CURL_OFF_T ".%06ld", connect / 1000000,
|
||||
(long)(connect % 1000000));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,10 +55,10 @@ int main(void)
|
|||
/* Ask for filetime */
|
||||
curl_easy_setopt(curl, CURLOPT_FILETIME, 1L);
|
||||
result = curl_easy_perform(curl);
|
||||
if(CURLE_OK == result) {
|
||||
if(result == CURLE_OK) {
|
||||
long filetime = 0;
|
||||
result = curl_easy_getinfo(curl, CURLINFO_FILETIME, &filetime);
|
||||
if((CURLE_OK == result) && (filetime != -1)) {
|
||||
if((result == CURLE_OK) && (filetime != -1)) {
|
||||
time_t file_time = (time_t)filetime;
|
||||
printf("filetime: %s", ctime(&file_time));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,10 +56,10 @@ int main(void)
|
|||
/* Ask for filetime */
|
||||
curl_easy_setopt(curl, CURLOPT_FILETIME, 1L);
|
||||
result = curl_easy_perform(curl);
|
||||
if(CURLE_OK == result) {
|
||||
if(result == CURLE_OK) {
|
||||
curl_off_t filetime;
|
||||
result = curl_easy_getinfo(curl, CURLINFO_FILETIME_T, &filetime);
|
||||
if((CURLE_OK == result) && (filetime != -1)) {
|
||||
if((result == CURLE_OK) && (filetime != -1)) {
|
||||
time_t file_time = (time_t)filetime;
|
||||
printf("filetime: %s", ctime(&file_time));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,11 +53,11 @@ int main(void)
|
|||
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
|
||||
result = curl_easy_perform(curl);
|
||||
|
||||
if(CURLE_OK == result) {
|
||||
if(result == CURLE_OK) {
|
||||
long port;
|
||||
result = curl_easy_getinfo(curl, CURLINFO_LOCAL_PORT, &port);
|
||||
|
||||
if(CURLE_OK == result) {
|
||||
if(result == CURLE_OK) {
|
||||
printf("We used local port: %ld\n", port);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,9 +48,9 @@ int main(void)
|
|||
double namelookup;
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
|
||||
result = curl_easy_perform(curl);
|
||||
if(CURLE_OK == result) {
|
||||
if(result == CURLE_OK) {
|
||||
result = curl_easy_getinfo(curl, CURLINFO_NAMELOOKUP_TIME, &namelookup);
|
||||
if(CURLE_OK == result) {
|
||||
if(result == CURLE_OK) {
|
||||
printf("Time: %.1f", namelookup);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,10 +48,10 @@ int main(void)
|
|||
curl_off_t namelookup;
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
|
||||
result = curl_easy_perform(curl);
|
||||
if(CURLE_OK == result) {
|
||||
if(result == CURLE_OK) {
|
||||
result = curl_easy_getinfo(curl, CURLINFO_NAMELOOKUP_TIME_T,
|
||||
&namelookup);
|
||||
if(CURLE_OK == result) {
|
||||
if(result == CURLE_OK) {
|
||||
printf("Time: %" CURL_FORMAT_CURL_OFF_T ".%06ld", namelookup / 1000000,
|
||||
(long)(namelookup % 1000000));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,11 +48,11 @@ int main(void)
|
|||
CURLcode result;
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
|
||||
result = curl_easy_perform(curl);
|
||||
if(CURLE_OK == result) {
|
||||
if(result == CURLE_OK) {
|
||||
curl_off_t posttransfer;
|
||||
result = curl_easy_getinfo(curl, CURLINFO_POSTTRANSFER_TIME_T,
|
||||
&posttransfer);
|
||||
if(CURLE_OK == result) {
|
||||
if(result == CURLE_OK) {
|
||||
printf("Request sent after: %" CURL_FORMAT_CURL_OFF_T ".%06ld s",
|
||||
posttransfer / 1000000, (long)(posttransfer % 1000000));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,10 +53,10 @@ int main(void)
|
|||
double pretransfer;
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
|
||||
result = curl_easy_perform(curl);
|
||||
if(CURLE_OK == result) {
|
||||
if(result == CURLE_OK) {
|
||||
result = curl_easy_getinfo(curl, CURLINFO_PRETRANSFER_TIME,
|
||||
&pretransfer);
|
||||
if(CURLE_OK == result) {
|
||||
if(result == CURLE_OK) {
|
||||
printf("Time: %.1f", pretransfer);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,10 +53,10 @@ int main(void)
|
|||
curl_off_t pretransfer;
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
|
||||
result = curl_easy_perform(curl);
|
||||
if(CURLE_OK == result) {
|
||||
if(result == CURLE_OK) {
|
||||
result = curl_easy_getinfo(curl, CURLINFO_PRETRANSFER_TIME_T,
|
||||
&pretransfer);
|
||||
if(CURLE_OK == result) {
|
||||
if(result == CURLE_OK) {
|
||||
printf("Time: %" CURL_FORMAT_CURL_OFF_T ".%06ld\n",
|
||||
pretransfer / 1000000,
|
||||
(long)(pretransfer % 1000000));
|
||||
|
|
|
|||
|
|
@ -49,9 +49,9 @@ int main(void)
|
|||
curl_off_t queue;
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
|
||||
result = curl_easy_perform(curl);
|
||||
if(CURLE_OK == result) {
|
||||
if(result == CURLE_OK) {
|
||||
result = curl_easy_getinfo(curl, CURLINFO_QUEUE_TIME_T, &queue);
|
||||
if(CURLE_OK == result) {
|
||||
if(result == CURLE_OK) {
|
||||
printf("Queued: %" CURL_FORMAT_CURL_OFF_T ".%06ld us", queue / 1000000,
|
||||
(long)(queue % 1000000));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,9 +50,9 @@ int main(void)
|
|||
double redirect;
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
|
||||
result = curl_easy_perform(curl);
|
||||
if(CURLE_OK == result) {
|
||||
if(result == CURLE_OK) {
|
||||
result = curl_easy_getinfo(curl, CURLINFO_REDIRECT_TIME, &redirect);
|
||||
if(CURLE_OK == result) {
|
||||
if(result == CURLE_OK) {
|
||||
printf("Time: %.1f", redirect);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,9 +51,9 @@ int main(void)
|
|||
curl_off_t redirect;
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
|
||||
result = curl_easy_perform(curl);
|
||||
if(CURLE_OK == result) {
|
||||
if(result == CURLE_OK) {
|
||||
result = curl_easy_getinfo(curl, CURLINFO_REDIRECT_TIME_T, &redirect);
|
||||
if(CURLE_OK == result) {
|
||||
if(result == CURLE_OK) {
|
||||
printf("Time: %" CURL_FORMAT_CURL_OFF_T ".%06ld", redirect / 1000000,
|
||||
(long)(redirect % 1000000));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,9 +51,9 @@ int main(void)
|
|||
double start;
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
|
||||
result = curl_easy_perform(curl);
|
||||
if(CURLE_OK == result) {
|
||||
if(result == CURLE_OK) {
|
||||
result = curl_easy_getinfo(curl, CURLINFO_STARTTRANSFER_TIME, &start);
|
||||
if(CURLE_OK == result) {
|
||||
if(result == CURLE_OK) {
|
||||
printf("Time: %.1f", start);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,9 +52,9 @@ int main(void)
|
|||
curl_off_t start;
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
|
||||
result = curl_easy_perform(curl);
|
||||
if(CURLE_OK == result) {
|
||||
if(result == CURLE_OK) {
|
||||
result = curl_easy_getinfo(curl, CURLINFO_STARTTRANSFER_TIME_T, &start);
|
||||
if(CURLE_OK == result) {
|
||||
if(result == CURLE_OK) {
|
||||
printf("Time: %" CURL_FORMAT_CURL_OFF_T ".%06ld", start / 1000000,
|
||||
(long)(start % 1000000));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,9 +49,9 @@ int main(void)
|
|||
double total;
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com/");
|
||||
result = curl_easy_perform(curl);
|
||||
if(CURLE_OK == result) {
|
||||
if(result == CURLE_OK) {
|
||||
result = curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME, &total);
|
||||
if(CURLE_OK == result) {
|
||||
if(result == CURLE_OK) {
|
||||
printf("Time: %.1f", total);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,9 +49,9 @@ int main(void)
|
|||
curl_off_t total;
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
|
||||
result = curl_easy_perform(curl);
|
||||
if(CURLE_OK == result) {
|
||||
if(result == CURLE_OK) {
|
||||
result = curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME_T, &total);
|
||||
if(CURLE_OK == result) {
|
||||
if(result == CURLE_OK) {
|
||||
printf("Time: %" CURL_FORMAT_CURL_OFF_T ".%06ld", total / 1000000,
|
||||
(long)(total % 1000000));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,10 +54,10 @@ int main(void)
|
|||
/* Ask for filetime */
|
||||
curl_easy_setopt(curl, CURLOPT_FILETIME, 1L);
|
||||
result = curl_easy_perform(curl);
|
||||
if(CURLE_OK == result) {
|
||||
if(result == CURLE_OK) {
|
||||
long filetime;
|
||||
result = curl_easy_getinfo(curl, CURLINFO_FILETIME, &filetime);
|
||||
if((CURLE_OK == result) && (filetime >= 0)) {
|
||||
if((result == CURLE_OK) && (filetime >= 0)) {
|
||||
time_t file_time = (time_t)filetime;
|
||||
printf("filetime: %s", ctime(&file_time));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ int main(void)
|
|||
curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, 60L);
|
||||
curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 30L);
|
||||
result = curl_easy_perform(curl);
|
||||
if(CURLE_OPERATION_TIMEDOUT == result) {
|
||||
if(result == CURLE_OPERATION_TIMEDOUT) {
|
||||
printf("Timeout.\n");
|
||||
}
|
||||
/* always cleanup */
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ int main(void)
|
|||
curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, 60L);
|
||||
curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 30L);
|
||||
result = curl_easy_perform(curl);
|
||||
if(CURLE_OPERATION_TIMEDOUT == result) {
|
||||
if(result == CURLE_OPERATION_TIMEDOUT) {
|
||||
printf("Timeout.\n");
|
||||
}
|
||||
/* always cleanup */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue