]> granicus.if.org Git - libevent/commitdiff
Fix some build warnings on MSVC, mostly related to signed/unsigned comparisons.
authorNick Mathewson <nickm@torproject.org>
Thu, 5 Nov 2009 21:22:23 +0000 (21:22 +0000)
committerNick Mathewson <nickm@torproject.org>
Thu, 5 Nov 2009 21:22:23 +0000 (21:22 +0000)
svn:r1510

buffer.c
buffer_iocp.c
http.c
test/regress_buffer.c
test/regress_bufferevent.c
test/regress_dns.c

index 28819094af5723de20264489713eb8197d5a32f8..bcfedb8ebcbec3e6f5761b75524b5a7bfad40fbc 100644 (file)
--- a/buffer.c
+++ b/buffer.c
@@ -2051,7 +2051,7 @@ evbuffer_peek(struct evbuffer *buffer, ev_ssize_t len,
 {
        struct evbuffer_chain *chain;
        int idx = 0;
-       size_t len_so_far = 0;
+       ev_ssize_t len_so_far = 0;
 
        EVBUFFER_LOCK(buffer, EVTHREAD_READ);
 
index cab782a392a0f8bb6246adc87a748cfcf6a477b3..2b346d3615b51f8ebf87308d279a20d46c71b2bc 100644 (file)
@@ -121,13 +121,14 @@ read_completed(struct event_overlapped *eo, uintptr_t _, ev_ssize_t nBytes, int
        int n_vec;
 
        // XXXX use ok
+       EVUTIL_ASSERT(nBytes >= 0); // XXXX Can this be false?
 
        EVBUFFER_LOCK(evbuf, EVTHREAD_WRITE);
        buf->read_in_progress = 0;
        evbuffer_unfreeze(evbuf, 0);
 
        iov[0].iov_base = buf_o->buffers[0].buf;
-       if (nBytes <= buf_o->buffers[0].len) {
+       if ((size_t)nBytes <= buf_o->buffers[0].len) {
                iov[0].iov_len = nBytes;
                n_vec = 1;
        } else {
diff --git a/http.c b/http.c
index 33990716239a657b76fefb658c5cfaa25eebc2da..c1e16e5a2de7384e16e51de392c78b0bfd7e1ce4 100644 (file)
--- a/http.c
+++ b/http.c
@@ -781,12 +781,12 @@ evhttp_handle_chunked_read(struct evhttp_request *req, struct evbuffer *buf)
                                /* could not get chunk size */
                                return (DATA_CORRUPTED);
                        }
-                       if (req->body_size + ntoread > req->evcon->max_body_size) {
+                       if (req->body_size + (size_t)ntoread > req->evcon->max_body_size) {
                                /* failed body length test */
                                event_debug(("Request body is too long"));
                                return (DATA_TOO_LONG);
                        }
-                       req->body_size += ntoread;
+                       req->body_size += (size_t)ntoread;
                        req->ntoread = ntoread;
                        if (req->ntoread == 0) {
                                /* Last chunk */
@@ -2910,8 +2910,8 @@ evhttp_get_request_connection(
        if (evcon == NULL)
                return (NULL);
 
-       evhttp_connection_set_max_headers_size(evcon, http->default_max_headers_size);
-       evhttp_connection_set_max_body_size(evcon, http->default_max_body_size);
+       evcon->max_headers_size = http->default_max_headers_size;
+       evcon->max_body_size = http->default_max_body_size;
         
        evcon->flags |= EVHTTP_CON_INCOMING;
        evcon->state = EVCON_READING_FIRSTLINE;
index cd491953ce26d14b6639324e13b6e3df6bc4b969..59ad45ba6749691c4248ddaa0a254dcf3806d1a3 100644 (file)
@@ -172,7 +172,7 @@ test_evbuffer(void *ptr)
        tt_assert(evbuffer_get_length(evb) == i * sizeof(buffer));
 
        /* test remove buffer */
-       sz_tmp = sizeof(buffer)*2.5;
+       sz_tmp = (size_t)(sizeof(buffer)*2.5);
        evbuffer_remove_buffer(evb, evb_two, sz_tmp);
        tt_assert(evbuffer_get_length(evb_two) == sz_tmp);
        tt_assert(evbuffer_get_length(evb) == sizeof(buffer) / 2);
@@ -630,14 +630,14 @@ test_evbuffer_iterative(void *ptr)
 {
        struct evbuffer *buf = evbuffer_new();
        const char *abc = "abcdefghijklmnopqrstvuwxyzabcdefghijklmnopqrstvuwxyzabcdefghijklmnopqrstvuwxyzabcdefghijklmnopqrstvuwxyz";
-       int i, j, sum;
+       unsigned i, j, sum;
 
        sum = 0;
        for (i = 0; i < 1000; ++i) {
                for (j = 1; j < strlen(abc); ++j) {
                        char format[32];
 
-                       evutil_snprintf(format, sizeof(format), "%%%d.%ds", j, j);
+                       evutil_snprintf(format, sizeof(format), "%%%u.%us", j, j);
                        evbuffer_add_printf(buf, format, abc);
                        evbuffer_validate(buf);
 
index 257abe5697abe43fb43086bf673e46cf74105e53..98e70434678a48709dd9b02f63c0a004cf406fd1 100644 (file)
@@ -287,7 +287,7 @@ bufferevent_input_filter(struct evbuffer *src, struct evbuffer *dst,
     ev_ssize_t lim, enum bufferevent_flush_mode state, void *ctx)
 {
        const unsigned char *buffer;
-       int i;
+       unsigned i;
 
        buffer = evbuffer_pullup(src, evbuffer_get_length(src));
        for (i = 0; i < evbuffer_get_length(src); i += 2) {
@@ -309,7 +309,7 @@ bufferevent_output_filter(struct evbuffer *src, struct evbuffer *dst,
     ev_ssize_t lim, enum bufferevent_flush_mode state, void *ctx)
 {
        const unsigned char *buffer;
-       int i;
+       unsigned i;
 
        buffer = evbuffer_pullup(src, evbuffer_get_length(src));
        for (i = 0; i < evbuffer_get_length(src); ++i) {
index 177261679a6528038e32b06d5c89bd4ec1e844e4..348bcb429176d303ea0af614386f345a633d52c9 100644 (file)
@@ -482,7 +482,7 @@ end:
 
 static struct evdns_server_port *
 get_generic_server(struct event_base *base,
-    ev_uint64_t portnum,
+    ev_uint16_t portnum,
     evdns_request_callback_fn_type cb,
     void *arg)
 {