]> granicus.if.org Git - libevent/commitdiff
Fix warnings on mingw with gcc 4.5
authorNick Mathewson <nickm@torproject.org>
Tue, 5 Oct 2010 18:29:48 +0000 (14:29 -0400)
committerNick Mathewson <nickm@torproject.org>
Tue, 5 Oct 2010 18:29:48 +0000 (14:29 -0400)
buffer_iocp.c
evdns.c
listener.c
signal.c
test/bench.c
test/bench_httpclient.c
test/regress_http.c

index e211e980c774885b3f0858bdbf502f1b39cb02dd..b1c9ccfd70de629babb31cf7e037f2c62acf9121 100644 (file)
@@ -197,7 +197,7 @@ evbuffer_launch_write(struct evbuffer *buf, ev_ssize_t at_most,
 
        for (i=0; i < MAX_WSABUFS && chain; ++i, chain=chain->next) {
                WSABUF *b = &buf_o->buffers[i];
-               b->buf = chain->buffer + chain->misalign;
+               b->buf = (char*)( chain->buffer + chain->misalign );
                _evbuffer_chain_pin(chain, EVBUFFER_MEM_PINNED_W);
 
                if ((size_t)at_most > chain->off) {
diff --git a/evdns.c b/evdns.c
index 7a1fd24b79f3ff388bb0d775e4d496d06d0350f2..0d1d32e45c34b6338f9981d56ef1c9c6047d20f1 100644 (file)
--- a/evdns.c
+++ b/evdns.c
@@ -1263,7 +1263,8 @@ nameserver_read(struct nameserver *ns) {
        ASSERT_LOCKED(ns->base);
 
        for (;;) {
-               const int r = recvfrom(ns->socket, packet, sizeof(packet), 0,
+               const int r = recvfrom(ns->socket, (void*)packet,
+                   sizeof(packet), 0,
                    (struct sockaddr*)&ss, &addrlen);
                if (r < 0) {
                        int err = evutil_socket_geterror(ns->socket);
@@ -1300,7 +1301,7 @@ server_port_read(struct evdns_server_port *s) {
 
        for (;;) {
                addrlen = sizeof(struct sockaddr_storage);
-               r = recvfrom(s->socket, packet, sizeof(packet), 0,
+               r = recvfrom(s->socket, (void*)packet, sizeof(packet), 0,
                                         (struct sockaddr*) &addr, &addrlen);
                if (r < 0) {
                        int err = evutil_socket_geterror(s->socket);
@@ -2084,7 +2085,7 @@ evdns_request_transmit_to(struct request *req, struct nameserver *server) {
        int r;
        ASSERT_LOCKED(req->base);
        ASSERT_VALID_REQUEST(req);
-       r = sendto(server->socket, req->request, req->request_len, 0,
+       r = sendto(server->socket, (void*)req->request, req->request_len, 0,
            (struct sockaddr *)&server->address, server->addrlen);
        if (r < 0) {
                int err = evutil_socket_geterror(server->socket);
index e9ce9c0f11d5969a6a65705345f4d20929ff4809..a1b770514afa96e7ee87698a5d63a8c446cab181 100644 (file)
@@ -289,8 +289,11 @@ listener_read_cb(evutil_socket_t fd, short what, void *p)
        int err;
        while (1) {
                struct sockaddr_storage ss;
+#ifdef WIN32
+               int socklen = sizeof(ss);
+#else
                socklen_t socklen = sizeof(ss);
-
+#endif
                evutil_socket_t new_fd = accept(fd, (struct sockaddr*)&ss, &socklen);
                if (new_fd < 0)
                        break;
index ce4673bb091e7e83ac493cce37368f1baa633e96..9a5c868f0afa99446a6d3c1ceed2b81a58b4ecb9 100644 (file)
--- a/signal.c
+++ b/signal.c
@@ -390,7 +390,7 @@ evsig_handler(int sig)
 
        /* Wake up our notification mechanism */
        msg = sig;
-       send(evsig_base_fd, &msg, 1, 0);
+       send(evsig_base_fd, (char*)&msg, 1, 0);
        errno = save_errno;
 #ifdef WIN32
        EVUTIL_SET_SOCKET_ERROR(socket_errno);
index d33c4ae94e867bda6b21723e500ef650b777fc7b..59cb6df5362009643ffdc34c0842129a81a6dd69 100644 (file)
@@ -67,7 +67,7 @@ read_cb(evutil_socket_t fd, short which, void *arg)
        long idx = (long) arg, widx = idx + 1;
        u_char ch;
 
-       count += recv(fd, &ch, sizeof(ch), 0);
+       count += recv(fd, (char*)&ch, sizeof(ch), 0);
        if (writes) {
                if (widx >= num_pipes)
                        widx -= num_pipes;
index a9a7f14cad352539dc71b5af6ef893d12396d003..0d4baa16ed1e425e175badf64220a54e428d617a 100644 (file)
@@ -195,14 +195,22 @@ main(int argc, char **argv)
        throughput = total_n_handled /
            (total.tv_sec+ ((double)total.tv_usec)/1000000.0);
 
+#ifdef WIN32
+#define I64_FMT "%I64d"
+#define I64_TYP __int64
+#else
+#define I64_FMT "%lld"
+#define I64_TYP long long int
+#endif
+
        printf("\n%d requests in %d.%06d sec. (%.2f throughput)\n"
            "Each took about %.02f msec latency\n"
-           "%lld bytes read. %d errors.\n",
+           I64_FMT "bytes read. %d errors.\n",
            total_n_handled,
            (int)total.tv_sec, (int)total.tv_usec,
            throughput,
            (double)(usec/1000) / total_n_handled,
-           (long long)total_n_bytes, n_errors);
+           (I64_TYP)total_n_bytes, n_errors);
 
        return 0;
 }
index 7baaa83664aa98b4e61e0ab5d092b7f75660a22e..5b899a23a7981a4b17c85a611e02f3f62731ab23 100644 (file)
@@ -1141,8 +1141,8 @@ http_dispatcher_test_done(struct evhttp_request *req, void *arg)
        }
 
        if (EVBUFFER_LENGTH(req->input_buffer) != strlen(what)) {
-               fprintf(stderr, "FAILED (length %zu vs %zu)\n",
-                   EVBUFFER_LENGTH(req->input_buffer), strlen(what));
+               fprintf(stderr, "FAILED (length %lu vs %lu)\n",
+                   (unsigned long)EVBUFFER_LENGTH(req->input_buffer), (unsigned long)strlen(what));
                exit(1);
        }
 
@@ -1257,8 +1257,8 @@ http_post_cb(struct evhttp_request *req, void *arg)
        }
 
        if (EVBUFFER_LENGTH(req->input_buffer) != strlen(POST_DATA)) {
-               fprintf(stdout, "FAILED (length: %zu vs %zu)\n",
-                   EVBUFFER_LENGTH(req->input_buffer), strlen(POST_DATA));
+               fprintf(stdout, "FAILED (length: %lu vs %lu)\n",
+                   (unsigned long) EVBUFFER_LENGTH(req->input_buffer), (unsigned long) strlen(POST_DATA));
                exit(1);
        }
 
@@ -1300,8 +1300,8 @@ http_postrequest_done(struct evhttp_request *req, void *arg)
        }
 
        if (EVBUFFER_LENGTH(req->input_buffer) != strlen(what)) {
-               fprintf(stderr, "FAILED (length %zu vs %zu)\n",
-                   EVBUFFER_LENGTH(req->input_buffer), strlen(what));
+               fprintf(stderr, "FAILED (length %lu vs %lu)\n",
+                   (unsigned long)EVBUFFER_LENGTH(req->input_buffer), (unsigned long)strlen(what));
                exit(1);
        }
 
@@ -1374,8 +1374,8 @@ http_put_cb(struct evhttp_request *req, void *arg)
        }
 
        if (EVBUFFER_LENGTH(req->input_buffer) != strlen(PUT_DATA)) {
-               fprintf(stdout, "FAILED (length: %zu vs %zu)\n",
-                   EVBUFFER_LENGTH(req->input_buffer), strlen(PUT_DATA));
+               fprintf(stdout, "FAILED (length: %lu vs %lu)\n",
+                   (unsigned long)EVBUFFER_LENGTH(req->input_buffer), (unsigned long)strlen(PUT_DATA));
                exit(1);
        }
 
@@ -1417,8 +1417,8 @@ http_putrequest_done(struct evhttp_request *req, void *arg)
        }
 
        if (EVBUFFER_LENGTH(req->input_buffer) != strlen(what)) {
-               fprintf(stderr, "FAILED (length %zu vs %zu)\n",
-                   EVBUFFER_LENGTH(req->input_buffer), strlen(what));
+               fprintf(stderr, "FAILED (length %lu vs %lu)\n",
+                   (unsigned long)EVBUFFER_LENGTH(req->input_buffer), (unsigned long)strlen(what));
                exit(1);
        }
 
@@ -2111,9 +2111,10 @@ _http_stream_in_test(char const *url,
        event_dispatch();
 
        if (evbuffer_get_length(reply) != expected_len) {
-               TT_DIE(("reply length %zu; expected %zu; FAILED (%s)\n",
-                               EVBUFFER_LENGTH(reply), expected_len,
-                               evbuffer_pullup(reply, -1)));
+               TT_DIE(("reply length %lu; expected %lu; FAILED (%s)\n",
+                               (unsigned long)EVBUFFER_LENGTH(reply),
+                               (unsigned long)expected_len,
+                               (char*)evbuffer_pullup(reply, -1)));
        }
 
        if (memcmp(evbuffer_pullup(reply, -1), expected, expected_len) != 0) {