diff --git a/bufferevent_filter.c b/bufferevent_filter.c index ad8a316b..2da45868 100644 --- a/bufferevent_filter.c +++ b/bufferevent_filter.c @@ -430,6 +430,7 @@ be_filter_readcb(struct bufferevent *underlying, void *_me) /* XXXX use return value */ res = be_filter_process_input(bevf, state, &processed_any); + (void)res; /* XXX This should be in process_input, not here. There are * other places that can call process-input, and they should diff --git a/bufferevent_openssl.c b/bufferevent_openssl.c index 4c9047e5..de6440e3 100644 --- a/bufferevent_openssl.c +++ b/bufferevent_openssl.c @@ -1014,6 +1014,7 @@ be_openssl_outbuf_cb(struct evbuffer *buf, consider_writing(bev_ssl); } /* XXX Handle r < 0 */ + (void)r; } diff --git a/bufferevent_sock.c b/bufferevent_sock.c index 7502736c..366f3896 100644 --- a/bufferevent_sock.c +++ b/bufferevent_sock.c @@ -452,6 +452,7 @@ bufferevent_connect_getaddrinfo_cb(int result, struct evutil_addrinfo *ai, /* XXX use the other addrinfos? */ /* XXX use this return value */ r = bufferevent_socket_connect(bev, ai->ai_addr, (int)ai->ai_addrlen); + (void)r; _bufferevent_decref_and_unlock(bev); evutil_freeaddrinfo(ai); } diff --git a/configure.in b/configure.in index 7b147591..462c0346 100644 --- a/configure.in +++ b/configure.in @@ -646,6 +646,16 @@ if test x$enable_gcc_warnings = xyes && test "$GCC" = "yes"; then #error #endif])], have_gcc45=yes, have_gcc45=no) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [ +#if !defined(__clang__) +#error +#endif])], have_clang=yes, have_clang=no) + + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [ +#if !defined(__clang__) || (__clang_major__ > 2) || (__clang_major__ == 2 && __clang_minor__ > 9) +#error +#endif])], have_clang29orlower=yes, have_clang29orlower=no) + CFLAGS="$CFLAGS -W -Wfloat-equal -Wundef -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wwrite-strings -Wredundant-decls -Wchar-subscripts -Wcomment -Wformat -Wwrite-strings -Wmissing-declarations -Wredundant-decls -Wnested-externs -Wbad-function-cast -Wswitch-enum -Werror" CFLAGS="$CFLAGS -Wno-unused-parameter -Wstrict-aliasing" @@ -657,13 +667,27 @@ if test x$enable_gcc_warnings = xyes && test "$GCC" = "yes"; then if test x$have_gcc42 = xyes ; then # These warnings break gcc 4.0.2 and work on gcc 4.2 - CFLAGS="$CFLAGS -Waddress -Wnormalized=id -Woverride-init" + CFLAGS="$CFLAGS -Waddress" + fi + + if test x$have_gcc42 = xyes && test x$have_clang29orlower = xno; then + # These warnings break gcc 4.0.2 and clang, but work on gcc 4.2 + # We only disable these for clang 2.9 and lower, in case they are + # supported in later versions. + CFLAGS="$CFLAGS -Wnormalized=id -Woverride-init" fi if test x$have_gcc45 = xyes ; then # These warnings work on gcc 4.5 CFLAGS="$CFLAGS -Wlogical-op" fi + + if test x$have_clang = xyes; then + # Disable the unused-function warnings, because these trigger + # for minheap-internal.h related code. + CFLAGS="$CFLAGS -Wno-unused-function" + fi + ##This will break the world on some 64-bit architectures # CFLAGS="$CFLAGS -Winline" diff --git a/evdns.c b/evdns.c index d7d563f0..69f3ff63 100644 --- a/evdns.c +++ b/evdns.c @@ -2701,10 +2701,13 @@ evdns_cancel_request(struct evdns_base *base, struct evdns_request *handle) { struct request *req; + if (!handle->current_req) + return; + if (!base) { /* This redundancy is silly; can we fix it? (Not for 2.0) XXXX */ base = handle->base; - if (!base && handle->current_req) + if (!base) base = handle->current_req->base; } diff --git a/evthread.c b/evthread.c index a8b2534f..37621dd8 100644 --- a/evthread.c +++ b/evthread.c @@ -228,6 +228,7 @@ debug_cond_wait(void *_cond, void *_lock, const struct timeval *tv) { int r; struct debug_lock *lock = _lock; + EVUTIL_ASSERT(lock); EVUTIL_ASSERT(DEBUG_LOCK_SIG == lock->signature); EVLOCK_ASSERT_LOCKED(_lock); evthread_debug_lock_mark_unlocked(0, lock); diff --git a/http.c b/http.c index 3909aa8c..f427e03f 100644 --- a/http.c +++ b/http.c @@ -1775,7 +1775,8 @@ evhttp_parse_headers(struct evhttp_request *req, struct evbuffer* buffer) } if (status == MORE_DATA_EXPECTED) { - if (req->headers_size + evbuffer_get_length(buffer) > req->evcon->max_headers_size) + if (req->evcon != NULL && + req->headers_size + evbuffer_get_length(buffer) > req->evcon->max_headers_size) return (DATA_TOO_LONG); } diff --git a/sample/dns-example.c b/sample/dns-example.c index 439a486a..f2c1e020 100644 --- a/sample/dns-example.c +++ b/sample/dns-example.c @@ -72,7 +72,6 @@ static void gai_callback(int err, struct evutil_addrinfo *ai, void *arg) { const char *name = arg; - struct evutil_addrinfo *ai_first = NULL; int i; if (err) { printf("%s: %s\n", name, evutil_gai_strerror(err)); @@ -95,8 +94,6 @@ gai_callback(int err, struct evutil_addrinfo *ai, void *arg) printf("[%d] %s: %s\n",i,name,buf); } } - if (ai_first) - evutil_freeaddrinfo(ai_first); } static void @@ -120,6 +117,8 @@ evdns_server_callback(struct evdns_server_request *req, void *data) printf(" -- replying for %s (PTR)\n", req->questions[i]->name); r = evdns_server_request_add_ptr_reply(req, NULL, req->questions[i]->name, "foo.bar.example.com", 10); + if (r<0) + printf("ugh, no luck"); } else { printf(" -- skipping %s [%d %d]\n", req->questions[i]->name, req->questions[i]->type, req->questions[i]->dns_question_class); diff --git a/test/bench_httpclient.c b/test/bench_httpclient.c index f0888e6c..87103cc8 100644 --- a/test/bench_httpclient.c +++ b/test/bench_httpclient.c @@ -36,6 +36,7 @@ # endif #endif #include +#include #include #include "event2/event.h" @@ -130,6 +131,8 @@ launch_request(void) struct request_info *ri; + memset(&sin, 0, sizeof(sin)); + ++total_n_launched; sin.sin_family = AF_INET; diff --git a/test/regress_buffer.c b/test/regress_buffer.c index f376f31e..cf68f848 100644 --- a/test/regress_buffer.c +++ b/test/regress_buffer.c @@ -1296,7 +1296,9 @@ test_evbuffer_callbacks(void *ptr) evbuffer_drain(buf_out2, evbuffer_get_length(buf_out2)); /* Let's test the obsolete buffer_setcb function too. */ cb1 = evbuffer_add_cb(buf, log_change_callback, buf_out1); + tt_assert(cb1 != NULL); cb2 = evbuffer_add_cb(buf, log_change_callback, buf_out2); + tt_assert(cb2 != NULL); evbuffer_setcb(buf, self_draining_callback, NULL); evbuffer_add_printf(buf, "This should get drained right away."); tt_uint_op(evbuffer_get_length(buf), ==, 0); diff --git a/test/regress_dns.c b/test/regress_dns.c index 086fd429..7868bbb3 100644 --- a/test/regress_dns.c +++ b/test/regress_dns.c @@ -1626,10 +1626,9 @@ gaic_launch(struct event_base *base, struct evdns_base *dns_base) } static void -test_getaddrinfo_async_cancel_stress(void *arg) +test_getaddrinfo_async_cancel_stress(void *ptr) { - struct basic_test_data *data = arg; - struct event_base *base = data->base; + struct event_base *base; struct evdns_base *dns_base = NULL; struct evdns_server_port *server = NULL; evutil_socket_t fd = -1; @@ -1701,7 +1700,7 @@ struct testcase_t dns_testcases[] = { { "getaddrinfo_async", test_getaddrinfo_async, TT_FORK|TT_NEED_BASE, &basic_setup, (char*)"" }, { "getaddrinfo_cancel_stress", test_getaddrinfo_async_cancel_stress, - TT_FORK|TT_NEED_BASE, &basic_setup, (char*)"" }, + TT_FORK, NULL, NULL }, END_OF_TESTCASES }; diff --git a/test/regress_http.c b/test/regress_http.c index a7a14301..62516b60 100644 --- a/test/regress_http.c +++ b/test/regress_http.c @@ -570,6 +570,8 @@ http_bad_request_test(void *arg) /* real NULL request */ http_request = ""; + bufferevent_write(bev, http_request, strlen(http_request)); + shutdown(fd, SHUT_WR); timerclear(&tv); tv.tv_usec = 10000; diff --git a/test/regress_zlib.c b/test/regress_zlib.c index 158d0d61..12ddcca9 100644 --- a/test/regress_zlib.c +++ b/test/regress_zlib.c @@ -276,6 +276,7 @@ test_bufferevent_zlib(void *arg) tt_int_op(r, ==, Z_OK); memset(&z_input, 0, sizeof(z_input)); r = inflateInit(&z_input); + tt_int_op(r, ==, Z_OK); /* initialize filters */ bev1 = bufferevent_filter_new(bev1, NULL, zlib_output_filter,