]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tests: fix bad printf format flags in test code
authorDaniel Stenberg <daniel@haxx.se>
Sun, 6 Aug 2023 20:29:40 +0000 (22:29 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 7 Aug 2023 08:46:14 +0000 (10:46 +0200)
tests/libtest/lib1156.c
tests/libtest/lib1523.c
tests/libtest/lib2304.c
tests/libtest/lib2305.c
tests/libtest/lib557.c
tests/unit/unit1323.c
tests/unit/unit1398.c
tests/unit/unit1607.c
tests/unit/unit1609.c
tests/unit/unit3200.c

index 84a5d48be0128ccd3aad9bbf0d8a43da35d59b57..aae2893ef377181e20f7ce413b3530a5dbadf5f4 100644 (file)
@@ -103,7 +103,7 @@ static int onetest(CURL *curl, const char *url, const struct testparams *p,
   hasbody = 0;
   res = curl_easy_perform(curl);
   if(res != p->result) {
-    printf("%d: bad error code (%d): resume=%s, fail=%s, http416=%s, "
+    printf("%zd: bad error code (%d): resume=%s, fail=%s, http416=%s, "
            "content-range=%s, expected=%d\n", num, res,
            (p->flags & F_RESUME)? "yes": "no",
            (p->flags & F_FAIL)? "yes": "no",
index 3da471f0e7d0f2e9a2feef1e9569a056349143c1..9aa9e3cb48fc5ef517de48815ef5e44b888afd34 100644 (file)
@@ -68,7 +68,6 @@ int test(char *URL)
   curl_easy_setopt(hnd, CURLOPT_NOPROGRESS, 0L);
   curl_easy_setopt(hnd, CURLOPT_XFERINFOFUNCTION, dload_progress_cb);
 
-  printf("Start: %d\n", time(NULL));
   ret = run(hnd, 1, 2);
   if(ret)
     fprintf(stderr, "error %d: %s\n", ret, buffer);
@@ -79,7 +78,6 @@ int test(char *URL)
   else
     ret = CURLE_OK;
 
-  printf("End: %d\n", time(NULL));
   curl_easy_cleanup(hnd);
   curl_global_cleanup();
 
index 5e375d851394d1d56bdc65f71a6571a0b53f2e1c..aff92bfa75fc824893e96922d6c8ea499a29cdb9 100644 (file)
@@ -63,7 +63,7 @@ static int recv_pong(CURL *curl, const char *exected_payload)
     }
   }
   fprintf(stderr, "ws: curl_ws_recv returned %u, received %u\n", (int)result,
-         rlen);
+          (int)rlen);
   return (int)result;
 }
 
index 92fb0065f2f25902d99767a2590ec12e000adb40..0778e0b5857693ce0842b8d1a103d4bce0ef49f2 100644 (file)
@@ -58,7 +58,7 @@ static void websocket(CURL *curl)
       printf("curl_ws_recv returned %d\n", (int)result);
       return;
     }
-    printf("%u: nread %u Age %u Flags %x "
+    printf("%u: nread %zu Age %u Flags %x "
            "Offset %" CURL_FORMAT_CURL_OFF_T " "
            "Bytesleft %" CURL_FORMAT_CURL_OFF_T "\n",
            (int)i,
index 409550aba17903e418d17be9f491233b0d61c998..6f96668da29b02c8de6318d7e4dc1a8eaeb65a26 100644 (file)
@@ -27,6 +27,8 @@
  * curl_m*printf formatting capabilities and handling of some data types.
  */
 
+#define CURL_NO_FMT_CHECKS /* disable compiler *printf format checks */
+
 #include "test.h"
 
 #include <limits.h>
index 26498edbdc70854bbbb1c2b98d745e2b6c35d40e..bdd02b5de5d01e2a1987a03595ab4bd643973c47 100644 (file)
@@ -54,13 +54,13 @@ UNITTEST_START
   for(i = 0; i < sizeof(tests)/sizeof(tests[0]); i++) {
     timediff_t result = Curl_timediff(tests[i].first, tests[i].second);
     if(result != tests[i].result) {
-      printf("%d.%06u to %d.%06u got %d, but expected %d\n",
-             tests[i].first.tv_sec,
+      printf("%ld.%06u to %ld.%06u got %d, but expected %ld\n",
+             (long)tests[i].first.tv_sec,
              tests[i].first.tv_usec,
-             tests[i].second.tv_sec,
+             (long)tests[i].second.tv_sec,
              tests[i].second.tv_usec,
-             result,
-             tests[i].result);
+             (int)result,
+             (long)tests[i].result);
       fail("unexpected result!");
     }
   }
index 184489c49d7c36e1005a77fb770e4408749ed1a0..bf8af12d362c46cd763a1fa36b9411260f1a1449 100644 (file)
@@ -21,6 +21,8 @@
  * SPDX-License-Identifier: curl
  *
  ***************************************************************************/
+#define CURL_NO_FMT_CHECKS
+
 #include "curlcheck.h"
 
 #include "curl/mprintf.h"
index 83af9c8058d2703b8d3605413eae6dd34d18a90a..cd2657147da761d65e4d104719a16e4201bcd53c 100644 (file)
@@ -190,7 +190,7 @@ UNITTEST_START
 
       if(port != tests[i].port) {
         fprintf(stderr, "%s:%d tests[%d] failed. the retrieved port "
-                "for tests[%d].address[%d] is %ld but tests[%d].port is %d.\n",
+                "for tests[%d].address[%d] is %d but tests[%d].port is %d.\n",
                 __FILE__, __LINE__, i, i, j, port, i, tests[i].port);
         problem = true;
         break;
index 9f483945fd5d2f145d11e81bd64d74c79fb92aa5..19c59ada3ee8f912df575b64b60058e1eb08b274 100644 (file)
@@ -189,7 +189,7 @@ UNITTEST_START
 
       if(port != tests[i].port) {
         fprintf(stderr, "%s:%d tests[%d] failed. the retrieved port "
-                "for tests[%d].address[%d] is %ld but tests[%d].port is %d.\n",
+                "for tests[%d].address[%d] is %d but tests[%d].port is %d.\n",
                 __FILE__, __LINE__, i, i, j, port, i, tests[i].port);
         problem = true;
         break;
index 58eaff90ddd74c3d759f741f981cb29a81567d7a..2d684cf82dabe0fb4f94c6df3c48c401738393bf 100644 (file)
@@ -94,7 +94,7 @@ UNITTEST_START
     fp = fopen(arg, "rb");
     abort_unless(fp != NULL, "Cannot open testfile");
 
-    fprintf(stderr, "Test %d...", i);
+    fprintf(stderr, "Test %zd...", i);
     switch(i) {
       case 0:
         line = Curl_get_line(buf, len, fp);