]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tests: stop overriding system printf symbols
authorViktor Szakats <commit@vsz.me>
Thu, 2 Oct 2025 14:01:15 +0000 (16:01 +0200)
committerViktor Szakats <commit@vsz.me>
Fri, 3 Oct 2025 22:51:06 +0000 (00:51 +0200)
To make the source code match the functions called at runtime.
And to avoid the preprocessor trick that may introduces build issues.

Before this patch, libtests, tunits and units were calling a mixture
of curl and system printf calls, then transformed them all to curl
printf calls by including `curl_printf.h`.

Changes made:
- tests: stop including `curl_printf.h`.
- libtest: switch a couple of outlier system printf calls to curl
  printf.
- unit: use more curl printf to avoid casts and show whole values.
- unit: switch remaining calls to curl printf explicitly.
- tunit: switch to call curl printf explicitly.
- libtest, tunit, unit: ban system printf.
- unit1307, unit1607, unit1609, unit1652, unit1655, unit3214: bump
  types/masks to avoid casts.

After this patch:
- libtests, tunits, units: use exclusively curl printf.
  (as before, but explicitly, without relying on redefinitions.)
- servers: is unchanged (it can only use system printf).

Closes #18814

26 files changed:
REUSE.toml
tests/libtest/.checksrc [new file with mode: 0644]
tests/libtest/Makefile.am
tests/libtest/first.h
tests/libtest/lib1549.c
tests/tunit/.checksrc [new file with mode: 0644]
tests/tunit/Makefile.am
tests/tunit/tool1394.c
tests/tunit/tool1604.c
tests/tunit/tool1621.c
tests/unit/.checksrc [new file with mode: 0644]
tests/unit/Makefile.am
tests/unit/unit1302.c
tests/unit/unit1307.c
tests/unit/unit1309.c
tests/unit/unit1323.c
tests/unit/unit1396.c
tests/unit/unit1607.c
tests/unit/unit1609.c
tests/unit/unit1652.c
tests/unit/unit1655.c
tests/unit/unit1658.c
tests/unit/unit1660.c
tests/unit/unit1664.c
tests/unit/unit2604.c
tests/unit/unit3214.c

index 6e8a272e795ccc35530883923e8a662cf70cb9db..0d07c8b3e1522841a3db4fde7a8633e76521562c 100644 (file)
@@ -48,7 +48,10 @@ path = [
   "lib/vssh/.checksrc",
   "lib/vtls/.checksrc",
   "src/.checksrc",
+  "tests/libtest/.checksrc",
   "tests/server/.checksrc",
+  "tests/tunit/.checksrc",
+  "tests/unit/.checksrc",
 ]
 SPDX-FileCopyrightText = "Daniel Stenberg, <daniel@haxx.se>, et al."
 SPDX-License-Identifier = "curl"
diff --git a/tests/libtest/.checksrc b/tests/libtest/.checksrc
new file mode 100644 (file)
index 0000000..a3f8f30
--- /dev/null
@@ -0,0 +1,8 @@
+banfunc aprintf
+banfunc fprintf
+banfunc msnprintf
+banfunc mvsnprintf
+banfunc printf
+banfunc vaprintf
+banfunc vfprintf
+banfunc vprintf
index b62a359eabefbeceb28d73174c274e3f1c11e80e..482e09d098a42ddd3bd488d1d22a0cf2f5b39be2 100644 (file)
@@ -41,7 +41,7 @@ AM_CPPFLAGS = -I$(top_srcdir)/include        \
 # Get BUNDLE, FIRST_C, FIRST_H, UTILS_C, UTILS_H, CURLX_C, TESTS_C variables
 include Makefile.inc
 
-EXTRA_DIST = CMakeLists.txt $(FIRST_C) $(FIRST_H) $(UTILS_C) $(UTILS_H) $(TESTS_C) \
+EXTRA_DIST = CMakeLists.txt .checksrc $(FIRST_C) $(FIRST_H) $(UTILS_C) $(UTILS_H) $(TESTS_C) \
   test307.pl test610.pl test613.pl test1013.pl test1022.pl mk-lib1521.pl
 
 CFLAGS += @CURL_CFLAG_EXTRAS@
index 1592922e39a88bdc56472e7c635b83e1a1afa933..a902bdb8f0edb65b49ecd7b2587da7ec346f0be1 100644 (file)
@@ -52,8 +52,6 @@ extern int unitfail; /* for unittests */
 #include <sys/select.h>
 #endif
 
-#include "curl_printf.h"
-
 /* GCC <4.6 does not support '#pragma GCC diagnostic push' and
    does not support 'pragma GCC diagnostic' inside functions. */
 #if (defined(__GNUC__) && \
index b7bf010612c05fe27f8dac8f8fd18b0ac0b14756..10d31838102782fe200845fee16d8e5af9add669 100644 (file)
@@ -58,14 +58,14 @@ static CURLcode test_lib1549(const char *URL)
       /* a linked list of cookies in cookie file format */
       struct curl_slist *each = cookies;
       while(each) {
-        printf("%s\n", each->data);
+        curl_mprintf("%s\n", each->data);
         each = each->next;
         num++;
       }
       /* we must free these cookies when we are done */
       curl_slist_free_all(cookies);
     }
-    fprintf(stderr, "%d cookies\n", num);
+    curl_mfprintf(stderr, "%d cookies\n", num);
   }
 test_cleanup:
 
diff --git a/tests/tunit/.checksrc b/tests/tunit/.checksrc
new file mode 100644 (file)
index 0000000..a3f8f30
--- /dev/null
@@ -0,0 +1,8 @@
+banfunc aprintf
+banfunc fprintf
+banfunc msnprintf
+banfunc mvsnprintf
+banfunc printf
+banfunc vaprintf
+banfunc vfprintf
+banfunc vprintf
index 219b7a10579c67e173a0856680c453a34eb45699..fea9d51152aea60f9863b2a8f557bd7ab760e92c 100644 (file)
@@ -43,7 +43,7 @@ AM_CPPFLAGS = -I$(top_srcdir)/include        \
 # Get BUNDLE, FIRST_C, TESTS_C variables
 include Makefile.inc
 
-EXTRA_DIST = CMakeLists.txt README.md $(TESTS_C)
+EXTRA_DIST = CMakeLists.txt .checksrc README.md $(TESTS_C)
 
 CFLAGS += @CURL_CFLAG_EXTRAS@
 
index 77a2021b0a88a0853982c573f4dfbbd8c2018367..3a5256bae1fce9cd43ccc7571995be75c2007ae9 100644 (file)
@@ -73,42 +73,42 @@ static CURLcode test_tool1394(const char *arg)
     if(p[1]) {
       if(certname) {
         if(strcmp(p[1], certname)) {
-          printf("expected certname '%s' but got '%s' "
-                 "for -E param '%s'\n", p[1], certname, p[0]);
+          curl_mprintf("expected certname '%s' but got '%s' "
+                       "for -E param '%s'\n", p[1], certname, p[0]);
           fail("assertion failure");
         }
       }
       else {
-        printf("expected certname '%s' but got NULL "
-               "for -E param '%s'\n", p[1], p[0]);
+        curl_mprintf("expected certname '%s' but got NULL "
+                     "for -E param '%s'\n", p[1], p[0]);
         fail("assertion failure");
       }
     }
     else {
       if(certname) {
-        printf("expected certname NULL but got '%s' "
-               "for -E param '%s'\n", certname, p[0]);
+        curl_mprintf("expected certname NULL but got '%s' "
+                     "for -E param '%s'\n", certname, p[0]);
         fail("assertion failure");
       }
     }
     if(p[2]) {
       if(passphrase) {
         if(strcmp(p[2], passphrase)) {
-          printf("expected passphrase '%s' but got '%s'"
-                 "for -E param '%s'\n", p[2], passphrase, p[0]);
+          curl_mprintf("expected passphrase '%s' but got '%s'"
+                       "for -E param '%s'\n", p[2], passphrase, p[0]);
           fail("assertion failure");
         }
       }
       else {
-        printf("expected passphrase '%s' but got NULL "
-               "for -E param '%s'\n", p[2], p[0]);
+        curl_mprintf("expected passphrase '%s' but got NULL "
+                     "for -E param '%s'\n", p[2], p[0]);
         fail("assertion failure");
       }
     }
     else {
       if(passphrase) {
-        printf("expected passphrase NULL but got '%s' "
-               "for -E param '%s'\n", passphrase, p[0]);
+        curl_mprintf("expected passphrase NULL but got '%s' "
+                     "for -E param '%s'\n", passphrase, p[0]);
         fail("assertion failure");
       }
     }
index db7ed1412408d1dafcbf7af63a9752321548a7e8..3b6f006e7cfd1deebf50461685e4f8e50b8f23f1 100644 (file)
@@ -33,11 +33,11 @@ static char *getflagstr(int flags)
 {
   char *buf = malloc(256);
   if(buf) {
-    msnprintf(buf, 256, "%s,%s",
-              ((flags & SANITIZE_ALLOW_PATH) ?
-               "SANITIZE_ALLOW_PATH" : ""),
-              ((flags & SANITIZE_ALLOW_RESERVED) ?
-               "SANITIZE_ALLOW_RESERVED" : ""));
+    curl_msnprintf(buf, 256, "%s,%s",
+                   ((flags & SANITIZE_ALLOW_PATH) ?
+                    "SANITIZE_ALLOW_PATH" : ""),
+                   ((flags & SANITIZE_ALLOW_RESERVED) ?
+                    "SANITIZE_ALLOW_RESERVED" : ""));
   }
   return buf;
 }
@@ -46,13 +46,12 @@ static char *getcurlcodestr(int cc)
 {
   char *buf = malloc(256);
   if(buf) {
-    msnprintf(buf, 256, "%s (%d)",
-              (cc == SANITIZE_ERR_OK ? "SANITIZE_ERR_OK" :
-               cc == SANITIZE_ERR_BAD_ARGUMENT ? "SANITIZE_ERR_BAD_ARGUMENT" :
-               cc == SANITIZE_ERR_INVALID_PATH ? "SANITIZE_ERR_INVALID_PATH" :
-               cc == SANITIZE_ERR_OUT_OF_MEMORY ? "SANITIZE_ERR_OUT_OF_MEMORY":
-               "unexpected error code - add name"),
-              cc);
+    curl_msnprintf(buf, 256, "%s (%d)",
+             (cc == SANITIZE_ERR_OK ? "SANITIZE_ERR_OK" :
+              cc == SANITIZE_ERR_BAD_ARGUMENT ? "SANITIZE_ERR_BAD_ARGUMENT" :
+              cc == SANITIZE_ERR_INVALID_PATH ? "SANITIZE_ERR_INVALID_PATH" :
+              cc == SANITIZE_ERR_OUT_OF_MEMORY ? "SANITIZE_ERR_OUT_OF_MEMORY" :
+              "unexpected error code - add name"), cc);
   }
   return buf;
 }
@@ -225,21 +224,21 @@ static CURLcode test_tool1604(const char *arg)
     abort_unless(expected_ccstr, "out of memory");
 
     unitfail++;
-    fprintf(stderr, "\n"
-            "%s:%d sanitize_file_name failed.\n"
-            "input: %s\n"
-            "flags: %s\n"
-            "output: %s\n"
-            "result: %s\n"
-            "expected output: %s\n"
-            "expected result: %s\n",
-            __FILE__, __LINE__,
-            data[i].input,
-            flagstr,
-            (output ? output : "(null)"),
-            received_ccstr,
-            (data[i].expected_output ? data[i].expected_output : "(null)"),
-            expected_ccstr);
+    curl_mfprintf(stderr, "\n"
+                  "%s:%d sanitize_file_name failed.\n"
+                  "input: %s\n"
+                  "flags: %s\n"
+                  "output: %s\n"
+                  "result: %s\n"
+                  "expected output: %s\n"
+                  "expected result: %s\n",
+                  __FILE__, __LINE__,
+                  data[i].input,
+                  flagstr,
+                  output ? output : "(null)",
+                  received_ccstr,
+                  data[i].expected_output ? data[i].expected_output : "(null)",
+                  expected_ccstr);
 
     free(output);
     free(flagstr);
@@ -248,7 +247,7 @@ static CURLcode test_tool1604(const char *arg)
   }
   /* END sanitize_file_name */
 #else
-  fprintf(stderr, "Skipped test not for this platform\n");
+  curl_mfprintf(stderr, "Skipped test not for this platform\n");
 #endif /* _WIN32 || MSDOS */
 
   UNITTEST_END_SIMPLE
index c7dfedddce23a59636b22db4ee51fd80f1c2d743..bb709cf39d21bcaf84dc87814dfa225a0639ec82 100644 (file)
@@ -74,8 +74,9 @@ static CURLcode test_tool1621(const char *arg)
     const char *url = tests[i].input;
     char *stripped = stripcredentials(url);
     const char *strippedstr = stripped ? stripped : "(null)";
-    printf("Test %u got input \"%s\", output: \"%s\", expected: \"%s\"\n",
-           i, tests[i].input, strippedstr, tests[i].output);
+    curl_mprintf("Test %u got input \"%s\", output: \"%s\", "
+                 "expected: \"%s\"\n",
+                 i, tests[i].input, strippedstr, tests[i].output);
 
     fail_if(strcmp(tests[i].output, strippedstr), tests[i].output);
     curl_free(stripped);
diff --git a/tests/unit/.checksrc b/tests/unit/.checksrc
new file mode 100644 (file)
index 0000000..a3f8f30
--- /dev/null
@@ -0,0 +1,8 @@
+banfunc aprintf
+banfunc fprintf
+banfunc msnprintf
+banfunc mvsnprintf
+banfunc printf
+banfunc vaprintf
+banfunc vfprintf
+banfunc vprintf
index 32c2f3895594b495fa0c2b8f37eccdf56c6f5f03..1e9940f48a0c3679d18a92bba6882c1591a50920 100644 (file)
@@ -42,7 +42,7 @@ AM_CPPFLAGS = -I$(top_srcdir)/include        \
 # Get BUNDLE, FIRST_C, TESTS_C variables
 include Makefile.inc
 
-EXTRA_DIST = CMakeLists.txt README.md $(TESTS_C)
+EXTRA_DIST = CMakeLists.txt .checksrc README.md $(TESTS_C)
 
 CFLAGS += @CURL_CFLAG_EXTRAS@
 
index a1676699f27d9b5d0e98c1aee5b09fc2cd37d941..2c4404d72702ff7e91e69062d9990c1e0aaa9ea3 100644 (file)
@@ -137,7 +137,7 @@ static CURLcode test_unit1302(const char *arg)
     abort_unless(rc == CURLE_OK, "return code should be CURLE_OK");
     abort_unless(olen == e->olen, "wrong output size");
     if(memcmp(out, e->output, e->olen)) {
-      fprintf(stderr, "Test %u encoded badly\n", i);
+      curl_mfprintf(stderr, "Test %u encoded badly\n", i);
       unitfail++;
     }
     Curl_safefree(out);
@@ -145,17 +145,17 @@ static CURLcode test_unit1302(const char *arg)
     /* then verify decode */
     rc = curlx_base64_decode(e->output, &decoded, &dlen);
     if(rc != CURLE_OK) {
-      fprintf(stderr, "Test %u URL decode returned %d\n", i, (int)rc);
+      curl_mfprintf(stderr, "Test %u URL decode returned %d\n", i, (int)rc);
       unitfail++;
     }
     if(dlen != e->ilen) {
-      fprintf(stderr, "Test %u URL decode output length %d instead of %d\n",
-              i, (int)dlen, (int)e->ilen);
+      curl_mfprintf(stderr, "Test %u URL decode output length %zu "
+                    "instead of %zu\n", i, dlen, e->ilen);
       unitfail++;
     }
     if(memcmp(decoded, e->input, dlen)) {
-      fprintf(stderr, "Test %u URL decoded badly. Got '%s', expected '%s'\n",
-              i, decoded, e->input);
+      curl_mfprintf(stderr, "Test %u URL decoded badly. Got '%s', "
+                    "expected '%s'\n", i, decoded, e->input);
       unitfail++;
     }
 
@@ -169,12 +169,12 @@ static CURLcode test_unit1302(const char *arg)
     rc = curlx_base64url_encode(e->input, e->ilen, &out, &olen);
     abort_unless(rc == CURLE_OK, "return code should be CURLE_OK");
     if(olen != e->olen) {
-      fprintf(stderr, "Test %u URL encoded output length %d instead of %d\n",
-              i, (int)olen, (int)e->olen);
+      curl_mfprintf(stderr, "Test %u URL encoded output length %zu "
+                    "instead of %zu\n", i, olen, e->olen);
     }
     if(out && memcmp(out, e->output, e->olen)) {
-      fprintf(stderr, "Test %u URL encoded badly. Got '%s', expected '%s'\n",
-              i, out, e->output);
+      curl_mfprintf(stderr, "Test %u URL encoded badly. Got '%s', "
+                    "expected '%s'\n", i, out, e->output);
       unitfail++;
     }
     Curl_safefree(out);
@@ -188,9 +188,9 @@ static CURLcode test_unit1302(const char *arg)
     /* then verify decode with illegal inputs */
     rc = curlx_base64_decode(e->output, &decoded, &dlen);
     if(rc != CURLE_BAD_CONTENT_ENCODING) {
-      fprintf(stderr, "Test %u URL bad decoded badly. "
-              "Returned '%d', expected '%d'\n",
-              i, (int)rc, CURLE_BAD_CONTENT_ENCODING);
+      curl_mfprintf(stderr, "Test %u URL bad decoded badly. "
+                    "Returned '%d', expected '%d'\n",
+                    i, (int)rc, CURLE_BAD_CONTENT_ENCODING);
       unitfail++;
     }
   }
index 6eb1d4826b70f745fefed71569d9cf3a774bfadd..248adb99c255589f84aeb59f6afe1e94b723d2f8 100644 (file)
@@ -264,7 +264,7 @@ static CURLcode test_unit1307(const char *arg)
                                   "a",                      NOMATCH|LINUX_FAIL}
   };
 
-  int i;
+  size_t i;
 
   enum system {
     SYSTEM_CUSTOM,
@@ -280,14 +280,14 @@ static CURLcode test_unit1307(const char *arg)
 #else
   machine = SYSTEM_LINUX;
 #endif
-  printf("Tested with system fnmatch(), %s-style\n",
-         machine == SYSTEM_LINUX ? "linux" : "mac");
+  curl_mprintf("Tested with system fnmatch(), %s-style\n",
+               machine == SYSTEM_LINUX ? "linux" : "mac");
 #else
-  printf("Tested with custom fnmatch()\n");
+  curl_mprintf("Tested with custom fnmatch()\n");
   machine = SYSTEM_CUSTOM;
 #endif
 
-  for(i = 0; i < (int)CURL_ARRAYSIZE(tests); i++) {
+  for(i = 0; i < CURL_ARRAYSIZE(tests); i++) {
     int result = tests[i].result;
     int rc = Curl_fnmatch(NULL, tests[i].pattern, tests[i].string);
     if(result & (LINUX_DIFFER|MAC_DIFFER)) {
@@ -298,10 +298,10 @@ static CURLcode test_unit1307(const char *arg)
       result &= 0x03; /* filter off all high bits */
     }
     if(rc != result) {
-      printf("Curl_fnmatch(\"%s\", \"%s\") should return %s (returns %s)"
-             " [%d]\n",
-             tests[i].pattern, tests[i].string, ret2name(result),
-             ret2name(rc), i);
+      curl_mprintf("Curl_fnmatch(\"%s\", \"%s\") should return %s (returns %s)"
+                   " [%zu]\n",
+                   tests[i].pattern, tests[i].string, ret2name(result),
+                   ret2name(rc), i);
       fail("pattern mismatch");
     }
   }
index 35b38fd8b6255edf11900f04019631834f53fbf7..2e2af21f2c75053d0d05c63fc3650c43dfa4745a 100644 (file)
@@ -36,10 +36,10 @@ static void splayprint(struct Curl_tree *t, int d, char output)
   splayprint(t->larger, d + 1, output);
   for(i = 0; i < d; i++)
     if(output)
-      printf("  ");
+      curl_mprintf("  ");
 
   if(output) {
-    printf("%ld.%ld[%d]", (long)t->key.tv_sec, (long)t->key.tv_usec, i);
+    curl_mprintf("%ld.%ld[%d]", (long)t->key.tv_sec, (long)t->key.tv_usec, i);
   }
 
   for(count = 0, node = t->samen; node != t; node = node->samen, count++)
@@ -47,9 +47,9 @@ static void splayprint(struct Curl_tree *t, int d, char output)
 
   if(output) {
     if(count)
-      printf(" [%d more]\n", count);
+      curl_mprintf(" [%d more]\n", count);
     else
-      printf("\n");
+      curl_mprintf("\n");
   }
 
   splayprint(t->smaller, d + 1, output);
@@ -86,14 +86,14 @@ static CURLcode test_unit1309(const char *arg)
 
   for(i = 0; i < NUM_NODES; i++) {
     int rem = (i + 7)%NUM_NODES;
-    printf("Tree look:\n");
+    curl_mprintf("Tree look:\n");
     splayprint(root, 0, 1);
     curl_mprintf("remove pointer %d, payload %zu\n", rem,
                  *(size_t *)Curl_splayget(&nodes[rem]));
     rc = Curl_splayremove(root, &nodes[rem], &root);
     if(rc) {
       /* failed! */
-      printf("remove %d failed!\n", rem);
+      curl_mprintf("remove %d failed!\n", rem);
       fail("remove");
     }
   }
@@ -117,7 +117,7 @@ static CURLcode test_unit1309(const char *arg)
 
   removed = NULL;
   for(i = 0; i <= 1100; i += 100) {
-    printf("Removing nodes not larger than %d\n", i);
+    curl_mprintf("Removing nodes not larger than %d\n", i);
     tv_now.tv_usec = i;
     root = Curl_splaygetbest(tv_now, root, &removed);
     while(removed) {
index f53df89226d5b2e2aead5d66c0e96569a132bc8d..41d4fd31d30789a5ab3a5f964403be36da6728d5 100644 (file)
@@ -45,13 +45,13 @@ static CURLcode test_unit1323(const char *arg)
   for(i = 0; i < CURL_ARRAYSIZE(tests); i++) {
     timediff_t result = curlx_timediff(tests[i].first, tests[i].second);
     if(result != tests[i].result) {
-      printf("%ld.%06u to %ld.%06u got %d, but expected %ld\n",
-             (long)tests[i].first.tv_sec,
-             tests[i].first.tv_usec,
-             (long)tests[i].second.tv_sec,
-             tests[i].second.tv_usec,
-             (int)result,
-             (long)tests[i].result);
+      curl_mprintf("%ld.%06u to %ld.%06u got %d, but expected %ld\n",
+                   (long)tests[i].first.tv_sec,
+                   tests[i].first.tv_usec,
+                   (long)tests[i].second.tv_sec,
+                   tests[i].second.tv_usec,
+                   (int)result,
+                   (long)tests[i].result);
       fail("unexpected result!");
     }
   }
index aa7ee933758198c93e8d8f7da69f8f02a961161a..0b74afa84f94342dd331cd0f1235e78eac860373 100644 (file)
@@ -95,7 +95,7 @@ static CURLcode test_unit1396(const char *arg)
     fail_unless(!memcmp(out, list1[i].out, list1[i].outlen),
                 "bad output data returned");
 
-    printf("curl_easy_unescape test %d DONE\n", i);
+    curl_mprintf("curl_easy_unescape test %d DONE\n", i);
 
     curl_free(out);
   }
@@ -110,7 +110,7 @@ static CURLcode test_unit1396(const char *arg)
     fail_unless(!memcmp(out, list2[i].out, list2[i].outlen),
                 "bad output data returned");
 
-    printf("curl_easy_escape test %d DONE (%s)\n", i, out);
+    curl_mprintf("curl_easy_escape test %d DONE (%s)\n", i, out);
 
     curl_free(out);
   }
index ad0df33be8d62a0a14a3df1f0fba4e487a5e09d4..dda67697829e0fcd6d8771221beb049d1bca1089 100644 (file)
@@ -102,14 +102,14 @@ static CURLcode test_unit1607(const char *arg)
     },
   };
 
-  int i;
+  size_t i;
   struct Curl_multi *multi = NULL;
   struct Curl_easy *easy = NULL;
   struct curl_slist *list = NULL;
 
-  for(i = 0; i < (int)CURL_ARRAYSIZE(tests); ++i) {
-    int j;
-    int addressnum = CURL_ARRAYSIZE(tests[i].address);
+  for(i = 0; i < CURL_ARRAYSIZE(tests); ++i) {
+    size_t j;
+    size_t addressnum = CURL_ARRAYSIZE(tests[i].address);
     struct Curl_addrinfo *addr;
     struct Curl_dns_entry *dns;
     void *entry_id;
@@ -152,7 +152,7 @@ static CURLcode test_unit1607(const char *arg)
 
       if(addr && !Curl_addr2string(addr->ai_addr, addr->ai_addrlen,
                                    ipaddress, &port)) {
-        curl_mfprintf(stderr, "%s:%d tests[%d] failed. "
+        curl_mfprintf(stderr, "%s:%d tests[%zu] failed. "
                       "getaddressinfo failed.\n",
                       __FILE__, __LINE__, i);
         problem = true;
@@ -160,24 +160,24 @@ static CURLcode test_unit1607(const char *arg)
       }
 
       if(addr && !tests[i].address[j]) {
-        curl_mfprintf(stderr, "%s:%d tests[%d] failed. the retrieved addr "
-                      "is %s but tests[%d].address[%d] is NULL.\n",
+        curl_mfprintf(stderr, "%s:%d tests[%zu] failed. the retrieved addr "
+                      "is %s but tests[%zu].address[%zu] is NULL.\n",
                       __FILE__, __LINE__, i, ipaddress, i, j);
         problem = true;
         break;
       }
 
       if(!addr && tests[i].address[j]) {
-        curl_mfprintf(stderr, "%s:%d tests[%d] failed. the retrieved addr "
-                      "is NULL but tests[%d].address[%d] is %s.\n",
+        curl_mfprintf(stderr, "%s:%d tests[%zu] failed. the retrieved addr "
+                      "is NULL but tests[%zu].address[%zu] is %s.\n",
                       __FILE__, __LINE__, i, i, j, tests[i].address[j]);
         problem = true;
         break;
       }
 
       if(!curl_strequal(ipaddress, tests[i].address[j])) {
-        curl_mfprintf(stderr, "%s:%d tests[%d] failed. the retrieved addr "
-                      "%s is not equal to tests[%d].address[%d] %s.\n",
+        curl_mfprintf(stderr, "%s:%d tests[%zu] failed. the retrieved addr "
+                      "%s is not equal to tests[%zu].address[%zu] %s.\n",
                       __FILE__, __LINE__, i, ipaddress, i, j,
                       tests[i].address[j]);
         problem = true;
@@ -185,9 +185,9 @@ static CURLcode test_unit1607(const char *arg)
       }
 
       if(port != tests[i].port) {
-        curl_mfprintf(stderr, "%s:%d tests[%d] failed. the retrieved port "
-                      "for tests[%d].address[%d] is %d "
-                      "but tests[%d].port is %d.\n",
+        curl_mfprintf(stderr, "%s:%d tests[%zu] failed. the retrieved port "
+                      "for tests[%zu].address[%zu] is %d "
+                      "but tests[%zu].port is %d.\n",
                       __FILE__, __LINE__, i, i, j, port, i, tests[i].port);
         problem = true;
         break;
@@ -195,16 +195,16 @@ static CURLcode test_unit1607(const char *arg)
 
       if(dns->timestamp.tv_sec && tests[i].permanent) {
         curl_mfprintf(stderr,
-                      "%s:%d tests[%d] failed. the timestamp is not zero "
-                      "but tests[%d].permanent is TRUE\n",
+                      "%s:%d tests[%zu] failed. the timestamp is not zero "
+                      "but tests[%zu].permanent is TRUE\n",
                       __FILE__, __LINE__, i, i);
         problem = true;
         break;
       }
 
       if(dns->timestamp.tv_sec == 0 && !tests[i].permanent) {
-        curl_mfprintf(stderr, "%s:%d tests[%d] failed. the timestamp is zero "
-                      "but tests[%d].permanent is FALSE\n",
+        curl_mfprintf(stderr, "%s:%d tests[%zu] failed. the timestamp is zero "
+                      "but tests[%zu].permanent is FALSE\n",
                       __FILE__, __LINE__, i, i);
         problem = true;
         break;
index 4485c3f046e2fb9751339a08037aee64de23feae..26934d89bf4546e845f1bfc5ea3399b8a0b329f8 100644 (file)
@@ -94,7 +94,7 @@ static CURLcode test_unit1609(const char *arg)
     },
   };
 
-  int i;
+  size_t i;
   struct Curl_multi *multi = NULL;
   struct Curl_easy *easy = NULL;
   struct curl_slist *list = NULL;
@@ -103,9 +103,9 @@ static CURLcode test_unit1609(const char *arg)
      and also clean cache after the loop. In contrast,for example,
      test 1607 sets up and cleans cache on each iteration. */
 
-  for(i = 0; i < (int)CURL_ARRAYSIZE(tests); ++i) {
-    int j;
-    int addressnum = CURL_ARRAYSIZE(tests[i].address);
+  for(i = 0; i < CURL_ARRAYSIZE(tests); ++i) {
+    size_t j;
+    size_t addressnum = CURL_ARRAYSIZE(tests[i].address);
     struct Curl_addrinfo *addr;
     struct Curl_dns_entry *dns;
     void *entry_id;
@@ -152,31 +152,31 @@ static CURLcode test_unit1609(const char *arg)
       if(addr && !Curl_addr2string(addr->ai_addr, addr->ai_addrlen,
                                    ipaddress, &port)) {
         curl_mfprintf(stderr,
-                      "%s:%d tests[%d] failed. Curl_addr2string failed.\n",
+                      "%s:%d tests[%zu] failed. Curl_addr2string failed.\n",
                       __FILE__, __LINE__, i);
         problem = true;
         break;
       }
 
       if(addr && !tests[i].address[j]) {
-        curl_mfprintf(stderr, "%s:%d tests[%d] failed. the retrieved addr "
-                      "is %s but tests[%d].address[%d] is NULL.\n",
+        curl_mfprintf(stderr, "%s:%d tests[%zu] failed. the retrieved addr "
+                      "is %s but tests[%zu].address[%zu] is NULL.\n",
                       __FILE__, __LINE__, i, ipaddress, i, j);
         problem = true;
         break;
       }
 
       if(!addr && tests[i].address[j]) {
-        curl_mfprintf(stderr, "%s:%d tests[%d] failed. the retrieved addr "
-                      "is NULL but tests[%d].address[%d] is %s.\n",
+        curl_mfprintf(stderr, "%s:%d tests[%zu] failed. the retrieved addr "
+                      "is NULL but tests[%zu].address[%zu] is %s.\n",
                       __FILE__, __LINE__, i, i, j, tests[i].address[j]);
         problem = true;
         break;
       }
 
       if(!curl_strequal(ipaddress, tests[i].address[j])) {
-        curl_mfprintf(stderr, "%s:%d tests[%d] failed. the retrieved addr "
-                      "%s is not equal to tests[%d].address[%d] %s.\n",
+        curl_mfprintf(stderr, "%s:%d tests[%zu] failed. the retrieved addr "
+                      "%s is not equal to tests[%zu].address[%zu] %s.\n",
                       __FILE__, __LINE__, i, ipaddress, i, j,
                       tests[i].address[j]);
         problem = true;
@@ -184,9 +184,9 @@ static CURLcode test_unit1609(const char *arg)
       }
 
       if(port != tests[i].port) {
-        curl_mfprintf(stderr, "%s:%d tests[%d] failed. the retrieved port "
-                      "for tests[%d].address[%d] is %d "
-                      "but tests[%d].port is %d.\n",
+        curl_mfprintf(stderr, "%s:%d tests[%zu] failed. the retrieved port "
+                      "for tests[%zu].address[%zu] is %d "
+                      "but tests[%zu].port is %d.\n",
                       __FILE__, __LINE__, i, i, j, port, i, tests[i].port);
         problem = true;
         break;
index ad3014edca47517e3d6d1a76d259a754ef8f562e..0b3337f6888f99d485c300f99dd48704620a2289 100644 (file)
@@ -124,7 +124,7 @@ static CURLcode test_unit1652(const char *arg)
   memset(input, '\0', sizeof(input));
   memset(input, 'A', 2045);
   Curl_infof(easy, "%s", input);
-  fprintf(stderr, "output len %d: %s", (int)strlen(output), output);
+  curl_mfprintf(stderr, "output len %zu: %s", strlen(output), output);
   /* output is input + \n */
   fail_unless(strlen(output) == 2046, "No truncation of infof input");
   fail_unless(verify(output, input) == 0, "No truncation of infof input");
@@ -134,7 +134,7 @@ static CURLcode test_unit1652(const char *arg)
   /* Just over the limit without newline for truncation via '...' */
   memset(input + 2045, 'A', 4);
   Curl_infof(easy, "%s", input);
-  fprintf(stderr, "output len %d: %s", (int)strlen(output), output);
+  curl_mfprintf(stderr, "output len %zu: %s", strlen(output), output);
   fail_unless(strlen(output) == 2047, "Truncation of infof input 1");
   fail_unless(output[sizeof(output) - 1] == '\0',
               "Truncation of infof input 1");
@@ -143,7 +143,7 @@ static CURLcode test_unit1652(const char *arg)
   memset(input + 2045, 'A', 4);
   memset(input + 2045 + 4, '\n', 1);
   Curl_infof(easy, "%s", input);
-  fprintf(stderr, "output len %d: %s", (int)strlen(output), output);
+  curl_mfprintf(stderr, "output len %zu: %s", strlen(output), output);
   fail_unless(strlen(output) == 2047, "Truncation of infof input 2");
   fail_unless(output[sizeof(output) - 1] == '\0',
               "Truncation of infof input 2");
@@ -152,7 +152,7 @@ static CURLcode test_unit1652(const char *arg)
   memset(input, '\0', sizeof(input));
   memset(input, 'A', sizeof(input) - 1);
   Curl_infof(easy, "%s", input);
-  fprintf(stderr, "output len %d: %s", (int)strlen(output), output);
+  curl_mfprintf(stderr, "output len %zu: %s", strlen(output), output);
   fail_unless(strlen(output) == 2047, "Truncation of infof input 3");
   fail_unless(output[sizeof(output) - 1] == '\0',
               "Truncation of infof input 3");
index a22e087271395ad253aa1abffbf7581dc1006bea..8b49fb32f89ef47f536791864a9d2fd642702e41 100644 (file)
@@ -67,7 +67,7 @@ static CURLcode test_unit1655(const char *arg)
       "this.is.an.otherwise-valid.hostname."
       "with-a-label-of-greater-length-than-the-sixty-three-characters-"
       "specified.in.the.RFCs.";
-    int i;
+    size_t i;
 
     struct test {
       const char *name;
@@ -89,7 +89,7 @@ static CURLcode test_unit1655(const char *arg)
       { max, DOH_OK }                      /* expect buffer overwrite */
     };
 
-    for(i = 0; i < (int)(CURL_ARRAYSIZE(playlist)); i++) {
+    for(i = 0; i < CURL_ARRAYSIZE(playlist); i++) {
       const char *name = playlist[i].name;
       size_t olen = 100000;
       struct demo victim;
index 0a6a2e71c15eb2a2ba0199fb220f41663600b7be..6db104309287de40a119cf0a73c6c6b1655048e7 100644 (file)
@@ -514,7 +514,7 @@ static CURLcode test_unit1658(const char *arg)
     for(i = 0; i < CURL_ARRAYSIZE(t); i++) {
       struct Curl_https_rrinfo *hrr;
 
-      printf("test %i: %s\n", i, t[i].name);
+      curl_mprintf("test %u: %s\n", i, t[i].name);
 
       result = doh_resp_decode_httpsrr(easy, t[i].dns, t[i].len, &hrr);
 
@@ -523,7 +523,7 @@ static CURLcode test_unit1658(const char *arg)
 
       /* is the output the expected? */
       if(strcmp(rrbuffer, t[i].expect)) {
-        curl_mfprintf(stderr, "Test %s (%i) failed\n"
+        curl_mfprintf(stderr, "Test %s (%u) failed\n"
                       "Expected: %s\n"
                       "Received: %s\n", t[i].name, i, t[i].expect, rrbuffer);
         unitfail++;
index 5c66b1831cf57a93dbf8726176b97b74223c564e..e74285d74ec451d9c7f1bbd092bc3becc66a8a76 100644 (file)
@@ -38,7 +38,7 @@ static CURLcode test_unit1660(const char *arg)
 static void showsts(struct stsentry *e, const char *chost)
 {
   if(!e)
-    printf("'%s' is not HSTS\n", chost);
+    curl_mprintf("'%s' is not HSTS\n", chost);
   else {
     curl_mprintf("%s [%s]: %" CURL_FORMAT_CURL_OFF_T "%s\n",
                  chost, e->host, e->expires,
@@ -141,7 +141,7 @@ static CURLcode test_unit1660(const char *arg)
         continue;
       }
       else if(result) {
-        printf("Input %u: error %d\n", i, (int) result);
+        curl_mprintf("Input %u: error %d\n", i, (int) result);
         continue;
       }
     }
index 72ae49676bd8e31d18afadfa597236cb4550f822..773bd8d386cce98786900702c4f78876e395d958 100644 (file)
@@ -57,26 +57,26 @@ static CURLcode test_unit1664(const char *arg)
   };
 
   int i;
-  printf("curlx_str_word\n");
+  curl_mprintf("curlx_str_word\n");
   for(i = 0; wordparse[i]; i++) {
     struct Curl_str out;
     const char *line = wordparse[i];
     const char *orgline = line;
     int rc = curlx_str_word(&line, &out, 7);
-    printf("%u: (\"%s\") %d, \"%.*s\" [%d], line %d\n",
-           i, orgline, rc, (int)out.len, out.str, (int)out.len,
-           (int)(line - orgline));
+    curl_mprintf("%u: (\"%s\") %d, \"%.*s\" [%d], line %d\n",
+                 i, orgline, rc, (int)out.len, out.str, (int)out.len,
+                 (int)(line - orgline));
   }
 
-  printf("curlx_str_until\n");
+  curl_mprintf("curlx_str_until\n");
   for(i = 0; wordparse[i]; i++) {
     struct Curl_str out;
     const char *line = wordparse[i];
     const char *orgline = line;
     int rc = curlx_str_until(&line, &out, 7, 'd');
-    printf("%u: (\"%s\") %d, \"%.*s\" [%d], line %d\n",
-           i, orgline, rc, (int)out.len, out.str, (int)out.len,
-           (int)(line - orgline));
+    curl_mprintf("%u: (\"%s\") %d, \"%.*s\" [%d], line %d\n",
+                 i, orgline, rc, (int)out.len, out.str, (int)out.len,
+                 (int)(line - orgline));
   }
 
   {
@@ -96,15 +96,15 @@ static CURLcode test_unit1664(const char *arg)
       NULL
     };
 
-    printf("curlx_str_quotedword\n");
+    curl_mprintf("curlx_str_quotedword\n");
     for(i = 0; qwords[i]; i++) {
       struct Curl_str out;
       const char *line = qwords[i];
       const char *orgline = line;
       int rc = curlx_str_quotedword(&line, &out, 7);
-      printf("%u: (\"%s\") %d, \"%.*s\" [%d], line %d\n",
-             i, orgline, rc, (int)out.len, out.str, (int)out.len,
-             (int)(line - orgline));
+      curl_mprintf("%u: (\"%s\") %d, \"%.*s\" [%d], line %d\n",
+                   i, orgline, rc, (int)out.len, out.str, (int)out.len,
+                   (int)(line - orgline));
     }
   }
 
@@ -119,13 +119,13 @@ static CURLcode test_unit1664(const char *arg)
       "",
       NULL
     };
-    printf("curlx_str_single\n");
+    curl_mprintf("curlx_str_single\n");
     for(i = 0; single[i]; i++) {
       const char *line = single[i];
       const char *orgline = line;
       int rc = curlx_str_single(&line, 'a');
-      printf("%u: (\"%s\") %d, line %d\n",
-             i, orgline, rc, (int)(line - orgline));
+      curl_mprintf("%u: (\"%s\") %d, line %d\n",
+                   i, orgline, rc, (int)(line - orgline));
     }
   }
   {
@@ -141,13 +141,13 @@ static CURLcode test_unit1664(const char *arg)
       "",
       NULL
     };
-    printf("curlx_str_singlespace\n");
+    curl_mprintf("curlx_str_singlespace\n");
     for(i = 0; single[i]; i++) {
       const char *line = single[i];
       const char *orgline = line;
       int rc = curlx_str_singlespace(&line);
-      printf("%u: (\"%s\") %d, line %d\n",
-             i, orgline, rc, (int)(line - orgline));
+      curl_mprintf("%u: (\"%s\") %d, line %d\n",
+                   i, orgline, rc, (int)(line - orgline));
     }
   }
 
@@ -162,13 +162,13 @@ static CURLcode test_unit1664(const char *arg)
       "",
       NULL
     };
-    printf("curlx_str_single\n");
+    curl_mprintf("curlx_str_single\n");
     for(i = 0; single[i]; i++) {
       const char *line = single[i];
       const char *orgline = line;
       int rc = curlx_str_single(&line, 'a');
-      printf("%u: (\"%s\") %d, line %d\n",
-             i, orgline, rc, (int)(line - orgline));
+      curl_mprintf("%u: (\"%s\") %d, line %d\n",
+                   i, orgline, rc, (int)(line - orgline));
     }
   }
   {
@@ -187,14 +187,14 @@ static CURLcode test_unit1664(const char *arg)
       "",
       NULL
     };
-    printf("curlx_str_number\n");
+    curl_mprintf("curlx_str_number\n");
     for(i = 0; nums[i]; i++) {
       curl_off_t num;
       const char *line = nums[i];
       const char *orgline = line;
       int rc = curlx_str_number(&line, &num, 1235);
-      printf("%u: (\"%s\") %d, [%u] line %d\n",
-             i, orgline, rc, (int)num, (int)(line - orgline));
+      curl_mprintf("%u: (\"%s\") %d, [%u] line %d\n",
+                   i, orgline, rc, (int)num, (int)(line - orgline));
     }
   }
 
@@ -219,7 +219,7 @@ static CURLcode test_unit1664(const char *arg)
       { "12", 10},
       {NULL, 0}
     };
-    printf("curlx_str_number varying max\n");
+    curl_mprintf("curlx_str_number varying max\n");
     for(i = 0; nums[i].str; i++) {
       curl_off_t num;
       const char *line = nums[i].str;
@@ -259,7 +259,7 @@ static CURLcode test_unit1664(const char *arg)
       { "12", 16},
       {NULL, 0}
     };
-    printf("curlx_str_hex varying max\n");
+    curl_mprintf("curlx_str_hex varying max\n");
     for(i = 0; nums[i].str; i++) {
       curl_off_t num;
       const char *line = nums[i].str;
@@ -294,7 +294,7 @@ static CURLcode test_unit1664(const char *arg)
       { "8", 10},
       {NULL, 0}
     };
-    printf("curlx_str_octal varying max\n");
+    curl_mprintf("curlx_str_octal varying max\n");
     for(i = 0; nums[i].str; i++) {
       curl_off_t num;
       const char *line = nums[i].str;
@@ -330,7 +330,7 @@ static CURLcode test_unit1664(const char *arg)
       "999999999999999999",
       NULL
     };
-    printf("curlx_str_number / max\n");
+    curl_mprintf("curlx_str_number / max\n");
     for(i = 0; nums[i]; i++) {
       curl_off_t num;
       const char *line = nums[i];
@@ -356,7 +356,7 @@ static CURLcode test_unit1664(const char *arg)
       "",
       NULL
     };
-    printf("curlx_str_newline\n");
+    curl_mprintf("curlx_str_newline\n");
     for(i = 0; newl[i]; i++) {
       const char *line = newl[i];
       const char *orgline = line;
@@ -382,7 +382,7 @@ static CURLcode test_unit1664(const char *arg)
       "",
       NULL
     };
-    printf("curlx_str_hex\n");
+    curl_mprintf("curlx_str_hex\n");
     for(i = 0; nums[i]; i++) {
       curl_off_t num;
       const char *line = nums[i];
@@ -409,7 +409,7 @@ static CURLcode test_unit1664(const char *arg)
       "",
       NULL
     };
-    printf("curlx_str_octal\n");
+    curl_mprintf("curlx_str_octal\n");
     for(i = 0; nums[i]; i++) {
       curl_off_t num;
       const char *line = nums[i];
@@ -433,7 +433,7 @@ static CURLcode test_unit1664(const char *arg)
       "666666666666666666666",
       NULL
     };
-    printf("curlx_str_octal / max\n");
+    curl_mprintf("curlx_str_octal / max\n");
     for(i = 0; nums[i]; i++) {
       curl_off_t num;
       const char *line = nums[i];
@@ -469,7 +469,7 @@ static CURLcode test_unit1664(const char *arg)
       "ABCDEF",
       NULL
     };
-    printf("curlx_str_hex / max\n");
+    curl_mprintf("curlx_str_hex / max\n");
     for(i = 0; nums[i]; i++) {
       curl_off_t num;
       const char *line = nums[i];
index 9111edafb884289b7a15c94eca04de2c76dd8ea9..3d57f16c8ff19b10ab89707a2a1ea252a136a804 100644 (file)
@@ -83,21 +83,21 @@ static CURLcode test_unit2604(const char *arg)
     char *path;
     const char *cp = i == 0 ? cp0 : list[i].cp;
     CURLcode result = Curl_get_pathname(&cp, &path, list[i].home);
-    printf("%u - Curl_get_pathname(\"%s\", ... \"%s\") == %u\n", i,
-           list[i].cp, list[i].home, list[i].result);
+    curl_mprintf("%u - Curl_get_pathname(\"%s\", ... \"%s\") == %u\n", i,
+                 list[i].cp, list[i].home, list[i].result);
     if(result != list[i].result) {
-      printf("... returned %d\n", result);
+      curl_mprintf("... returned %d\n", result);
       unitfail++;
     }
     if(!result) {
       if(cp && strcmp(cp, list[i].next)) {
-        printf("... cp points to '%s', not '%s' as expected \n",
-               cp, list[i].next);
+        curl_mprintf("... cp points to '%s', not '%s' as expected \n",
+                     cp, list[i].next);
         unitfail++;
       }
       if(path && strcmp(path, list[i].expect)) {
-        printf("... gave '%s', not '%s' as expected \n",
-               path, list[i].expect);
+        curl_mprintf("... gave '%s', not '%s' as expected \n",
+                     path, list[i].expect);
         unitfail++;
       }
       curl_free(path);
index 34549fc2966c82c94ba1212474a065beb90c1a09..08ce6fff394456e861c6eca4753ca4aaa9772d07 100644 (file)
 static void checksize(const char *name, size_t size, size_t allowed)
 {
   if(size > allowed) {
-    fprintf(stderr, "BAD: struct %s is %d bytes, allowed to be %d",
-            name, (int)size, (int)allowed);
-    fprintf(stderr, ": %d bytes too big\n", (int)(size - allowed));
+    curl_mfprintf(stderr, "BAD: struct %s is %zu bytes, "
+                  "allowed to be %zu: %zu bytes too big\n",
+                  name, size, allowed, size - allowed);
     unitfail++;
   }
   else {
-    printf("FINE: struct %s is %d bytes, allowed %d (margin: %d bytes)\n",
-           name, (int)size, (int)allowed, (int)(allowed - size));
+    curl_mprintf("FINE: struct %s is %zu bytes, "
+                 "allowed %zu (margin: %zu bytes)\n",
+                 name, size, allowed, allowed - size);
   }
 }