gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libmicrohttpd] 03/31: testcurl/https: fixed compiler warnings, wrong ty


From: gnunet
Subject: [libmicrohttpd] 03/31: testcurl/https: fixed compiler warnings, wrong types
Date: Mon, 10 Oct 2022 13:00:48 +0200

This is an automated email from the git hooks/post-receive script.

karlson2k pushed a commit to branch master
in repository libmicrohttpd.

commit 28e28436c68a1d52b1620e29e1046c88b5452bf4
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
AuthorDate: Sun Oct 2 19:57:36 2022 +0300

    testcurl/https: fixed compiler warnings, wrong types
---
 src/testcurl/https/test_empty_response.c           |  10 +-
 src/testcurl/https/test_https_get.c                |  23 ++---
 src/testcurl/https/test_https_get_iovec.c          |  48 +++++-----
 src/testcurl/https/test_https_get_parallel.c       |  22 ++---
 .../https/test_https_get_parallel_threads.c        |  24 ++---
 src/testcurl/https/test_https_get_select.c         |  19 ++--
 src/testcurl/https/test_https_multi_daemon.c       |  17 ++--
 src/testcurl/https/test_https_session_info.c       |   8 +-
 src/testcurl/https/test_https_sni.c                |  12 +--
 src/testcurl/https/test_https_time_out.c           |  13 +--
 src/testcurl/https/test_tls_authentication.c       |  17 ++--
 src/testcurl/https/test_tls_extensions.c           |   7 +-
 src/testcurl/https/test_tls_options.c              |  14 +--
 src/testcurl/https/tls_test_common.c               | 101 +++++++++++----------
 src/testcurl/https/tls_test_common.h               |  50 +++++-----
 15 files changed, 201 insertions(+), 184 deletions(-)

diff --git a/src/testcurl/https/test_empty_response.c 
b/src/testcurl/https/test_empty_response.c
index 3f53bbb4..07388b76 100644
--- a/src/testcurl/https/test_empty_response.c
+++ b/src/testcurl/https/test_empty_response.c
@@ -57,7 +57,7 @@ ahc_echo (void *cls,
 }
 
 
-static int
+static unsigned int
 testInternalSelectGet (void)
 {
   struct MHD_Daemon *d;
@@ -74,8 +74,8 @@ testInternalSelectGet (void)
   struct CURLMsg *msg;
   time_t start;
   struct timeval tv;
-  int port;
-  char *aes256_sha = "AES256-SHA";
+  uint16_t port;
+  const char *aes256_sha = "AES256-SHA";
 
   if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
     port = 0;
@@ -88,7 +88,7 @@ testInternalSelectGet (void)
   cbc.pos = 0;
   d = MHD_start_daemon (MHD_USE_ERROR_LOG | MHD_USE_TLS
                         | MHD_USE_INTERNAL_POLLING_THREAD,
-                        port, NULL, NULL, &ahc_echo, "GET",
+                        port, NULL, NULL, &ahc_echo, NULL,
                         MHD_OPTION_HTTPS_MEM_KEY, srv_key_pem,
                         MHD_OPTION_HTTPS_MEM_CERT, srv_self_signed_cert_pem,
                         MHD_OPTION_END);
@@ -103,7 +103,7 @@ testInternalSelectGet (void)
     {
       MHD_stop_daemon (d); return 32;
     }
-    port = (int) dinfo->port;
+    port = dinfo->port;
   }
   if (curl_tls_is_nss ())
   {
diff --git a/src/testcurl/https/test_https_get.c 
b/src/testcurl/https/test_https_get.c
index f2016cc2..7c917d3b 100644
--- a/src/testcurl/https/test_https_get.c
+++ b/src/testcurl/https/test_https_get.c
@@ -36,18 +36,18 @@
 #include "tls_test_keys.h"
 
 
-static int global_port;
+static uint16_t global_port;
 
 
 /* perform a HTTP GET request via SSL/TLS */
-static int
+static unsigned int
 test_secure_get (FILE *test_fd,
                  const char *cipher_suite,
                  int proto_version)
 {
-  int ret;
+  unsigned int ret;
   struct MHD_Daemon *d;
-  int port;
+  uint16_t port;
 
   if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
     port = 0;
@@ -66,7 +66,7 @@ test_secure_get (FILE *test_fd,
   if (d == NULL)
   {
     fprintf (stderr, MHD_E_SERVER_INIT);
-    return -1;
+    return 1;
   }
   if (0 == port)
   {
@@ -74,9 +74,10 @@ test_secure_get (FILE *test_fd,
     dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
     if ((NULL == dinfo) || (0 == dinfo->port) )
     {
-      MHD_stop_daemon (d); return -1;
+      MHD_stop_daemon (d);
+      return 1;
     }
-    port = (int) dinfo->port;
+    port = dinfo->port;
   }
 
   ret = test_https_transfer (test_fd,
@@ -109,7 +110,7 @@ ahc_empty (void *cls,
   (void) upload_data;
   (void) upload_data_size; /* Unused. Silent compiler warning. */
 
-  if (0 != strcmp ("GET",
+  if (0 != strcmp (MHD_HTTP_METHOD_GET,
                    method))
     return MHD_NO;              /* unexpected method */
   if (&ptr != *req_cls)
@@ -151,8 +152,8 @@ curlExcessFound (CURL *c,
 }
 
 
-static int
-testEmptyGet (int poll_flag)
+static unsigned int
+testEmptyGet (unsigned int poll_flag)
 {
   struct MHD_Daemon *d;
   CURL *c;
@@ -189,7 +190,7 @@ testEmptyGet (int poll_flag)
     {
       MHD_stop_daemon (d); return 32;
     }
-    global_port = (int) dinfo->port;
+    global_port = dinfo->port;
   }
   c = curl_easy_init ();
   curl_easy_setopt (c, CURLOPT_URL, "https://127.0.0.1/";);
diff --git a/src/testcurl/https/test_https_get_iovec.c 
b/src/testcurl/https/test_https_get_iovec.c
index 33272952..39da52f3 100644
--- a/src/testcurl/https/test_https_get_iovec.c
+++ b/src/testcurl/https/test_https_get_iovec.c
@@ -44,7 +44,7 @@
 #include "tls_test_keys.h"
 
 
-static int global_port;
+static uint16_t global_port;
 
 /* Use large enough pieces (>16KB) to test partially consumed
  * data as TLS doesn't take more than 16KB by a single call. */
@@ -117,16 +117,17 @@ iovec_ahc (void *cls,
 
   for (j = 0; j < TESTSTR_IOVCNT; ++j)
   {
+    int *chunk;
     /* Assign chunks of memory area in the reverse order
      * to make non-continous set of data therefore
      * possible buffer overruns could be detected */
-    iov[j].iov_base = data + (((TESTSTR_IOVCNT - 1) - j)
-                              * (TESTSTR_SIZE / TESTSTR_IOVCNT
-                                 / sizeof(int)));
+    chunk = data + (((TESTSTR_IOVCNT - 1) - (unsigned int) j)
+                    * (TESTSTR_SIZE / TESTSTR_IOVCNT / sizeof(int)));
+    iov[j].iov_base = chunk;
     iov[j].iov_len = TESTSTR_SIZE / TESTSTR_IOVCNT;
 
     for (i = 0; i < (int) (TESTSTR_IOVLEN / sizeof(int)); ++i)
-      ((int *) iov[j].iov_base)[i] = i + (j * TESTSTR_IOVLEN / sizeof(int));
+      chunk[i] = i + (j * (int) (TESTSTR_IOVLEN / sizeof(int)));
   }
 
   response = MHD_create_response_from_iovec (iov,
@@ -139,14 +140,14 @@ iovec_ahc (void *cls,
 }
 
 
-static int
+static unsigned int
 test_iovec_transfer (void *cls,
-                     int port,
+                     uint16_t port,
                      const char *cipher_suite,
                      int proto_version)
 {
-  int len;
-  int ret = 0;
+  size_t len;
+  unsigned int ret = 0;
   struct CBC cbc;
   char url[255];
   (void) cls;    /* Unused. Silent compiler warning. */
@@ -155,7 +156,7 @@ test_iovec_transfer (void *cls,
   if (NULL == (cbc.buf = malloc (sizeof (char) * len)))
   {
     fprintf (stderr, MHD_E_MEM);
-    return -1;
+    return 1;
   }
   cbc.size = len;
   cbc.pos = 0;
@@ -164,14 +165,14 @@ test_iovec_transfer (void *cls,
                          sizeof (url),
                          port))
   {
-    ret = -1;
+    ret = 1;
     goto cleanup;
   }
 
   if (CURLE_OK !=
       send_curl_req (url, &cbc, cipher_suite, proto_version))
   {
-    ret = -1;
+    ret = 1;
     goto cleanup;
   }
 
@@ -180,7 +181,7 @@ test_iovec_transfer (void *cls,
       (0 != check_read_data (cbc.buf, cbc.pos)))
   {
     fprintf (stderr, "Error: local file & received file differ.\n");
-    ret = -1;
+    ret = 1;
   }
 cleanup:
   free (cbc.buf);
@@ -189,14 +190,14 @@ cleanup:
 
 
 /* perform a HTTP GET request via SSL/TLS */
-static int
+static unsigned int
 test_secure_get (FILE *test_fd,
                  const char *cipher_suite,
                  int proto_version)
 {
-  int ret;
+  unsigned int ret;
   struct MHD_Daemon *d;
-  int port;
+  uint16_t port;
 
   if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
     port = 0;
@@ -215,7 +216,7 @@ test_secure_get (FILE *test_fd,
   if (d == NULL)
   {
     fprintf (stderr, MHD_E_SERVER_INIT);
-    return -1;
+    return 1;
   }
   if (0 == port)
   {
@@ -223,9 +224,10 @@ test_secure_get (FILE *test_fd,
     dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
     if ((NULL == dinfo) || (0 == dinfo->port) )
     {
-      MHD_stop_daemon (d); return -1;
+      MHD_stop_daemon (d);
+      return 1;
     }
-    port = (int) dinfo->port;
+    port = dinfo->port;
   }
 
   ret = test_iovec_transfer (test_fd,
@@ -259,7 +261,7 @@ ahc_empty (void *cls,
   (void) upload_data;
   (void) upload_data_size; /* Unused. Silent compiler warning. */
 
-  if (0 != strcmp ("GET",
+  if (0 != strcmp (MHD_HTTP_METHOD_GET,
                    method))
     return MHD_NO;              /* unexpected method */
   if (&ptr != *req_cls)
@@ -308,8 +310,8 @@ curlExcessFound (CURL *c,
 }
 
 
-static int
-testEmptyGet (int poll_flag)
+static unsigned int
+testEmptyGet (unsigned int poll_flag)
 {
   struct MHD_Daemon *d;
   CURL *c;
@@ -346,7 +348,7 @@ testEmptyGet (int poll_flag)
     {
       MHD_stop_daemon (d); return 32;
     }
-    global_port = (int) dinfo->port;
+    global_port = dinfo->port;
   }
   c = curl_easy_init ();
   curl_easy_setopt (c, CURLOPT_URL, "https://127.0.0.1/";);
diff --git a/src/testcurl/https/test_https_get_parallel.c 
b/src/testcurl/https/test_https_get_parallel.c
index d24a05ff..3fe65637 100644
--- a/src/testcurl/https/test_https_get_parallel.c
+++ b/src/testcurl/https/test_https_get_parallel.c
@@ -54,7 +54,7 @@ https_transfer_thread_adapter (void *args)
 {
   static int nonnull;
   struct https_test_data *cargs = args;
-  int ret;
+  unsigned int ret;
 
   /* time spread incoming requests */
   usleep ((useconds_t) 10.0 * ((double) rand ()) / ((double) RAND_MAX));
@@ -69,12 +69,12 @@ https_transfer_thread_adapter (void *args)
 /**
  * Test non-parallel requests.
  *
- * @return: 0 upon all client requests returning '0', -1 otherwise.
+ * @return: 0 upon all client requests returning '0', 1 otherwise.
  *
  * TODO : make client_count a parameter - number of curl client threads to 
spawn
  */
-static int
-test_single_client (void *cls, int port, const char *cipher_suite,
+static unsigned int
+test_single_client (void *cls, uint16_t port, const char *cipher_suite,
                     int curl_proto_version)
 {
   void *client_thread_ret;
@@ -84,7 +84,7 @@ test_single_client (void *cls, int port, const char 
*cipher_suite,
 
   client_thread_ret = https_transfer_thread_adapter (&client_args);
   if (client_thread_ret != NULL)
-    return -1;
+    return 1;
   return 0;
 }
 
@@ -92,12 +92,12 @@ test_single_client (void *cls, int port, const char 
*cipher_suite,
 /**
  * Test parallel request handling.
  *
- * @return: 0 upon all client requests returning '0', -1 otherwise.
+ * @return: 0 upon all client requests returning '0', 1 otherwise.
  *
  * TODO : make client_count a parameter - number of curl client threads to 
spawn
  */
-static int
-test_parallel_clients (void *cls, int port, const char *cipher_suite,
+static unsigned int
+test_parallel_clients (void *cls, uint16_t port, const char *cipher_suite,
                        int curl_proto_version)
 {
   int i;
@@ -114,7 +114,7 @@ test_parallel_clients (void *cls, int port, const char 
*cipher_suite,
                         &https_transfer_thread_adapter, &client_args) != 0)
     {
       fprintf (stderr, "Error: failed to spawn test client threads.\n");
-      return -1;
+      return 1;
     }
   }
 
@@ -123,7 +123,7 @@ test_parallel_clients (void *cls, int port, const char 
*cipher_suite,
   {
     if ((pthread_join (client_arr[i], &client_thread_ret) != 0) ||
         (client_thread_ret != NULL))
-      return -1;
+      return 1;
   }
 
   return 0;
@@ -135,7 +135,7 @@ main (int argc, char *const *argv)
 {
   unsigned int errorCount = 0;
   const char *aes256_sha = "AES256-SHA";
-  int port;
+  uint16_t port;
   unsigned int iseed;
   (void) argc;   /* Unused. Silent compiler warning. */
 
diff --git a/src/testcurl/https/test_https_get_parallel_threads.c 
b/src/testcurl/https/test_https_get_parallel_threads.c
index 8603f693..ae63b9fd 100644
--- a/src/testcurl/https/test_https_get_parallel_threads.c
+++ b/src/testcurl/https/test_https_get_parallel_threads.c
@@ -55,7 +55,7 @@ https_transfer_thread_adapter (void *args)
 {
   static int nonnull;
   struct https_test_data *cargs = args;
-  int ret;
+  unsigned int ret;
 
   /* time spread incoming requests */
   usleep ((useconds_t) 10.0 * ((double) rand ()) / ((double) RAND_MAX));
@@ -70,12 +70,12 @@ https_transfer_thread_adapter (void *args)
 /**
  * Test non-parallel requests.
  *
- * @return: 0 upon all client requests returning '0', -1 otherwise.
+ * @return: 0 upon all client requests returning '0', 1 otherwise.
  *
  * TODO : make client_count a parameter - number of curl client threads to 
spawn
  */
-static int
-test_single_client (void *cls, int port, const char *cipher_suite,
+static unsigned int
+test_single_client (void *cls, uint16_t port, const char *cipher_suite,
                     int curl_proto_version)
 {
   void *client_thread_ret;
@@ -85,7 +85,7 @@ test_single_client (void *cls, int port, const char 
*cipher_suite,
 
   client_thread_ret = https_transfer_thread_adapter (&client_args);
   if (client_thread_ret != NULL)
-    return -1;
+    return 1;
   return 0;
 }
 
@@ -93,12 +93,12 @@ test_single_client (void *cls, int port, const char 
*cipher_suite,
 /**
  * Test parallel request handling.
  *
- * @return: 0 upon all client requests returning '0', -1 otherwise.
+ * @return: 0 upon all client requests returning '0', 1 otherwise.
  *
  * TODO : make client_count a parameter - number of curl client threads to 
spawn
  */
-static int
-test_parallel_clients (void *cls, int port, const char *cipher_suite,
+static unsigned int
+test_parallel_clients (void *cls, uint16_t port, const char *cipher_suite,
                        int curl_proto_version)
 {
   int i;
@@ -116,7 +116,7 @@ test_parallel_clients (void *cls, int port, const char 
*cipher_suite,
     {
       fprintf (stderr, "Error: failed to spawn test client threads.\n");
 
-      return -1;
+      return 1;
     }
   }
 
@@ -125,7 +125,7 @@ test_parallel_clients (void *cls, int port, const char 
*cipher_suite,
   {
     if ((pthread_join (client_arr[i], &client_thread_ret) != 0) ||
         (client_thread_ret != NULL))
-      return -1;
+      return 1;
   }
 
   return 0;
@@ -137,9 +137,9 @@ main (int argc, char *const *argv)
 {
   unsigned int errorCount = 0;
   const char *ssl_version;
-  int port;
+  uint16_t port;
   unsigned int iseed;
-  char *aes256_sha = "AES256-SHA";
+  const char *aes256_sha = "AES256-SHA";
   (void) argc;   /* Unused. Silent compiler warning. */
 
   if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
diff --git a/src/testcurl/https/test_https_get_select.c 
b/src/testcurl/https/test_https_get_select.c
index 92774771..4de66fe6 100644
--- a/src/testcurl/https/test_https_get_select.c
+++ b/src/testcurl/https/test_https_get_select.c
@@ -47,12 +47,12 @@ ahc_echo (void *cls,
           void **req_cls)
 {
   static int ptr;
-  const char *me = cls;
   struct MHD_Response *response;
   enum MHD_Result ret;
+  (void) cls;
   (void) version; (void) upload_data; (void) upload_data_size;       /* 
Unused. Silent compiler warning. */
 
-  if (0 != strcmp (me, method))
+  if (0 != strcmp (MHD_HTTP_METHOD_GET, method))
     return MHD_NO;              /* unexpected method */
   if (&ptr != *req_cls)
   {
@@ -60,9 +60,8 @@ ahc_echo (void *cls,
     return MHD_YES;
   }
   *req_cls = NULL;
-  response = MHD_create_response_from_buffer (strlen (url),
-                                              (void *) url,
-                                              MHD_RESPMEM_MUST_COPY);
+  response = MHD_create_response_from_buffer_copy (strlen (url),
+                                                   (const void *) url);
   ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
   MHD_destroy_response (response);
   if (ret == MHD_NO)
@@ -71,8 +70,8 @@ ahc_echo (void *cls,
 }
 
 
-static int
-testExternalGet (int flags)
+static unsigned int
+testExternalGet (unsigned int flags)
 {
   struct MHD_Daemon *d;
   CURL *c;
@@ -94,7 +93,7 @@ testExternalGet (int flags)
   time_t start;
   struct timeval tv;
   const char *aes256_sha = "AES256-SHA";
-  int port;
+  uint16_t port;
 
   if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
     port = 0;
@@ -106,7 +105,7 @@ testExternalGet (int flags)
   cbc.size = 2048;
   cbc.pos = 0;
   d = MHD_start_daemon (MHD_USE_ERROR_LOG | MHD_USE_TLS | flags,
-                        port, NULL, NULL, &ahc_echo, "GET",
+                        port, NULL, NULL, &ahc_echo, NULL,
                         MHD_OPTION_HTTPS_MEM_KEY, srv_key_pem,
                         MHD_OPTION_HTTPS_MEM_CERT, srv_self_signed_cert_pem,
                         MHD_OPTION_END);
@@ -120,7 +119,7 @@ testExternalGet (int flags)
     {
       MHD_stop_daemon (d); return 32;
     }
-    port = (int) dinfo->port;
+    port = dinfo->port;
   }
 
   if (curl_tls_is_nss ())
diff --git a/src/testcurl/https/test_https_multi_daemon.c 
b/src/testcurl/https/test_https_multi_daemon.c
index da60c543..e8a9c13f 100644
--- a/src/testcurl/https/test_https_multi_daemon.c
+++ b/src/testcurl/https/test_https_multi_daemon.c
@@ -39,15 +39,15 @@
  * assert initiating two separate daemons and having one shut down
  * doesn't affect the other
  */
-static int
+static unsigned int
 test_concurent_daemon_pair (void *cls,
                             const char *cipher_suite,
                             int proto_version)
 {
-  int ret;
+  unsigned int ret;
   struct MHD_Daemon *d1;
   struct MHD_Daemon *d2;
-  int port1, port2;
+  uint16_t port1, port2;
   (void) cls;    /* Unused. Silent compiler warning. */
 
 
@@ -70,7 +70,7 @@ test_concurent_daemon_pair (void *cls,
   if (d1 == NULL)
   {
     fprintf (stderr, MHD_E_SERVER_INIT);
-    return -1;
+    return 1;
   }
   if (0 == port1)
   {
@@ -78,7 +78,9 @@ test_concurent_daemon_pair (void *cls,
     dinfo = MHD_get_daemon_info (d1, MHD_DAEMON_INFO_BIND_PORT);
     if ((NULL == dinfo) || (0 == dinfo->port) )
     {
-      MHD_stop_daemon (d1); return -1;
+      fprintf (stderr, "Cannot detect daemon bind port.\n");
+      MHD_stop_daemon (d1);
+      return 1;
     }
     port1 = (int) dinfo->port;
   }
@@ -95,7 +97,7 @@ test_concurent_daemon_pair (void *cls,
   {
     MHD_stop_daemon (d1);
     fprintf (stderr, MHD_E_SERVER_INIT);
-    return -1;
+    return 1;
   }
   if (0 == port2)
   {
@@ -103,9 +105,10 @@ test_concurent_daemon_pair (void *cls,
     dinfo = MHD_get_daemon_info (d2, MHD_DAEMON_INFO_BIND_PORT);
     if ((NULL == dinfo) || (0 == dinfo->port) )
     {
+      fprintf (stderr, "Cannot detect daemon bind port.\n");
       MHD_stop_daemon (d1);
       MHD_stop_daemon (d2);
-      return -1;
+      return 1;
     }
     port2 = (int) dinfo->port;
   }
diff --git a/src/testcurl/https/test_https_session_info.c 
b/src/testcurl/https/test_https_session_info.c
index 7fc97fc5..3070c5f7 100644
--- a/src/testcurl/https/test_https_session_info.c
+++ b/src/testcurl/https/test_https_session_info.c
@@ -94,14 +94,14 @@ query_session_ahc (void *cls, struct MHD_Connection 
*connection,
  * negotiate a secure connection with server & query negotiated security 
parameters
  */
 #if LIBCURL_VERSION_NUM >= 0x072200
-static int
+static unsigned int
 test_query_session (void)
 {
   CURL *c;
   struct CBC cbc;
   CURLcode errornum;
   char url[256];
-  int port;
+  uint16_t port;
   const char *aes256_sha = "AES256-SHA";
 
   if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
@@ -139,7 +139,7 @@ test_query_session (void)
       free (cbc.buf);
       return 32;
     }
-    port = (int) dinfo->port;
+    port = dinfo->port;
   }
 
   if (curl_tls_is_nss ())
@@ -180,7 +180,7 @@ test_query_session (void)
     MHD_stop_daemon (d);
     curl_easy_cleanup (c);
     free (cbc.buf);
-    return -1;
+    return 1;
   }
 
   curl_easy_cleanup (c);
diff --git a/src/testcurl/https/test_https_sni.c 
b/src/testcurl/https/test_https_sni.c
index 3581aa17..739feb1f 100644
--- a/src/testcurl/https/test_https_sni.c
+++ b/src/testcurl/https/test_https_sni.c
@@ -180,7 +180,7 @@ sni_callback (gnutls_session_t session,
 
 /* perform a HTTP GET request via SSL/TLS */
 static int
-do_get (const char *url, int port)
+do_get (const char *url, uint16_t port)
 {
   CURL *c;
   struct CBC cbc;
@@ -215,9 +215,9 @@ do_get (const char *url, int port)
   /* TODO merge into send_curl_req */
   curl_easy_setopt (c, CURLOPT_SSL_VERIFYPEER, 0L);
   curl_easy_setopt (c, CURLOPT_SSL_VERIFYHOST, 2L);
-  sprintf (buf, "mhdhost1:%d:127.0.0.1", port);
+  sprintf (buf, "mhdhost1:%u:127.0.0.1", (unsigned int) port);
   dns_info = curl_slist_append (NULL, buf);
-  sprintf (buf, "mhdhost2:%d:127.0.0.1", port);
+  sprintf (buf, "mhdhost2:%u:127.0.0.1", (unsigned int) port);
   dns_info = curl_slist_append (dns_info, buf);
   curl_easy_setopt (c, CURLOPT_RESOLVE, dns_info);
   curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L);
@@ -255,9 +255,9 @@ main (int argc, char *const *argv)
 {
   unsigned int error_count = 0;
   struct MHD_Daemon *d;
-  int port;
-  (void) argc;   /* Unused. Silent compiler warning. */
+  uint16_t port;
   const char *tls_backend;
+  (void) argc;   /* Unused. Silent compiler warning. */
 
   if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
     port = 0;
@@ -313,7 +313,7 @@ main (int argc, char *const *argv)
     {
       MHD_stop_daemon (d); return -1;
     }
-    port = (int) dinfo->port;
+    port = dinfo->port;
   }
   if (0 != do_get ("https://mhdhost1/";, port))
     error_count++;
diff --git a/src/testcurl/https/test_https_time_out.c 
b/src/testcurl/https/test_https_time_out.c
index cb44acb2..86859ca3 100644
--- a/src/testcurl/https/test_https_time_out.c
+++ b/src/testcurl/https/test_https_time_out.c
@@ -121,8 +121,8 @@ socket_cb (void *cls,
 }
 
 
-static int
-test_tls_session_time_out (gnutls_session_t session, int port)
+static unsigned int
+test_tls_session_time_out (gnutls_session_t session, uint16_t port)
 {
   int ret;
   MHD_socket sd;
@@ -183,11 +183,11 @@ test_tls_session_time_out (gnutls_session_t session, int 
port)
 int
 main (int argc, char *const *argv)
 {
-  int errorCount = 0;
+  unsigned int errorCount = 0;
   struct MHD_Daemon *d;
   gnutls_session_t session;
   gnutls_certificate_credentials_t xcred;
-  int port;
+  uint16_t port;
   (void) argc;   /* Unused. Silent compiler warning. */
 
   if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
@@ -241,9 +241,10 @@ main (int argc, char *const *argv)
     dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
     if ((NULL == dinfo) || (0 == dinfo->port) )
     {
-      MHD_stop_daemon (d); return -1;
+      MHD_stop_daemon (d);
+      return 99;
     }
-    port = (int) dinfo->port;
+    port = dinfo->port;
   }
 
   if (0 != setup_session (&session, &xcred))
diff --git a/src/testcurl/https/test_tls_authentication.c 
b/src/testcurl/https/test_tls_authentication.c
index 0bb87f42..aa09460f 100644
--- a/src/testcurl/https/test_tls_authentication.c
+++ b/src/testcurl/https/test_tls_authentication.c
@@ -37,12 +37,12 @@
 
 
 /* perform a HTTP GET request via SSL/TLS */
-static int
-test_secure_get (void *cls, char *cipher_suite, int proto_version)
+static unsigned int
+test_secure_get (void *cls, const char *cipher_suite, int proto_version)
 {
-  int ret;
+  unsigned int ret;
   struct MHD_Daemon *d;
-  int port;
+  uint16_t port;
   (void) cls;    /* Unused. Silent compiler warning. */
 
   if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
@@ -61,7 +61,7 @@ test_secure_get (void *cls, char *cipher_suite, int 
proto_version)
   if (d == NULL)
   {
     fprintf (stderr, MHD_E_SERVER_INIT);
-    return -1;
+    return 1;
   }
   if (0 == port)
   {
@@ -69,9 +69,10 @@ test_secure_get (void *cls, char *cipher_suite, int 
proto_version)
     dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
     if ((NULL == dinfo) || (0 == dinfo->port) )
     {
-      MHD_stop_daemon (d); return -1;
+      MHD_stop_daemon (d);
+      return 1;
     }
-    port = (int) dinfo->port;
+    port = dinfo->port;
   }
 
   ret = test_daemon_get (NULL, cipher_suite, proto_version, port, 0);
@@ -85,7 +86,7 @@ int
 main (int argc, char *const *argv)
 {
   unsigned int errorCount = 0;
-  char *aes256_sha = "AES256-SHA";
+  const char *aes256_sha = "AES256-SHA";
   FILE *crt;
   (void) argc;
   (void) argv;       /* Unused. Silent compiler warning. */
diff --git a/src/testcurl/https/test_tls_extensions.c 
b/src/testcurl/https/test_tls_extensions.c
index 277bd010..ecfbf7cc 100644
--- a/src/testcurl/https/test_tls_extensions.c
+++ b/src/testcurl/https/test_tls_extensions.c
@@ -47,7 +47,8 @@
  * @return 0 on successful test completion, -1 otherwise
  */
 static int
-test_hello_extension (gnutls_session_t session, int port, extensions_t exten_t,
+test_hello_extension (gnutls_session_t session, uint16_t port,
+                      extensions_t exten_t,
                       int ext_count, int ext_length)
 {
   int i, ret = 0, pos = 0;
@@ -213,7 +214,7 @@ main (int argc, char *const *argv)
     GNUTLS_EXTENSION_SERVER_NAME,
     -1
   };
-  int port;
+  uint16_t port;
 
   if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
     port = 0;
@@ -258,7 +259,7 @@ main (int argc, char *const *argv)
     {
       MHD_stop_daemon (d); return -1;
     }
-    port = (int) dinfo->port;
+    port = dinfo->port;
   }
 
   i = 0;
diff --git a/src/testcurl/https/test_tls_options.c 
b/src/testcurl/https/test_tls_options.c
index 5dd73438..b0f969a8 100644
--- a/src/testcurl/https/test_tls_options.c
+++ b/src/testcurl/https/test_tls_options.c
@@ -38,8 +38,8 @@
  * test server refuses to negotiate connections with unsupported protocol 
versions
  *
  */
-static int
-test_unmatching_ssl_version (void *cls, int port, const char *cipher_suite,
+static unsigned int
+test_unmatching_ssl_version (void *cls, uint16_t port, const char 
*cipher_suite,
                              int curl_req_ssl_version)
 {
   struct CBC cbc;
@@ -49,7 +49,7 @@ test_unmatching_ssl_version (void *cls, int port, const char 
*cipher_suite,
   {
     fprintf (stderr, "Error: failed to allocate: %s\n",
              strerror (errno));
-    return -1;
+    return 1;
   }
   cbc.size = 256;
   cbc.pos = 0;
@@ -61,7 +61,7 @@ test_unmatching_ssl_version (void *cls, int port, const char 
*cipher_suite,
     free (cbc.buf);
     fprintf (stderr,
              "Internal error in gen_test_file_url\n");
-    return -1;
+    return 1;
   }
 
   /* assert daemon *rejected* request */
@@ -71,7 +71,7 @@ test_unmatching_ssl_version (void *cls, int port, const char 
*cipher_suite,
     free (cbc.buf);
     fprintf (stderr,
              "cURL failed to reject request despite SSL version mismatch!\n");
-    return -1;
+    return 1;
   }
 
   free (cbc.buf);
@@ -85,10 +85,10 @@ main (int argc, char *const *argv)
 {
   unsigned int errorCount = 0;
   const char *ssl_version;
-  int daemon_flags =
+  unsigned int daemon_flags =
     MHD_USE_THREAD_PER_CONNECTION | MHD_USE_INTERNAL_POLLING_THREAD
     | MHD_USE_TLS | MHD_USE_ERROR_LOG;
-  int port;
+  uint16_t port;
   const char *aes128_sha = "AES128-SHA";
   const char *aes256_sha = "AES256-SHA";
   (void) argc; (void) argv;       /* Unused. Silent compiler warning. */
diff --git a/src/testcurl/https/tls_test_common.c 
b/src/testcurl/https/tls_test_common.c
index 0520a24d..cc04df9f 100644
--- a/src/testcurl/https/tls_test_common.c
+++ b/src/testcurl/https/tls_test_common.c
@@ -60,11 +60,11 @@ setup_ca_cert (void)
 /*
  * test HTTPS transfer
  */
-int
+unsigned int
 test_daemon_get (void *cls,
                  const char *cipher_suite,
                  int proto_version,
-                 int port,
+                 uint16_t port,
                  int ver_peer)
 {
   CURL *c;
@@ -79,7 +79,7 @@ test_daemon_get (void *cls,
   if (NULL == (cbc.buf = malloc (sizeof (char) * len)))
   {
     fprintf (stderr, MHD_E_MEM);
-    return -1;
+    return 1;
   }
   cbc.size = len;
   cbc.pos = 0;
@@ -108,7 +108,7 @@ test_daemon_get (void *cls,
              curl_easy_strerror (e));
     curl_easy_cleanup (c);
     free (cbc.buf);
-    return e;
+    return 1;
   }
 
   /* TLS options */
@@ -127,16 +127,17 @@ test_daemon_get (void *cls,
              curl_easy_strerror (e));
     curl_easy_cleanup (c);
     free (cbc.buf);
-    return e;
+    return 1;
   }
   if (ver_peer &&
-      (CURLE_OK != curl_easy_setopt (c, CURLOPT_CAINFO, ca_cert_file_name)))
+      (CURLE_OK !=
+       (e = curl_easy_setopt (c, CURLOPT_CAINFO, ca_cert_file_name))))
   {
     fprintf (stderr, "HTTPS curl_easy_setopt failed: `%s'\n",
              curl_easy_strerror (e));
     curl_easy_cleanup (c);
     free (cbc.buf);
-    return e;
+    return 1;
   }
   if (CURLE_OK != (errornum = curl_easy_perform (c)))
   {
@@ -144,7 +145,7 @@ test_daemon_get (void *cls,
              curl_easy_strerror (errornum));
     curl_easy_cleanup (c);
     free (cbc.buf);
-    return errornum;
+    return 1;
   }
 
   curl_easy_cleanup (c);
@@ -153,7 +154,7 @@ test_daemon_get (void *cls,
   {
     fprintf (stderr, "Error: local file & received file differ.\n");
     free (cbc.buf);
-    return -1;
+    return 1;
   }
 
   free (cbc.buf);
@@ -162,15 +163,13 @@ test_daemon_get (void *cls,
 
 
 void
-print_test_result (int test_outcome,
-                   char *test_name)
+print_test_result (unsigned int test_outcome,
+                   const char *test_name)
 {
   if (test_outcome != 0)
     fprintf (stderr,
              "running test: %s [fail: %u]\n",
-             test_name, (unsigned
-                         int)
-             test_outcome);
+             test_name, test_outcome);
 #if 0
   else
     fprintf (stdout,
@@ -189,7 +188,10 @@ copyBuffer (void *ptr,
   struct CBC *cbc = ctx;
 
   if (cbc->pos + size * nmemb > cbc->size)
+  {
+    fprintf (stderr, "Server data does not fit buffer.\n");
     return 0;                   /* overflow */
+  }
   memcpy (&cbc->buf[cbc->pos], ptr, size * nmemb);
   cbc->pos += size * nmemb;
   return size * nmemb;
@@ -264,7 +266,7 @@ http_dummy_ahc (void *cls,
  * @return
  */
 /* TODO have test wrap consider a NULL cbc */
-int
+CURLcode
 send_curl_req (char *url,
                struct CBC *cbc,
                const char *cipher_suite,
@@ -339,29 +341,29 @@ send_curl_req (char *url,
  * @param[out] url - char buffer into which the url is compiled
  * @param url_len number of bytes available in url
  * @param port port to use for the test
- * @return -1 on error
+ * @return 1 on error
  */
-int
+unsigned int
 gen_test_file_url (char *url,
                    size_t url_len,
-                   int port)
+                   uint16_t port)
 {
-  int ret = 0;
+  unsigned int ret = 0;
   char *doc_path;
   size_t doc_path_len;
+#ifdef WINDOWS
+  size_t i;
+#endif /* ! WINDOWS */
   /* setup test file path, url */
 #ifdef PATH_MAX
   doc_path_len = PATH_MAX > 4096 ? 4096 : PATH_MAX;
 #else  /* ! PATH_MAX */
   doc_path_len = 4096;
 #endif /* ! PATH_MAX */
-#ifdef WINDOWS
-  size_t i;
-#endif /* ! WINDOWS */
   if (NULL == (doc_path = malloc (doc_path_len)))
   {
     fprintf (stderr, MHD_E_MEM);
-    return -1;
+    return 1;
   }
   if (NULL == getcwd (doc_path, doc_path_len))
   {
@@ -369,7 +371,7 @@ gen_test_file_url (char *url,
              "Error: failed to get working directory. %s\n",
              strerror (errno));
     free (doc_path);
-    return -1;
+    return 1;
   }
 #ifdef WINDOWS
   for (i = 0; i < doc_path_len; i++)
@@ -391,12 +393,12 @@ gen_test_file_url (char *url,
   /* construct url */
   if (snprintf (url,
                 url_len,
-                "%s:%d%s/%s",
+                "%s:%u%s/%s",
                 "https://127.0.0.1";,
-                port,
+                (unsigned int) port,
                 doc_path,
                 "urlpath") >= (long long) url_len)
-    ret = -1;
+    ret = 1;
 
   free (doc_path);
   return ret;
@@ -406,14 +408,14 @@ gen_test_file_url (char *url,
 /**
  * test HTTPS file transfer
  */
-int
+unsigned int
 test_https_transfer (void *cls,
-                     int port,
+                     uint16_t port,
                      const char *cipher_suite,
                      int proto_version)
 {
-  int len;
-  int ret = 0;
+  size_t len;
+  unsigned int ret = 0;
   struct CBC cbc;
   char url[255];
   (void) cls;    /* Unused. Silent compiler warning. */
@@ -422,7 +424,7 @@ test_https_transfer (void *cls,
   if (NULL == (cbc.buf = malloc (sizeof (char) * len)))
   {
     fprintf (stderr, MHD_E_MEM);
-    return -1;
+    return 1;
   }
   cbc.size = len;
   cbc.pos = 0;
@@ -431,14 +433,14 @@ test_https_transfer (void *cls,
                          sizeof (url),
                          port))
   {
-    ret = -1;
+    ret = 1;
     goto cleanup;
   }
 
   if (CURLE_OK !=
       send_curl_req (url, &cbc, cipher_suite, proto_version))
   {
-    ret = -1;
+    ret = 1;
     goto cleanup;
   }
 
@@ -449,7 +451,7 @@ test_https_transfer (void *cls,
                 len) != 0) )
   {
     fprintf (stderr, "Error: local file & received file differ.\n");
-    ret = -1;
+    ret = 1;
   }
 cleanup:
   free (cbc.buf);
@@ -465,9 +467,9 @@ cleanup:
  * @param arg_list
  * @return port number on success or zero on failure
  */
-int
-setup_testcase (struct MHD_Daemon **d, int port, int daemon_flags, va_list
-                arg_list)
+uint16_t
+setup_testcase (struct MHD_Daemon **d, uint16_t port, unsigned int 
daemon_flags,
+                va_list arg_list)
 {
   *d = MHD_start_daemon_va (daemon_flags, port,
                             NULL, NULL, &http_ahc, NULL, arg_list);
@@ -487,7 +489,7 @@ setup_testcase (struct MHD_Daemon **d, int port, int 
daemon_flags, va_list
       MHD_stop_daemon (*d);
       return 0;
     }
-    port = (int) dinfo->port;
+    port = dinfo->port;
   }
 
   return port;
@@ -501,7 +503,7 @@ teardown_testcase (struct MHD_Daemon *d)
 }
 
 
-int
+unsigned int
 setup_session (gnutls_session_t *session,
                gnutls_certificate_credentials_t *xcred)
 {
@@ -522,11 +524,11 @@ setup_session (gnutls_session_t *session,
     }
     gnutls_deinit (*session);
   }
-  return -1;
+  return 1;
 }
 
 
-int
+unsigned int
 teardown_session (gnutls_session_t session,
                   gnutls_certificate_credentials_t xcred)
 {
@@ -537,14 +539,15 @@ teardown_session (gnutls_session_t session,
 
 
 /* TODO test_wrap: change sig to (setup_func, test, va_list test_arg) */
-int
-test_wrap (const char *test_name, int
-           (*test_function)(void *cls, int port, const char *cipher_suite,
+unsigned int
+test_wrap (const char *test_name, unsigned int
+           (*test_function)(void *cls, uint16_t port, const char *cipher_suite,
                             int proto_version), void *cls,
-           int port,
-           int daemon_flags, const char *cipher_suite, int proto_version, ...)
+           uint16_t port,
+           unsigned int daemon_flags, const char *cipher_suite,
+           int proto_version, ...)
 {
-  int ret;
+  unsigned int ret;
   va_list arg_list;
   struct MHD_Daemon *d;
   (void) cls;    /* Unused. Silent compiler warning. */
@@ -555,7 +558,7 @@ test_wrap (const char *test_name, int
   {
     va_end (arg_list);
     fprintf (stderr, "Failed to setup testcase %s\n", test_name);
-    return -1;
+    return 1;
   }
 #if 0
   fprintf (stdout, "running test: %s ", test_name);
diff --git a/src/testcurl/https/tls_test_common.h 
b/src/testcurl/https/tls_test_common.h
index a10f31e7..f0cd7b8a 100644
--- a/src/testcurl/https/tls_test_common.h
+++ b/src/testcurl/https/tls_test_common.h
@@ -52,7 +52,7 @@
 struct https_test_data
 {
   void *cls;
-  int port;
+  uint16_t port;
   const char *cipher_suite;
   int proto_version;
 };
@@ -95,13 +95,14 @@ setup_ca_cert (void);
 /**
  * perform cURL request for file
  */
-int
+unsigned int
 test_daemon_get (void *cls,
                  const char *cipher_suite, int proto_version,
-                 int port, int ver_peer);
+                 uint16_t port, int ver_peer);
 
 void
-print_test_result (int test_outcome, char *test_name);
+print_test_result (unsigned int test_outcome,
+                   const char *test_name);
 
 size_t
 copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx);
@@ -124,43 +125,48 @@ http_dummy_ahc (void *cls, struct MHD_Connection 
*connection,
  * @param[out] url - char buffer into which the url is compiled
  * @param url_len number of bytes available in @a url
  * @param port port to use for the test
- * @return -1 on error
+ * @return 1 on error
  */
-int
+unsigned int
 gen_test_file_url (char *url,
                    size_t url_len,
-                   int port);
+                   uint16_t port);
 
-int
-send_curl_req (char *url, struct CBC *cbc, const char *cipher_suite,
+CURLcode
+send_curl_req (char *url,
+               struct CBC *cbc,
+               const char *cipher_suite,
                int proto_version);
 
-int
-test_https_transfer (void *cls, int port, const char *cipher_suite, int
-                     proto_version);
+unsigned int
+test_https_transfer (void *cls,
+                     uint16_t port,
+                     const char *cipher_suite,
+                     int proto_version);
 
-int
-setup_testcase (struct MHD_Daemon **d, int port, int daemon_flags, va_list
-                arg_list);
+uint16_t
+setup_testcase (struct MHD_Daemon **d, uint16_t port, unsigned int 
daemon_flags,
+                va_list arg_list);
 
 void
 teardown_testcase (struct MHD_Daemon *d);
 
 
-int
+unsigned int
 setup_session (gnutls_session_t *session,
                gnutls_certificate_credentials_t *xcred);
 
-int
+unsigned int
 teardown_session (gnutls_session_t session,
                   gnutls_certificate_credentials_t xcred);
 
-int
-test_wrap (const char *test_name, int
-           (*test_function)(void *cls, int port, const char *cipher_suite,
+unsigned int
+test_wrap (const char *test_name, unsigned int
+           (*test_function)(void *cls, uint16_t port, const char *cipher_suite,
                             int proto_version), void *cls,
-           int port,
-           int daemon_flags, const char *cipher_suite, int proto_version, ...);
+           uint16_t port,
+           unsigned int daemon_flags, const char *cipher_suite,
+           int proto_version, ...);
 
 int testsuite_curl_global_init (void);
 

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]