]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
cmake: fix clang-tidy builds to verify tests, fix fallouts
authorViktor Szakats <commit@vsz.me>
Mon, 17 Mar 2025 23:39:57 +0000 (00:39 +0100)
committerViktor Szakats <commit@vsz.me>
Mon, 24 Mar 2025 09:14:58 +0000 (10:14 +0100)
- cmake: disable test bundles for clang-tidy builds.
  clang-tidy ignores #included .c sources, and incompatible with unity
  and bundles. It caused clang-tidy ignoring all test sources. It also
  means this is the first time tests sources are checked with
  clang-tidy. (autotools doesn't run it on tests.)

- cmake: update description for `CURL_TEST_BUNDLES` option.

- fix tests using special `CURLE_*` enums that were missing from
  `curl/curl.h`. Add them as reserved codes.

- fix about ~50 other issues detected by clang-tidy: unchecked results,
  NULL derefs, memory leaks, casts to enums, unused assigments,
  uninitialized `errno` uses, unchecked `open`, indent, and more.

- drop unnecessary casts (lib1533, lib3207).

- suppress a few impossible cases with detailed `NOLINT`s.

- lib/escape.c: drop `NOLINT` no longer necessary.
  Follow-up to 72abf7c13a479edcde80afa60faad3f35f672c0b #13862 (possibly)

- extend two existing `NOLINT` comments with details.

Follow-up to fabfa8e4024473035b3e5c3c30c330be726d9bb4 #15825

Closes #16756

52 files changed:
CMakeLists.txt
docs/INSTALL-CMAKE.md
include/curl/curl.h
lib/cf-socket.c
lib/escape.c
lib/mprintf.c
lib/strerror.c
tests/CMakeLists.txt
tests/libtest/lib1301.c
tests/libtest/lib1501.c
tests/libtest/lib1517.c
tests/libtest/lib1518.c
tests/libtest/lib1533.c
tests/libtest/lib1538.c
tests/libtest/lib1559.c
tests/libtest/lib1560.c
tests/libtest/lib1597.c
tests/libtest/lib1905.c
tests/libtest/lib1911.c
tests/libtest/lib2302.c
tests/libtest/lib3026.c
tests/libtest/lib3207.c
tests/libtest/lib506.c
tests/libtest/lib507.c
tests/libtest/lib518.c
tests/libtest/lib537.c
tests/libtest/lib539.c
tests/libtest/lib540.c
tests/libtest/lib541.c
tests/libtest/lib557.c
tests/libtest/lib568.c
tests/libtest/lib569.c
tests/libtest/lib570.c
tests/libtest/lib572.c
tests/libtest/lib579.c
tests/libtest/lib590.c
tests/libtest/lib643.c
tests/libtest/lib654.c
tests/libtest/lib667.c
tests/libtest/lib694.c
tests/libtest/mk-lib1521.pl
tests/libtest/test.h
tests/server/rtspd.c
tests/server/sws.c
tests/test1119.pl
tests/test1477.pl
tests/unit/unit1300.c
tests/unit/unit1620.c
tests/unit/unit1654.c
tests/unit/unit1661.c
tests/unit/unit1663.c
tests/unit/unit3200.c

index fcbd3426c83da9c38828429ce504f661b898d017..8e04ec203afc6b5ad57d39ab35becd1eace2950c 100644 (file)
@@ -300,9 +300,14 @@ if(ENABLE_CURLDEBUG)
   list(APPEND CURL_DEBUG_MACROS "CURLDEBUG")
 endif()
 
+option(CURL_TEST_BUNDLES "Build tests into single-binary bundles" OFF)
+
 option(CURL_CLANG_TIDY "Run the build through clang-tidy" OFF)
 if(CURL_CLANG_TIDY)
+  # clang-tidy is not looking into #included sources, thus not compatible with
+  # unity builds and test bundles.
   set(CMAKE_UNITY_BUILD OFF)
+  set(CURL_TEST_BUNDLES OFF)
   set(_tidy_checks "")
   list(APPEND _tidy_checks "-clang-analyzer-security.insecureAPI.strcpy")
   list(APPEND _tidy_checks "-clang-analyzer-optin.performance.Padding")
index 38d1fec1ba4686a21b9f95e1e0eb9030ea588f76..5375ef11f1397b6b379e41ae388f54593c4f1722 100644 (file)
@@ -240,7 +240,7 @@ target_link_libraries(my_target PRIVATE CURL::libcurl)
 - `CURL_LTO`:                               Enable compiler Link Time Optimizations. Default: `OFF`
 - `CURL_STATIC_CRT`:                        Build libcurl with static CRT with MSVC (`/MT`) (requires UCRT, static libcurl or no curl executable). Default: `OFF`
 - `CURL_TARGET_WINDOWS_VERSION`:            Minimum target Windows version as hex string.
-- `CURL_TEST_BUNDLES`:                      Bundle `libtest` and `unittest` tests into single binaries. Default: `OFF`
+- `CURL_TEST_BUNDLES`:                      Build tests into single-binary bundles. Default: `OFF`
 - `CURL_WERROR`:                            Turn compiler warnings into errors. Default: `OFF`
 - `ENABLE_CURLDEBUG`:                       Enable TrackMemory debug feature. Default: =`ENABLE_DEBUG`
 - `ENABLE_CURL_MANUAL`:                     Build the man page for curl and enable its `-M`/`--manual` option. Default: `ON`
index 81dbab379146106273412a376f1916e40ded062f..84966e81e45547592586ace9b1ea5e26d627c63b 100644 (file)
@@ -645,7 +645,20 @@ typedef enum {
   CURLE_UNRECOVERABLE_POLL,      /* 99 - poll/select returned fatal error */
   CURLE_TOO_LARGE,               /* 100 - a value/data met its maximum */
   CURLE_ECH_REQUIRED,            /* 101 - ECH tried but failed */
-  CURL_LAST /* never use! */
+  CURL_LAST, /* never use! */
+
+  CURLE_RESERVED115 = 115,       /* 115-126 - used in tests */
+  CURLE_RESERVED116 = 116,
+  CURLE_RESERVED117 = 117,
+  CURLE_RESERVED118 = 118,
+  CURLE_RESERVED119 = 119,
+  CURLE_RESERVED120 = 120,
+  CURLE_RESERVED121 = 121,
+  CURLE_RESERVED122 = 122,
+  CURLE_RESERVED123 = 123,
+  CURLE_RESERVED124 = 124,
+  CURLE_RESERVED125 = 125,
+  CURLE_RESERVED126 = 126
 } CURLcode;
 
 #ifndef CURL_NO_OLDIES /* define this to test if your app builds with all
index e02b0351270acbca134bcccf707515d1a7380517..eeea77aceccb3c26d3d6943df51e2dd195fcddb0 100644 (file)
@@ -1828,7 +1828,9 @@ static CURLcode cf_udp_setup_quic(struct Curl_cfilter *cf,
   /* QUIC needs a connected socket, nonblocking */
   DEBUGASSERT(ctx->sock != CURL_SOCKET_BAD);
 
-  rc = connect(ctx->sock, &ctx->addr.curl_sa_addr,  /* NOLINT */
+  /* error: The 1st argument to 'connect' is -1 but should be >= 0
+     NOLINTNEXTLINE(clang-analyzer-unix.StdCLibraryFunctions) */
+  rc = connect(ctx->sock, &ctx->addr.curl_sa_addr,
                (curl_socklen_t)ctx->addr.addrlen);
   if(-1 == rc) {
     return socket_connect_result(data, ctx->ip.remote_ip, SOCKERRNO);
index eaad6d33ad439b68fb38e8d68130a9e531a4b318..0afc96fc01d5d9a8a2fe624cf9d78b73d0bcdae1 100644 (file)
@@ -223,8 +223,6 @@ void Curl_hexencode(const unsigned char *src, size_t len, /* input length */
   DEBUGASSERT(src && len && (olen >= 3));
   if(src && len && (olen >= 3)) {
     while(len-- && (olen >= 3)) {
-      /* clang-tidy warns on this line without this comment: */
-      /* NOLINTNEXTLINE(clang-analyzer-core.UndefinedBinaryOperatorResult) */
       *out++ = (unsigned char)hex[(*src & 0xF0) >> 4];
       *out++ = (unsigned char)hex[*src & 0x0F];
       ++src;
index 16b30bf4b9ff6b319df1a6d4ac4ffb8d531e8186..bedd3615cb398a861cb9d4147523c6b76142aedf 100644 (file)
@@ -993,7 +993,9 @@ number:
       /* NOTE NOTE NOTE!! Not all sprintf implementations return number of
          output characters */
 #ifdef HAVE_SNPRINTF
-      (snprintf)(work, BUFFSIZE, formatbuf, iptr->val.dnum); /* NOLINT */
+      /* !checksrc! disable LONGLINE */
+      /* NOLINTNEXTLINE(clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling) */
+      (snprintf)(work, BUFFSIZE, formatbuf, iptr->val.dnum);
 #ifdef _WIN32
       /* Old versions of the Windows CRT do not terminate the snprintf output
          buffer if it reaches the max size so we do that here. */
index abbdb857e3ad061228cf7cb18834ae81a4fcc016..564b197e5db85dca9bf8f7f2d93dfdec402ed87e 100644 (file)
@@ -335,6 +335,20 @@ curl_easy_strerror(CURLcode error)
   case CURLE_OBSOLETE62:
   case CURLE_OBSOLETE75:
   case CURLE_OBSOLETE76:
+
+    /* error codes used by curl tests */
+  case CURLE_RESERVED115:
+  case CURLE_RESERVED116:
+  case CURLE_RESERVED117:
+  case CURLE_RESERVED118:
+  case CURLE_RESERVED119:
+  case CURLE_RESERVED120:
+  case CURLE_RESERVED121:
+  case CURLE_RESERVED122:
+  case CURLE_RESERVED123:
+  case CURLE_RESERVED124:
+  case CURLE_RESERVED125:
+  case CURLE_RESERVED126:
   case CURL_LAST:
     break;
   }
index 295750c85b56cdff09e5036485f6c4c46522566a..306aa240a843388b7e46cf998f4489f4a646384e 100644 (file)
@@ -21,8 +21,6 @@
 # SPDX-License-Identifier: curl
 #
 ###########################################################################
-option(CURL_TEST_BUNDLES "Bundle libtest and unittest tests into single binaries" OFF)
-
 find_program(TEST_NGHTTPX "nghttpx")
 if(NOT TEST_NGHTTPX)
   set(TEST_NGHTTPX "nghttpx")
index de3aaeac6a9ea62a8c5038cbfed32268210c0545..39ba7dc1fc3121e5fef5f0f00b81e8a41bb61383 100644 (file)
@@ -28,7 +28,7 @@
     if(!(expr)) {                                          \
       fprintf(stderr, "%s:%d Assertion '%s' failed: %s\n", \
               __FILE__, __LINE__, #expr, msg);             \
-      return (CURLcode)1;                                  \
+      return TEST_ERR_FAILURE;                             \
     }                                                      \
   } while(0)
 
index ced1d5d987f09b4d27fad47956be285f0f69f5db..34b4ea7ada462c330b2fbdba8e095bf4dc59e2f1 100644 (file)
@@ -96,7 +96,7 @@ CURLcode test(char *URL)
     fprintf(stderr, "pong = %ld\n", e);
 
     if(e > MAX_BLOCKED_TIME_MS) {
-      res = (CURLcode) 100;
+      res = CURLE_TOO_LARGE;
       break;
     }
   }
index 3957eb19904ddc446bcd50a5aa0537c841518411..571b7585af8a7fb48a734d62bbc3bb3778cdaec8 100644 (file)
@@ -64,7 +64,8 @@ CURLcode test(char *URL)
 #if (defined(_WIN32) || defined(__CYGWIN__))
     printf("Windows TCP does not deliver response data but reports "
            "CONNABORTED\n");
-    return (CURLcode)1; /* skip since it fails on Windows without workaround */
+    return TEST_ERR_FAILURE; /* skip since it fails on Windows without
+                                workaround */
 #else
     return CURLE_OK; /* sure, run this! */
 #endif
index 560d79ce23f38025a28620888299f8e78a7fee37..5588ea098a42fff39e31907ec1492b02c88456c9 100644 (file)
@@ -76,6 +76,8 @@ CURLcode test(char *URL)
 
   /* Perform the request, res will get the return code */
   res = curl_easy_perform(curl);
+  if(res)
+    goto test_cleanup;
 
   curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &curlResponseCode);
   curl_easy_getinfo(curl, CURLINFO_REDIRECT_COUNT, &curlRedirectCount);
index e1dd16c9ceb67743a531ccc6290e72dee9b4a6e4..4f0a39e8aa2534f7578f322078b7ddbb79c01605 100644 (file)
@@ -98,8 +98,9 @@ static size_t write_callback(char *ptr, size_t size, size_t nmemb,
 }
 
 
-static int perform_and_check_connections(CURL *curl, const char *description,
-                                         long expected_connections)
+static CURLcode perform_and_check_connections(CURL *curl,
+                                              const char *description,
+                                              long expected_connections)
 {
   CURLcode res;
   long connections = 0;
@@ -132,7 +133,7 @@ CURLcode test(char *URL)
   struct cb_data data;
   CURL *curl = NULL;
   CURLcode res = TEST_ERR_FAILURE;
-  int result;
+  CURLcode result;
 
   if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
     fprintf(stderr, "curl_global_init() failed\n");
@@ -161,7 +162,7 @@ CURLcode test(char *URL)
   result = perform_and_check_connections(curl,
     "First request without CURLOPT_KEEP_SENDING_ON_ERROR", 1);
   if(result != TEST_ERR_SUCCESS) {
-    res = (CURLcode) result;
+    res = result;
     goto test_cleanup;
   }
 
@@ -170,7 +171,7 @@ CURLcode test(char *URL)
   result = perform_and_check_connections(curl,
     "Second request without CURLOPT_KEEP_SENDING_ON_ERROR", 1);
   if(result != TEST_ERR_SUCCESS) {
-    res = (CURLcode) result;
+    res = result;
     goto test_cleanup;
   }
 
@@ -181,7 +182,7 @@ CURLcode test(char *URL)
   result = perform_and_check_connections(curl,
     "First request with CURLOPT_KEEP_SENDING_ON_ERROR", 1);
   if(result != TEST_ERR_SUCCESS) {
-    res = (CURLcode) result;
+    res = result;
     goto test_cleanup;
   }
 
@@ -190,7 +191,7 @@ CURLcode test(char *URL)
   result = perform_and_check_connections(curl,
     "Second request with CURLOPT_KEEP_SENDING_ON_ERROR", 0);
   if(result != TEST_ERR_SUCCESS) {
-    res = (CURLcode) result;
+    res = result;
     goto test_cleanup;
   }
 
index ebc68573f1f066a03b3cfcc0ae08dda49204e299..bd830b2830b022253168d69c2bb3bfcd3f993171 100644 (file)
@@ -34,6 +34,7 @@ CURLcode test(char *URL)
   CURLUcode urlret;
   (void)URL;
 
+  /* NOLINTBEGIN(clang-analyzer-optin.core.EnumCastOutOfRange) */
   curl_easy_strerror((CURLcode)INT_MAX);
   curl_multi_strerror((CURLMcode)INT_MAX);
   curl_share_strerror((CURLSHcode)INT_MAX);
@@ -42,6 +43,7 @@ CURLcode test(char *URL)
   curl_multi_strerror((CURLMcode)-INT_MAX);
   curl_share_strerror((CURLSHcode)-INT_MAX);
   curl_url_strerror((CURLUcode)-INT_MAX);
+  /* NOLINTEND(clang-analyzer-optin.core.EnumCastOutOfRange) */
   for(easyret = CURLE_OK; easyret <= CURL_LAST; easyret++) {
     printf("e%d: %s\n", (int)easyret, curl_easy_strerror(easyret));
   }
index 37c0b8aace4c24e417158b8bc4a7764d6cf82e7e..0d1a450ac0f779798ceb068e9238e4c6c829d987 100644 (file)
@@ -32,19 +32,22 @@ CURLcode test(char *URL)
 {
   CURLcode res = CURLE_OK;
   CURL *curl = NULL;
-  char *longurl = malloc(EXCESSIVE);
+  char *longurl = NULL;
   CURLU *u;
   (void)URL;
 
-  if(!longurl)
-    return (CURLcode)1;
+  global_init(CURL_GLOBAL_ALL);
+  easy_init(curl);
+
+  longurl = malloc(EXCESSIVE);
+  if(!longurl) {
+    res = TEST_ERR_MAJOR_BAD;
+    goto test_cleanup;
+  }
 
   memset(longurl, 'a', EXCESSIVE);
   longurl[EXCESSIVE-1] = 0;
 
-  global_init(CURL_GLOBAL_ALL);
-  easy_init(curl);
-
   res = curl_easy_setopt(curl, CURLOPT_URL, longurl);
   printf("CURLOPT_URL %d bytes URL == %d\n",
          EXCESSIVE, res);
index 95971ec7a5b59547ab276787e1be197a1ee025d8..9f24ff53a76ae06f0d405b774e7b9c4abf572a00 100644 (file)
@@ -1128,6 +1128,7 @@ static CURLUPart part2id(char *part)
     return CURLUPART_FRAGMENT;
   if(!strcmp("zoneid", part))
     return CURLUPART_ZONEID;
+  /* NOLINTNEXTLINE(clang-analyzer-optin.core.EnumCastOutOfRange) */
   return (CURLUPart)9999; /* bad input => bad output */
 }
 
index fa09e71d6cb398734ac07324650eee6e20533f20..1b7285d0dcc587c4faa2f15acc66c22f0d280b21 100644 (file)
@@ -37,7 +37,6 @@ CURLcode test(char *URL)
 {
   CURL *curl = NULL;
   CURLcode res = CURLE_OK;
-  CURLcode result = CURLE_OK;
   curl_version_info_data *curlinfo;
   const char *const *proto;
   int n;
@@ -97,9 +96,9 @@ CURLcode test(char *URL)
 
   /* Run the tests. */
   for(i = 0; prots[i].in; i++) {
-    result = curl_easy_setopt(curl, CURLOPT_PROTOCOLS_STR, prots[i].in);
-    if(result != *prots[i].exp) {
-      printf("unexpectedly '%s' returned %d\n", prots[i].in, result);
+    res = curl_easy_setopt(curl, CURLOPT_PROTOCOLS_STR, prots[i].in);
+    if(res != *prots[i].exp) {
+      printf("unexpectedly '%s' returned %d\n", prots[i].in, res);
       break;
     }
   }
@@ -109,5 +108,5 @@ test_cleanup:
   curl_easy_cleanup(curl);
   curl_global_cleanup();
 
-  return result;
+  return res;
 }
index bba0400cbbcc45362a64e10d2f724c6305a88392..df35de18b2033052f5502736563036454833b480 100644 (file)
@@ -40,7 +40,7 @@ CURLcode test(char *URL)
   cm = curl_multi_init();
   if(!cm) {
     curl_global_cleanup();
-    return (CURLcode)1;
+    return TEST_ERR_MULTI;
   }
   sh = curl_share_init();
   if(!sh)
index 0fd62a8b92ae83b1205303078968ddff8bab9adc..4177ed0b3766dec4c3067637579700ea580059e7 100644 (file)
@@ -44,7 +44,7 @@ CURLcode test(char *URL)
   easy = curl_easy_init();
   if(!easy) {
     curl_global_cleanup();
-    return (CURLcode)1;
+    return TEST_ERR_EASY_INIT;
   }
 
   /* make it a null-terminated C string with just As */
index ccf8dfb5878a9af7718fb09939c2eedaf8228490..c83a04c783e113ff2f0ac42e9e30f7c5c4bb7514 100644 (file)
@@ -98,32 +98,31 @@ CURLcode test(char *URL)
   CURL *curl;
   CURLcode res = CURLE_OK;
   struct ws_data ws_data;
-  memset(&ws_data, 0, sizeof(ws_data));
-
-  ws_data.buf = (char *)calloc(LIB2302_BUFSIZE, 1);
-  if(!ws_data.buf)
-    return res;
 
   global_init(CURL_GLOBAL_ALL);
 
-  curl = curl_easy_init();
-  if(curl) {
-    ws_data.easy = curl;
-
-    curl_easy_setopt(curl, CURLOPT_URL, URL);
-    /* use the callback style */
-    curl_easy_setopt(curl, CURLOPT_USERAGENT, "webbie-sox/3");
-    curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
-    curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writecb);
-    curl_easy_setopt(curl, CURLOPT_WRITEDATA, &ws_data);
-    res = curl_easy_perform(curl);
-    fprintf(stderr, "curl_easy_perform() returned %d\n", res);
-    /* always cleanup */
-    curl_easy_cleanup(curl);
-    flush_data(&ws_data);
+  memset(&ws_data, 0, sizeof(ws_data));
+  ws_data.buf = (char *)calloc(LIB2302_BUFSIZE, 1);
+  if(ws_data.buf) {
+    curl = curl_easy_init();
+    if(curl) {
+      ws_data.easy = curl;
+
+      curl_easy_setopt(curl, CURLOPT_URL, URL);
+      /* use the callback style */
+      curl_easy_setopt(curl, CURLOPT_USERAGENT, "webbie-sox/3");
+      curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
+      curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writecb);
+      curl_easy_setopt(curl, CURLOPT_WRITEDATA, &ws_data);
+      res = curl_easy_perform(curl);
+      fprintf(stderr, "curl_easy_perform() returned %d\n", res);
+      /* always cleanup */
+      curl_easy_cleanup(curl);
+      flush_data(&ws_data);
+    }
+    free(ws_data.buf);
   }
   curl_global_cleanup();
-  free(ws_data.buf);
   return res;
 }
 
index dd3732b465dc34aaf90e4c176e06b69e70b9df57..287adde8a023fa948f225c825fc07e9bb3f93c43 100644 (file)
@@ -55,7 +55,7 @@ CURLcode test(char *URL)
   CURLcode results[NUM_THREADS];
   curl_win_thread_handle_t ths[NUM_THREADS];
   unsigned tid_count = NUM_THREADS, i;
-  int test_failure = 0;
+  CURLcode test_failure = CURLE_OK;
   curl_version_info_data *ver;
   (void) URL;
 
@@ -64,7 +64,7 @@ CURLcode test(char *URL)
     fprintf(stderr, "%s:%d On Windows but the "
             "CURL_VERSION_THREADSAFE feature flag is not set\n",
             __FILE__, __LINE__);
-    return (CURLcode)-1;
+    return TEST_ERR_MAJOR_BAD;
   }
 
   /* On Windows libcurl global init/cleanup calls LoadLibrary/FreeLibrary for
@@ -87,7 +87,7 @@ CURLcode test(char *URL)
       fprintf(stderr, "%s:%d Couldn't create thread, errno %lu\n",
               __FILE__, __LINE__, GetLastError());
       tid_count = i;
-      test_failure = -1;
+      test_failure = TEST_ERR_MAJOR_BAD;
       goto cleanup;
     }
     ths[i] = th;
@@ -101,11 +101,11 @@ cleanup:
       fprintf(stderr, "%s:%d thread[%u]: curl_global_init() failed,"
               "with code %d (%s)\n", __FILE__, __LINE__,
               i, (int) results[i], curl_easy_strerror(results[i]));
-      test_failure = -1;
+      test_failure = TEST_ERR_MAJOR_BAD;
     }
   }
 
-  return (CURLcode)test_failure;
+  return test_failure;
 }
 
 #elif defined(HAVE_PTHREAD_H)
@@ -137,7 +137,7 @@ CURLcode test(char *URL)
     fprintf(stderr, "%s:%d Have pthread but the "
             "CURL_VERSION_THREADSAFE feature flag is not set\n",
             __FILE__, __LINE__);
-    return (CURLcode)-1;
+    return TEST_ERR_MAJOR_BAD;
   }
 
   for(i = 0; i < tid_count; i++) {
@@ -148,7 +148,7 @@ CURLcode test(char *URL)
       fprintf(stderr, "%s:%d Couldn't create thread, errno %d\n",
               __FILE__, __LINE__, res);
       tid_count = i;
-      test_failure = (CURLcode)-1;
+      test_failure = TEST_ERR_MAJOR_BAD;
       goto cleanup;
     }
   }
@@ -160,7 +160,7 @@ cleanup:
       fprintf(stderr, "%s:%d thread[%u]: curl_global_init() failed,"
               "with code %d (%s)\n", __FILE__, __LINE__,
               i, (int) results[i], curl_easy_strerror(results[i]));
-      test_failure = (CURLcode)-1;
+      test_failure = TEST_ERR_MAJOR_BAD;
     }
   }
 
@@ -178,7 +178,7 @@ CURLcode test(char *URL)
     fprintf(stderr, "%s:%d No pthread but the "
             "CURL_VERSION_THREADSAFE feature flag is set\n",
             __FILE__, __LINE__);
-    return (CURLcode)-1;
+    return TEST_ERR_MAJOR_BAD;
   }
   return CURLE_OK;
 }
index e2c0233fb2451d2da91998ba3bb5ab92f57106e8..adb31aa2641087a2cffb3ebe7d355e2326dc74dc 100644 (file)
@@ -41,7 +41,7 @@
 struct Ctx {
   const char *URL;
   CURLSH *share;
-  int result;
+  CURLcode result;
   int thread_id;
   struct curl_slist *contents;
 };
@@ -120,7 +120,7 @@ test_thread(void *ptr)
   }
 
 test_cleanup:
-  ctx->result = (int)res;
+  ctx->result = res;
   return 0;
 }
 
@@ -186,7 +186,7 @@ static void execute(CURLSH *share, struct Ctx *ctx)
 
 CURLcode test(char *URL)
 {
-  int res = 0;
+  CURLcode res = CURLE_OK;
   int i;
   CURLSH* share;
   struct Ctx ctx[THREAD_SIZE];
@@ -203,7 +203,7 @@ CURLcode test(char *URL)
     ctx[i].share = share;
     ctx[i].URL = URL;
     ctx[i].thread_id = i;
-    ctx[i].result = 0;
+    ctx[i].result = CURLE_OK;
     ctx[i].contents = NULL;
   }
 
@@ -227,5 +227,5 @@ test_cleanup:
   if(share)
     curl_share_cleanup(share);
   curl_global_cleanup();
-  return (CURLcode)res;
+  return res;
 }
index 03eb11ddda210250f99de1590a3d9c7d06305c31..57b7f67fd0625aeec72b393867e187b36c7aed4e 100644 (file)
@@ -261,8 +261,6 @@ CURLcode test(char *URL)
   curl_easy_cleanup(curl);
 
 
-  res = CURLE_OK;
-
   /* start treads */
   for(i = 1; i <= THREADS; i++) {
 
@@ -328,6 +326,8 @@ CURLcode test(char *URL)
   printf("CURLOPT_COOKIELIST RELOAD\n");
   test_setopt(curl, CURLOPT_COOKIELIST, "RELOAD");
 
+  res = CURLE_OK;
+
   code = curl_easy_getinfo(curl, CURLINFO_COOKIELIST, &cookies);
   if(code != CURLE_OK) {
     fprintf(stderr, "curl_easy_getinfo() failed\n");
index a228d08aa4b5f7632867d274763cad6632c5b7b7..f86ee79b923bddd8933191fb3c4afbb35543352f 100644 (file)
@@ -34,7 +34,7 @@ CURLcode test(char *URL)
   CURL *curls = NULL;
   CURLM *multi = NULL;
   int still_running;
-  CURLcode i = (CURLcode)-1;
+  CURLcode i = TEST_ERR_MAJOR_BAD;
   CURLcode res = CURLE_OK;
   CURLMsg *msg;
 
index 289692c3f9ce572e6fc98ef53ac0f239536590c7..0aed4336a973f6a2dc3b7b721cc6e77c820dc69a 100644 (file)
@@ -454,7 +454,7 @@ CURLcode test(char *URL)
     /* used by the test script to ask if we can run this test or not */
     if(test_rlimit(FALSE)) {
       fprintf(stdout, "test_rlimit problem: %s\n", msgbuff);
-      return (CURLcode)1;
+      return TEST_ERR_FAILURE;
     }
     return CURLE_OK; /* sure, run this! */
   }
index 6e1baee7ed4b5ab5a7b367c830c4c7e87539b925..2279f93b4bd912ddd520e500bc7b4e1179147679 100644 (file)
@@ -465,7 +465,7 @@ CURLcode test(char *URL)
     /* used by the test script to ask if we can run this test or not */
     if(test_rlimit(FALSE)) {
       fprintf(stdout, "test_rlimit problem: %s\n", msgbuff);
-      return (CURLcode)1;
+      return TEST_ERR_FAILURE;
     }
     return CURLE_OK; /* sure, run this! */
   }
@@ -512,7 +512,7 @@ CURLcode test(char *URL)
 {
   (void)URL;
   printf("system lacks necessary system function(s)");
-  return (CURLcode)1; /* skip test */
+  return TEST_ERR_MAJOR_BAD; /* skip test */
 }
 
 #endif /* defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT) */
index 2e079fae368d9fd9d7b041d41c86b94b171fc266..363d0a296beabdd370384a4f07e71123e26a9953 100644 (file)
 
 CURLcode test(char *URL)
 {
-   CURLcode res;
-   CURL *curl;
-   char *newURL = NULL;
-   struct curl_slist *slist = NULL;
+  CURLcode res;
+  CURL *curl;
+  char *newURL = NULL;
+  struct curl_slist *slist = NULL;
 
-   if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
-     fprintf(stderr, "curl_global_init() failed\n");
-     return TEST_ERR_MAJOR_BAD;
-   }
+  if(curl_global_init(CURL_GLOBAL_ALL) != CURLE_OK) {
+    fprintf(stderr, "curl_global_init() failed\n");
+    return TEST_ERR_MAJOR_BAD;
+  }
 
-   curl = curl_easy_init();
-   if(!curl) {
-     fprintf(stderr, "curl_easy_init() failed\n");
-     curl_global_cleanup();
-     return TEST_ERR_MAJOR_BAD;
-   }
+  curl = curl_easy_init();
+  if(!curl) {
+    fprintf(stderr, "curl_easy_init() failed\n");
+    curl_global_cleanup();
+    return TEST_ERR_MAJOR_BAD;
+  }
 
-   /*
-    * Begin with curl set to use a single CWD to the URL's directory.
-    */
-   test_setopt(curl, CURLOPT_URL, URL);
-   test_setopt(curl, CURLOPT_VERBOSE, 1L);
-   test_setopt(curl, CURLOPT_FTP_FILEMETHOD, (long) CURLFTPMETHOD_SINGLECWD);
+  /*
+   * Begin with curl set to use a single CWD to the URL's directory.
+   */
+  test_setopt(curl, CURLOPT_URL, URL);
+  test_setopt(curl, CURLOPT_VERBOSE, 1L);
+  test_setopt(curl, CURLOPT_FTP_FILEMETHOD, (long) CURLFTPMETHOD_SINGLECWD);
 
-   res = curl_easy_perform(curl);
+  res = curl_easy_perform(curl);
+  if(res == CURLE_OK) {
+    /*
+     * Change the FTP_FILEMETHOD option to use full paths rather than a CWD
+     * command. Use an innocuous QUOTE command, after which curl will CWD to
+     * ftp_conn->entrypath and then (on the next call to ftp_statemach_act)
+     * find a non-zero ftpconn->dirdepth even though no directories are stored
+     * in the ftpconn->dirs array (after a call to freedirs).
+     */
 
-   /*
-    * Change the FTP_FILEMETHOD option to use full paths rather than a CWD
-    * command. Use an innocuous QUOTE command, after which curl will CWD to
-    * ftp_conn->entrypath and then (on the next call to ftp_statemach_act)
-    * find a non-zero ftpconn->dirdepth even though no directories are stored
-    * in the ftpconn->dirs array (after a call to freedirs).
-    */
+    slist = curl_slist_append(NULL, "SYST");
+    if(!slist) {
+      curl_free(newURL);
+      curl_easy_cleanup(curl);
+      curl_global_cleanup();
+      return TEST_ERR_MAJOR_BAD;
+    }
 
-   slist = curl_slist_append(NULL, "SYST");
-   if(!slist) {
-     curl_free(newURL);
-     curl_easy_cleanup(curl);
-     curl_global_cleanup();
-     return TEST_ERR_MAJOR_BAD;
-   }
-
-   test_setopt(curl, CURLOPT_URL, libtest_arg2);
-   test_setopt(curl, CURLOPT_FTP_FILEMETHOD, (long) CURLFTPMETHOD_NOCWD);
-   test_setopt(curl, CURLOPT_QUOTE, slist);
-
-   res = curl_easy_perform(curl);
+    test_setopt(curl, CURLOPT_URL, libtest_arg2);
+    test_setopt(curl, CURLOPT_FTP_FILEMETHOD, (long) CURLFTPMETHOD_NOCWD);
+    test_setopt(curl, CURLOPT_QUOTE, slist);
 
+    res = curl_easy_perform(curl);
+  }
 test_cleanup:
 
-   curl_slist_free_all(slist);
-   curl_free(newURL);
-   curl_easy_cleanup(curl);
-   curl_global_cleanup();
+  curl_slist_free_all(slist);
+  curl_free(newURL);
+  curl_easy_cleanup(curl);
+  curl_global_cleanup();
 
-   return res;
+  return res;
 }
index b53b955639f801c92c3b26fc5e736a3521c70cb1..571f4046486bd55e6537dd6ff10877cbfbf6f076 100644 (file)
@@ -206,7 +206,7 @@ CURLcode test(char *URL)
   start_test_timing();
 
   if(test_argc < 4)
-    return (CURLcode)99;
+    return TEST_ERR_MAJOR_BAD;
 
   msnprintf(buffer, sizeof(buffer), "Host: %s", HOST);
 
index 1a7a4cce39afc84effc22e708cfdcfc8cd69df6d..1e221a84da0760dc6dd5943f12545ea4d6168d06 100644 (file)
@@ -51,7 +51,7 @@ CURLcode test(char *URL)
     fprintf(stderr, "fopen failed with error (%d) %s\n",
             errno, strerror(errno));
     fprintf(stderr, "Error opening file '%s'\n", libtest_arg2);
-    return (CURLcode)-2; /* if this happens things are major weird */
+    return TEST_ERR_MAJOR_BAD; /* if this happens things are major weird */
   }
 
   /* get the file size of the local file */
index ec34ed378130373a308eff7c17f95b5b9e33df0e..85cc4e20bc92e1602c6d0d9ed3fe32118960d628 100644 (file)
@@ -1254,21 +1254,21 @@ static int test_weird_arguments(void)
   int rc;
 
   /* verify %% */
-  rc = curl_msnprintf(buf, sizeof(buf), "%-20d%% right? %%", 500);
+  (void)curl_msnprintf(buf, sizeof(buf), "%-20d%% right? %%", 500);
   errors += string_check(buf, "500                 % right? %");
 
   /* 100 x % */
-  rc = curl_msnprintf(buf, sizeof(buf), "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
-                      "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
-                      "%%%%%%%%%%%%%%%%%%%%%%");
+  (void)curl_msnprintf(buf, sizeof(buf), "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
+                       "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
+                       "%%%%%%%%%%%%%%%%%%%%%%");
   /* 50 x % */
   errors += string_check(buf, "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%"
                          "%%%%%%%%%%%%%%%");
 
-  rc = curl_msnprintf(buf, sizeof(buf), "%2 AA %d %K", 500, 501, 502);
+  (void)curl_msnprintf(buf, sizeof(buf), "%2 AA %d %K", 500, 501, 502);
   errors += string_check(buf, "%2 AA 500 %K");
 
-  rc = curl_msnprintf(buf, sizeof(buf), "%2 %d %K", 500, 501, 502);
+  (void)curl_msnprintf(buf, sizeof(buf), "%2 %d %K", 500, 501, 502);
   errors += string_check(buf, "%2 500 %K");
 
   /* MAX_PARAMETERS is 128, try exact 128! */
index ae29c06415335cc3688c109f82b41b629a5f1eb8..e5e619c025a4e6e2cfe2a90c8f8b40a3dac42b9e 100644 (file)
@@ -79,12 +79,17 @@ CURLcode test(char *URL)
   stream_uri = NULL;
 
   sdp = open(libtest_arg2, O_RDONLY);
+  if(sdp == -1) {
+    fprintf(stderr, "can't open %s\n", libtest_arg2);
+    res = TEST_ERR_MAJOR_BAD;
+    goto test_cleanup;
+  }
   fstat(sdp, &file_info);
   close(sdp);
 
   sdpf = fopen(libtest_arg2, "rb");
   if(!sdpf) {
-    fprintf(stderr, "can't open %s\n", libtest_arg2);
+    fprintf(stderr, "can't fopen %s\n", libtest_arg2);
     res = TEST_ERR_MAJOR_BAD;
     goto test_cleanup;
   }
index 847116a34ab0af218018511e5954264f4053b6ba..3f735ae79a80c54a9b57356ad94680741ef60a2a 100644 (file)
@@ -110,6 +110,8 @@ CURLcode test(char *URL)
 
     test_setopt(curl, CURLOPT_RTSP_REQUEST, CURL_RTSPREQ_TEARDOWN);
     res = curl_easy_perform(curl);
+    if(res)
+      goto test_cleanup;
 
     /* Clear for the next go-round */
     test_setopt(curl, CURLOPT_RTSP_SESSION_ID, NULL);
index 3d15e9bcf87cd1b51f7af2e5033aa40f322d8c4f..49c768abd31e94e333a3079b057d0213d21b6e15 100644 (file)
@@ -108,7 +108,7 @@ CURLcode test(char *URL)
   }
   else {
     fprintf(stderr, "Failed to detect a Session ID mismatch");
-    res = (CURLcode)1;
+    res = TEST_ERR_FAILURE;
   }
 
 test_cleanup:
index f28b741b0bee9260d48a03cdf88ff93d0715f30a..86a0f7b33103673dd8ee1b5cd038784df5686481 100644 (file)
@@ -98,12 +98,17 @@ CURLcode test(char *URL)
 
   /* PUT style GET_PARAMETERS */
   params = open(libtest_arg2, O_RDONLY);
+  if(params == -1) {
+    fprintf(stderr, "can't open %s\n", libtest_arg2);
+    res = TEST_ERR_MAJOR_BAD;
+    goto test_cleanup;
+  }
   fstat(params, &file_info);
   close(params);
 
   paramsf = fopen(libtest_arg2, "rb");
   if(!paramsf) {
-    fprintf(stderr, "can't open %s\n", libtest_arg2);
+    fprintf(stderr, "can't fopen %s\n", libtest_arg2);
     res = TEST_ERR_MAJOR_BAD;
     goto test_cleanup;
   }
index 9b1591fad1be2154a74104b869c6b65f249d631c..21904c1e8bf34cb12853f7242c55b53ce9b7e618 100644 (file)
@@ -45,9 +45,13 @@ static size_t last_ul_total = 0;
 static void progress_final_report(void)
 {
   FILE *moo = fopen(libtest_arg2, "ab");
-  fprintf(moo, "Progress: end UL %zu/%zu\n", last_ul, last_ul_total);
+  fprintf(moo ? moo : stderr, "Progress: end UL %zu/%zu\n",
+                              last_ul, last_ul_total);
+  if(moo)
+    fclose(moo);
+  else
+    fprintf(stderr, "Progress: end UL, can't open %s\n", libtest_arg2);
   started = FALSE;
-  fclose(moo);
 }
 
 static int progress_callback(void *clientp, double dltotal, double dlnow,
@@ -65,9 +69,13 @@ static int progress_callback(void *clientp, double dltotal, double dlnow,
   last_ul_total = (size_t)ultotal;
   if(!started) {
     FILE *moo = fopen(libtest_arg2, "ab");
-    fprintf(moo, "Progress: start UL %zu/%zu\n", last_ul, last_ul_total);
+    fprintf(moo ? moo : stderr, "Progress: start UL %zu/%zu\n",
+                                last_ul, last_ul_total);
+    if(moo)
+      fclose(moo);
+    else
+      fprintf(stderr, "Progress: start UL, can't open %s\n", libtest_arg2);
     started = TRUE;
-    fclose(moo);
   }
 
   return 0;
index 8fc483e48373d695f38e4cb347272d097efcc612..f07bc9a0f5beba0147b8c3bae91c1cff4f2e90b8 100644 (file)
@@ -68,6 +68,8 @@ CURLcode test(char *URL)
   test_setopt(curl, CURLOPT_PROXYUSERPWD, "me:password");
 
   res = curl_easy_perform(curl);
+  if(res)
+    goto test_cleanup;
 
   res = curl_easy_getinfo(curl, CURLINFO_PROXYAUTH_USED, &usedauth);
   if(CURLAUTH_NTLM != usedauth) {
index bd7f5e0f8c1c53b5b0f2199f34e035c400cbf268..d25f3ec6e0f304cfb7c317cbe11716f1192b7c02 100644 (file)
@@ -36,12 +36,14 @@ struct WriteThis {
 static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp)
 {
   struct WriteThis *pooh = (struct WriteThis *)userp;
-  int eof = !*pooh->readptr;
+  int eof;
 
   if(size*nmemb < 1)
     return 0;
 
-#ifndef LIB645
+#ifdef LIB645
+  eof = !*pooh->readptr;
+#else
   eof = pooh->sizeleft <= 0;
   if(!eof)
     pooh->sizeleft--;
@@ -242,7 +244,7 @@ static CURLcode cyclic_add(void)
   curl_easy_cleanup(easy);
   if(a1 != CURLE_BAD_FUNCTION_ARGUMENT)
     /* that should have failed */
-    return (CURLcode)1;
+    return TEST_ERR_FAILURE;
 
   return CURLE_OK;
 }
index 66ec29d17c69f779c158abc5f4432e00371acf9a..93c47612d707e10f2ecce65839b3c1c8800b973c 100644 (file)
@@ -44,7 +44,7 @@ static void free_callback(void *userp)
 static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp)
 {
   struct WriteThis *pooh = (struct WriteThis *)userp;
-  int eof = !*pooh->readptr;
+  int eof;
 
   if(size*nmemb < 1)
     return 0;
index d190601464fa3187815cf93d42db7bdf859a9617..3d02595ba87b2d62c4da9d58c29c7a2d6a810a69 100644 (file)
@@ -36,7 +36,7 @@ struct WriteThis {
 static size_t read_callback(char *ptr, size_t size, size_t nmemb, void *userp)
 {
   struct WriteThis *pooh = (struct WriteThis *)userp;
-  int eof = !*pooh->readptr;
+  int eof;
 
   if(size*nmemb < 1)
     return 0;
index b1791e4dd749491cada247589a0f78f87ac0e5d7..6057eaeafbc680345fc8728279dfbf568a48c96d 100644 (file)
@@ -54,8 +54,12 @@ CURLcode test(char *URL)
   do {
 
     res = curl_easy_perform(curl);
+    if(res)
+      goto test_cleanup;
 
     res = curl_easy_getinfo(curl, CURLINFO_HTTPAUTH_USED, &usedauth);
+    if(res)
+      goto test_cleanup;
     if(CURLAUTH_NTLM != usedauth) {
       printf("CURLINFO_HTTPAUTH_USED did not say NTLM\n");
     }
index 273dfc29eca9ec511237e62d1ebad03f8fa2d829..82970d1d4b9ddf5ba558f64916f6ad50c3f9b37f 100755 (executable)
@@ -594,6 +594,7 @@ MOO
 
 print $fh <<FOOTER
   )
+  /* NOLINTNEXTLINE(clang-analyzer-optin.core.EnumCastOutOfRange) */
   curl_easy_setopt(curl, (CURLoption)1, 0);
   res = CURLE_OK;
 test_cleanup:
index d1dda0622fae099392c814bbddb1cc7bd7f3f6b4..ab024374280ba264c534ca4b9a413a30a5194a7a 100644 (file)
@@ -96,18 +96,18 @@ extern int unitfail;
 ** For portability reasons TEST_ERR_* values should be less than 127.
 */
 
-#define TEST_ERR_MAJOR_BAD     (CURLcode) 126
-#define TEST_ERR_RUNS_FOREVER  (CURLcode) 125
-#define TEST_ERR_EASY_INIT     (CURLcode) 124
-#define TEST_ERR_MULTI         (CURLcode) 123
-#define TEST_ERR_NUM_HANDLES   (CURLcode) 122
-#define TEST_ERR_SELECT        (CURLcode) 121
-#define TEST_ERR_SUCCESS       (CURLcode) 120
-#define TEST_ERR_FAILURE       (CURLcode) 119
-#define TEST_ERR_USAGE         (CURLcode) 118
-#define TEST_ERR_FOPEN         (CURLcode) 117
-#define TEST_ERR_FSTAT         (CURLcode) 116
-#define TEST_ERR_BAD_TIMEOUT   (CURLcode) 115
+#define TEST_ERR_MAJOR_BAD     CURLE_RESERVED126
+#define TEST_ERR_RUNS_FOREVER  CURLE_RESERVED125
+#define TEST_ERR_EASY_INIT     CURLE_RESERVED124
+#define TEST_ERR_MULTI         CURLE_RESERVED123
+#define TEST_ERR_NUM_HANDLES   CURLE_RESERVED122
+#define TEST_ERR_SELECT        CURLE_RESERVED121
+#define TEST_ERR_SUCCESS       CURLE_RESERVED120
+#define TEST_ERR_FAILURE       CURLE_RESERVED119
+#define TEST_ERR_USAGE         CURLE_RESERVED118
+#define TEST_ERR_FOPEN         CURLE_RESERVED117
+#define TEST_ERR_FSTAT         CURLE_RESERVED116
+#define TEST_ERR_BAD_TIMEOUT   CURLE_RESERVED115
 
 /*
 ** Macros for test source code readability/maintainability.
@@ -507,7 +507,7 @@ extern int unitfail;
   {                                             \
     (void)URL;                                  \
     fprintf(stderr, "Missing support\n");       \
-    return (CURLcode)1;                         \
+    return CURLE_UNSUPPORTED_PROTOCOL;          \
   }
 #endif
 
@@ -525,6 +525,6 @@ extern CURLcode test(char *URL); /* the actual test function provided by each
   {                                             \
     (void)URL;                                  \
     fprintf(stderr, "Missing support\n");       \
-    return (CURLcode)1;                         \
+    return CURLE_UNSUPPORTED_PROTOCOL;          \
   }
 #endif
index bf0acce1ed837b2f175e54249f382de9eaa91ea1..964fe692f7fed1b53e64ac576540759620778511 100644 (file)
@@ -584,14 +584,14 @@ static void rtspd_storerequest(char *reqbuf, size_t totalsize)
 
   writeleft = totalsize;
   do {
-    written = fwrite(&reqbuf[totalsize-writeleft],
-                     1, writeleft, dump);
+    written = fwrite(&reqbuf[totalsize-writeleft], 1, writeleft, dump);
     if(got_exit_signal)
       goto storerequest_cleanup;
     if(written > 0)
       writeleft -= written;
+    error = errno;
     /* !checksrc! disable ERRNOVAR 1 */
-  } while((writeleft > 0) && ((error = errno) == EINTR));
+  } while((writeleft > 0) && (error == EINTR));
 
   if(writeleft == 0)
     logmsg("Wrote request (%zu bytes) input to %s", totalsize, dumpfile);
index df73f69257847b504eaa8bd0461b6a741fb7664c..d4abe3cb38a8861ee3551a1b47a490fad555bf56 100644 (file)
@@ -772,14 +772,14 @@ static void sws_storerequest(const char *reqbuf, size_t totalsize)
 
   writeleft = totalsize;
   do {
-    written = fwrite(&reqbuf[totalsize-writeleft],
-                     1, writeleft, dump);
+    written = fwrite(&reqbuf[totalsize-writeleft], 1, writeleft, dump);
     if(got_exit_signal)
       goto storerequest_cleanup;
     if(written > 0)
       writeleft -= written;
+    error = errno;
     /* !checksrc! disable ERRNOVAR 1 */
-  } while((writeleft > 0) && ((error = errno) == EINTR));
+  } while((writeleft > 0) && (error == EINTR));
 
   if(writeleft == 0)
     logmsg("Wrote request (%zu bytes) input to %s", totalsize, dumpfile);
index 89a93cab55687309b8f1f368a3716fa4942e4ac1..f48d6029192f58de78be00101babcaeb097f147a 100755 (executable)
@@ -176,7 +176,7 @@ for my $e (sort @syms) {
     # last entry in many enum series.
     #
 
-    if($e =~ /(OBSOLETE|^CURL_EXTERN|^CURLINC_|_LAST\z|_LASTENTRY\z|^CURL_TEMP_)/) {
+    if($e =~ /(OBSOLETE|CURLE_RESERVED|^CURL_EXTERN|^CURLINC_|_LAST\z|_LASTENTRY\z|^CURL_TEMP_)/) {
         $ignored++;
         next;
     }
index 2529ebc4894496443ca73ab4944e3c6ecce4f618..089e9e3ae64c8f354b2285345ec674c06624376b 100755 (executable)
@@ -49,7 +49,7 @@ sub scanheader {
         $line++;
         if($_ =~ /^  (CURL(E|UE|SHE|HE|M)_[A-Z0-9_]*)/) {
             my ($name)=($1);
-            if(($name !~ /OBSOLETE/) && ($name !~ /_LAST\z/)) {
+            if(($name !~ /(OBSOLETE|CURLE_RESERVED)/) && ($name !~ /_LAST\z/)) {
                 push @hnames, $name;
                 if($wherefrom{$name}) {
                     print STDERR "double: $name\n";
index 60a0a0e1b8cd9eebf716f0dd3a44852e50d44479..55caaca1a1a5a8b1c7261480924ecbebee5956dc 100644 (file)
@@ -60,7 +60,7 @@ UNITTEST_START
   struct Curl_llist_node *element_next;
   struct Curl_llist_node *element_prev;
   struct Curl_llist_node *to_remove;
-  size_t llist_size = Curl_llist_count(&llist);
+  size_t llist_size;
 
   /**
    * testing llist_init
index 5830d78364c2988c1a9f5bdb5c02c7c33a098879..29c8539c9d6074d6bd758d817b45dbf56cce6c2d 100644 (file)
@@ -58,11 +58,14 @@ static void test_parse(
   fail_unless(!!exp_options == !!options, "options expectation failed");
 
   if(!unitfail) {
-    fail_unless(!exp_username || strcmp(userstr, exp_username) == 0,
+    fail_unless(!userstr || !exp_username ||
+                strcmp(userstr, exp_username) == 0,
                 "userstr should be equal to exp_username");
-    fail_unless(!exp_password || strcmp(passwdstr, exp_password) == 0,
+    fail_unless(!passwdstr || !exp_password ||
+                strcmp(passwdstr, exp_password) == 0,
                 "passwdstr should be equal to exp_password");
-    fail_unless(!exp_options || strcmp(options, exp_options) == 0,
+    fail_unless(!options || !exp_options ||
+                strcmp(options, exp_options) == 0,
                 "options should be equal to exp_options");
   }
 
index aea3f8a5e5720f453857e375486068441121d61c..0762d4ea8d22f3881bbd172a5c45ebfc6698f090 100644 (file)
@@ -88,7 +88,7 @@ UNITTEST_START
   result = Curl_altsvc_parse(curl, asi,
                              "h2=\"example.net:443\"; ma=\"180\";\r\n",
                              ALPN_h2, "example.net", 80);
-  fail_if(result, "Curl_altsvc_parse(4) failed!");
+  fail_if(result, "Curl_altsvc_parse(5) failed!");
   fail_unless(Curl_llist_count(&asi->list) == 10, "wrong number of entries");
 
   result =
@@ -96,34 +96,38 @@ UNITTEST_START
                       "h2=\":443\", h3=\":443\"; "
                       "persist = \"1\"; ma = 120;\r\n",
                       ALPN_h1, "curl.se", 80);
-  fail_if(result, "Curl_altsvc_parse(5) failed!");
+  fail_if(result, "Curl_altsvc_parse(6) failed!");
   fail_unless(Curl_llist_count(&asi->list) == 12, "wrong number of entries");
 
   /* clear that one again and decrease the counter */
   result = Curl_altsvc_parse(curl, asi, "clear;\r\n",
                              ALPN_h1, "curl.se", 80);
-  fail_if(result, "Curl_altsvc_parse(6) failed!");
+  fail_if(result, "Curl_altsvc_parse(7) failed!");
   fail_unless(Curl_llist_count(&asi->list) == 10, "wrong number of entries");
 
   /* only a non-existing alpn */
   result = Curl_altsvc_parse(curl, asi,
                              "h6=\"example.net:443\"; ma=\"180\";\r\n",
                              ALPN_h2, "5.example.net", 80);
+  fail_if(result, "Curl_altsvc_parse(8) failed!");
 
   /* missing quote in alpn host */
   result = Curl_altsvc_parse(curl, asi,
                              "h2=\"example.net:443,; ma=\"180\";\r\n",
                              ALPN_h2, "6.example.net", 80);
+  fail_if(result, "Curl_altsvc_parse(9) failed!");
 
   /* missing port in host name */
   result = Curl_altsvc_parse(curl, asi,
                              "h2=\"example.net\"; ma=\"180\";\r\n",
                              ALPN_h2, "7.example.net", 80);
+  fail_if(result, "Curl_altsvc_parse(10) failed!");
 
   /* illegal port in host name */
   result = Curl_altsvc_parse(curl, asi,
                              "h2=\"example.net:70000\"; ma=\"180\";\r\n",
                              ALPN_h2, "8.example.net", 80);
+  fail_if(result, "Curl_altsvc_parse(11) failed!");
 
   Curl_altsvc_save(curl, asi, outname);
 
index c2037ee9140e74873f4aac40f3fa112d4025f013..3d4eead93f4d2dada5e75841193ba6c9d5e3f2bd 100644 (file)
@@ -100,8 +100,10 @@ UNITTEST_START
   buffer = (const char *)Curl_bufref_ptr(&bufref);
   fail_unless(buffer, "Allocated pointer is NULL");
   fail_unless(bufref.len == 3, "Wrong data size stored");
-  fail_unless(!buffer[3], "Duplicated data should have been truncated");
-  fail_unless(!strcmp(buffer, "166"), "Bad duplicated data");
+  if(buffer) {
+    fail_unless(!buffer[3], "Duplicated data should have been truncated");
+    fail_unless(!strcmp(buffer, "166"), "Bad duplicated data");
+  }
 
   /**
    * testing Curl_bufref_free
index 6967c0231f06e986d79f31146dec7cd1529900e9..f60d60f625c2e9113217248fcc823a16cb5b6092 100644 (file)
@@ -66,11 +66,11 @@ static void test_parse(
   fail_unless(!!exp_host == !!host, "host expectation failed");
 
   if(!unitfail) {
-    fail_unless(!exp_dev || strcmp(dev, exp_dev) == 0,
+    fail_unless(!dev || !exp_dev || strcmp(dev, exp_dev) == 0,
                 "dev should be equal to exp_dev");
-    fail_unless(!exp_iface || strcmp(iface, exp_iface) == 0,
+    fail_unless(!iface || !exp_iface || strcmp(iface, exp_iface) == 0,
                 "iface should be equal to exp_iface");
-    fail_unless(!exp_host || strcmp(host, exp_host) == 0,
+    fail_unless(!host || !exp_host || strcmp(host, exp_host) == 0,
                 "host should be equal to exp_host");
   }
 
index c6af86061d3660a9a9a503a325bc348311280296..30d6281c4f420993738c5f61bed2a829bdd99d53 100644 (file)
@@ -108,11 +108,11 @@ UNITTEST_START
       case 0:
         rc = Curl_get_line(&buf, fp);
         line = Curl_dyn_ptr(&buf);
-        fail_unless(line && !strcmp("LINE1\n", line),
+        fail_unless(rc && line && !strcmp("LINE1\n", line),
                     "First line failed (1)");
         rc = Curl_get_line(&buf, fp);
         line = Curl_dyn_ptr(&buf);
-        fail_unless(line && !strcmp("LINE2 NEWLINE\n", line),
+        fail_unless(rc && line && !strcmp("LINE2 NEWLINE\n", line),
                     "Second line failed (1)");
         rc = Curl_get_line(&buf, fp);
         abort_unless(!Curl_dyn_len(&buf), "Missed EOF (1)");
@@ -120,11 +120,11 @@ UNITTEST_START
       case 1:
         rc = Curl_get_line(&buf, fp);
         line = Curl_dyn_ptr(&buf);
-        fail_unless(line && !strcmp("LINE1\n", line),
+        fail_unless(rc && line && !strcmp("LINE1\n", line),
                     "First line failed (2)");
         rc = Curl_get_line(&buf, fp);
         line = Curl_dyn_ptr(&buf);
-        fail_unless(line && !strcmp("LINE2 NONEWLINE\n", line),
+        fail_unless(rc && line && !strcmp("LINE2 NONEWLINE\n", line),
                     "Second line failed (2)");
         rc = Curl_get_line(&buf, fp);
         abort_unless(!Curl_dyn_len(&buf), "Missed EOF (2)");
@@ -132,7 +132,7 @@ UNITTEST_START
       case 2:
         rc = Curl_get_line(&buf, fp);
         line = Curl_dyn_ptr(&buf);
-        fail_unless(line && !strcmp("LINE1\n", line),
+        fail_unless(rc && line && !strcmp("LINE1\n", line),
                     "First line failed (3)");
         rc = Curl_get_line(&buf, fp);
         fail_unless(!Curl_dyn_len(&buf),
@@ -141,7 +141,7 @@ UNITTEST_START
       case 3:
         rc = Curl_get_line(&buf, fp);
         line = Curl_dyn_ptr(&buf);
-        fail_unless(line && !strcmp("LINE1\n", line),
+        fail_unless(rc && line && !strcmp("LINE1\n", line),
                     "First line failed (4)");
         rc = Curl_get_line(&buf, fp);
         fail_unless(!Curl_dyn_len(&buf),
@@ -150,7 +150,7 @@ UNITTEST_START
       case 4:
         rc = Curl_get_line(&buf, fp);
         line = Curl_dyn_ptr(&buf);
-        fail_unless(line && !strcmp("LINE1\n", line),
+        fail_unless(rc && line && !strcmp("LINE1\n", line),
                     "First line failed (5)");
         rc = Curl_get_line(&buf, fp);
         fail_unless(!Curl_dyn_len(&buf),
@@ -159,7 +159,7 @@ UNITTEST_START
       case 5:
         rc = Curl_get_line(&buf, fp);
         line = Curl_dyn_ptr(&buf);
-        fail_unless(line && !strcmp("LINE1\x1aTEST\n", line),
+        fail_unless(rc && line && !strcmp("LINE1\x1aTEST\n", line),
                     "Missed/Misinterpreted ^Z (6)");
         rc = Curl_get_line(&buf, fp);
         abort_unless(!Curl_dyn_len(&buf), "Missed EOF (6)");