]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
examples/chkspeed: portable printing when outputting curl_off_t values
authorJimFuller-RedHat <jfuller@redhat.com>
Sat, 18 Oct 2025 09:21:15 +0000 (11:21 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Sat, 18 Oct 2025 21:26:15 +0000 (23:26 +0200)
Closes #19112

docs/examples/chkspeed.c

index 996db393f5840416a060ddac372bbebdadab78ac..efa2b0d5ea351f8ae1bc4cfafc9deda449dbef0a 100644 (file)
@@ -184,20 +184,22 @@ int main(int argc, char *argv[])
       /* check for bytes downloaded */
       res = curl_easy_getinfo(curl_handle, CURLINFO_SIZE_DOWNLOAD_T, &val);
       if((CURLE_OK == res) && (val > 0))
-        printf("Data downloaded: %lu bytes.\n", (unsigned long)val);
+        printf("Data downloaded: %" CURL_FORMAT_CURL_OFF_T " bytes.\n", val);
 
       /* check for total download time */
       res = curl_easy_getinfo(curl_handle, CURLINFO_TOTAL_TIME_T, &val);
       if((CURLE_OK == res) && (val > 0))
-        printf("Total download time: %lu.%06lu sec.\n",
-               (unsigned long)(val / 1000000),
-               (unsigned long)(val % 1000000));
+        printf("Total download time: %" CURL_FORMAT_CURL_OFF_T
+               ".%06" CURL_FORMAT_CURL_OFF_T " sec.\n",
+               val / 1000000,
+               val % 1000000);
 
       /* check for average download speed */
       res = curl_easy_getinfo(curl_handle, CURLINFO_SPEED_DOWNLOAD_T, &val);
       if((CURLE_OK == res) && (val > 0))
-        printf("Average download speed: %lu kbyte/sec.\n",
-               (unsigned long)(val / 1024));
+        printf("Average download speed: %"
+               CURL_FORMAT_CURL_OFF_T " kbyte/sec.\n",
+               val / 1024);
 
       if(prtall) {
         /* check for name resolution time */