libmicrohttpd2

HTTP server C library (MHD 2.x, alpha)
Log | Files | Refs | README | LICENSE

commit bb41e87905cd249a2c60d15a89ef2f1d1d508606
parent 28ccbe52c21aa9839c8746ac443be799dbca330f
Author: Evgeny Grin <k2k@drgrin.dev>
Date:   Thu, 15 May 2025 21:09:22 +0300

json_echo.c: fixed compiler warnings

Diffstat:
Msrc/examples2/json_echo.c | 24+++++++++++++++++-------
1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/src/examples2/json_echo.c b/src/examples2/json_echo.c @@ -34,6 +34,7 @@ # include <unistd.h> #endif #include <assert.h> +struct AppSockContext; /* Forward declaration */ #define MHD_APP_SOCKET_CNTX_TYPE struct AppSockContext #include <microhttpd2.h> #include <jansson.h> @@ -108,8 +109,9 @@ handle_upload (void *upload_cls, json_error_t err; char *s; struct MHD_Response *response; + (void) upload_cls; /* Unused. Mute compiler warning. */ - j = json_loadb (content_data, + j = json_loadb ((char *) content_data, content_data_size, 0, &err); @@ -136,6 +138,9 @@ handle_request (void *cls, enum MHD_HTTP_Method method, uint_fast64_t upload_size) { + (void) cls; /* Unused. Mute compiler warning. */ + (void) path; /* Unused. Mute compiler warning. */ + if (method != MHD_HTTP_METHOD_POST) return MHD_action_from_response (request, file_not_found_response); @@ -159,6 +164,7 @@ sock_reg_update_cb ( MHD_APP_SOCKET_CNTX_TYPE *app_cntx, struct MHD_EventUpdateContext *ecb_cntx) { + (void) cls; /* Unused. Mute compiler warning. */ fprintf (stderr, "reg update on %d - %d\n", fd, @@ -183,7 +189,8 @@ sock_reg_update_cb ( { /* First time, allocate data structure to keep the socket and MHD's context */ - app_cntx = malloc (sizeof (MHD_APP_SOCKET_CNTX_TYPE)); + app_cntx = + (MHD_APP_SOCKET_CNTX_TYPE *) malloc (sizeof (MHD_APP_SOCKET_CNTX_TYPE)); if (NULL == app_cntx) return NULL; /* closes connection */ /* prepend to DLL */ @@ -324,8 +331,8 @@ main (int argc, /* This will cause MHD to call the #sock_reg_update_cb() */ MHD_daemon_process_reg_events (d, &next_wait); - ts.tv_sec = next_wait / 1000000; - ts.tv_usec = next_wait % 1000000; + ts.tv_sec = (time_t) (next_wait / 1000000); + ts.tv_usec = (long) (next_wait % 1000000); /* Real applications may do nicer error handling here */ (void) select (max_fd + 1, &rs, @@ -343,13 +350,16 @@ main (int argc, if (FD_ISSET (pos->fd, &rs)) - current_state |= MHD_FD_STATE_RECV; + current_state = + (enum MHD_FdState) (current_state | MHD_FD_STATE_RECV); if (FD_ISSET (pos->fd, &ws)) - current_state |= MHD_FD_STATE_SEND; + current_state = + (enum MHD_FdState) (current_state | MHD_FD_STATE_SEND); if (FD_ISSET (pos->fd, &es)) - current_state |= MHD_FD_STATE_EXCEPT; + current_state = + (enum MHD_FdState) (current_state | MHD_FD_STATE_EXCEPT); MHD_daemon_event_update (d, pos->ecb_cntx, current_state);