diff --git a/configure.in b/configure.in index f1972bf6..89494b4d 100644 --- a/configure.in +++ b/configure.in @@ -216,11 +216,13 @@ AC_CHECK_HEADERS([ \ sys/select.h \ sys/sendfile.h \ sys/socket.h \ + sys/stat.h \ sys/time.h \ sys/timerfd.h \ sys/uio.h \ sys/wait.h \ ]) + AC_CHECK_HEADERS(sys/sysctl.h, [], [], [ #ifdef HAVE_SYS_PARAM_H #include @@ -354,6 +356,7 @@ AC_CHECK_FUNCS([ \ strtoll \ sysctl \ timerfd_create \ + umask \ unsetenv \ usleep \ vasprintf \ diff --git a/test/regress.c b/test/regress.c index 0ab93a98..cd7e7465 100644 --- a/test/regress.c +++ b/test/regress.c @@ -2274,6 +2274,10 @@ test_event_pending(void *ptr) NULL); t = evtimer_new(data->base, timeout_cb, NULL); + tt_assert(r); + tt_assert(w); + tt_assert(t); + evutil_gettimeofday(&now, NULL); event_add(r, NULL); event_add(t, &tv); @@ -2371,7 +2375,8 @@ end: event_free(ev1); if (ev2) event_free(ev2); - close(dfd); + if (dfd >= 0) + close(dfd); } #endif diff --git a/test/regress_buffer.c b/test/regress_buffer.c index d94a8b37..365b0c37 100644 --- a/test/regress_buffer.c +++ b/test/regress_buffer.c @@ -1232,6 +1232,8 @@ test_evbuffer_find(void *ptr) unsigned int i; struct evbuffer * buf = evbuffer_new(); + tt_assert(buf); + /* make sure evbuffer_find doesn't match past the end of the buffer */ evbuffer_add(buf, (u_char*)test1, strlen(test1)); evbuffer_validate(buf); @@ -1273,6 +1275,8 @@ test_evbuffer_ptr_set(void *ptr) struct evbuffer_ptr pos; struct evbuffer_iovec v[1]; + tt_assert(buf); + tt_int_op(evbuffer_get_length(buf), ==, 0); tt_assert(evbuffer_ptr_set(buf, &pos, 0, EVBUFFER_PTR_SET) == 0); @@ -1331,6 +1335,9 @@ test_evbuffer_search(void *ptr) struct evbuffer *tmp = evbuffer_new(); struct evbuffer_ptr pos, end; + tt_assert(buf); + tt_assert(tmp); + pos = evbuffer_search(buf, "x", 1, NULL); tt_int_op(pos.pos, ==, -1); tt_assert(evbuffer_ptr_set(buf, &pos, 0, EVBUFFER_PTR_SET) == 0); @@ -1436,6 +1443,10 @@ test_evbuffer_callbacks(void *ptr) struct evbuffer *buf_out2 = evbuffer_new(); struct evbuffer_cb_entry *cb1, *cb2; + tt_assert(buf); + tt_assert(buf_out1); + tt_assert(buf_out2); + cb1 = evbuffer_add_cb(buf, log_change_callback, buf_out1); cb2 = evbuffer_add_cb(buf, log_change_callback, buf_out2); diff --git a/test/regress_bufferevent.c b/test/regress_bufferevent.c index 06b8831f..335ed44d 100644 --- a/test/regress_bufferevent.c +++ b/test/regress_bufferevent.c @@ -256,6 +256,8 @@ test_bufferevent_watermarks_impl(int use_pair) bev1 = bufferevent_new(pair[0], NULL, wm_writecb, wm_errorcb, NULL); bev2 = bufferevent_new(pair[1], wm_readcb, NULL, wm_errorcb, NULL); } + tt_assert(bev1); + tt_assert(bev2); bufferevent_disable(bev1, EV_READ); bufferevent_enable(bev2, EV_READ); @@ -280,8 +282,10 @@ test_bufferevent_watermarks_impl(int use_pair) tt_assert(!event_pending(&bev2->ev_write, EV_WRITE, NULL)); end: - bufferevent_free(bev1); - bufferevent_free(bev2); + if (bev1) + bufferevent_free(bev1); + if (bev2) + bufferevent_free(bev2); } static void @@ -390,8 +394,10 @@ test_bufferevent_filters_impl(int use_pair) test_ok = 0; end: - bufferevent_free(bev1); - bufferevent_free(bev2); + if (bev1) + bufferevent_free(bev1); + if (bev2) + bufferevent_free(bev2); } diff --git a/test/regress_dns.c b/test/regress_dns.c index 8f853253..cfb32552 100644 --- a/test/regress_dns.c +++ b/test/regress_dns.c @@ -1070,6 +1070,7 @@ test_bufferevent_connect_hostname(void *arg) &n_accept, LEV_OPT_REUSEABLE|LEV_OPT_CLOSE_ON_EXEC, -1, (struct sockaddr *)&sin, sizeof(sin)); + tt_assert(listener); listener_port = regress_get_socket_port( evconnlistener_get_fd(listener)); @@ -1215,6 +1216,7 @@ test_getaddrinfo_async(void *arg) int n_dns_questions = 0; struct evdns_base *dns_base = evdns_base_new(data->base, 0); + tt_assert(dns_base); /* for localhost */ evdns_base_load_hosts(dns_base, NULL); @@ -1712,6 +1714,7 @@ testleak_cleanup(const struct testcase_t *testcase, void *env_) { int ok = 0; struct testleak_env_t *env = env_; + tt_assert(env); #ifdef EVENT__DISABLE_DEBUG_MODE tt_int_op(allocated_chunks, ==, 0); #else @@ -1720,12 +1723,13 @@ testleak_cleanup(const struct testcase_t *testcase, void *env_) #endif ok = 1; end: - if (env->dns_base) - evdns_base_free(env->dns_base, 0); - if (env->base) - event_base_free(env->base); - if (env) + if (env) { + if (env->dns_base) + evdns_base_free(env->dns_base, 0); + if (env->base) + event_base_free(env->base); free(env); + } return ok; } diff --git a/test/regress_et.c b/test/regress_et.c index 74dc4b7d..7f700cf3 100644 --- a/test/regress_et.c +++ b/test/regress_et.c @@ -173,7 +173,9 @@ test_edgetriggered_mix_error(void *data_) /* try mixing edge-triggered and level-triggered to make sure it fails*/ ev_et = event_new(base, data->pair[0], EV_READ|EV_ET, read_cb, ev_et); + tt_assert(ev_et); ev_lt = event_new(base, data->pair[0], EV_READ, read_cb, ev_lt); + tt_assert(ev_lt); /* Add edge-triggered, then level-triggered. Get an error. */ tt_int_op(0, ==, event_add(ev_et, NULL)); diff --git a/test/regress_http.c b/test/regress_http.c index ad6acbb9..cc755de2 100644 --- a/test/regress_http.c +++ b/test/regress_http.c @@ -2665,9 +2665,11 @@ http_chunked_errorcb(struct bufferevent *bev, short what, void *arg) if (header == NULL) goto out; /* 13 chars */ - if (strcmp(header, "d")) + if (strcmp(header, "d")) { + free((void*)header); goto out; - free((char*)header); + } + free((void*)header); if (strncmp((char *)evbuffer_pullup(bufferevent_get_input(bev), 13), "This is funny", 13)) @@ -2693,8 +2695,10 @@ http_chunked_errorcb(struct bufferevent *bev, short what, void *arg) if (header == NULL) goto out; /* 8 chars */ - if (strcmp(header, "8")) + if (strcmp(header, "8")) { + free((void*)header); goto out; + } free((char *)header); if (strncmp((char *)evbuffer_pullup(bufferevent_get_input(bev), 8), @@ -2707,9 +2711,11 @@ http_chunked_errorcb(struct bufferevent *bev, short what, void *arg) if (header == NULL) goto out; /* 0 chars */ - if (strcmp(header, "0")) + if (strcmp(header, "0")) { + free((void*)header); goto out; - free((char *)header); + } + free((void *)header); test_ok = 2; @@ -3220,26 +3226,30 @@ static void http_primitives(void *ptr) { char *escaped = NULL; - struct evhttp *http; + struct evhttp *http = NULL; escaped = evhttp_htmlescape("