libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit bf1993237a6ad5b01f3e4b5051d15316fc8e03d7
parent bd3325c9240e65e556fd42f0fd6692ef60b558ff
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Fri, 17 Sep 2021 11:53:55 +0300

Use type specifiers for printf() from inttypes.h

This should improve compatibility with various C libs.

Diffstat:
Msrc/examples/benchmark.c | 9++++++++-
Msrc/examples/benchmark_https.c | 9++++++++-
Msrc/examples/connection_close.c | 15+++++++++++----
Msrc/microhttpd/daemon.c | 16++++++++--------
Msrc/microhttpd/test_postprocessor_large.c | 2+-
Msrc/microhttpd/test_postprocessor_md.c | 4++--
6 files changed, 38 insertions(+), 17 deletions(-)

diff --git a/src/examples/benchmark.c b/src/examples/benchmark.c @@ -25,6 +25,13 @@ #include "platform.h" #include <microhttpd.h> +#ifdef HAVE_INTTYPES_H +#include <inttypes.h> +#endif /* HAVE_INTTYPES_H */ +#ifndef PRIu64 +#define PRIu64 "llu" +#endif /* ! PRIu64 */ + #if defined(MHD_CPU_COUNT) && (MHD_CPU_COUNT + 0) < 2 #undef MHD_CPU_COUNT #endif @@ -87,7 +94,7 @@ completed_callback (void *cls, if (delta < SMALL) small_deltas[delta]++; else - fprintf (stdout, "D: %llu 1\n", (unsigned long long) delta); + fprintf (stdout, "D: %" PRIu64 " 1\n", delta); free (tv); } diff --git a/src/examples/benchmark_https.c b/src/examples/benchmark_https.c @@ -25,6 +25,13 @@ #include "platform.h" #include <microhttpd.h> +#ifdef HAVE_INTTYPES_H +#include <inttypes.h> +#endif /* HAVE_INTTYPES_H */ +#ifndef PRIu64 +#define PRIu64 "llu" +#endif /* ! PRIu64 */ + #if defined(MHD_CPU_COUNT) && (MHD_CPU_COUNT + 0) < 2 #undef MHD_CPU_COUNT #endif @@ -87,7 +94,7 @@ completed_callback (void *cls, if (delta < SMALL) small_deltas[delta]++; else - fprintf (stdout, "D: %llu 1\n", (unsigned long long) delta); + fprintf (stdout, "D: %" PRIu64 " 1\n", delta); free (tv); } diff --git a/src/examples/connection_close.c b/src/examples/connection_close.c @@ -25,6 +25,13 @@ #include "platform.h" #include <microhttpd.h> +#ifdef HAVE_INTTYPES_H +#include <inttypes.h> +#endif /* HAVE_INTTYPES_H */ +#ifndef PRIu64 +#define PRIu64 "llu" +#endif /* ! PRIu64 */ + #define PAGE \ "<html><head><title>libmicrohttpd demo</title></head><body>libmicrohttpd demo</body></html>" @@ -72,8 +79,8 @@ request_completed (void *cls, enum MHD_RequestTerminationCode toe) { fprintf (stderr, - "%llu - RC: %d\n", - (unsigned long long) __rdtsc (), + "%" PRIu64 " - RC: %d\n", + (uint64_t) __rdtsc (), toe); } @@ -85,8 +92,8 @@ connection_completed (void *cls, enum MHD_ConnectionNotificationCode toe) { fprintf (stderr, - "%llu - CC: %d\n", - (unsigned long long) __rdtsc (), + "%" PRIu64 " - CC: %d\n", + (uint64_t) __rdtsc (), toe); } diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c @@ -1382,9 +1382,9 @@ process_urh (struct MHD_UpgradeResponseHandle *urh) #ifdef HAVE_MESSAGES MHD_DLOG (daemon, _ ("Failed to forward to application " - MHD_UNSIGNED_LONG_LONG_PRINTF \ + "%" PRIu64 \ " bytes of data received from remote side: application shut down socket.\n"), - (MHD_UNSIGNED_LONG_LONG) urh->in_buffer_used); + (uint64_t) urh->in_buffer_used); #endif } @@ -1550,9 +1550,9 @@ process_urh (struct MHD_UpgradeResponseHandle *urh) MHD_DLOG (daemon, _ ( "Failed to forward to remote client " - MHD_UNSIGNED_LONG_LONG_PRINTF \ + "%" PRIu64 \ " bytes of data received from application: %s\n"), - (MHD_UNSIGNED_LONG_LONG) urh->out_buffer_used, + (uint64_t) urh->out_buffer_used, gnutls_strerror (res)); #endif /* Discard any data unsent to remote. */ @@ -1620,9 +1620,9 @@ process_urh (struct MHD_UpgradeResponseHandle *urh) MHD_DLOG (daemon, _ ( "Failed to forward to application " - MHD_UNSIGNED_LONG_LONG_PRINTF \ + "%" PRIu64 \ " bytes of data received from remote side: %s\n"), - (MHD_UNSIGNED_LONG_LONG) urh->in_buffer_used, + (uint64_t) urh->in_buffer_used, MHD_socket_strerr_ (err)); #endif /* Discard any data received form remote. */ @@ -1676,9 +1676,9 @@ process_urh (struct MHD_UpgradeResponseHandle *urh) MHD_DLOG (daemon, _ ( "Failed to forward to remote client " - MHD_UNSIGNED_LONG_LONG_PRINTF \ + "%" PRIu64 \ " bytes of data received from application: daemon shut down.\n"), - (MHD_UNSIGNED_LONG_LONG) urh->out_buffer_used); + (uint64_t) urh->out_buffer_used); #endif /* Discard any data unsent to remote. */ urh->out_buffer_used = 0; diff --git a/src/microhttpd/test_postprocessor_large.c b/src/microhttpd/test_postprocessor_large.c @@ -47,7 +47,7 @@ value_checker (void *cls, (void) transfer_encoding; (void) data; (void) off; /* Unused. Silent compiler warning. */ #if 0 fprintf (stderr, - "VC: %llu %u `%s' `%s' `%s' `%s' `%.*s'\n", + "VC: %" PRIu64 " %u `%s' `%s' `%s' `%s' `%.*s'\n", off, size, key, filename, content_type, transfer_encoding, size, data); #endif diff --git a/src/microhttpd/test_postprocessor_md.c b/src/microhttpd/test_postprocessor_md.c @@ -130,10 +130,10 @@ post_data_iterator2 (void *cls, (void) content_type; (void) transfer_encoding; #if DEBUG - printf ("%s\t%s@ %llu\n", + printf ("%s\t%s@ %" PRIu64 "\n", key, data, - (unsigned long long) off); + off); #endif if (0 == strcmp (key, "text")) {