aboutsummaryrefslogtreecommitdiff
path: root/src/testcurl
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2021-04-13 20:42:49 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2021-04-13 20:42:49 +0300
commit9ce7aa953ad32e25b63b2cce669baf7fdb9da133 (patch)
tree51aae8208e4c17967ebd9ca37c4f81e90c12b324 /src/testcurl
parent2704ce98953d8609e7ce53ecbbf1de6c0060c3bb (diff)
downloadlibmicrohttpd-9ce7aa953ad32e25b63b2cce669baf7fdb9da133.tar.gz
libmicrohttpd-9ce7aa953ad32e25b63b2cce669baf7fdb9da133.zip
Style and shadowing fixes
Diffstat (limited to 'src/testcurl')
-rw-r--r--src/testcurl/https/test_empty_response.c2
-rw-r--r--src/testcurl/https/test_https_get_parallel.c3
-rw-r--r--src/testcurl/https/test_https_get_parallel_threads.c5
-rw-r--r--src/testcurl/https/test_https_session_info.c2
-rw-r--r--src/testcurl/https/test_https_time_out.c2
-rw-r--r--src/testcurl/https/test_tls_options.c6
-rw-r--r--src/testcurl/test_add_conn.c7
-rw-r--r--src/testcurl/test_get_response_cleanup.c4
-rw-r--r--src/testcurl/test_quiesce.c2
-rw-r--r--src/testcurl/test_quiesce_stream.c43
-rw-r--r--src/testcurl/test_termination.c9
11 files changed, 47 insertions, 38 deletions
diff --git a/src/testcurl/https/test_empty_response.c b/src/testcurl/https/test_empty_response.c
index 2cd159f9..bf05baca 100644
--- a/src/testcurl/https/test_empty_response.c
+++ b/src/testcurl/https/test_empty_response.c
@@ -78,6 +78,7 @@ testInternalSelectGet ()
78 time_t start; 78 time_t start;
79 struct timeval tv; 79 struct timeval tv;
80 int port; 80 int port;
81 char *aes256_sha = "AES256-SHA";
81 82
82 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) 83 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
83 port = 0; 84 port = 0;
@@ -107,7 +108,6 @@ testInternalSelectGet ()
107 } 108 }
108 port = (int) dinfo->port; 109 port = (int) dinfo->port;
109 } 110 }
110 char *aes256_sha = "AES256-SHA";
111 if (curl_uses_nss_ssl () == 0) 111 if (curl_uses_nss_ssl () == 0)
112 { 112 {
113 aes256_sha = "rsa_aes_256_sha"; 113 aes256_sha = "rsa_aes_256_sha";
diff --git a/src/testcurl/https/test_https_get_parallel.c b/src/testcurl/https/test_https_get_parallel.c
index af5345bc..cce97fca 100644
--- a/src/testcurl/https/test_https_get_parallel.c
+++ b/src/testcurl/https/test_https_get_parallel.c
@@ -140,6 +140,7 @@ main (int argc, char *const *argv)
140 unsigned int errorCount = 0; 140 unsigned int errorCount = 0;
141 const char *aes256_sha = "AES256-SHA"; 141 const char *aes256_sha = "AES256-SHA";
142 int port; 142 int port;
143 unsigned int iseed;
143 (void) argc; /* Unused. Silent compiler warning. */ 144 (void) argc; /* Unused. Silent compiler warning. */
144 145
145 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) 146 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
@@ -148,7 +149,7 @@ main (int argc, char *const *argv)
148 port = 3020; 149 port = 3020;
149 150
150 /* initialize random seed used by curl clients */ 151 /* initialize random seed used by curl clients */
151 unsigned int iseed = (unsigned int) time (NULL); 152 iseed = (unsigned int) time (NULL);
152 srand (iseed); 153 srand (iseed);
153 if (! testsuite_curl_global_init ()) 154 if (! testsuite_curl_global_init ())
154 return 99; 155 return 99;
diff --git a/src/testcurl/https/test_https_get_parallel_threads.c b/src/testcurl/https/test_https_get_parallel_threads.c
index 969bd45e..4a7d1b1d 100644
--- a/src/testcurl/https/test_https_get_parallel_threads.c
+++ b/src/testcurl/https/test_https_get_parallel_threads.c
@@ -142,6 +142,8 @@ main (int argc, char *const *argv)
142 unsigned int errorCount = 0; 142 unsigned int errorCount = 0;
143 const char *ssl_version; 143 const char *ssl_version;
144 int port; 144 int port;
145 unsigned int iseed;
146 char *aes256_sha = "AES256-SHA";
145 (void) argc; /* Unused. Silent compiler warning. */ 147 (void) argc; /* Unused. Silent compiler warning. */
146 148
147 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) 149 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
@@ -150,7 +152,7 @@ main (int argc, char *const *argv)
150 port = 3010; 152 port = 3010;
151 153
152 /* initialize random seed used by curl clients */ 154 /* initialize random seed used by curl clients */
153 unsigned int iseed = (unsigned int) time (NULL); 155 iseed = (unsigned int) time (NULL);
154 156
155#ifdef MHD_HTTPS_REQUIRE_GRYPT 157#ifdef MHD_HTTPS_REQUIRE_GRYPT
156#ifdef GCRYCTL_INITIALIZATION_FINISHED 158#ifdef GCRYCTL_INITIALIZATION_FINISHED
@@ -174,7 +176,6 @@ main (int argc, char *const *argv)
174 return 77; 176 return 77;
175 } 177 }
176 178
177 char *aes256_sha = "AES256-SHA";
178 if (curl_uses_nss_ssl () == 0) 179 if (curl_uses_nss_ssl () == 0)
179 { 180 {
180 aes256_sha = "rsa_aes_256_sha"; 181 aes256_sha = "rsa_aes_256_sha";
diff --git a/src/testcurl/https/test_https_session_info.c b/src/testcurl/https/test_https_session_info.c
index f80ea4cd..9ca97b36 100644
--- a/src/testcurl/https/test_https_session_info.c
+++ b/src/testcurl/https/test_https_session_info.c
@@ -103,6 +103,7 @@ test_query_session ()
103 CURLcode errornum; 103 CURLcode errornum;
104 char url[256]; 104 char url[256];
105 int port; 105 int port;
106 const char *aes256_sha = "AES256-SHA";
106 107
107 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) 108 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
108 port = 0; 109 port = 0;
@@ -142,7 +143,6 @@ test_query_session ()
142 port = (int) dinfo->port; 143 port = (int) dinfo->port;
143 } 144 }
144 145
145 const char *aes256_sha = "AES256-SHA";
146 if (curl_uses_nss_ssl () == 0) 146 if (curl_uses_nss_ssl () == 0)
147 { 147 {
148 aes256_sha = "rsa_aes_256_sha"; 148 aes256_sha = "rsa_aes_256_sha";
diff --git a/src/testcurl/https/test_https_time_out.c b/src/testcurl/https/test_https_time_out.c
index 7721d486..ca214315 100644
--- a/src/testcurl/https/test_https_time_out.c
+++ b/src/testcurl/https/test_https_time_out.c
@@ -103,7 +103,7 @@ test_tls_session_time_out (gnutls_session_t session, int port)
103int 103int
104main (int argc, char *const *argv) 104main (int argc, char *const *argv)
105{ 105{
106 int errorCount = 0;; 106 int errorCount = 0;
107 struct MHD_Daemon *d; 107 struct MHD_Daemon *d;
108 gnutls_session_t session; 108 gnutls_session_t session;
109 gnutls_datum_t key; 109 gnutls_datum_t key;
diff --git a/src/testcurl/https/test_tls_options.c b/src/testcurl/https/test_tls_options.c
index f94834b5..f42e324b 100644
--- a/src/testcurl/https/test_tls_options.c
+++ b/src/testcurl/https/test_tls_options.c
@@ -47,6 +47,7 @@ test_unmatching_ssl_version (void *cls, int port, const char *cipher_suite,
47 int curl_req_ssl_version) 47 int curl_req_ssl_version)
48{ 48{
49 struct CBC cbc; 49 struct CBC cbc;
50 char url[255];
50 (void) cls; /* Unused. Silent compiler warning. */ 51 (void) cls; /* Unused. Silent compiler warning. */
51 if (NULL == (cbc.buf = malloc (sizeof (char) * 256))) 52 if (NULL == (cbc.buf = malloc (sizeof (char) * 256)))
52 { 53 {
@@ -57,7 +58,6 @@ test_unmatching_ssl_version (void *cls, int port, const char *cipher_suite,
57 cbc.size = 256; 58 cbc.size = 256;
58 cbc.pos = 0; 59 cbc.pos = 0;
59 60
60 char url[255];
61 if (gen_test_file_url (url, 61 if (gen_test_file_url (url,
62 sizeof (url), 62 sizeof (url),
63 port)) 63 port))
@@ -93,6 +93,8 @@ main (int argc, char *const *argv)
93 MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD 93 MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD
94 | MHD_USE_TLS | MHD_USE_ERROR_LOG; 94 | MHD_USE_TLS | MHD_USE_ERROR_LOG;
95 int port; 95 int port;
96 const char *aes128_sha = "AES128-SHA";
97 const char *aes256_sha = "AES256-SHA";
96 (void) argc; (void) argv; /* Unused. Silent compiler warning. */ 98 (void) argc; (void) argv; /* Unused. Silent compiler warning. */
97 99
98 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) 100 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
@@ -126,8 +128,6 @@ main (int argc, char *const *argv)
126 if (! testsuite_curl_global_init ()) 128 if (! testsuite_curl_global_init ())
127 return 99; 129 return 99;
128 130
129 const char *aes128_sha = "AES128-SHA";
130 const char *aes256_sha = "AES256-SHA";
131 if (curl_uses_nss_ssl () == 0) 131 if (curl_uses_nss_ssl () == 0)
132 { 132 {
133 aes128_sha = "rsa_aes_128_sha"; 133 aes128_sha = "rsa_aes_128_sha";
diff --git a/src/testcurl/test_add_conn.c b/src/testcurl/test_add_conn.c
index c1dbdd40..d122a50e 100644
--- a/src/testcurl/test_add_conn.c
+++ b/src/testcurl/test_add_conn.c
@@ -77,9 +77,10 @@
77 77
78/* Cleanup test: max number of concurrent daemons depending on maximum number 78/* Cleanup test: max number of concurrent daemons depending on maximum number
79 * of open FDs. */ 79 * of open FDs. */
80#define CLEANUP_MAX_DAEMONS(max_fds) (((max_fds) - 10) / \ 80#define CLEANUP_MAX_DAEMONS(max_fds) ( ((max_fds) < 10) ? 0 : \
81 (CLEANUP_NUM_REQS_PER_DAEMON * 5 \ 81 ( (((max_fds) - 10) / \
82 + 3)) 82 (CLEANUP_NUM_REQS_PER_DAEMON * 5 \
83 + 3)) ) )
83 84
84#define EXPECTED_URI_BASE_PATH "/hello_world" 85#define EXPECTED_URI_BASE_PATH "/hello_world"
85#define EXPECTED_URI_QUERY "a=%26&b=c" 86#define EXPECTED_URI_QUERY "a=%26&b=c"
diff --git a/src/testcurl/test_get_response_cleanup.c b/src/testcurl/test_get_response_cleanup.c
index db6ba54f..0bb154c8 100644
--- a/src/testcurl/test_get_response_cleanup.c
+++ b/src/testcurl/test_get_response_cleanup.c
@@ -109,10 +109,10 @@ push_callback (void *cls, uint64_t pos, char *buf, size_t max)
109static void 109static void
110push_free_callback (void *cls) 110push_free_callback (void *cls)
111{ 111{
112 int *ok = cls; 112 int *ok_p = cls;
113 113
114 // fprintf (stderr, "Cleanup callback called!\n"); 114 // fprintf (stderr, "Cleanup callback called!\n");
115 *ok = 0; 115 *ok_p = 0;
116} 116}
117 117
118 118
diff --git a/src/testcurl/test_quiesce.c b/src/testcurl/test_quiesce.c
index 0c4ad001..85f6f756 100644
--- a/src/testcurl/test_quiesce.c
+++ b/src/testcurl/test_quiesce.c
@@ -108,8 +108,8 @@ static void
108request_completed (void *cls, struct MHD_Connection *connection, 108request_completed (void *cls, struct MHD_Connection *connection,
109 void **con_cls, enum MHD_RequestTerminationCode code) 109 void **con_cls, enum MHD_RequestTerminationCode code)
110{ 110{
111 (void) connection; (void) con_cls; (void) code; /* Unused. Silent compiler warning. */
112 int *done = (int *) cls; 111 int *done = (int *) cls;
112 (void) connection; (void) con_cls; (void) code; /* Unused. Silent compiler warning. */
113 *done = 1; 113 *done = 1;
114} 114}
115 115
diff --git a/src/testcurl/test_quiesce_stream.c b/src/testcurl/test_quiesce_stream.c
index f20ebcac..c9336f2c 100644
--- a/src/testcurl/test_quiesce_stream.c
+++ b/src/testcurl/test_quiesce_stream.c
@@ -73,13 +73,14 @@ static void
73suspend_connection (struct MHD_Connection *connection) 73suspend_connection (struct MHD_Connection *connection)
74{ 74{
75 pthread_t thread_id; 75 pthread_t thread_id;
76 int status;
76 77
77 /* fprintf (stderr, "Calling suspend\n"); */ 78 /* fprintf (stderr, "Calling suspend\n"); */
78 MHD_suspend_connection (connection); 79 MHD_suspend_connection (connection);
79 int status = pthread_create (&thread_id, 80 status = pthread_create (&thread_id,
80 NULL, 81 NULL,
81 &resume_connection, 82 &resume_connection,
82 connection); 83 connection);
83 if (0 != status) 84 if (0 != status)
84 { 85 {
85 fprintf (stderr, 86 fprintf (stderr,
@@ -143,6 +144,7 @@ http_AccessHandlerCallback (void *cls,
143 void **con_cls) 144 void **con_cls)
144{ 145{
145 enum MHD_Result ret; 146 enum MHD_Result ret;
147 struct MHD_Response *response;
146 (void) cls; (void) url; /* Unused. Silent compiler warning. */ 148 (void) cls; (void) url; /* Unused. Silent compiler warning. */
147 (void) method; (void) version; (void) upload_data; /* Unused. Silent compiler warning. */ 149 (void) method; (void) version; (void) upload_data; /* Unused. Silent compiler warning. */
148 (void) upload_data_size; /* Unused. Silent compiler warning. */ 150 (void) upload_data_size; /* Unused. Silent compiler warning. */
@@ -150,12 +152,12 @@ http_AccessHandlerCallback (void *cls,
150 /* Never respond on first call */ 152 /* Never respond on first call */
151 if (NULL == *con_cls) 153 if (NULL == *con_cls)
152 { 154 {
155 struct ContentReaderUserdata *userdata;
153 fprintf (stderr, 156 fprintf (stderr,
154 "start: %d\n", 157 "start: %d\n",
155 ++request_counter); 158 ++request_counter);
156 159
157 struct ContentReaderUserdata *userdata = malloc (sizeof(struct 160 userdata = malloc (sizeof(struct ContentReaderUserdata));
158 ContentReaderUserdata));
159 161
160 if (NULL == userdata) 162 if (NULL == userdata)
161 return MHD_NO; 163 return MHD_NO;
@@ -166,7 +168,7 @@ http_AccessHandlerCallback (void *cls,
166 } 168 }
167 169
168 /* Second call: create response */ 170 /* Second call: create response */
169 struct MHD_Response *response 171 response
170 = MHD_create_response_from_callback (-1, 172 = MHD_create_response_from_callback (-1,
171 32 * 1024, 173 32 * 1024,
172 &http_ContentReaderCallback, 174 &http_ContentReaderCallback,
@@ -187,6 +189,13 @@ main (void)
187{ 189{
188 int port; 190 int port;
189 char command_line[1024]; 191 char command_line[1024];
192 /* Flags */
193 unsigned int daemon_flags
194 = MHD_USE_INTERNAL_POLLING_THREAD
195 | MHD_USE_AUTO
196 | MHD_ALLOW_SUSPEND_RESUME
197 | MHD_USE_ITC;
198 struct MHD_Daemon *daemon;
190 199
191 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) 200 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
192 port = 0; 201 port = 0;
@@ -197,21 +206,15 @@ main (void)
197 MHD_set_panic_func (&http_PanicCallback, 206 MHD_set_panic_func (&http_PanicCallback,
198 NULL); 207 NULL);
199 208
200 /* Flags */
201 unsigned int daemon_flags
202 = MHD_USE_INTERNAL_POLLING_THREAD
203 | MHD_USE_AUTO
204 | MHD_ALLOW_SUSPEND_RESUME
205 | MHD_USE_ITC;
206 209
207 /* Create daemon */ 210 /* Create daemon */
208 struct MHD_Daemon *daemon = MHD_start_daemon (daemon_flags, 211 daemon = MHD_start_daemon (daemon_flags,
209 port, 212 port,
210 NULL, 213 NULL,
211 NULL, 214 NULL,
212 &http_AccessHandlerCallback, 215 &http_AccessHandlerCallback,
213 NULL, 216 NULL,
214 MHD_OPTION_END); 217 MHD_OPTION_END);
215 if (NULL == daemon) 218 if (NULL == daemon)
216 return 1; 219 return 1;
217 if (0 == port) 220 if (0 == port)
diff --git a/src/testcurl/test_termination.c b/src/testcurl/test_termination.c
index 01c4bf59..e32d3322 100644
--- a/src/testcurl/test_termination.c
+++ b/src/testcurl/test_termination.c
@@ -57,6 +57,8 @@ connection_handler (void *cls,
57 void **ptr) 57 void **ptr)
58{ 58{
59 static int i; 59 static int i;
60 struct MHD_Response *response;
61 enum MHD_Result ret;
60 (void) cls; (void) url; /* Unused. Silent compiler warning. */ 62 (void) cls; (void) url; /* Unused. Silent compiler warning. */
61 (void) method; (void) version; (void) upload_data; /* Unused. Silent compiler warning. */ 63 (void) method; (void) version; (void) upload_data; /* Unused. Silent compiler warning. */
62 (void) upload_data_size; /* Unused. Silent compiler warning. */ 64 (void) upload_data_size; /* Unused. Silent compiler warning. */
@@ -73,10 +75,10 @@ connection_handler (void *cls,
73 return MHD_YES; 75 return MHD_YES;
74 } 76 }
75 77
76 struct MHD_Response *response = 78 response =
77 MHD_create_response_from_buffer (strlen ("Response"), "Response", 79 MHD_create_response_from_buffer (strlen ("Response"), "Response",
78 MHD_RESPMEM_PERSISTENT); 80 MHD_RESPMEM_PERSISTENT);
79 enum MHD_Result ret = MHD_queue_response (connection, MHD_HTTP_OK, response); 81 ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
80 MHD_destroy_response (response); 82 MHD_destroy_response (response);
81 83
82 return ret; 84 return ret;
@@ -98,6 +100,7 @@ main (void)
98 int port; 100 int port;
99 char url[255]; 101 char url[255];
100 CURL *curl; 102 CURL *curl;
103 CURLcode success;
101 104
102 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) 105 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
103 port = 0; 106 port = 0;
@@ -137,7 +140,7 @@ main (void)
137 curl_easy_setopt (curl, CURLOPT_URL, url); 140 curl_easy_setopt (curl, CURLOPT_URL, url);
138 curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, write_data); 141 curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, write_data);
139 142
140 CURLcode success = curl_easy_perform (curl); 143 success = curl_easy_perform (curl);
141 if (success != 0) 144 if (success != 0)
142 { 145 {
143 fprintf (stderr, "CURL Error"); 146 fprintf (stderr, "CURL Error");