From 976f286134a64ef19929b679bf4e5d2ae40fc85f Mon Sep 17 00:00:00 2001 From: Sergey Lyubka Date: Mon, 20 Jan 2014 20:57:21 +0000 Subject: [PATCH] Made mg_connection::content_len int -> size_t, which is 64-bit on 64-bit systems --- mongoose.c | 4 ++-- mongoose.h | 2 +- unit_test.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/mongoose.c b/mongoose.c index d1473a10..6cc7ce30 100644 --- a/mongoose.c +++ b/mongoose.c @@ -2229,7 +2229,7 @@ static void call_uri_handler_if_data_is_buffered(struct connection *conn) { do { } while (deliver_websocket_frame(conn)); } else #endif - if (loc->len >= c->content_len) { + if ((size_t) loc->len >= c->content_len) { call_uri_handler(conn); } } @@ -3329,7 +3329,7 @@ static void handle_lsp_request(struct connection *conn, const char *path, prepare_lua_environment(&conn->mg_conn, L); lua_pushcclosure(L, &lua_error_handler, 0); lua_pushglobaltable(L); - lsp(conn, p, st->st_size, L); + lsp(conn, p, (int) st->st_size, L); close_local_endpoint(conn); } diff --git a/mongoose.h b/mongoose.h index bf419b38..1362ba25 100644 --- a/mongoose.h +++ b/mongoose.h @@ -46,7 +46,7 @@ struct mg_connection { } http_headers[30]; char *content; // POST (or websocket message) data, or NULL - long int content_len; // content length + size_t content_len; // content length int is_websocket; // Connection is a websocket connection int status_code; // HTTP status code for HTTP error handler diff --git a/unit_test.c b/unit_test.c index f7cda390..aa722359 100644 --- a/unit_test.c +++ b/unit_test.c @@ -440,7 +440,7 @@ static int cb2(struct mg_connection *conn) { file_name = file1; } if ((file_data = read_file(file_name, &file_len)) != NULL) { - if (file_len == conn->content_len && + if ((size_t) file_len == conn->content_len && memcmp(file_data, conn->content, file_len) == 0) { strcat(buf, "d"); } else { @@ -526,7 +526,7 @@ static int us1(struct mg_connection *conn) { } else if (conn->status_code == MG_DOWNLOAD_SUCCESS) { char *file_data = read_file(file_name, &file_size); sprintf((char *) conn->connection_param, "%d", - file_size == conn->content_len && + (size_t) file_size == conn->content_len && memcmp(file_data, conn->content, file_size) == 0 ? 1 : 0); free(file_data); } else if (conn->status_code == MG_CONNECT_FAILURE) {