diff options
author | Daniel Stenberg <daniel@haxx.se> | 2016-04-03 11:57:34 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2016-04-03 11:57:34 +0200 |
commit | 365322b8bcf9efb6a361473d227b70f2032212ce (patch) | |
tree | 1c6aa49fce74e802ac29e33098abf4c81ed4836b /tests/libtest | |
parent | c7e4266a2e52d0dd0ad446044174c60ebfe10f73 (diff) | |
download | curl-365322b8bcf9efb6a361473d227b70f2032212ce.tar.gz |
tests/libtest: follow our code style guidelines better
... checksrc of all test code is pending.
Diffstat (limited to 'tests/libtest')
71 files changed, 682 insertions, 661 deletions
diff --git a/tests/libtest/chkhostname.c b/tests/libtest/chkhostname.c index 02a4eefaa..79e382b38 100644 --- a/tests/libtest/chkhostname.c +++ b/tests/libtest/chkhostname.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2016, 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 @@ -28,12 +28,12 @@ int main(int argc, char *argv[]) { char buff[HOSTNAME_MAX]; - if (argc != 2) { + if(argc != 2) { printf("Usage: %s EXPECTED_HOSTNAME\n", argv[0]); return 1; } - if (Curl_gethostname(buff, HOSTNAME_MAX)) { + if(Curl_gethostname(buff, HOSTNAME_MAX)) { printf("Curl_gethostname() failed\n"); return 1; } diff --git a/tests/libtest/lib1500.c b/tests/libtest/lib1500.c index 89983613d..f3c495869 100644 --- a/tests/libtest/lib1500.c +++ b/tests/libtest/lib1500.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2016, 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 @@ -56,7 +56,7 @@ int test(char *URL) while(still_running) { int num; res = curl_multi_wait(multi, NULL, 0, TEST_HANG_TIMEOUT, &num); - if (res != CURLM_OK) { + if(res != CURLM_OK) { printf("curl_multi_wait() returned %d\n", res); res = TEST_ERR_MAJOR_BAD; goto test_cleanup; diff --git a/tests/libtest/lib1501.c b/tests/libtest/lib1501.c index f9bd9663b..cc442b529 100644 --- a/tests/libtest/lib1501.c +++ b/tests/libtest/lib1501.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2016, 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 @@ -41,7 +41,7 @@ static int elapsed(struct timeval *before, result = (after->tv_sec - before->tv_sec) * 1000000 + after->tv_usec - before->tv_usec; - if (result < 0) + if(result < 0) result = 0; return curlx_sztosi(result); diff --git a/tests/libtest/lib1506.c b/tests/libtest/lib1506.c index 9e03e63f0..47fc335ce 100644 --- a/tests/libtest/lib1506.c +++ b/tests/libtest/lib1506.c @@ -46,7 +46,8 @@ int test(char *URL) /* Create fake DNS entries for serverX.example.com for all handles */ for(i=0; i < NUM_HANDLES; i++) { - snprintf(dnsentry, sizeof(dnsentry), "server%d.example.com:%s:%s", i + 1, port, address); + snprintf(dnsentry, sizeof(dnsentry), "server%d.example.com:%s:%s", + i + 1, port, address); printf("%s\n", dnsentry); slist2 = curl_slist_append(slist, dnsentry); if(!slist2) { diff --git a/tests/libtest/lib1507.c b/tests/libtest/lib1507.c index 5340c57a9..5a7994ebd 100644 --- a/tests/libtest/lib1507.c +++ b/tests/libtest/lib1507.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2016, 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 @@ -137,7 +137,7 @@ int test(char *URL) rc = select(maxfd+1, &fdread, &fdwrite, &fdexcep, &timeout); - if (tvdiff(tvnow(), mp_start) > MULTI_PERFORM_HANG_TIMEOUT) { + if(tvdiff(tvnow(), mp_start) > MULTI_PERFORM_HANG_TIMEOUT) { fprintf(stderr, "ABORTING TEST, since it seems " "that it would have run forever.\n"); break; diff --git a/tests/libtest/lib1510.c b/tests/libtest/lib1510.c index d28bef39a..25e9fed31 100644 --- a/tests/libtest/lib1510.c +++ b/tests/libtest/lib1510.c @@ -44,7 +44,8 @@ int test(char *URL) /* Create fake DNS entries for serverX.example.com for all handles */ for(i=0; i < NUM_URLS; i++) { - snprintf(dnsentry, sizeof(dnsentry), "server%d.example.com:%s:%s", i + 1, port, address); + snprintf(dnsentry, sizeof(dnsentry), "server%d.example.com:%s:%s", i + 1, + port, address); printf("%s\n", dnsentry); slist2 = curl_slist_append(slist, dnsentry); if(!slist2) { diff --git a/tests/libtest/lib1512.c b/tests/libtest/lib1512.c index bf03e1a4f..f4091b45a 100644 --- a/tests/libtest/lib1512.c +++ b/tests/libtest/lib1512.c @@ -49,7 +49,8 @@ int test(char *URL) return TEST_ERR_MAJOR_BAD; } - snprintf(dnsentry, sizeof(dnsentry), "server.example.curl:%s:%s", port, address); + snprintf(dnsentry, sizeof(dnsentry), "server.example.curl:%s:%s", + port, address); printf("%s\n", dnsentry); slist = curl_slist_append(slist, dnsentry); diff --git a/tests/libtest/lib1515.c b/tests/libtest/lib1515.c index db0d09ed6..2fd19bb7b 100644 --- a/tests/libtest/lib1515.c +++ b/tests/libtest/lib1515.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2016, 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 @@ -39,7 +39,8 @@ #define sleep(s) Sleep(s * 1000) #endif -static int debug_callback(CURL *curl, curl_infotype info, char *msg, size_t len, void *ptr) +static int debug_callback(CURL *curl, curl_infotype info, char *msg, + size_t len, void *ptr) { (void)curl; (void)ptr; @@ -121,7 +122,8 @@ int test(char *URL) int i; int count = 2; - snprintf(dns_entry, sizeof(dns_entry), "testserver.example.com:%s:%s", port, address); + snprintf(dns_entry, sizeof(dns_entry), "testserver.example.com:%s:%s", + port, address); start_test_timing(); @@ -130,7 +132,8 @@ int test(char *URL) for(i = 1; i <= count; i++) { char target_url[256]; - snprintf(target_url, sizeof(target_url), "http://testserver.example.com:%s/%s%04d", port, path, i); + snprintf(target_url, sizeof(target_url), + "http://testserver.example.com:%s/%s%04d", port, path, i); /* second request must succeed like the first one */ if((res = do_one_request(multi, target_url, dns_entry))) diff --git a/tests/libtest/lib1525.c b/tests/libtest/lib1525.c index 270a002b5..c58ebeda9 100644 --- a/tests/libtest/lib1525.c +++ b/tests/libtest/lib1525.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al. * Copyright (C) 2014, Vijay Panghal, <vpanghal@maginatics.com>, et al. * * This software is licensed as described in the file COPYING, which @@ -35,7 +35,7 @@ static char data [] = "Hello Cloud!\n"; static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *stream) { size_t amount = nmemb * size; /* Total bytes curl wants */ - if (amount < strlen(data)) { + if(amount < strlen(data)) { return strlen(data); } (void)stream; @@ -64,7 +64,7 @@ int test(char *URL) hhl = curl_slist_append(hhl, "User-Agent: Http Agent"); - if (!hhl) { + if(!hhl) { goto test_cleanup; } diff --git a/tests/libtest/lib1526.c b/tests/libtest/lib1526.c index 0ebd8edad..ef66a484d 100644 --- a/tests/libtest/lib1526.c +++ b/tests/libtest/lib1526.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Vijay Panghal, <vpanghal@maginatics.com>, et al. + * Copyright (C) 1998 - 2016, Vijay Panghal, <vpanghal@maginatics.com>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -34,7 +34,7 @@ static char data [] = "Hello Cloud!\n"; static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *stream) { size_t amount = nmemb * size; /* Total bytes curl wants */ - if (amount < strlen(data)) { + if(amount < strlen(data)) { return strlen(data); } (void)stream; @@ -62,11 +62,11 @@ int test(char *URL) hhl = curl_slist_append(hhl, "User-Agent: Http Agent"); phl = curl_slist_append(phl, "User-Agent: Proxy Agent"); - if (!hhl || !phl) { + if(!hhl || !phl) { goto test_cleanup; } tmp = curl_slist_append(phl, "Expect:"); - if (!tmp) { + if(!tmp) { goto test_cleanup; } phl = tmp; diff --git a/tests/libtest/lib1527.c b/tests/libtest/lib1527.c index e3ba10613..f008cf1e4 100644 --- a/tests/libtest/lib1527.c +++ b/tests/libtest/lib1527.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Vijay Panghal, <vpanghal@maginatics.com>, et al. + * Copyright (C) 1998 - 2016, Vijay Panghal, <vpanghal@maginatics.com>, et al. * * This software is licensed as described in the file COPYING, which * you should have received as part of this distribution. The terms @@ -34,7 +34,7 @@ static char data [] = "Hello Cloud!\n"; static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *stream) { size_t amount = nmemb * size; /* Total bytes curl wants */ - if (amount < strlen(data)) { + if(amount < strlen(data)) { return strlen(data); } (void)stream; @@ -62,11 +62,11 @@ int test(char *URL) } hhl = curl_slist_append(hhl, "User-Agent: Http Agent"); - if (!hhl) { + if(!hhl) { goto test_cleanup; } tmp = curl_slist_append(hhl, "Expect: 100-continue"); - if (!tmp) { + if(!tmp) { goto test_cleanup; } hhl = tmp; diff --git a/tests/libtest/lib1528.c b/tests/libtest/lib1528.c index cd953d6f5..09af481f4 100644 --- a/tests/libtest/lib1528.c +++ b/tests/libtest/lib1528.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2016, 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 @@ -46,7 +46,7 @@ int test(char *URL) hhl = curl_slist_append(hhl, "User-Agent: Http Agent"); phl = curl_slist_append(phl, "Proxy-User-Agent: Http Agent2"); - if (!hhl) { + if(!hhl) { goto test_cleanup; } diff --git a/tests/libtest/lib1531.c b/tests/libtest/lib1531.c index 438408dfb..b21d06733 100644 --- a/tests/libtest/lib1531.c +++ b/tests/libtest/lib1531.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2016, 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 @@ -49,7 +49,8 @@ int test(char *URL) /* set the options (I left out a few, you'll get the point anyway) */ curl_easy_setopt(easy, CURLOPT_URL, URL); - curl_easy_setopt(easy, CURLOPT_POSTFIELDSIZE_LARGE, (curl_off_t)testDataSize); + curl_easy_setopt(easy, CURLOPT_POSTFIELDSIZE_LARGE, + (curl_off_t)testDataSize); curl_easy_setopt(easy, CURLOPT_POSTFIELDS, testData); /* we start some action by calling perform right away */ @@ -87,8 +88,7 @@ int test(char *URL) /* get file descriptors from the transfers */ mc = curl_multi_fdset(multi_handle, &fdread, &fdwrite, &fdexcep, &maxfd); - if(mc != CURLM_OK) - { + if(mc != CURLM_OK) { fprintf(stderr, "curl_multi_fdset() failed, code %d.\n", mc); break; } @@ -127,8 +127,8 @@ int test(char *URL) } while(still_running); /* See how the transfers went */ - while ((msg = curl_multi_info_read(multi_handle, &msgs_left))) { - if (msg->msg == CURLMSG_DONE) { + while((msg = curl_multi_info_read(multi_handle, &msgs_left))) { + if(msg->msg == CURLMSG_DONE) { printf("HTTP transfer completed with status %d\n", msg->data.result); break; } diff --git a/tests/libtest/lib1900.c b/tests/libtest/lib1900.c index 0c6328483..4502fc0d6 100644 --- a/tests/libtest/lib1900.c +++ b/tests/libtest/lib1900.c @@ -192,12 +192,12 @@ int test(char *URL) abort_on_test_timeout(); /* See how the transfers went */ - while ((msg = curl_multi_info_read(m, &msgs_left))) { - if (msg->msg == CURLMSG_DONE) { + while((msg = curl_multi_info_read(m, &msgs_left))) { + if(msg->msg == CURLMSG_DONE) { int i, found = 0; /* Find out which handle this message is about */ - for (i = 0; i < num_handles; i++) { + for(i = 0; i < num_handles; i++) { found = (msg->easy_handle == handles[i]); if(found) break; diff --git a/tests/libtest/lib500.c b/tests/libtest/lib500.c index e249d9f9d..43b05982c 100644 --- a/tests/libtest/lib500.c +++ b/tests/libtest/lib500.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2016, 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 @@ -63,12 +63,12 @@ int test(char *URL) CURL *curl; char *ipstr=NULL; - if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); return TEST_ERR_MAJOR_BAD; } - if ((curl = curl_easy_init()) == NULL) { + if((curl = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); curl_global_cleanup(); return TEST_ERR_MAJOR_BAD; @@ -92,42 +92,42 @@ int test(char *URL) if(!res) { res = curl_easy_getinfo(curl, CURLINFO_PRIMARY_IP, &ipstr); - if (libtest_arg2) { + if(libtest_arg2) { FILE *moo = fopen(libtest_arg2, "wb"); if(moo) { - double time_namelookup; - double time_connect; - double time_pretransfer; - double time_starttransfer; - double time_total; - fprintf(moo, "IP: %s\n", ipstr); - curl_easy_getinfo(curl, CURLINFO_NAMELOOKUP_TIME, &time_namelookup); - curl_easy_getinfo(curl, CURLINFO_CONNECT_TIME, &time_connect); - curl_easy_getinfo(curl, CURLINFO_PRETRANSFER_TIME, &time_pretransfer); - curl_easy_getinfo(curl, CURLINFO_STARTTRANSFER_TIME, - &time_starttransfer); - curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME, &time_total); - - /* since the timing will always vary we only compare relative differences - between these 5 times */ - if(time_namelookup > time_connect) { - fprintf(moo, "namelookup vs connect: %f %f\n", - time_namelookup, time_connect); - } - if(time_connect > time_pretransfer) { - fprintf(moo, "connect vs pretransfer: %f %f\n", - time_connect, time_pretransfer); - } - if(time_pretransfer > time_starttransfer) { - fprintf(moo, "pretransfer vs starttransfer: %f %f\n", - time_pretransfer, time_starttransfer); - } - if(time_starttransfer > time_total) { - fprintf(moo, "starttransfer vs total: %f %f\n", - time_starttransfer, time_total); - } - - fclose(moo); + double time_namelookup; + double time_connect; + double time_pretransfer; + double time_starttransfer; + double time_total; + fprintf(moo, "IP: %s\n", ipstr); + curl_easy_getinfo(curl, CURLINFO_NAMELOOKUP_TIME, &time_namelookup); + curl_easy_getinfo(curl, CURLINFO_CONNECT_TIME, &time_connect); + curl_easy_getinfo(curl, CURLINFO_PRETRANSFER_TIME, &time_pretransfer); + curl_easy_getinfo(curl, CURLINFO_STARTTRANSFER_TIME, + &time_starttransfer); + curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME, &time_total); + + /* since the timing will always vary we only compare relative + differences between these 5 times */ + if(time_namelookup > time_connect) { + fprintf(moo, "namelookup vs connect: %f %f\n", + time_namelookup, time_connect); + } + if(time_connect > time_pretransfer) { + fprintf(moo, "connect vs pretransfer: %f %f\n", + time_connect, time_pretransfer); + } + if(time_pretransfer > time_starttransfer) { + fprintf(moo, "pretransfer vs starttransfer: %f %f\n", + time_pretransfer, time_starttransfer); + } + if(time_starttransfer > time_total) { + fprintf(moo, "starttransfer vs total: %f %f\n", + time_starttransfer, time_total); + } + + fclose(moo); } } } diff --git a/tests/libtest/lib501.c b/tests/libtest/lib501.c index b1b9ad413..2a105f0cd 100644 --- a/tests/libtest/lib501.c +++ b/tests/libtest/lib501.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2016, 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 @@ -30,12 +30,12 @@ int test(char *URL) (void)URL; /* we don't use this */ - if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); return TEST_ERR_MAJOR_BAD; } - if ((curl = curl_easy_init()) == NULL) { + if((curl = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); curl_global_cleanup(); return TEST_ERR_MAJOR_BAD; diff --git a/tests/libtest/lib504.c b/tests/libtest/lib504.c index 557342059..3466dc948 100644 --- a/tests/libtest/lib504.c +++ b/tests/libtest/lib504.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2016, 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 @@ int test(char *URL) /* The point here is that there must not be anything running on the given proxy port */ - if (libtest_arg2) + if(libtest_arg2) easy_setopt(c, CURLOPT_PROXY, libtest_arg2); easy_setopt(c, CURLOPT_URL, URL); easy_setopt(c, CURLOPT_VERBOSE, 1L); diff --git a/tests/libtest/lib505.c b/tests/libtest/lib505.c index 79c3bc79b..127fde77e 100644 --- a/tests/libtest/lib505.c +++ b/tests/libtest/lib505.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2016, 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 @@ -38,8 +38,8 @@ int test(char *URL) { CURL *curl; CURLcode res = CURLE_OK; - FILE *hd_src ; - int hd ; + FILE *hd_src; + int hd; struct_stat file_info; struct curl_slist *hl; int error; @@ -48,7 +48,7 @@ int test(char *URL) const char *buf_1 = "RNFR 505"; const char *buf_2 = "RNTO 505-forreal"; - if (!libtest_arg2) { + if(!libtest_arg2) { fprintf(stderr, "Usage: <url> <file-to-upload>\n"); return TEST_ERR_USAGE; } @@ -56,7 +56,7 @@ int test(char *URL) hd_src = fopen(libtest_arg2, "rb"); if(NULL == hd_src) { error = ERRNO; - fprintf(stderr, "fopen() failed with error: %d %s\n", + fprintf(stderr, "fopen failed with error: %d %s\n", error, strerror(error)); fprintf(stderr, "Error opening file: %s\n", libtest_arg2); return TEST_ERR_MAJOR_BAD; /* if this happens things are major weird */ @@ -80,14 +80,15 @@ int test(char *URL) return TEST_ERR_MAJOR_BAD; } - if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); fclose(hd_src); return TEST_ERR_MAJOR_BAD; } /* get a curl handle */ - if ((curl = curl_easy_init()) == NULL) { + curl = curl_easy_init(); + if(!curl) { fprintf(stderr, "curl_easy_init() failed\n"); curl_global_cleanup(); fclose(hd_src); @@ -96,14 +97,16 @@ int test(char *URL) /* build a list of commands to pass to libcurl */ - if ((hl = curl_slist_append(headerlist, buf_1)) == NULL) { + hl = curl_slist_append(headerlist, buf_1); + if(!hl) { fprintf(stderr, "curl_slist_append() failed\n"); curl_easy_cleanup(curl); curl_global_cleanup(); fclose(hd_src); return TEST_ERR_MAJOR_BAD; } - if ((headerlist = curl_slist_append(hl, buf_2)) == NULL) { + headerlist = curl_slist_append(hl, buf_2); + if(!headerlist) { fprintf(stderr, "curl_slist_append() failed\n"); curl_slist_free_all(hl); curl_easy_cleanup(curl); @@ -120,7 +123,7 @@ int test(char *URL) test_setopt(curl, CURLOPT_VERBOSE, 1L); /* specify target */ - test_setopt(curl,CURLOPT_URL, URL); + test_setopt(curl, CURLOPT_URL, URL); /* pass in that last of FTP commands to run after the transfer */ test_setopt(curl, CURLOPT_POSTQUOTE, headerlist); diff --git a/tests/libtest/lib506.c b/tests/libtest/lib506.c index 4ee384f04..265b1ed5c 100644 --- a/tests/libtest/lib506.c +++ b/tests/libtest/lib506.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2016, 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 @@ -40,8 +40,8 @@ struct userdata { int lock[3]; /* lock callback */ -static void my_lock(CURL *handle, curl_lock_data data, curl_lock_access laccess, - void *useptr ) +static void my_lock(CURL *handle, curl_lock_data data, + curl_lock_access laccess, void *useptr) { const char *what; struct userdata *user = (struct userdata *)useptr; @@ -50,7 +50,7 @@ static void my_lock(CURL *handle, curl_lock_data data, curl_lock_access laccess, (void)handle; (void)laccess; - switch ( data ) { + switch (data) { case CURL_LOCK_DATA_SHARE: what = "share"; locknum = 0; @@ -86,7 +86,7 @@ static void my_unlock(CURL *handle, curl_lock_data data, void *useptr ) struct userdata *user = (struct userdata *)useptr; int locknum; (void)handle; - switch ( data ) { + switch (data) { case CURL_LOCK_DATA_SHARE: what = "share"; locknum = 0; @@ -120,7 +120,7 @@ static void my_unlock(CURL *handle, curl_lock_data data, void *useptr ) static struct curl_slist *sethost(struct curl_slist *headers) { (void)headers; - return curl_slist_append(NULL, HOSTHEADER ); + return curl_slist_append(NULL, HOSTHEADER); } @@ -133,7 +133,8 @@ static void *fire(void *ptr) CURL *curl; int i=0; - if ((curl = curl_easy_init()) == NULL) { + curl = curl_easy_init(); + if(!curl) { fprintf(stderr, "curl_easy_init() failed\n"); return NULL; } @@ -142,17 +143,17 @@ static void *fire(void *ptr) curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L); curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers); curl_easy_setopt(curl, CURLOPT_URL, tdata->url); - printf( "CURLOPT_SHARE\n" ); + printf("CURLOPT_SHARE\n"); curl_easy_setopt(curl, CURLOPT_SHARE, tdata->share); - printf( "PERFORM\n" ); + printf("PERFORM\n"); code = curl_easy_perform(curl); - if( code != CURLE_OK ) { + if(code) { fprintf(stderr, "perform url '%s' repeat %d failed, curlcode %d\n", tdata->url, i, (int)code); } - printf( "CLEANUP\n" ); + printf("CLEANUP\n"); curl_easy_cleanup(curl); curl_slist_free_all(headers); @@ -186,42 +187,42 @@ int test(char *URL) user.text = (char *)"Pigs in space"; user.counter = 0; - printf( "GLOBAL_INIT\n" ); - if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + printf("GLOBAL_INIT\n"); + if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); return TEST_ERR_MAJOR_BAD; } /* prepare share */ - printf( "SHARE_INIT\n" ); - if ((share = curl_share_init()) == NULL) { + printf("SHARE_INIT\n"); + if((share = curl_share_init()) == NULL) { fprintf(stderr, "curl_share_init() failed\n"); curl_global_cleanup(); return TEST_ERR_MAJOR_BAD; } - if ( CURLSHE_OK == scode ) { - printf( "CURLSHOPT_LOCKFUNC\n" ); - scode = curl_share_setopt( share, CURLSHOPT_LOCKFUNC, my_lock); + if(CURLSHE_OK == scode) { + printf("CURLSHOPT_LOCKFUNC\n"); + scode = curl_share_setopt(share, CURLSHOPT_LOCKFUNC, my_lock); } - if ( CURLSHE_OK == scode ) { - printf( "CURLSHOPT_UNLOCKFUNC\n" ); - scode = curl_share_setopt( share, CURLSHOPT_UNLOCKFUNC, my_unlock); + if(CURLSHE_OK == scode) { + printf("CURLSHOPT_UNLOCKFUNC\n"); + scode = curl_share_setopt(share, CURLSHOPT_UNLOCKFUNC, my_unlock); } - if ( CURLSHE_OK == scode ) { - printf( "CURLSHOPT_USERDATA\n" ); - scode = curl_share_setopt( share, CURLSHOPT_USERDATA, &user); + if(CURLSHE_OK == scode) { + printf("CURLSHOPT_USERDATA\n"); + scode = curl_share_setopt(share, CURLSHOPT_USERDATA, &user); } - if ( CURLSHE_OK == scode ) { - printf( "CURL_LOCK_DATA_COOKIE\n" ); - scode = curl_share_setopt( share, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE); + if(CURLSHE_OK == scode) { + printf("CURL_LOCK_DATA_COOKIE\n"); + scode = curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_COOKIE); } - if ( CURLSHE_OK == scode ) { - printf( "CURL_LOCK_DATA_DNS\n" ); - scode = curl_share_setopt( share, CURLSHOPT_SHARE, CURL_LOCK_DATA_DNS); + if(CURLSHE_OK == scode) { + printf("CURL_LOCK_DATA_DNS\n"); + scode = curl_share_setopt(share, CURLSHOPT_SHARE, CURL_LOCK_DATA_DNS); } - if ( CURLSHE_OK != scode ) { + if(CURLSHE_OK != scode) { fprintf(stderr, "curl_share_setopt() failed\n"); curl_share_cleanup(share); curl_global_cleanup(); @@ -229,149 +230,145 @@ int test(char *URL) } /* initial cookie manipulation */ - if ((curl = curl_easy_init()) == NULL) { + if((curl = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); curl_share_cleanup(share); curl_global_cleanup(); return TEST_ERR_MAJOR_BAD; } - printf( "CURLOPT_SHARE\n" ); - test_setopt( curl, CURLOPT_SHARE, share ); - printf( "CURLOPT_COOKIELIST injected_and_clobbered\n" ); - test_setopt( curl, CURLOPT_COOKIELIST, + printf("CURLOPT_SHARE\n"); + test_setopt(curl, CURLOPT_SHARE, share); + printf("CURLOPT_COOKIELIST injected_and_clobbered\n"); + test_setopt(curl, CURLOPT_COOKIELIST, "Set-Cookie: injected_and_clobbered=yes; " - "domain=host.foo.com; expires=Sat Feb 2 11:56:27 GMT 2030" ); - printf( "CURLOPT_COOKIELIST ALL\n" ); - test_setopt( curl, CURLOPT_COOKIELIST, "ALL" ); - printf( "CURLOPT_COOKIELIST session\n" ); - test_setopt( curl, CURLOPT_COOKIELIST, "Set-Cookie: session=elephants" ); - printf( "CURLOPT_COOKIELIST injected\n" ); - test_setopt( curl, CURLOPT_COOKIELIST, + "domain=host.foo.com; expires=Sat Feb 2 11:56:27 GMT 2030"); + printf("CURLOPT_COOKIELIST ALL\n"); + test_setopt(curl, CURLOPT_COOKIELIST, "ALL"); + printf("CURLOPT_COOKIELIST session\n"); + test_setopt(curl, CURLOPT_COOKIELIST, "Set-Cookie: session=elephants"); + printf("CURLOPT_COOKIELIST injected\n"); + test_setopt(curl, CURLOPT_COOKIELIST, "Set-Cookie: injected=yes; domain=host.foo.com; " - "expires=Sat Feb 2 11:56:27 GMT 2030" ); - printf( "CURLOPT_COOKIELIST SESS\n" ); - test_setopt( curl, CURLOPT_COOKIELIST, "SESS" ); - printf( "CLEANUP\n" ); - curl_easy_cleanup( curl ); + "expires=Sat Feb 2 11:56:27 GMT 2030"); + printf("CURLOPT_COOKIELIST SESS\n"); + test_setopt(curl, CURLOPT_COOKIELIST, "SESS"); + printf("CLEANUP\n"); + curl_easy_cleanup(curl); res = 0; /* start treads */ - for (i=1; i<=THREADS; i++ ) { + for(i=1; i<=THREADS; i++) { /* set thread data */ - tdata.url = suburl( URL, i ); /* must be curl_free()d */ + tdata.url = suburl(URL, i); /* must be curl_free()d */ tdata.share = share; /* simulate thread, direct call of "thread" function */ - printf( "*** run %d\n",i ); - fire( &tdata ); - - curl_free( tdata.url ); + printf("*** run %d\n",i); + fire(&tdata); + curl_free(tdata.url); } /* fetch a another one and save cookies */ - printf( "*** run %d\n", i ); - if ((curl = curl_easy_init()) == NULL) { + printf("*** run %d\n", i); + if((curl = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); curl_share_cleanup(share); curl_global_cleanup(); return TEST_ERR_MAJOR_BAD; } - url = suburl( URL, i ); - headers = sethost( NULL ); - test_setopt( curl, CURLOPT_HTTPHEADER, headers ); - test_setopt( curl, CURLOPT_URL, url ); - printf( "CURLOPT_SHARE\n" ); - test_setopt( curl, CURLOPT_SHARE, share ); - printf( "CURLOPT_COOKIEJAR\n" ); - test_setopt( curl, CURLOPT_COOKIEJAR, JAR ); - printf( "CURLOPT_COOKIELIST FLUSH\n" ); - test_setopt( curl, CURLOPT_COOKIELIST, "FLUSH" ); - - printf( "PERFORM\n" ); - curl_easy_perform( curl ); - - printf( "CLEANUP\n" ); - curl_easy_cleanup( curl ); + url = suburl(URL, i); + headers = sethost(NULL); + test_setopt(curl, CURLOPT_HTTPHEADER, headers); + test_setopt(curl, CURLOPT_URL, url); + printf("CURLOPT_SHARE\n"); + test_setopt(curl, CURLOPT_SHARE, share); + printf("CURLOPT_COOKIEJAR\n"); + test_setopt(curl, CURLOPT_COOKIEJAR, JAR); + printf("CURLOPT_COOKIELIST FLUSH\n"); + test_setopt(curl, CURLOPT_COOKIELIST, "FLUSH"); + + printf("PERFORM\n"); + curl_easy_perform(curl); + + printf("CLEANUP\n"); + curl_easy_cleanup(curl); curl_free(url); - curl_slist_free_all( headers ); + curl_slist_free_all(headers); /* load cookies */ - if ((curl = curl_easy_init()) == NULL) { + if((curl = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); curl_share_cleanup(share); curl_global_cleanup(); return TEST_ERR_MAJOR_BAD; } - url = suburl( URL, i ); - headers = sethost( NULL ); - test_setopt( curl, CURLOPT_HTTPHEADER, headers ); - test_setopt( curl, CURLOPT_URL, url ); - printf( "CURLOPT_SHARE\n" ); - test_setopt( curl, CURLOPT_SHARE, share ); - printf( "CURLOPT_COOKIELIST ALL\n" ); - test_setopt( curl, CURLOPT_COOKIELIST, "ALL" ); - printf( "CURLOPT_COOKIEJAR\n" ); - test_setopt( curl, CURLOPT_COOKIEFILE, JAR ); - printf( "CURLOPT_COOKIELIST RELOAD\n" ); - test_setopt( curl, CURLOPT_COOKIELIST, "RELOAD" ); + url = suburl(URL, i); + headers = sethost(NULL); + test_setopt(curl, CURLOPT_HTTPHEADER, headers); + test_setopt(curl, CURLOPT_URL, url); + printf("CURLOPT_SHARE\n"); + test_setopt(curl, CURLOPT_SHARE, share); + printf("CURLOPT_COOKIELIST ALL\n"); + test_setopt(curl, CURLOPT_COOKIELIST, "ALL"); + printf("CURLOPT_COOKIEJAR\n"); + test_setopt(curl, CURLOPT_COOKIEFILE, JAR); + printf("CURLOPT_COOKIELIST RELOAD\n"); + test_setopt(curl, CURLOPT_COOKIELIST, "RELOAD"); code = curl_easy_getinfo(curl, CURLINFO_COOKIELIST, &cookies); - if ( code != CURLE_OK ) - { + if(code != CURLE_OK) { fprintf(stderr, "curl_easy_getinfo() failed\n"); res = TEST_ERR_MAJOR_BAD; goto test_cleanup; } printf("loaded cookies:\n"); - if ( !cookies ) - { + if(!cookies) { fprintf(stderr, " reloading cookies from '%s' failed\n", JAR); res = TEST_ERR_MAJOR_BAD; goto test_cleanup; } printf("-----------------\n"); next_cookie = cookies; - while ( next_cookie ) - { - printf( " %s\n", next_cookie->data ); + while(next_cookie) { + printf(" %s\n", next_cookie->data); next_cookie = next_cookie->next; } printf("-----------------\n"); - curl_slist_free_all( cookies ); + curl_slist_free_all(cookies); /* try to free share, expect to fail because share is in use*/ - printf( "try SHARE_CLEANUP...\n" ); - scode = curl_share_cleanup( share ); - if ( scode==CURLSHE_OK ) - { + printf("try SHARE_CLEANUP...\n"); + scode = curl_share_cleanup(share); + if(scode==CURLSHE_OK ) { fprintf(stderr, "curl_share_cleanup succeed but error expected\n"); share = NULL; - } else { - printf( "SHARE_CLEANUP failed, correct\n" ); + } + else { + printf("SHARE_CLEANUP failed, correct\n"); } test_cleanup: /* clean up last handle */ - printf( "CLEANUP\n" ); - curl_easy_cleanup( curl ); - curl_slist_free_all( headers ); + printf("CLEANUP\n"); + curl_easy_cleanup(curl); + curl_slist_free_all(headers); curl_free(url); /* free share */ - printf( "SHARE_CLEANUP\n" ); - scode = curl_share_cleanup( share ); - if ( scode!=CURLSHE_OK ) + printf("SHARE_CLEANUP\n"); + scode = curl_share_cleanup(share); + if(scode!=CURLSHE_OK ) fprintf(stderr, "curl_share_cleanup failed, code errno %d\n", (int)scode); - printf( "GLOBAL_CLEANUP\n" ); + printf("GLOBAL_CLEANUP\n"); curl_global_cleanup(); return res; diff --git a/tests/libtest/lib508.c b/tests/libtest/lib508.c index 5b2ff1f29..cb60ce1bd 100644 --- a/tests/libtest/lib508.c +++ b/tests/libtest/lib508.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2016, 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 @@ -57,12 +57,12 @@ int test(char *URL) pooh.readptr = data; pooh.sizeleft = strlen(data); - if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); return TEST_ERR_MAJOR_BAD; } - if ((curl = curl_easy_init()) == NULL) { + if((curl = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); curl_global_cleanup(); return TEST_ERR_MAJOR_BAD; diff --git a/tests/libtest/lib509.c b/tests/libtest/lib509.c index 1f9e3e499..085a9753e 100644 --- a/tests/libtest/lib509.c +++ b/tests/libtest/lib509.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2016, 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 @@ -117,12 +117,12 @@ int test(char *URL) custom_realloc, custom_strdup, custom_calloc); - if (res != CURLE_OK) { + if(res != CURLE_OK) { fprintf(stderr, "curl_global_init_mem() failed\n"); return TEST_ERR_MAJOR_BAD; } - if ((curl = curl_easy_init()) == NULL) { + if((curl = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); curl_global_cleanup(); return TEST_ERR_MAJOR_BAD; diff --git a/tests/libtest/lib510.c b/tests/libtest/lib510.c index f84af76c0..cb5296ec3 100644 --- a/tests/libtest/lib510.c +++ b/tests/libtest/lib510.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2016, 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 @@ -63,19 +63,19 @@ int test(char *URL) struct WriteThis pooh; pooh.counter = 0; - if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); return TEST_ERR_MAJOR_BAD; } - if ((curl = curl_easy_init()) == NULL) { + if((curl = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); curl_global_cleanup(); return TEST_ERR_MAJOR_BAD; } slist = curl_slist_append(slist, "Transfer-Encoding: chunked"); - if (slist == NULL) { + if(slist == NULL) { fprintf(stderr, "curl_slist_append() failed\n"); curl_easy_cleanup(curl); curl_global_cleanup(); diff --git a/tests/libtest/lib511.c b/tests/libtest/lib511.c index 81dc75311..0b7ae6f43 100644 --- a/tests/libtest/lib511.c +++ b/tests/libtest/lib511.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2016, 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 @@ -28,12 +28,12 @@ int test(char *URL) CURLcode res; CURL *curl; - if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); return TEST_ERR_MAJOR_BAD; } - if ((curl = curl_easy_init()) == NULL) { + if((curl = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); curl_global_cleanup(); return TEST_ERR_MAJOR_BAD; diff --git a/tests/libtest/lib513.c b/tests/libtest/lib513.c index 6462ac7d5..b2f1d7788 100644 --- a/tests/libtest/lib513.c +++ b/tests/libtest/lib513.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2011, 2016, 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 @@ -37,12 +37,12 @@ int test(char *URL) CURL *curl; CURLcode res=CURLE_OK; - if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); return TEST_ERR_MAJOR_BAD; } - if ((curl = curl_easy_init()) == NULL) { + if((curl = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); curl_global_cleanup(); return TEST_ERR_MAJOR_BAD; diff --git a/tests/libtest/lib514.c b/tests/libtest/lib514.c index 916ed6b93..75c5acc4a 100644 --- a/tests/libtest/lib514.c +++ b/tests/libtest/lib514.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2011, 2016, 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 @@ -28,12 +28,12 @@ int test(char *URL) CURL *curl; CURLcode res=CURLE_OK; - if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); return TEST_ERR_MAJOR_BAD; } - if ((curl = curl_easy_init()) == NULL) { + if((curl = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); curl_global_cleanup(); return TEST_ERR_MAJOR_BAD; diff --git a/tests/libtest/lib515.c b/tests/libtest/lib515.c index d982145ac..f9ace04ee 100644 --- a/tests/libtest/lib515.c +++ b/tests/libtest/lib515.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2011, 2016, 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 @@ -28,12 +28,12 @@ int test(char *URL) CURL *curl; CURLcode res=CURLE_OK; - if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); return TEST_ERR_MAJOR_BAD; } - if ((curl = curl_easy_init()) == NULL) { + if((curl = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); curl_global_cleanup(); return TEST_ERR_MAJOR_BAD; diff --git a/tests/libtest/lib516.c b/tests/libtest/lib516.c index 4c04af63f..13b3b3d17 100644 --- a/tests/libtest/lib516.c +++ b/tests/libtest/lib516.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2011, 2016, 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 @@ -28,12 +28,12 @@ int test(char *URL) CURL *curl; CURLcode res=CURLE_OK; - if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); return TEST_ERR_MAJOR_BAD; } - if ((curl = curl_easy_init()) == NULL) { + if((curl = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); curl_global_cleanup(); return TEST_ERR_MAJOR_BAD; diff --git a/tests/libtest/lib518.c b/tests/libtest/lib518.c index 3e6c492dc..e37a7771d 100644 --- a/tests/libtest/lib518.c +++ b/tests/libtest/lib518.c @@ -56,18 +56,19 @@ static char msgbuff[256]; static void store_errmsg(const char *msg, int err) { - if (!err) + if(!err) snprintf(msgbuff, sizeof(msgbuff), "%s", msg); else - snprintf(msgbuff, sizeof(msgbuff), "%s, errno %d, %s", msg, err, strerror(err)); + snprintf(msgbuff, sizeof(msgbuff), "%s, errno %d, %s", msg, + err, strerror(err)); } static void close_file_descriptors(void) { - for (num_open.rlim_cur = 0; - num_open.rlim_cur < num_open.rlim_max; - num_open.rlim_cur++) - if (fd[num_open.rlim_cur] > 0) + for(num_open.rlim_cur = 0; + num_open.rlim_cur < num_open.rlim_max; + num_open.rlim_cur++) + if(fd[num_open.rlim_cur] > 0) close(fd[num_open.rlim_cur]); free(fd); fd = NULL; @@ -79,20 +80,20 @@ static int fopen_works(void) int i; int ret = 1; - for (i = 0; i < 3; i++) { + for(i = 0; i < 3; i++) { fpa[i] = NULL; } - for (i = 0; i < 3; i++) { - fpa[i] = fopen(DEV_NULL, "r"); - if (fpa[i] == NULL) { - store_errmsg("fopen() failed", ERRNO); + for(i = 0; i < 3; i++) { + fpa[i] = fopen(DEV_NULL, FOPEN_READTEXT); + if(fpa[i] == NULL) { + store_errmsg("fopen failed", ERRNO); fprintf(stderr, "%s\n", msgbuff); ret = 0; break; } } - for (i = 0; i < 3; i++) { - if (fpa[i] != NULL) + for(i = 0; i < 3; i++) { + if(fpa[i] != NULL) fclose(fpa[i]); } return ret; @@ -112,7 +113,7 @@ static int rlimit(int keep_open) #ifdef HAVE_LONGLONG char fmt_llu[] = "%llu"; - if (sizeof(rl.rlim_max) > sizeof(long)) + if(sizeof(rl.rlim_max) > sizeof(long)) fmt = fmt_llu; else #endif @@ -120,7 +121,7 @@ static int rlimit(int keep_open) /* get initial open file limits */ - if (getrlimit(RLIMIT_NOFILE, &rl) != 0) { + if(getrlimit(RLIMIT_NOFILE, &rl) != 0) { store_errmsg("getrlimit() failed", ERRNO); fprintf(stderr, "%s\n", msgbuff); return -1; @@ -129,7 +130,7 @@ static int rlimit(int keep_open) /* show initial open file limits */ #ifdef RLIM_INFINITY - if (rl.rlim_cur == RLIM_INFINITY) + if(rl.rlim_cur == RLIM_INFINITY) strcpy(strbuff, "INFINITY"); else #endif @@ -137,7 +138,7 @@ static int rlimit(int keep_open) fprintf(stderr, "initial soft limit: %s\n", strbuff); #ifdef RLIM_INFINITY - if (rl.rlim_max == RLIM_INFINITY) + if(rl.rlim_max == RLIM_INFINITY) strcpy(strbuff, "INFINITY"); else #endif @@ -159,14 +160,14 @@ static int rlimit(int keep_open) * open more than soft limit file descriptors will fail. */ - if (rl.rlim_cur != rl.rlim_max) { + if(rl.rlim_cur != rl.rlim_max) { #ifdef OPEN_MAX - if ((rl.rlim_cur > 0) && - (rl.rlim_cur < OPEN_MAX)) { + if((rl.rlim_cur > 0) && + (rl.rlim_cur < OPEN_MAX)) { fprintf(stderr, "raising soft limit up to OPEN_MAX\n"); rl.rlim_cur = OPEN_MAX; - if (setrlimit(RLIMIT_NOFILE, &rl) != 0) { + if(setrlimit(RLIMIT_NOFILE, &rl) != 0) { /* on failure don't abort just issue a warning */ store_errmsg("setrlimit() failed", ERRNO); fprintf(stderr, "%s\n", msgbuff); @@ -177,7 +178,7 @@ static int rlimit(int keep_open) fprintf(stderr, "raising soft limit up to hard limit\n"); rl.rlim_cur = rl.rlim_max; - if (setrlimit(RLIMIT_NOFILE, &rl) != 0) { + if(setrlimit(RLIMIT_NOFILE, &rl) != 0) { /* on failure don't abort just issue a warning */ store_errmsg("setrlimit() failed", ERRNO); fprintf(stderr, "%s\n", msgbuff); @@ -186,7 +187,7 @@ static int rlimit(int keep_open) /* get current open file limits */ - if (getrlimit(RLIMIT_NOFILE, &rl) != 0) { + if(getrlimit(RLIMIT_NOFILE, &rl) != 0) { store_errmsg("getrlimit() failed", ERRNO); fprintf(stderr, "%s\n", msgbuff); return -3; @@ -195,7 +196,7 @@ static int rlimit(int keep_open) /* show current open file limits */ #ifdef RLIM_INFINITY - if (rl.rlim_cur == RLIM_INFINITY) + if(rl.rlim_cur == RLIM_INFINITY) strcpy(strbuff, "INFINITY"); else #endif @@ -203,7 +204,7 @@ static int rlimit(int keep_open) fprintf(stderr, "current soft limit: %s\n", strbuff); #ifdef RLIM_INFINITY - if (rl.rlim_max == RLIM_INFINITY) + if(rl.rlim_max == RLIM_INFINITY) strcpy(strbuff, "INFINITY"); else #endif @@ -229,7 +230,7 @@ static int rlimit(int keep_open) num_open.rlim_cur = NUM_NEEDED; - if ((rl.rlim_cur > 0) && + if((rl.rlim_cur > 0) && #ifdef RLIM_INFINITY (rl.rlim_cur != RLIM_INFINITY) && #endif @@ -252,21 +253,21 @@ static int rlimit(int keep_open) * that it becomes available to the test. */ - for (nitems = i = 1; nitems <= i; i *= 2) + for(nitems = i = 1; nitems <= i; i *= 2) nitems = i; - if (nitems > 0x7fff) + if(nitems > 0x7fff) nitems = 0x40000; do { num_open.rlim_max = sizeof(*memchunk) * (size_t)nitems; snprintf(strbuff, sizeof(strbuff), fmt, num_open.rlim_max); fprintf(stderr, "allocating memchunk %s byte array\n", strbuff); memchunk = malloc(sizeof(*memchunk) * (size_t)nitems); - if (!memchunk) { + if(!memchunk) { fprintf(stderr, "memchunk, malloc() failed\n"); nitems /= 2; } - } while (nitems && !memchunk); - if (!memchunk) { + } while(nitems && !memchunk); + if(!memchunk) { store_errmsg("memchunk, malloc() failed", ERRNO); fprintf(stderr, "%s\n", msgbuff); return -5; @@ -276,7 +277,7 @@ static int rlimit(int keep_open) fprintf(stderr, "initializing memchunk array\n"); - for (i = 0; i < nitems; i++) + for(i = 0; i < nitems; i++) memchunk[i] = -1; /* set the number of file descriptors we will try to open */ @@ -285,7 +286,7 @@ static int rlimit(int keep_open) /* verify that we won't overflow size_t in malloc() */ - if ((size_t)(num_open.rlim_max) > ((size_t)-1) / sizeof(*fd)) { + if((size_t)(num_open.rlim_max) > ((size_t)-1) / sizeof(*fd)) { snprintf(strbuff1, sizeof(strbuff1), fmt, num_open.rlim_max); snprintf(strbuff, sizeof(strbuff), "unable to allocate an array for %s " "file descriptors, would overflow size_t", strbuff1); @@ -301,7 +302,7 @@ static int rlimit(int keep_open) fprintf(stderr, "allocating array for %s file descriptors\n", strbuff); fd = malloc(sizeof(*fd) * (size_t)(num_open.rlim_max)); - if (!fd) { + if(!fd) { store_errmsg("fd, malloc() failed", ERRNO); fprintf(stderr, "%s\n", msgbuff); free(memchunk); @@ -312,9 +313,9 @@ static int rlimit(int keep_open) fprintf(stderr, "initializing fd array\n"); - for (num_open.rlim_cur = 0; - num_open.rlim_cur < num_open.rlim_max; - num_open.rlim_cur++) + for(num_open.rlim_cur = 0; + num_open.rlim_cur < num_open.rlim_max; + num_open.rlim_cur++) fd[num_open.rlim_cur] = -1; snprintf(strbuff, sizeof(strbuff), fmt, num_open.rlim_max); @@ -323,7 +324,7 @@ static int rlimit(int keep_open) /* open a dummy descriptor */ fd[0] = open(DEV_NULL, O_RDONLY); - if (fd[0] < 0) { + if(fd[0] < 0) { snprintf(strbuff, sizeof(strbuff), "opening of %s failed", DEV_NULL); store_errmsg(strbuff, ERRNO); fprintf(stderr, "%s\n", msgbuff); @@ -335,13 +336,13 @@ static int rlimit(int keep_open) /* create a bunch of file descriptors */ - for (num_open.rlim_cur = 1; - num_open.rlim_cur < num_open.rlim_max; - num_open.rlim_cur++) { + for(num_open.rlim_cur = 1; + num_open.rlim_cur < num_open.rlim_max; + num_open.rlim_cur++) { fd[num_open.rlim_cur] = dup(fd[0]); - if (fd[num_open.rlim_cur] < 0) { + if(fd[num_open.rlim_cur] < 0) { fd[num_open.rlim_cur] = -1; @@ -350,7 +351,8 @@ static int rlimit(int keep_open) fprintf(stderr, "%s\n", strbuff); snprintf(strbuff1, sizeof(strbuff), fmt, num_open.rlim_cur); - snprintf(strbuff, sizeof(strbuff), "fds system limit seems close to %s", strbuff1); + snprintf(strbuff, sizeof(strbuff), "fds system limit seems close to %s", + strbuff1); fprintf(stderr, "%s\n", strbuff); num_open.rlim_max = NUM_NEEDED; @@ -362,9 +364,9 @@ static int rlimit(int keep_open) store_errmsg(strbuff, 0); fprintf(stderr, "%s\n", msgbuff); - for (num_open.rlim_cur = 0; - fd[num_open.rlim_cur] >= 0; - num_open.rlim_cur++) + for(num_open.rlim_cur = 0; + fd[num_open.rlim_cur] >= 0; + num_open.rlim_cur++) close(fd[num_open.rlim_cur]); free(fd); fd = NULL; @@ -394,7 +396,7 @@ static int rlimit(int keep_open) */ num_open.rlim_cur = FD_SETSIZE - SAFETY_MARGIN; - if (num_open.rlim_max > num_open.rlim_cur) { + if(num_open.rlim_max > num_open.rlim_cur) { snprintf(strbuff, sizeof(strbuff), "select limit is FD_SETSIZE %d", FD_SETSIZE); store_errmsg(strbuff, 0); @@ -405,10 +407,10 @@ static int rlimit(int keep_open) } num_open.rlim_cur = FD_SETSIZE - SAFETY_MARGIN; - for (rl.rlim_cur = 0; - rl.rlim_cur < num_open.rlim_max; - rl.rlim_cur++) { - if ((fd[rl.rlim_cur] > 0) && + for(rl.rlim_cur = 0; + rl.rlim_cur < num_open.rlim_max; + rl.rlim_cur++) { + if((fd[rl.rlim_cur] > 0) && ((unsigned int)fd[rl.rlim_cur] > num_open.rlim_cur)) { snprintf(strbuff, sizeof(strbuff), "select limit is FD_SETSIZE %d", FD_SETSIZE); @@ -431,14 +433,14 @@ static int rlimit(int keep_open) * if it is capable of fopen()ing some additional files. */ - if (!fopen_works()) { + if(!fopen_works()) { snprintf(strbuff1, sizeof(strbuff1), fmt, num_open.rlim_max); snprintf(strbuff, sizeof(strbuff), - "stdio fopen() fails with %s fds open()", + "fopen fails with %s fds open()", strbuff1); fprintf(stderr, "%s\n", msgbuff); snprintf(strbuff, sizeof(strbuff), - "stdio fopen() fails with lots of fds open()"); + "fopen fails with lots of fds open()"); store_errmsg(strbuff, 0); close_file_descriptors(); free(memchunk); @@ -452,7 +454,7 @@ static int rlimit(int keep_open) /* close file descriptors unless instructed to keep them */ - if (!keep_open) { + if(!keep_open) { close_file_descriptors(); } @@ -473,7 +475,7 @@ int test(char *URL) return 0; /* sure, run this! */ } - if (rlimit(TRUE)) { + if(rlimit(TRUE)) { /* failure */ return TEST_ERR_MAJOR_BAD; } @@ -481,13 +483,13 @@ int test(char *URL) /* run the test with the bunch of open file descriptors and close them all once the test is over */ - if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); close_file_descriptors(); return TEST_ERR_MAJOR_BAD; } - if ((curl = curl_easy_init()) == NULL) { + if((curl = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); close_file_descriptors(); curl_global_cleanup(); diff --git a/tests/libtest/lib519.c b/tests/libtest/lib519.c index a95bc3c1a..730d42a3c 100644 --- a/tests/libtest/lib519.c +++ b/tests/libtest/lib519.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2011, 2016, 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 @@ -28,12 +28,12 @@ int test(char *URL) CURLcode res; CURL *curl; - if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); return TEST_ERR_MAJOR_BAD; } - if ((curl = curl_easy_init()) == NULL) { + if((curl = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); curl_global_cleanup(); return TEST_ERR_MAJOR_BAD; diff --git a/tests/libtest/lib520.c b/tests/libtest/lib520.c index 556b66b30..7e54cd180 100644 --- a/tests/libtest/lib520.c +++ b/tests/libtest/lib520.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2011, 2016, 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 @@ -28,12 +28,12 @@ int test(char *URL) CURLcode res; CURL *curl; - if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); return TEST_ERR_MAJOR_BAD; } - if ((curl = curl_easy_init()) == NULL) { + if((curl = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); curl_global_cleanup(); return TEST_ERR_MAJOR_BAD; diff --git a/tests/libtest/lib521.c b/tests/libtest/lib521.c index d15add773..e6d6b2387 100644 --- a/tests/libtest/lib521.c +++ b/tests/libtest/lib521.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2011, 2016, 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 @@ -28,12 +28,12 @@ int test(char *URL) CURLcode res; CURL *curl; - if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); return TEST_ERR_MAJOR_BAD; } - if ((curl = curl_easy_init()) == NULL) { + if((curl = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); curl_global_cleanup(); return TEST_ERR_MAJOR_BAD; diff --git a/tests/libtest/lib523.c b/tests/libtest/lib523.c index 3272df42a..f94738205 100644 --- a/tests/libtest/lib523.c +++ b/tests/libtest/lib523.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2011, 2016, 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 @@ -28,12 +28,12 @@ int test(char *URL) CURLcode res; CURL *curl; - if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); return TEST_ERR_MAJOR_BAD; } - if ((curl = curl_easy_init()) == NULL) { + if((curl = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); curl_global_cleanup(); return TEST_ERR_MAJOR_BAD; diff --git a/tests/libtest/lib524.c b/tests/libtest/lib524.c index e5ab187e0..77d486b00 100644 --- a/tests/libtest/lib524.c +++ b/tests/libtest/lib524.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2011, 2016, 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 @@ -28,12 +28,12 @@ int test(char *URL) CURLcode res; CURL *curl; - if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); return TEST_ERR_MAJOR_BAD; } - if ((curl = curl_easy_init()) == NULL) { + if((curl = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); curl_global_cleanup(); return TEST_ERR_MAJOR_BAD; diff --git a/tests/libtest/lib525.c b/tests/libtest/lib525.c index 8290cad04..2daa1ef31 100644 --- a/tests/libtest/lib525.c +++ b/tests/libtest/lib525.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2011, 2016, 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 @@ -34,7 +34,7 @@ int test(char *URL) int res = 0; CURL *curl = NULL; FILE *hd_src = NULL; - int hd ; + int hd; int error; struct_stat file_info; CURLM *m = NULL; @@ -56,7 +56,7 @@ int test(char *URL) hd_src = fopen(libtest_arg2, "rb"); if(NULL == hd_src) { error = ERRNO; - fprintf(stderr, "fopen() failed with error: %d (%s)\n", + fprintf(stderr, "fopen failed with error: %d (%s)\n", error, strerror(error)); fprintf(stderr, "Error opening file: (%s)\n", libtest_arg2); return TEST_ERR_FOPEN; @@ -86,7 +86,7 @@ int test(char *URL) easy_setopt(curl, CURLOPT_UPLOAD, 1L); /* specify target */ - easy_setopt(curl,CURLOPT_URL, URL); + easy_setopt(curl, CURLOPT_URL, URL); /* go verbose */ easy_setopt(curl, CURLOPT_VERBOSE, 1L); diff --git a/tests/libtest/lib537.c b/tests/libtest/lib537.c index 3e00776a3..4efb5387c 100644 --- a/tests/libtest/lib537.c +++ b/tests/libtest/lib537.c @@ -66,9 +66,9 @@ static void store_errmsg(const char *msg, int err) static void close_file_descriptors(void) { - for (num_open.rlim_cur = 0; - num_open.rlim_cur < num_open.rlim_max; - num_open.rlim_cur++) + for(num_open.rlim_cur = 0; + num_open.rlim_cur < num_open.rlim_max; + num_open.rlim_cur++) if(fd[num_open.rlim_cur] > 0) close(fd[num_open.rlim_cur]); free(fd); @@ -81,19 +81,19 @@ static int fopen_works(void) int i; int ret = 1; - for (i = 0; i < 3; i++) { + for(i = 0; i < 3; i++) { fpa[i] = NULL; } - for (i = 0; i < 3; i++) { - fpa[i] = fopen(DEV_NULL, "r"); + for(i = 0; i < 3; i++) { + fpa[i] = fopen(DEV_NULL, FOPEN_READTEXT); if(fpa[i] == NULL) { - store_errmsg("fopen() failed", ERRNO); + store_errmsg("fopen failed", ERRNO); fprintf(stderr, "%s\n", msgbuff); ret = 0; break; } } - for (i = 0; i < 3; i++) { + for(i = 0; i < 3; i++) { if(fpa[i] != NULL) fclose(fpa[i]); } @@ -227,7 +227,7 @@ static int rlimit(int keep_open) * that it becomes available to the test. */ - for (nitems = i = 1; nitems <= i; i *= 2) + for(nitems = i = 1; nitems <= i; i *= 2) nitems = i; if(nitems > 0x7fff) nitems = 0x40000; @@ -240,7 +240,7 @@ static int rlimit(int keep_open) fprintf(stderr, "memchunk, malloc() failed\n"); nitems /= 2; } - } while (nitems && !memchunk); + } while(nitems && !memchunk); if(!memchunk) { store_errmsg("memchunk, malloc() failed", ERRNO); fprintf(stderr, "%s\n", msgbuff); @@ -251,7 +251,7 @@ static int rlimit(int keep_open) fprintf(stderr, "initializing memchunk array\n"); - for (i = 0; i < nitems; i++) + for(i = 0; i < nitems; i++) memchunk[i] = -1; /* set the number of file descriptors we will try to open */ @@ -266,7 +266,7 @@ static int rlimit(int keep_open) } else { /* a huge number of file descriptors */ - for (nitems = i = 1; nitems <= i; i *= 2) + for(nitems = i = 1; nitems <= i; i *= 2) nitems = i; if(nitems > 0x7fff) nitems = 0x40000; @@ -295,7 +295,7 @@ static int rlimit(int keep_open) fprintf(stderr, "fd, malloc() failed\n"); num_open.rlim_max /= 2; } - } while (num_open.rlim_max && !fd); + } while(num_open.rlim_max && !fd); if(!fd) { store_errmsg("fd, malloc() failed", ERRNO); fprintf(stderr, "%s\n", msgbuff); @@ -307,9 +307,9 @@ static int rlimit(int keep_open) fprintf(stderr, "initializing fd array\n"); - for (num_open.rlim_cur = 0; - num_open.rlim_cur < num_open.rlim_max; - num_open.rlim_cur++) + for(num_open.rlim_cur = 0; + num_open.rlim_cur < num_open.rlim_max; + num_open.rlim_cur++) fd[num_open.rlim_cur] = -1; snprintf(strbuff, sizeof(strbuff), fmt, num_open.rlim_max); @@ -330,9 +330,9 @@ static int rlimit(int keep_open) /* create a bunch of file descriptors */ - for (num_open.rlim_cur = 1; - num_open.rlim_cur < num_open.rlim_max; - num_open.rlim_cur++) { + for(num_open.rlim_cur = 1; + num_open.rlim_cur < num_open.rlim_max; + num_open.rlim_cur++) { fd[num_open.rlim_cur] = dup(fd[0]); @@ -345,19 +345,21 @@ static int rlimit(int keep_open) fprintf(stderr, "%s\n", strbuff); snprintf(strbuff1, sizeof(strbuff1), fmt, num_open.rlim_cur); - snprintf(strbuff, sizeof(strbuff), "fds system limit seems close to %s", strbuff1); + snprintf(strbuff, sizeof(strbuff), "fds system limit seems close to %s", + strbuff1); fprintf(stderr, "%s\n", strbuff); num_open.rlim_max = num_open.rlim_cur - SAFETY_MARGIN; num_open.rlim_cur -= num_open.rlim_max; snprintf(strbuff1, sizeof(strbuff1), fmt, num_open.rlim_cur); - snprintf(strbuff, sizeof(strbuff), "closing %s file descriptors", strbuff1); + snprintf(strbuff, sizeof(strbuff), "closing %s file descriptors", + strbuff1); fprintf(stderr, "%s\n", strbuff); - for (num_open.rlim_cur = num_open.rlim_max; - fd[num_open.rlim_cur] >= 0; - num_open.rlim_cur++) { + for(num_open.rlim_cur = num_open.rlim_max; + fd[num_open.rlim_cur] >= 0; + num_open.rlim_cur++) { close(fd[num_open.rlim_cur]); fd[num_open.rlim_cur] = -1; } @@ -399,7 +401,8 @@ static int rlimit(int keep_open) num_open.rlim_cur = FD_SETSIZE - SAFETY_MARGIN; if(num_open.rlim_max > num_open.rlim_cur) { - snprintf(strbuff, sizeof(strbuff), "select limit is FD_SETSIZE %d", FD_SETSIZE); + snprintf(strbuff, sizeof(strbuff), "select limit is FD_SETSIZE %d", + FD_SETSIZE); store_errmsg(strbuff, 0); fprintf(stderr, "%s\n", msgbuff); close_file_descriptors(); @@ -408,12 +411,13 @@ static int rlimit(int keep_open) } num_open.rlim_cur = FD_SETSIZE - SAFETY_MARGIN; - for (rl.rlim_cur = 0; - rl.rlim_cur < num_open.rlim_max; - rl.rlim_cur++) { + for(rl.rlim_cur = 0; + rl.rlim_cur < num_open.rlim_max; + rl.rlim_cur++) { if((fd[rl.rlim_cur] > 0) && ((unsigned int)fd[rl.rlim_cur] > num_open.rlim_cur)) { - snprintf(strbuff, sizeof(strbuff), "select limit is FD_SETSIZE %d", FD_SETSIZE); + snprintf(strbuff, sizeof(strbuff), "select limit is FD_SETSIZE %d", + FD_SETSIZE); store_errmsg(strbuff, 0); fprintf(stderr, "%s\n", msgbuff); close_file_descriptors(); @@ -435,10 +439,10 @@ static int rlimit(int keep_open) if(!fopen_works()) { snprintf(strbuff1, sizeof(strbuff1), fmt, num_open.rlim_max); - snprintf(strbuff, sizeof(strbuff), "stdio fopen() fails with %s fds open()", + snprintf(strbuff, sizeof(strbuff), "fopen fails with %s fds open", strbuff1); fprintf(stderr, "%s\n", msgbuff); - snprintf(strbuff, sizeof(strbuff), "stdio fopen() fails with lots of fds open()"); + snprintf(strbuff, sizeof(strbuff), "fopen fails with lots of fds open"); store_errmsg(strbuff, 0); close_file_descriptors(); free(memchunk); diff --git a/tests/libtest/lib539.c b/tests/libtest/lib539.c index c6ca0d258..34dee9245 100644 --- a/tests/libtest/lib539.c +++ b/tests/libtest/lib539.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2011, 2016, 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 @@ -30,12 +30,12 @@ int test(char *URL) char *newURL = NULL; struct curl_slist *slist = NULL; - if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); return TEST_ERR_MAJOR_BAD; } - if ((curl = curl_easy_init()) == NULL) { + if((curl = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); curl_global_cleanup(); return TEST_ERR_MAJOR_BAD; @@ -58,16 +58,15 @@ int test(char *URL) * even though no directories are stored in the ftpconn->dirs array (after a * call to freedirs). */ - newURL = malloc(strlen(URL) + 3); - if (newURL == NULL) { + newURL = aprintf("%s./", URL); + if(newURL == NULL) { curl_easy_cleanup(curl); curl_global_cleanup(); return TEST_ERR_MAJOR_BAD; } - newURL = strcat(strcpy(newURL, URL), "./"); slist = curl_slist_append (NULL, "SYST"); - if (slist == NULL) { + if(slist == NULL) { free(newURL); curl_easy_cleanup(curl); curl_global_cleanup(); diff --git a/tests/libtest/lib540.c b/tests/libtest/lib540.c index 89dc6bc77..9b3b5a40e 100644 --- a/tests/libtest/lib540.c +++ b/tests/libtest/lib540.c @@ -113,7 +113,7 @@ static int loop(int num, CURLM *cm, const char* url, const char* userpwd, if(res) return res; - while (U) { + while(U) { int M = -99; @@ -125,7 +125,7 @@ static int loop(int num, CURLM *cm, const char* url, const char* userpwd, if(res) return res; - if (U) { + if(U) { FD_ZERO(&R); FD_ZERO(&W); FD_ZERO(&E); diff --git a/tests/libtest/lib541.c b/tests/libtest/lib541.c index 64c7d20f5..9992da7f5 100644 --- a/tests/libtest/lib541.c +++ b/tests/libtest/lib541.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2011, 2016, 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 @@ -35,12 +35,12 @@ int test(char *URL) { CURL *curl; CURLcode res = CURLE_OK; - FILE *hd_src ; + FILE *hd_src; int hd; struct_stat file_info; int error; - if (!libtest_arg2) { + if(!libtest_arg2) { fprintf(stderr, "Usage: <url> <file-to-upload>\n"); return TEST_ERR_USAGE; } @@ -48,7 +48,7 @@ int test(char *URL) hd_src = fopen(libtest_arg2, "rb"); if(NULL == hd_src) { error = ERRNO; - fprintf(stderr, "fopen() failed with error: %d %s\n", + fprintf(stderr, "fopen failed with error: %d %s\n", error, strerror(error)); fprintf(stderr, "Error opening file: %s\n", libtest_arg2); return -2; /* if this happens things are major weird */ @@ -72,14 +72,14 @@ int test(char *URL) return TEST_ERR_MAJOR_BAD; } - if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); fclose(hd_src); return TEST_ERR_MAJOR_BAD; } /* get a curl handle */ - if ((curl = curl_easy_init()) == NULL) { + if((curl = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); curl_global_cleanup(); fclose(hd_src); @@ -93,7 +93,7 @@ int test(char *URL) test_setopt(curl, CURLOPT_VERBOSE, 1L); /* specify target */ - test_setopt(curl,CURLOPT_URL, URL); + test_setopt(curl, CURLOPT_URL, URL); /* now specify which file to upload */ test_setopt(curl, CURLOPT_READDATA, hd_src); diff --git a/tests/libtest/lib542.c b/tests/libtest/lib542.c index 0d0d574fc..2ce67b944 100644 --- a/tests/libtest/lib542.c +++ b/tests/libtest/lib542.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2011, 2016, 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 @@ -36,13 +36,13 @@ int test(char *URL) CURL *curl; CURLcode res = CURLE_OK; - if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); return TEST_ERR_MAJOR_BAD; } /* get a curl handle */ - if ((curl = curl_easy_init()) == NULL) { + if((curl = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); curl_global_cleanup(); return TEST_ERR_MAJOR_BAD; @@ -58,7 +58,7 @@ int test(char *URL) test_setopt(curl, CURLOPT_HEADER, 0L); /* specify target */ - test_setopt(curl,CURLOPT_URL, URL); + test_setopt(curl, CURLOPT_URL, URL); /* Now run off and do what you've been told! */ res = curl_easy_perform(curl); diff --git a/tests/libtest/lib543.c b/tests/libtest/lib543.c index 367248389..6001e8f1c 100644 --- a/tests/libtest/lib543.c +++ b/tests/libtest/lib543.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2012, 2016, 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 @@ -36,7 +36,7 @@ int test(char *URL) char *s; (void)URL; - if ((easy = curl_easy_init()) == NULL) { + if((easy = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); return TEST_ERR_MAJOR_BAD; } diff --git a/tests/libtest/lib544.c b/tests/libtest/lib544.c index 9bd80d875..736744425 100644 --- a/tests/libtest/lib544.c +++ b/tests/libtest/lib544.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2014, 2016, 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 @@ -42,12 +42,12 @@ int test(char *URL) CURL *curl; CURLcode res=CURLE_OK; - if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); return TEST_ERR_MAJOR_BAD; } - if ((curl = curl_easy_init()) == NULL) { + if((curl = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); curl_global_cleanup(); return TEST_ERR_MAJOR_BAD; diff --git a/tests/libtest/lib547.c b/tests/libtest/lib547.c index c282be186..4ec42a330 100644 --- a/tests/libtest/lib547.c +++ b/tests/libtest/lib547.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2016, 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 @@ -85,12 +85,12 @@ int test(char *URL) int counter=0; #endif - if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); return TEST_ERR_MAJOR_BAD; } - if ((curl = curl_easy_init()) == NULL) { + if((curl = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); curl_global_cleanup(); return TEST_ERR_MAJOR_BAD; @@ -108,7 +108,8 @@ int test(char *URL) test_setopt(curl, CURLOPT_IOCTLDATA, &counter); test_setopt(curl, CURLOPT_READFUNCTION, readcallback); test_setopt(curl, CURLOPT_READDATA, &counter); - /* We CANNOT do the POST fine without setting the size (or choose chunked)! */ + /* We CANNOT do the POST fine without setting the size (or choose + chunked)! */ test_setopt(curl, CURLOPT_POSTFIELDSIZE, (long)strlen(UPLOADTHIS)); #endif test_setopt(curl, CURLOPT_POST, 1L); diff --git a/tests/libtest/lib549.c b/tests/libtest/lib549.c index 961a4ba5b..4b35c26ca 100644 --- a/tests/libtest/lib549.c +++ b/tests/libtest/lib549.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2011, 2016, 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 @@ -33,12 +33,12 @@ int test(char *URL) CURLcode res; CURL *curl; - if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); return TEST_ERR_MAJOR_BAD; } - if ((curl = curl_easy_init()) == NULL) { + if((curl = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); curl_global_cleanup(); return TEST_ERR_MAJOR_BAD; diff --git a/tests/libtest/lib552.c b/tests/libtest/lib552.c index 408b60cdb..e63cebc49 100644 --- a/tests/libtest/lib552.c +++ b/tests/libtest/lib552.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2016, 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 @@ -63,14 +63,14 @@ void dump(const char *text, for(c = 0; (c < width) && (i+c < size); c++) { /* check for 0D0A; if found, skip past and start a new line of output */ - if (nohex && (i+c+1 < size) && ptr[i+c]==0x0D && ptr[i+c+1]==0x0A) { + if(nohex && (i+c+1 < size) && ptr[i+c]==0x0D && ptr[i+c+1]==0x0A) { i+=(c+2-width); break; } fprintf(stream, "%c", (ptr[i+c]>=0x20) && (ptr[i+c]<0x80)?ptr[i+c]:'.'); /* check again for 0D0A, to avoid an extra \n if it's at width */ - if (nohex && (i+c+2 < size) && ptr[i+c+1]==0x0D && ptr[i+c+2]==0x0A) { + if(nohex && (i+c+2 < size) && ptr[i+c+1]==0x0D && ptr[i+c+2]==0x0A) { i+=(c+3-width); break; } @@ -121,12 +121,14 @@ int my_trace(CURL *handle, curl_infotype type, static size_t current_offset = 0; -static char databuf[70000]; /* MUST be more than 64k OR MAX_INITIAL_POST_SIZE */ +static char databuf[70000]; /* MUST be more than 64k OR + MAX_INITIAL_POST_SIZE */ static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *stream) { size_t amount = nmemb * size; /* Total bytes curl wants */ - size_t available = sizeof(databuf) - current_offset; /* What we have to give */ + size_t available = sizeof(databuf) - current_offset; /* What we have to + give */ size_t given = amount < available ? amount : available; /* What is given */ (void)stream; memcpy(ptr, databuf + current_offset, given); @@ -135,7 +137,8 @@ static size_t read_callback(void *ptr, size_t size, size_t nmemb, void *stream) } -static size_t write_callback(void *ptr, size_t size, size_t nmemb, void *stream) +static size_t write_callback(void *ptr, size_t size, size_t nmemb, + void *stream) { int amount = curlx_uztosi(size * nmemb); printf("%.*s", amount, (char *)ptr); @@ -147,7 +150,7 @@ static size_t write_callback(void *ptr, size_t size, size_t nmemb, void *stream) static curlioerr ioctl_callback(CURL * handle, int cmd, void *clientp) { (void)clientp; - if (cmd == CURLIOCMD_RESTARTREAD ) { + if(cmd == CURLIOCMD_RESTARTREAD ) { printf("APPLICATION: recieved a CURLIOCMD_RESTARTREAD request\n"); printf("APPLICATION: ** REWINDING! **\n"); current_offset = 0; @@ -181,7 +184,7 @@ int test(char *URL) test_setopt(curl, CURLOPT_VERBOSE, 1L); /* setup repeated data string */ - for (i=0; i < sizeof(databuf); ++i) + for(i=0; i < sizeof(databuf); ++i) databuf[i] = fill[i % sizeof fill]; /* Post */ @@ -206,7 +209,8 @@ int test(char *URL) test_setopt(curl, CURLOPT_URL, URL); - /* Accept any auth. But for this bug configure proxy with DIGEST, basic might work too, not NTLM */ + /* Accept any auth. But for this bug configure proxy with DIGEST, basic + might work too, not NTLM */ test_setopt(curl, CURLOPT_PROXYAUTH, (long)CURLAUTH_ANY); res = curl_easy_perform(curl); diff --git a/tests/libtest/lib553.c b/tests/libtest/lib553.c index ab4db74c7..9afaad48f 100644 --- a/tests/libtest/lib553.c +++ b/tests/libtest/lib553.c @@ -39,7 +39,7 @@ static size_t myreadfunc(void *ptr, size_t size, size_t nmemb, void *stream) memset(buf, 'A', sizeof(buf)); size *= nmemb; - if (size > total) + if(size > total) size = total; if(size > sizeof(buf)) @@ -73,18 +73,18 @@ int test(char *URL) return TEST_ERR_MAJOR_BAD; } - for (i = 0; i < NUM_HEADERS; i++) { + for(i = 0; i < NUM_HEADERS; i++) { int len = snprintf(buf, sizeof(buf), "Header%d: ", i); memset(&buf[len], 'A', SIZE_HEADERS); buf[len + SIZE_HEADERS]=0; /* zero terminate */ hl = curl_slist_append(headerlist, buf); - if (!hl) + if(!hl) goto test_cleanup; headerlist = hl; } hl = curl_slist_append(headerlist, "Expect: "); - if (!hl) + if(!hl) goto test_cleanup; headerlist = hl; diff --git a/tests/libtest/lib554.c b/tests/libtest/lib554.c index 23f0e2397..803df26d1 100644 --- a/tests/libtest/lib554.c +++ b/tests/libtest/lib554.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2016, 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 @@ -162,7 +162,7 @@ static int once(char *URL, bool oldstyle) if(formrc) printf("curl_formadd(4) = %d\n", (int)formrc); - if ((curl = curl_easy_init()) == NULL) { + if((curl = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); curl_formfree(formpost); curl_global_cleanup(); @@ -208,7 +208,7 @@ int test(char *URL) { int res; - if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); return TEST_ERR_MAJOR_BAD; } diff --git a/tests/libtest/lib555.c b/tests/libtest/lib555.c index fea4ea48c..6083c0237 100644 --- a/tests/libtest/lib555.c +++ b/tests/libtest/lib555.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2011, 2016, 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 @@ -96,7 +96,8 @@ int test(char *URL) easy_setopt(curl, CURLOPT_IOCTLDATA, &counter); easy_setopt(curl, CURLOPT_READFUNCTION, readcallback); easy_setopt(curl, CURLOPT_READDATA, &counter); - /* We CANNOT do the POST fine without setting the size (or choose chunked)! */ + /* We CANNOT do the POST fine without setting the size (or choose + chunked)! */ easy_setopt(curl, CURLOPT_POSTFIELDSIZE, strlen(UPLOADTHIS)); easy_setopt(curl, CURLOPT_POST, 1L); @@ -113,7 +114,7 @@ int test(char *URL) multi_add_handle(m, curl); - while (running) { + while(running) { struct timeval timeout; fd_set fdread, fdwrite, fdexcep; int maxfd = -99; diff --git a/tests/libtest/lib556.c b/tests/libtest/lib556.c index 3c1ff0ebb..a0b360b33 100644 --- a/tests/libtest/lib556.c +++ b/tests/libtest/lib556.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2014, 2016, 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 @@ -40,12 +40,12 @@ int test(char *URL) CURLcode res; CURL *curl; - if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); return TEST_ERR_MAJOR_BAD; } - if ((curl = curl_easy_init()) == NULL) { + if((curl = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); curl_global_cleanup(); return TEST_ERR_MAJOR_BAD; diff --git a/tests/libtest/lib558.c b/tests/libtest/lib558.c index 39475635b..05353aa97 100644 --- a/tests/libtest/lib558.c +++ b/tests/libtest/lib558.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2013, 2016, 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 @@ -33,7 +33,7 @@ int test(char *URL) (void)URL; /* we don't use this */ - if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); return TEST_ERR_MAJOR_BAD; } diff --git a/tests/libtest/lib562.c b/tests/libtest/lib562.c index b5c3970d9..819b50759 100644 --- a/tests/libtest/lib562.c +++ b/tests/libtest/lib562.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2016, 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 @@ -40,13 +40,13 @@ int test(char *URL) CURL *curl; CURLcode res = CURLE_OK; - if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); return TEST_ERR_MAJOR_BAD; } /* get a curl handle */ - if ((curl = curl_easy_init()) == NULL) { + if((curl = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); curl_global_cleanup(); return TEST_ERR_MAJOR_BAD; @@ -59,7 +59,7 @@ int test(char *URL) test_setopt(curl, CURLOPT_PORT, strtol(libtest_arg2, NULL, 10)); /* specify target */ - test_setopt(curl,CURLOPT_URL, URL); + test_setopt(curl, CURLOPT_URL, URL); /* Now run off and do what you've been told! */ res = curl_easy_perform(curl); diff --git a/tests/libtest/lib566.c b/tests/libtest/lib566.c index fc03d4e7d..59edb54f4 100644 --- a/tests/libtest/lib566.c +++ b/tests/libtest/lib566.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2011, 2016, 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 @@ -30,12 +30,12 @@ int test(char *URL) double content_length = 3; - if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); return TEST_ERR_MAJOR_BAD; } - if ((curl = curl_easy_init()) == NULL) { + if((curl = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); curl_global_cleanup(); return TEST_ERR_MAJOR_BAD; diff --git a/tests/libtest/lib567.c b/tests/libtest/lib567.c index 080efb1a3..b71778d7c 100644 --- a/tests/libtest/lib567.c +++ b/tests/libtest/lib567.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2011, 2016, 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 @@ -32,12 +32,12 @@ int test(char *URL) CURL *curl; struct curl_slist *custom_headers=NULL; - if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); return TEST_ERR_MAJOR_BAD; } - if ((curl = curl_easy_init()) == NULL) { + if((curl = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); curl_global_cleanup(); return TEST_ERR_MAJOR_BAD; diff --git a/tests/libtest/lib568.c b/tests/libtest/lib568.c index 3dfb94887..9b3a07787 100644 --- a/tests/libtest/lib568.c +++ b/tests/libtest/lib568.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2016, 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,12 +50,12 @@ int test(char *URL) int request=1; struct curl_slist *custom_headers=NULL; - if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); return TEST_ERR_MAJOR_BAD; } - if ((curl = curl_easy_init()) == NULL) { + if((curl = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); curl_global_cleanup(); return TEST_ERR_MAJOR_BAD; @@ -131,7 +131,8 @@ int test(char *URL) } test_setopt(curl, CURLOPT_RTSPHEADER, custom_headers); test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_ANNOUNCE); - test_setopt(curl, CURLOPT_POSTFIELDS, "postyfield=postystuff&project=curl\n"); + test_setopt(curl, CURLOPT_POSTFIELDS, + "postyfield=postystuff&project=curl\n"); res = curl_easy_perform(curl); if(res) diff --git a/tests/libtest/lib569.c b/tests/libtest/lib569.c index 909a12cda..e8578fd3f 100644 --- a/tests/libtest/lib569.c +++ b/tests/libtest/lib569.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2011, 2016, 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 @@ -47,13 +47,13 @@ int test(char *URL) return TEST_ERR_MAJOR_BAD; } - if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); fclose(idfile); return TEST_ERR_MAJOR_BAD; } - if ((curl = curl_easy_init()) == NULL) { + if((curl = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); curl_global_cleanup(); fclose(idfile); @@ -86,7 +86,8 @@ int test(char *URL) stream_uri = NULL; test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_SETUP); - test_setopt(curl, CURLOPT_RTSP_TRANSPORT, "Fake/NotReal/JustATest;foo=baz"); + test_setopt(curl, CURLOPT_RTSP_TRANSPORT, + "Fake/NotReal/JustATest;foo=baz"); res = curl_easy_perform(curl); if(res) goto test_cleanup; diff --git a/tests/libtest/lib570.c b/tests/libtest/lib570.c index db4498553..511a0a99f 100644 --- a/tests/libtest/lib570.c +++ b/tests/libtest/lib570.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2013, 2016, 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 @@ -35,12 +35,12 @@ int test(char *URL) int request=1; char *stream_uri = NULL; - if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); return TEST_ERR_MAJOR_BAD; } - if ((curl = curl_easy_init()) == NULL) { + if((curl = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); curl_global_cleanup(); return TEST_ERR_MAJOR_BAD; diff --git a/tests/libtest/lib571.c b/tests/libtest/lib571.c index 95c868485..1a4b9d75e 100644 --- a/tests/libtest/lib571.c +++ b/tests/libtest/lib571.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2013, 2016, 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,8 +75,9 @@ static size_t rtp_write(void *ptr, size_t size, size_t nmemb, void *stream) { printf("RTP PAYLOAD CORRUPTED [%s]\n", data + i); return failure; } - } else { - if (memcmp(RTP_DATA, data + i, message_size - i) != 0) { + } + else { + if(memcmp(RTP_DATA, data + i, message_size - i) != 0) { printf("RTP PAYLOAD END CORRUPTED (%d), [%s]\n", message_size - i, data + i); return failure; @@ -110,13 +111,13 @@ int test(char *URL) return TEST_ERR_MAJOR_BAD; } - if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); fclose(protofile); return TEST_ERR_MAJOR_BAD; } - if ((curl = curl_easy_init()) == NULL) { + if((curl = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); fclose(protofile); curl_global_cleanup(); diff --git a/tests/libtest/lib572.c b/tests/libtest/lib572.c index 9e7a9feca..bab9bae1a 100644 --- a/tests/libtest/lib572.c +++ b/tests/libtest/lib572.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2011, 2016, 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,12 +50,12 @@ int test(char *URL) int request=1; struct curl_slist *custom_headers=NULL; - if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); return TEST_ERR_MAJOR_BAD; } - if ((curl = curl_easy_init()) == NULL) { + if((curl = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); curl_global_cleanup(); return TEST_ERR_MAJOR_BAD; diff --git a/tests/libtest/lib573.c b/tests/libtest/lib573.c index 527c19b61..78840b745 100644 --- a/tests/libtest/lib573.c +++ b/tests/libtest/lib573.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2012, 2016, 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 @@ -44,7 +44,7 @@ int test(char *URL) dbl_epsilon = 1.0; do { dbl_epsilon /= 2.0; - } while ((double)(1.0 + (dbl_epsilon/2.0)) > (double)1.0); + } while((double)(1.0 + (dbl_epsilon/2.0)) > (double)1.0); start_test_timing(); @@ -65,7 +65,7 @@ int test(char *URL) multi_add_handle(m, c); - while (running) { + while(running) { struct timeval timeout; fd_set fdread, fdwrite, fdexcep; int maxfd = -99; @@ -94,7 +94,7 @@ int test(char *URL) } curl_easy_getinfo(c, CURLINFO_CONNECT_TIME, &connect_time); - if (connect_time < dbl_epsilon) { + if(connect_time < dbl_epsilon) { fprintf(stderr, "connect time %e is < epsilon %e\n", connect_time, dbl_epsilon); res = TEST_ERR_MAJOR_BAD; diff --git a/tests/libtest/lib574.c b/tests/libtest/lib574.c index 6baeb00b9..b29bd2ad5 100644 --- a/tests/libtest/lib574.c +++ b/tests/libtest/lib574.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2011, 2016, 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 @@ -35,12 +35,12 @@ int test(char *URL) int res; CURL *curl; - if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); return TEST_ERR_MAJOR_BAD; } - if ((curl = curl_easy_init()) == NULL) { + if((curl = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); curl_global_cleanup(); return TEST_ERR_MAJOR_BAD; diff --git a/tests/libtest/lib576.c b/tests/libtest/lib576.c index 692faf392..7bf5ab029 100644 --- a/tests/libtest/lib576.c +++ b/tests/libtest/lib576.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2011, 2016, 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,7 +74,8 @@ long chunk_bgn(const struct curl_fileinfo *finfo, void *ptr, int remains) } if(finfo->filetype == CURLFILETYPE_FILE) { ch_d->print_content = 1; - printf("Content:\n-------------------------------------------------------------\n"); + printf("Content:\n-----------------------" + "--------------------------------------\n"); } if(strcmp(finfo->filename, "someothertext.txt") == 0) { printf("# THIS CONTENT WAS SKIPPED IN CHUNK_BGN CALLBACK #\n"); @@ -100,7 +101,7 @@ int test(char *URL) { CURL *handle = NULL; CURLcode res = CURLE_OK; - chunk_data_t chunk_data = {0,0}; + chunk_data_t chunk_data = {0, 0}; curl_global_init(CURL_GLOBAL_ALL); handle = curl_easy_init(); if(!handle) { diff --git a/tests/libtest/lib578.c b/tests/libtest/lib578.c index 9189d6e4f..8d79dc0cc 100644 --- a/tests/libtest/lib578.c +++ b/tests/libtest/lib578.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2011, 2016, 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 @@ -28,7 +28,8 @@ static char data[]="this is a short string.\n"; static size_t data_size = sizeof(data) / sizeof(char); -static int progress_callback(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow) +static int progress_callback(void *clientp, double dltotal, double dlnow, + double ultotal, double ulnow) { FILE *moo = fopen(libtest_arg2, "wb"); @@ -37,10 +38,11 @@ static int progress_callback(void *clientp, double dltotal, double dlnow, double (void)dlnow; /* UNUSED */ if(moo) { - if ((size_t)ultotal == data_size && (size_t)ulnow == data_size) + if((size_t)ultotal == data_size && (size_t)ulnow == data_size) fprintf(moo, "PASSED, UL data matched data size\n"); else - fprintf(moo, "Progress callback called with UL %f out of %f\n", ulnow, ultotal); + fprintf(moo, "Progress callback called with UL %f out of %f\n", + ulnow, ultotal); fclose(moo); } return 0; @@ -51,12 +53,12 @@ int test(char *URL) CURL *curl; CURLcode res=CURLE_OK; - if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); return TEST_ERR_MAJOR_BAD; } - if ((curl = curl_easy_init()) == NULL) { + if((curl = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); curl_global_cleanup(); return TEST_ERR_MAJOR_BAD; diff --git a/tests/libtest/lib579.c b/tests/libtest/lib579.c index fc9f79168..63f3f0521 100644 --- a/tests/libtest/lib579.c +++ b/tests/libtest/lib579.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2012, 2016, 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 @@ -92,19 +92,19 @@ int test(char *URL) struct WriteThis pooh; pooh.counter = 0; - if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); return TEST_ERR_MAJOR_BAD; } - if ((curl = curl_easy_init()) == NULL) { + if((curl = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); curl_global_cleanup(); return TEST_ERR_MAJOR_BAD; } slist = curl_slist_append(slist, "Transfer-Encoding: chunked"); - if (slist == NULL) { + if(slist == NULL) { fprintf(stderr, "curl_slist_append() failed\n"); curl_easy_cleanup(curl); curl_global_cleanup(); diff --git a/tests/libtest/lib582.c b/tests/libtest/lib582.c index 738aa63c2..444b416ff 100644 --- a/tests/libtest/lib582.c +++ b/tests/libtest/lib582.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2016, 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 @@ -51,9 +51,9 @@ static void removeFd(struct Sockets* sockets, curl_socket_t fd, int mention) if(mention) fprintf(stderr, "Remove socket fd %d\n", (int) fd); - for (i = 0; i < sockets->count; ++i) { - if (sockets->sockets[i] == fd) { - if (i < sockets->count - 1) + for(i = 0; i < sockets->count; ++i) { + if(sockets->sockets[i] == fd) { + if(i < sockets->count - 1) memmove(&sockets->sockets[i], &sockets->sockets[i + 1], sizeof(curl_socket_t) * (sockets->count - (i + 1))); --sockets->count; @@ -110,10 +110,10 @@ static int curlSocketCallback(CURL *easy, curl_socket_t s, int action, (void)easy; /* unused */ (void)socketp; /* unused */ - if (action == CURL_POLL_IN || action == CURL_POLL_INOUT) + if(action == CURL_POLL_IN || action == CURL_POLL_INOUT) addFd(&sockets->read, s, "read"); - if (action == CURL_POLL_OUT || action == CURL_POLL_INOUT) + if(action == CURL_POLL_OUT || action == CURL_POLL_INOUT) addFd(&sockets->write, s, "write"); if(action == CURL_POLL_REMOVE) { @@ -132,7 +132,7 @@ static int curlTimerCallback(CURLM *multi, long timeout_ms, void *userp) struct timeval* timeout = userp; (void)multi; /* unused */ - if (timeout_ms != -1) { + if(timeout_ms != -1) { *timeout = tutil_tvnow(); timeout->tv_usec += timeout_ms * 1000; } @@ -151,10 +151,10 @@ static int checkForCompletion(CURLM* curl, int* success) CURLMsg* message; int result = 0; *success = 0; - while ((message = curl_multi_info_read(curl, &numMessages)) != NULL) { - if (message->msg == CURLMSG_DONE) { + while((message = curl_multi_info_read(curl, &numMessages)) != NULL) { + if(message->msg == CURLMSG_DONE) { result = 1; - if (message->data.result == CURLE_OK) + if(message->data.result == CURLE_OK) *success = 1; else *success = 0; @@ -176,7 +176,7 @@ static int getMicroSecondTimeout(struct timeval* timeout) now = tutil_tvnow(); result = (timeout->tv_sec - now.tv_sec) * 1000000 + timeout->tv_usec - now.tv_usec; - if (result < 0) + if(result < 0) result = 0; return curlx_sztosi(result); @@ -189,9 +189,9 @@ static void updateFdSet(struct Sockets* sockets, fd_set* fdset, curl_socket_t *maxFd) { int i; - for (i = 0; i < sockets->count; ++i) { + for(i = 0; i < sockets->count; ++i) { FD_SET(sockets->sockets[i], fdset); - if (*maxFd < sockets->sockets[i] + 1) { + if(*maxFd < sockets->sockets[i] + 1) { *maxFd = sockets->sockets[i] + 1; } } @@ -202,7 +202,7 @@ static void notifyCurl(CURLM *curl, curl_socket_t s, int evBitmask, { int numhandles = 0; CURLMcode result = curl_multi_socket_action(curl, s, evBitmask, &numhandles); - if (result != CURLM_OK) { + if(result != CURLM_OK) { fprintf(stderr, "Curl error on %s: %i (%s)\n", info, result, curl_multi_strerror(result)); } @@ -215,8 +215,8 @@ static void checkFdSet(CURLM *curl, struct Sockets *sockets, fd_set *fdset, int evBitmask, const char *name) { int i; - for (i = 0; i < sockets->count; ++i) { - if (FD_ISSET(sockets->sockets[i], fdset)) { + for(i = 0; i < sockets->count; ++i) { + if(FD_ISSET(sockets->sockets[i], fdset)) { notifyCurl(curl, sockets->sockets[i], evBitmask, name); } } @@ -227,7 +227,7 @@ int test(char *URL) int res = 0; CURL *curl = NULL; FILE *hd_src = NULL; - int hd ; + int hd; int error; struct_stat file_info; CURLM *m = NULL; @@ -237,7 +237,7 @@ int test(char *URL) start_test_timing(); - if (!libtest_arg3) { + if(!libtest_arg3) { fprintf(stderr, "Usage: lib582 [url] [filename] [username]\n"); return TEST_ERR_USAGE; } @@ -276,7 +276,7 @@ int test(char *URL) easy_setopt(curl, CURLOPT_UPLOAD, 1L); /* specify target */ - easy_setopt(curl,CURLOPT_URL, URL); + easy_setopt(curl, CURLOPT_URL, URL); /* go verbose */ easy_setopt(curl, CURLOPT_VERBOSE, 1L); @@ -300,8 +300,7 @@ int test(char *URL) multi_add_handle(m, curl); - while (!checkForCompletion(m, &success)) - { + while(!checkForCompletion(m, &success)) { fd_set readSet, writeSet; curl_socket_t maxFd = 0; struct timeval tv = {10, 0}; @@ -311,14 +310,12 @@ int test(char *URL) updateFdSet(&sockets.read, &readSet, &maxFd); updateFdSet(&sockets.write, &writeSet, &maxFd); - if (timeout.tv_sec != -1) - { + if(timeout.tv_sec != -1) { int usTimeout = getMicroSecondTimeout(&timeout); tv.tv_sec = usTimeout / 1000000; tv.tv_usec = usTimeout % 1000000; } - else if (maxFd <= 0) - { + else if(maxFd <= 0) { tv.tv_sec = 0; tv.tv_usec = 100000; } @@ -329,8 +326,7 @@ int test(char *URL) checkFdSet(m, &sockets.read, &readSet, CURL_CSELECT_IN, "read"); checkFdSet(m, &sockets.write, &writeSet, CURL_CSELECT_OUT, "write"); - if (timeout.tv_sec != -1 && getMicroSecondTimeout(&timeout) == 0) - { + if(timeout.tv_sec != -1 && getMicroSecondTimeout(&timeout) == 0) { /* Curl's timer has elapsed. */ notifyCurl(m, CURL_SOCKET_TIMEOUT, 0, "timeout"); } @@ -338,8 +334,7 @@ int test(char *URL) abort_on_test_timeout(); } - if (!success) - { + if(!success) { fprintf(stderr, "Error uploading file.\n"); res = TEST_ERR_MAJOR_BAD; } diff --git a/tests/libtest/lib586.c b/tests/libtest/lib586.c index 3965c7461..55ab6b655 100644 --- a/tests/libtest/lib586.c +++ b/tests/libtest/lib586.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2016, 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 @@ -36,8 +36,8 @@ struct userdata { }; /* lock callback */ -static void my_lock(CURL *handle, curl_lock_data data, curl_lock_access laccess, - void *useptr ) +static void my_lock(CURL *handle, curl_lock_data data, + curl_lock_access laccess, void *useptr) { const char *what; struct userdata *user = (struct userdata *)useptr; @@ -101,7 +101,7 @@ static void *fire(void *ptr) CURL *curl; int i=0; - if ((curl = curl_easy_init()) == NULL) { + if((curl = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); return NULL; } @@ -114,7 +114,7 @@ static void *fire(void *ptr) printf( "PERFORM\n" ); code = curl_easy_perform(curl); - if( code != CURLE_OK ) { + if(code != CURLE_OK ) { fprintf(stderr, "perform url '%s' repeat %d failed, curlcode %d\n", tdata->url, i, (int)code); } @@ -141,37 +141,38 @@ int test(char *URL) user.counter = 0; printf( "GLOBAL_INIT\n" ); - if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); return TEST_ERR_MAJOR_BAD; } /* prepare share */ printf( "SHARE_INIT\n" ); - if ((share = curl_share_init()) == NULL) { + if((share = curl_share_init()) == NULL) { fprintf(stderr, "curl_share_init() failed\n"); curl_global_cleanup(); return TEST_ERR_MAJOR_BAD; } - if ( CURLSHE_OK == scode ) { + if(CURLSHE_OK == scode ) { printf( "CURLSHOPT_LOCKFUNC\n" ); scode = curl_share_setopt( share, CURLSHOPT_LOCKFUNC, my_lock); } - if ( CURLSHE_OK == scode ) { + if(CURLSHE_OK == scode ) { printf( "CURLSHOPT_UNLOCKFUNC\n" ); scode = curl_share_setopt( share, CURLSHOPT_UNLOCKFUNC, my_unlock); } - if ( CURLSHE_OK == scode ) { + if(CURLSHE_OK == scode ) { printf( "CURLSHOPT_USERDATA\n" ); scode = curl_share_setopt( share, CURLSHOPT_USERDATA, &user); } - if ( CURLSHE_OK == scode ) { + if(CURLSHE_OK == scode ) { printf( "CURL_LOCK_DATA_SSL_SESSION\n" ); - scode = curl_share_setopt( share, CURLSHOPT_SHARE, CURL_LOCK_DATA_SSL_SESSION); + scode = curl_share_setopt( share, CURLSHOPT_SHARE, + CURL_LOCK_DATA_SSL_SESSION); } - if ( CURLSHE_OK != scode ) { + if(CURLSHE_OK != scode ) { fprintf(stderr, "curl_share_setopt() failed\n"); curl_share_cleanup(share); curl_global_cleanup(); @@ -182,7 +183,7 @@ int test(char *URL) res = 0; /* start treads */ - for (i=1; i<=THREADS; i++ ) { + for(i=1; i<=THREADS; i++ ) { /* set thread data */ tdata.url = URL; @@ -196,7 +197,7 @@ int test(char *URL) /* fetch a another one */ printf( "*** run %d\n", i ); - if ((curl = curl_easy_init()) == NULL) { + if((curl = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); curl_share_cleanup(share); curl_global_cleanup(); @@ -214,11 +215,11 @@ int test(char *URL) /* try to free share, expect to fail because share is in use*/ printf( "try SHARE_CLEANUP...\n" ); scode = curl_share_cleanup( share ); - if ( scode==CURLSHE_OK ) - { + if(scode==CURLSHE_OK) { fprintf(stderr, "curl_share_cleanup succeed but error expected\n"); share = NULL; - } else { + } + else { printf( "SHARE_CLEANUP failed, correct\n" ); } @@ -231,7 +232,7 @@ test_cleanup: /* free share */ printf( "SHARE_CLEANUP\n" ); scode = curl_share_cleanup( share ); - if ( scode!=CURLSHE_OK ) + if(scode!=CURLSHE_OK ) fprintf(stderr, "curl_share_cleanup failed, code errno %d\n", (int)scode); diff --git a/tests/libtest/lib590.c b/tests/libtest/lib590.c index 44409afa6..3d4d0bddf 100644 --- a/tests/libtest/lib590.c +++ b/tests/libtest/lib590.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2012, 2016, 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 @@ -41,12 +41,12 @@ int test(char *URL) CURLcode res; CURL *curl; - if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); return TEST_ERR_MAJOR_BAD; } - if ((curl = curl_easy_init()) == NULL) { + if((curl = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); curl_global_cleanup(); return TEST_ERR_MAJOR_BAD; diff --git a/tests/libtest/lib597.c b/tests/libtest/lib597.c index 493d4d8dc..813af7541 100644 --- a/tests/libtest/lib597.c +++ b/tests/libtest/lib597.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2016, 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 @@ -69,7 +69,7 @@ int test(char *URL) multi_init(multi); - for (phase = CONNECT_ONLY_PHASE; phase < LAST_PHASE; ++phase) { + for(phase = CONNECT_ONLY_PHASE; phase < LAST_PHASE; ++phase) { /* go verbose */ easy_setopt(easy, CURLOPT_VERBOSE, 1L); @@ -77,11 +77,11 @@ int test(char *URL) easy_setopt(easy, CURLOPT_URL, URL); /* enable 'CONNECT_ONLY' option when in connect phase */ - if (phase == CONNECT_ONLY_PHASE) + if(phase == CONNECT_ONLY_PHASE) easy_setopt(easy, CURLOPT_CONNECT_ONLY, 1L); /* enable 'NOBODY' option to send 'QUIT' command in quit phase */ - if (phase == QUIT_PHASE) { + if(phase == QUIT_PHASE) { easy_setopt(easy, CURLOPT_CONNECT_ONLY, 0L); easy_setopt(easy, CURLOPT_NOBODY, 1L); easy_setopt(easy, CURLOPT_FORBID_REUSE, 1L); @@ -114,7 +114,8 @@ int test(char *URL) multi_timeout(multi, &timeout); - /* At this point, timeout is guaranteed to be greater or equal than -1. */ + /* At this point, timeout is guaranteed to be greater or equal than + -1. */ if(timeout != -1L) { int itimeout = (timeout > (long)INT_MAX) ? INT_MAX : (int)timeout; diff --git a/tests/libtest/lib598.c b/tests/libtest/lib598.c index 215ab5777..12d4decb8 100644 --- a/tests/libtest/lib598.c +++ b/tests/libtest/lib598.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2012, 2016, 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 @@ -28,12 +28,12 @@ int test(char *URL) CURLcode res; CURL *curl; - if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); return TEST_ERR_MAJOR_BAD; } - if ((curl = curl_easy_init()) == NULL) { + if((curl = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); curl_global_cleanup(); return TEST_ERR_MAJOR_BAD; diff --git a/tests/libtest/lib599.c b/tests/libtest/lib599.c index 20b089167..f917f51a3 100644 --- a/tests/libtest/lib599.c +++ b/tests/libtest/lib599.c @@ -5,7 +5,7 @@ * | (__| |_| | _ <| |___ * \___|\___/|_| \_\_____| * - * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al. + * Copyright (C) 1998 - 2012, 2016, 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 @@ -45,12 +45,12 @@ int test(char *URL) CURLcode res=CURLE_OK; double content_length = 0.0; - if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); return TEST_ERR_MAJOR_BAD; } - if ((curl = curl_easy_init()) == NULL) { + if((curl = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); curl_global_cleanup(); return TEST_ERR_MAJOR_BAD; @@ -75,12 +75,12 @@ int test(char *URL) /* Perform the request, res will get the return code */ res = curl_easy_perform(curl); - if (!res) { + if(!res) { FILE *moo; res = curl_easy_getinfo(curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &content_length); moo = fopen(libtest_arg2, "wb"); - if (moo) { + if(moo) { fprintf(moo, "CL: %.0f\n", content_length); fclose(moo); } diff --git a/tests/libtest/libauthretry.c b/tests/libtest/libauthretry.c index fac07fbee..994f9de06 100644 --- a/tests/libtest/libauthretry.c +++ b/tests/libtest/libauthretry.c @@ -34,7 +34,7 @@ static CURLcode send_request(CURL *curl, const char *url, int seq, CURLcode res; size_t len = strlen(url) + 4 + 1; char* full_url = malloc(len); - if (!full_url) { + if(!full_url) { fprintf(stderr, "Not enough memory for full url\n"); return CURLE_OUT_OF_MEMORY; } @@ -70,13 +70,13 @@ static CURLcode send_right_password(CURL *curl, const char *url, int seq, static long parse_auth_name(const char *arg) { - if (!arg) + if(!arg) return CURLAUTH_NONE; - if (strequal(arg, "basic")) + if(strequal(arg, "basic")) return CURLAUTH_BASIC; - if (strequal(arg, "digest")) + if(strequal(arg, "digest")) return CURLAUTH_DIGEST; - if (strequal(arg, "ntlm")) + if(strequal(arg, "ntlm")) return CURLAUTH_NTLM; return CURLAUTH_NONE; } @@ -89,58 +89,58 @@ int test(char *url) long main_auth_scheme = parse_auth_name(libtest_arg2); long fallback_auth_scheme = parse_auth_name(libtest_arg3); - if (main_auth_scheme == CURLAUTH_NONE || + if(main_auth_scheme == CURLAUTH_NONE || fallback_auth_scheme == CURLAUTH_NONE) { fprintf(stderr, "auth schemes not found on commandline\n"); return TEST_ERR_MAJOR_BAD; } - if (curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { + if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) { fprintf(stderr, "curl_global_init() failed\n"); return TEST_ERR_MAJOR_BAD; } /* Send wrong password, then right password */ - if ((curl = curl_easy_init()) == NULL) { + if((curl = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); curl_global_cleanup(); return TEST_ERR_MAJOR_BAD; } res = send_wrong_password(curl, url, 100, main_auth_scheme); - if (res != CURLE_OK) - goto test_cleanup; + if(res != CURLE_OK) + goto test_cleanup; curl_easy_reset(curl); res = send_right_password(curl, url, 200, fallback_auth_scheme); - if (res != CURLE_OK) - goto test_cleanup; + if(res != CURLE_OK) + goto test_cleanup; curl_easy_reset(curl); curl_easy_cleanup(curl); /* Send wrong password twice, then right password */ - if ((curl = curl_easy_init()) == NULL) { + if((curl = curl_easy_init()) == NULL) { fprintf(stderr, "curl_easy_init() failed\n"); curl_global_cleanup(); return TEST_ERR_MAJOR_BAD; } res = send_wrong_password(curl, url, 300, main_auth_scheme); - if (res != CURLE_OK) - goto test_cleanup; + if(res != CURLE_OK) + goto test_cleanup; curl_easy_reset(curl); res = send_wrong_password(curl, url, 400, fallback_auth_scheme); - if (res != CURLE_OK) - goto test_cleanup; + if(res != CURLE_OK) + goto test_cleanup; curl_easy_reset(curl); res = send_right_password(curl, url, 500, fallback_auth_scheme); - if (res != CURLE_OK) - goto test_cleanup; + if(res != CURLE_OK) + goto test_cleanup; curl_easy_reset(curl); test_cleanup: diff --git a/tests/libtest/libntlmconnect.c b/tests/libtest/libntlmconnect.c index 0e2e9f4a6..736222dc6 100644 --- a/tests/libtest/libntlmconnect.c +++ b/tests/libtest/libntlmconnect.c @@ -47,7 +47,7 @@ static size_t callback(char* ptr, size_t size, size_t nmemb, void* data) const size_t failure = (size * nmemb) ? 0 : 1; char *output = malloc(size * nmemb + 1); - if (!output) { + if(!output) { fprintf(stderr, "output, malloc() failed\n"); res = TEST_ERR_MAJOR_BAD; return failure; @@ -60,25 +60,25 @@ static size_t callback(char* ptr, size_t size, size_t nmemb, void* data) /* Get socket being used for this easy handle, otherwise CURL_SOCKET_BAD */ code = curl_easy_getinfo(easy[idx], CURLINFO_LASTSOCKET, &longdata); - if (CURLE_OK != code) { + if(CURLE_OK != code) { fprintf(stderr, "%s:%d curl_easy_getinfo() failed, " "with code %d (%s)\n", __FILE__, __LINE__, (int)code, curl_easy_strerror(code)); res = TEST_ERR_MAJOR_BAD; return failure; } - if (longdata == -1L) + if(longdata == -1L) sock = CURL_SOCKET_BAD; else sock = (curl_socket_t)longdata; - if (sock != CURL_SOCKET_BAD) { + if(sock != CURL_SOCKET_BAD) { /* Track relationship between this easy handle and the socket. */ - if (sockets[idx] == CURL_SOCKET_BAD) { + if(sockets[idx] == CURL_SOCKET_BAD) { /* An easy handle without previous socket, record the socket. */ sockets[idx] = sock; } - else if (sock != sockets[idx]) { + else if(sock != sockets[idx]) { /* An easy handle with a socket different to previously tracked one, log and fail right away. Known bug #37. */ fprintf(stderr, "Handle %d started on socket %d and moved to %d\n", @@ -113,7 +113,7 @@ int test(char *url) return TEST_ERR_MAJOR_BAD; } - for (i = 0; i < MAX_EASY_HANDLES; ++i) { + for(i = 0; i < MAX_EASY_HANDLES; ++i) { easy[i] = NULL; sockets[i] = CURL_SOCKET_BAD; } @@ -148,7 +148,8 @@ int test(char *url) if(num_handles % 3 == 2) { snprintf(full_url, urllen, "%s0200", url); easy_setopt(easy[num_handles], CURLOPT_HTTPAUTH, CURLAUTH_NTLM); - } else { + } + else { snprintf(full_url, urllen, "%s0100", url); easy_setopt(easy[num_handles], CURLOPT_HTTPAUTH, CURLAUTH_BASIC); } @@ -182,7 +183,7 @@ int test(char *url) /* At this point, maxfd is guaranteed to be greater or equal than -1. */ /* Any socket which is new in fdread is associated with the new handle */ - for (i = 0; i <= maxfd; ++i) { + for(i = 0; i <= maxfd; ++i) { bool socket_exists = FALSE; curl_socket_t curfd = (curl_socket_t)i; @@ -192,7 +193,7 @@ int test(char *url) /* Check if this socket was already detected for an earlier handle (or for this handle, num_handles-1, in the callback */ - for (j = 0; j < num_handles; ++j) { + for(j = 0; j < num_handles; ++j) { if(sockets[j] == curfd) { socket_exists = TRUE; break; diff --git a/tests/libtest/test.h b/tests/libtest/test.h index 4bf6dcfe2..6b699fc3a 100644 --- a/tests/libtest/test.h +++ b/tests/libtest/test.h @@ -43,10 +43,10 @@ #include "curl_printf.h" #define test_setopt(A,B,C) \ - if((res = curl_easy_setopt((A),(B),(C))) != CURLE_OK) goto test_cleanup + if((res = curl_easy_setopt((A), (B), (C))) != CURLE_OK) goto test_cleanup #define test_multi_setopt(A,B,C) \ - if((res = curl_multi_setopt((A),(B),(C))) != CURLE_OK) goto test_cleanup + if((res = curl_multi_setopt((A), (B), (C))) != CURLE_OK) goto test_cleanup extern char *libtest_arg2; /* set by first.c to the argv[2] or NULL */ extern char *libtest_arg3; /* set by first.c to the argv[3] or NULL */ @@ -132,16 +132,16 @@ extern int unitfail; } WHILE_FALSE #define res_easy_init(A) \ - exe_easy_init((A),(__FILE__),(__LINE__)) + exe_easy_init((A), (__FILE__), (__LINE__)) #define chk_easy_init(A,Y,Z) do { \ - exe_easy_init((A),(Y),(Z)); \ + exe_easy_init((A), (Y), (Z)); \ if(res) \ goto test_cleanup; \ } WHILE_FALSE #define easy_init(A) \ - chk_easy_init((A),(__FILE__),(__LINE__)) + chk_easy_init((A), (__FILE__), (__LINE__)) /* ---------------------------------------------------------------- */ @@ -153,70 +153,70 @@ extern int unitfail; } WHILE_FALSE #define res_multi_init(A) \ - exe_multi_init((A),(__FILE__),(__LINE__)) + exe_multi_init((A), (__FILE__), (__LINE__)) #define chk_multi_init(A,Y,Z) do { \ - exe_multi_init((A),(Y),(Z)); \ + exe_multi_init((A), (Y), (Z)); \ if(res) \ goto test_cleanup; \ } WHILE_FALSE #define multi_init(A) \ - chk_multi_init((A),(__FILE__),(__LINE__)) + chk_multi_init((A), (__FILE__), (__LINE__)) /* ---------------------------------------------------------------- */ -#define exe_easy_setopt(A,B,C,Y,Z) do { \ - CURLcode ec; \ - if((ec = curl_easy_setopt((A),(B),(C))) != CURLE_OK) { \ - fprintf(stderr, "%s:%d curl_easy_setopt() failed, " \ - "with code %d (%s)\n", \ - (Y), (Z), (int)ec, curl_easy_strerror(ec)); \ - res = (int)ec; \ - } \ +#define exe_easy_setopt(A,B,C,Y,Z) do { \ + CURLcode ec; \ + if((ec = curl_easy_setopt((A), (B), (C))) != CURLE_OK) { \ + fprintf(stderr, "%s:%d curl_easy_setopt() failed, " \ + "with code %d (%s)\n", \ + (Y), (Z), (int)ec, curl_easy_strerror(ec)); \ + res = (int)ec; \ + } \ } WHILE_FALSE -#define res_easy_setopt(A,B,C) \ - exe_easy_setopt((A),(B),(C),(__FILE__),(__LINE__)) +#define res_easy_setopt(A, B, C) \ + exe_easy_setopt((A), (B), (C), (__FILE__), (__LINE__)) -#define chk_easy_setopt(A,B,C,Y,Z) do { \ - exe_easy_setopt((A),(B),(C),(Y),(Z)); \ - if(res) \ - goto test_cleanup; \ +#define chk_easy_setopt(A, B, C, Y, Z) do { \ + exe_easy_setopt((A), (B), (C), (Y), (Z)); \ + if(res) \ + goto test_cleanup; \ } WHILE_FALSE -#define easy_setopt(A,B,C) \ - chk_easy_setopt((A),(B),(C),(__FILE__),(__LINE__)) +#define easy_setopt(A, B, C) \ + chk_easy_setopt((A), (B), (C), (__FILE__), (__LINE__)) /* ---------------------------------------------------------------- */ -#define exe_multi_setopt(A,B,C,Y,Z) do { \ - CURLMcode ec; \ - if((ec = curl_multi_setopt((A),(B),(C))) != CURLM_OK) { \ - fprintf(stderr, "%s:%d curl_multi_setopt() failed, " \ - "with code %d (%s)\n", \ - (Y), (Z), (int)ec, curl_multi_strerror(ec)); \ - res = (int)ec; \ - } \ +#define exe_multi_setopt(A, B, C, Y, Z) do { \ + CURLMcode ec; \ + if((ec = curl_multi_setopt((A), (B), (C))) != CURLM_OK) { \ + fprintf(stderr, "%s:%d curl_multi_setopt() failed, " \ + "with code %d (%s)\n", \ + (Y), (Z), (int)ec, curl_multi_strerror(ec)); \ + res = (int)ec; \ + } \ } WHILE_FALSE #define res_multi_setopt(A,B,C) \ - exe_multi_setopt((A),(B),(C),(__FILE__),(__LINE__)) + exe_multi_setopt((A), (B), (C), (__FILE__), (__LINE__)) -#define chk_multi_setopt(A,B,C,Y,Z) do { \ - exe_multi_setopt((A),(B),(C),(Y),(Z)); \ - if(res) \ - goto test_cleanup; \ +#define chk_multi_setopt(A,B,C,Y,Z) do { \ + exe_multi_setopt((A), (B), (C), (Y), (Z)); \ + if(res) \ + goto test_cleanup; \ } WHILE_FALSE #define multi_setopt(A,B,C) \ - chk_multi_setopt((A),(B),(C),(__FILE__),(__LINE__)) + chk_multi_setopt((A), (B), (C), (__FILE__), (__LINE__)) /* ---------------------------------------------------------------- */ #define exe_multi_add_handle(A,B,Y,Z) do { \ CURLMcode ec; \ - if((ec = curl_multi_add_handle((A),(B))) != CURLM_OK) { \ + if((ec = curl_multi_add_handle((A), (B))) != CURLM_OK) { \ fprintf(stderr, "%s:%d curl_multi_add_handle() failed, " \ "with code %d (%s)\n", \ (Y), (Z), (int)ec, curl_multi_strerror(ec)); \ @@ -224,23 +224,23 @@ extern int unitfail; } \ } WHILE_FALSE -#define res_multi_add_handle(A,B) \ - exe_multi_add_handle((A),(B),(__FILE__),(__LINE__)) +#define res_multi_add_handle(A, B) \ + exe_multi_add_handle((A), (B), (__FILE__), (__LINE__)) -#define chk_multi_add_handle(A,B,Y,Z) do { \ - exe_multi_add_handle((A),(B),(Y),(Z)); \ - if(res) \ - goto test_cleanup; \ +#define chk_multi_add_handle(A, B, Y, Z) do { \ + exe_multi_add_handle((A), (B), (Y), (Z)); \ + if(res) \ + goto test_cleanup; \ } WHILE_FALSE -#define multi_add_handle(A,B) \ - chk_multi_add_handle((A),(B),(__FILE__),(__LINE__)) +#define multi_add_handle(A, B) \ + chk_multi_add_handle((A), (B), (__FILE__), (__LINE__)) /* ---------------------------------------------------------------- */ #define exe_multi_remove_handle(A,B,Y,Z) do { \ CURLMcode ec; \ - if((ec = curl_multi_remove_handle((A),(B))) != CURLM_OK) { \ + if((ec = curl_multi_remove_handle((A), (B))) != CURLM_OK) { \ fprintf(stderr, "%s:%d curl_multi_remove_handle() failed, " \ "with code %d (%s)\n", \ (Y), (Z), (int)ec, curl_multi_strerror(ec)); \ @@ -248,24 +248,24 @@ extern int unitfail; } \ } WHILE_FALSE -#define res_multi_remove_handle(A,B) \ - exe_multi_remove_handle((A),(B),(__FILE__),(__LINE__)) +#define res_multi_remove_handle(A, B) \ + exe_multi_remove_handle((A), (B), (__FILE__), (__LINE__)) -#define chk_multi_remove_handle(A,B,Y,Z) do { \ - exe_multi_remove_handle((A),(B),(Y),(Z)); \ - if(res) \ - goto test_cleanup; \ +#define chk_multi_remove_handle(A, B, Y, Z) do { \ + exe_multi_remove_handle((A), (B), (Y), (Z)); \ + if(res) \ + goto test_cleanup; \ } WHILE_FALSE -#define multi_remove_handle(A,B) \ - chk_multi_remove_handle((A),(B),(__FILE__),(__LINE__)) +#define multi_remove_handle(A, B) \ + chk_multi_remove_handle((A), (B), (__FILE__), (__LINE__)) /* ---------------------------------------------------------------- */ #define exe_multi_perform(A,B,Y,Z) do { \ CURLMcode ec; \ - if((ec = curl_multi_perform((A),(B))) != CURLM_OK) { \ + if((ec = curl_multi_perform((A), (B))) != CURLM_OK) { \ fprintf(stderr, "%s:%d curl_multi_perform() failed, " \ "with code %d (%s)\n", \ (Y), (Z), (int)ec, curl_multi_strerror(ec)); \ @@ -279,53 +279,53 @@ extern int unitfail; } \ } WHILE_FALSE -#define res_multi_perform(A,B) \ - exe_multi_perform((A),(B),(__FILE__),(__LINE__)) +#define res_multi_perform(A, B) \ + exe_multi_perform((A), (B), (__FILE__), (__LINE__)) -#define chk_multi_perform(A,B,Y,Z) do { \ - exe_multi_perform((A),(B),(Y),(Z)); \ - if(res) \ - goto test_cleanup; \ +#define chk_multi_perform(A, B, Y, Z) do { \ + exe_multi_perform((A), (B), (Y), (Z)); \ + if(res) \ + goto test_cleanup; \ } WHILE_FALSE #define multi_perform(A,B) \ - chk_multi_perform((A),(B),(__FILE__),(__LINE__)) + chk_multi_perform((A), (B), (__FILE__), (__LINE__)) /* ---------------------------------------------------------------- */ -#define exe_multi_fdset(A,B,C,D,E,Y,Z) do { \ - CURLMcode ec; \ - if((ec = curl_multi_fdset((A),(B),(C),(D),(E))) != CURLM_OK) { \ - fprintf(stderr, "%s:%d curl_multi_fdset() failed, " \ - "with code %d (%s)\n", \ - (Y), (Z), (int)ec, curl_multi_strerror(ec)); \ - res = (int)ec; \ - } \ - else if(*((E)) < -1) { \ - fprintf(stderr, "%s:%d curl_multi_fdset() succeeded, " \ - "but returned invalid max_fd value (%d)\n", \ - (Y), (Z), (int)*((E))); \ - res = TEST_ERR_NUM_HANDLES; \ - } \ +#define exe_multi_fdset(A, B, C, D, E, Y, Z) do { \ + CURLMcode ec; \ + if((ec = curl_multi_fdset((A), (B), (C), (D), (E))) != CURLM_OK) { \ + fprintf(stderr, "%s:%d curl_multi_fdset() failed, " \ + "with code %d (%s)\n", \ + (Y), (Z), (int)ec, curl_multi_strerror(ec)); \ + res = (int)ec; \ + } \ + else if(*((E)) < -1) { \ + fprintf(stderr, "%s:%d curl_multi_fdset() succeeded, " \ + "but returned invalid max_fd value (%d)\n", \ + (Y), (Z), (int)*((E))); \ + res = TEST_ERR_NUM_HANDLES; \ + } \ } WHILE_FALSE -#define res_multi_fdset(A,B,C,D,E) \ - exe_multi_fdset((A),(B),(C),(D),(E),(__FILE__),(__LINE__)) +#define res_multi_fdset(A, B, C, D, E) \ + exe_multi_fdset((A), (B), (C), (D), (E), (__FILE__), (__LINE__)) -#define chk_multi_fdset(A,B,C,D,E,Y,Z) do { \ - exe_multi_fdset((A),(B),(C),(D),(E),(Y),(Z)); \ - if(res) \ - goto test_cleanup; \ -} WHILE_FALSE +#define chk_multi_fdset(A, B, C, D, E, Y, Z) do { \ + exe_multi_fdset((A), (B), (C), (D), (E), (Y), (Z)); \ + if(res) \ + goto test_cleanup; \ + } WHILE_FALSE -#define multi_fdset(A,B,C,D,E) \ - chk_multi_fdset((A),(B),(C),(D),(E),(__FILE__),(__LINE__)) +#define multi_fdset(A, B, C, D, E) \ + chk_multi_fdset((A), (B), (C), (D), (E), (__FILE__), (__LINE__)) /* ---------------------------------------------------------------- */ #define exe_multi_timeout(A,B,Y,Z) do { \ CURLMcode ec; \ - if((ec = curl_multi_timeout((A),(B))) != CURLM_OK) { \ + if((ec = curl_multi_timeout((A), (B))) != CURLM_OK) { \ fprintf(stderr, "%s:%d curl_multi_timeout() failed, " \ "with code %d (%s)\n", \ (Y), (Z), (int)ec, curl_multi_strerror(ec)); \ @@ -339,42 +339,42 @@ extern int unitfail; } \ } WHILE_FALSE -#define res_multi_timeout(A,B) \ - exe_multi_timeout((A),(B),(__FILE__),(__LINE__)) +#define res_multi_timeout(A, B) \ + exe_multi_timeout((A), (B), (__FILE__), (__LINE__)) -#define chk_multi_timeout(A,B,Y,Z) do { \ - exe_multi_timeout((A),(B),(Y),(Z)); \ - if(res) \ - goto test_cleanup; \ -} WHILE_FALSE +#define chk_multi_timeout(A, B, Y, Z) do { \ + exe_multi_timeout((A), (B), (Y), (Z)); \ + if(res) \ + goto test_cleanup; \ + } WHILE_FALSE -#define multi_timeout(A,B) \ - chk_multi_timeout((A),(B),(__FILE__),(__LINE__)) +#define multi_timeout(A, B) \ + chk_multi_timeout((A), (B), (__FILE__), (__LINE__)) /* ---------------------------------------------------------------- */ -#define exe_select_test(A,B,C,D,E,Y,Z) do { \ - int ec; \ - if(select_wrapper((A),(B),(C),(D),(E)) == -1 ) { \ - ec = SOCKERRNO; \ - fprintf(stderr, "%s:%d select() failed, with " \ - "errno %d (%s)\n", \ - (Y), (Z), ec, strerror(ec)); \ - res = TEST_ERR_SELECT; \ - } \ -} WHILE_FALSE - -#define res_select_test(A,B,C,D,E) \ - exe_select_test((A),(B),(C),(D),(E),(__FILE__),(__LINE__)) - -#define chk_select_test(A,B,C,D,E,Y,Z) do { \ - exe_select_test((A),(B),(C),(D),(E),(Y),(Z)); \ - if(res) \ - goto test_cleanup; \ -} WHILE_FALSE - -#define select_test(A,B,C,D,E) \ - chk_select_test((A),(B),(C),(D),(E),(__FILE__),(__LINE__)) +#define exe_select_test(A, B, C, D, E, Y, Z) do { \ + int ec; \ + if(select_wrapper((A), (B), (C), (D), (E)) == -1 ) { \ + ec = SOCKERRNO; \ + fprintf(stderr, "%s:%d select() failed, with " \ + "errno %d (%s)\n", \ + (Y), (Z), ec, strerror(ec)); \ + res = TEST_ERR_SELECT; \ + } \ + } WHILE_FALSE + +#define res_select_test(A, B, C, D, E) \ + exe_select_test((A), (B), (C), (D), (E), (__FILE__), (__LINE__)) + +#define chk_select_test(A, B, C, D, E, Y, Z) do { \ + exe_select_test((A), (B), (C), (D), (E), (Y), (Z)); \ + if(res) \ + goto test_cleanup; \ + } WHILE_FALSE + +#define select_test(A, B, C, D, E) \ + chk_select_test((A), (B), (C), (D), (E), (__FILE__), (__LINE__)) /* ---------------------------------------------------------------- */ @@ -391,16 +391,16 @@ extern int unitfail; } WHILE_FALSE #define res_test_timedout() \ - exe_test_timedout((__FILE__),(__LINE__)) + exe_test_timedout((__FILE__), (__LINE__)) -#define chk_test_timedout(Y,Z) do { \ - exe_test_timedout(Y,Z); \ - if(res) \ - goto test_cleanup; \ -} WHILE_FALSE +#define chk_test_timedout(Y, Z) do { \ + exe_test_timedout(Y, Z); \ + if(res) \ + goto test_cleanup; \ + } WHILE_FALSE #define abort_on_test_timeout() \ - chk_test_timedout((__FILE__),(__LINE__)) + chk_test_timedout((__FILE__), (__LINE__)) /* ---------------------------------------------------------------- */ @@ -415,18 +415,18 @@ extern int unitfail; } WHILE_FALSE #define res_global_init(A) \ - exe_global_init((A),(__FILE__),(__LINE__)) + exe_global_init((A), (__FILE__), (__LINE__)) -#define chk_global_init(A,Y,Z) do { \ - exe_global_init((A),(Y),(Z)); \ - if(res) \ - return res; \ -} WHILE_FALSE +#define chk_global_init(A, Y, Z) do { \ + exe_global_init((A), (Y), (Z)); \ + if(res) \ + return res; \ + } WHILE_FALSE /* global_init() is different than other macros. In case of failure it 'return's instead of going to 'test_cleanup'. */ #define global_init(A) \ - chk_global_init((A),(__FILE__),(__LINE__)) + chk_global_init((A), (__FILE__), (__LINE__)) /* ---------------------------------------------------------------- */ |