Skip to content

Commit d240328

Browse files
committed
Fix even more coverity warnings.
1 parent 860767e commit d240328

File tree

3 files changed

+24
-16
lines changed

3 files changed

+24
-16
lines changed

evrpc.c

+1-2
Original file line numberDiff line numberDiff line change
@@ -492,8 +492,7 @@ evrpc_request_done_closure(void *arg, enum EVRPC_HOOK_RESULT hook_res)
492492
return;
493493

494494
error:
495-
if (rpc_state != NULL)
496-
evrpc_reqstate_free_(rpc_state);
495+
evrpc_reqstate_free_(rpc_state);
497496
evhttp_send_error(req, HTTP_SERVUNAVAIL, NULL);
498497
return;
499498
}

test/regress_buffer.c

+1
Original file line numberDiff line numberDiff line change
@@ -1827,6 +1827,7 @@ test_evbuffer_prepend(void *ptr)
18271827
evbuffer_validate(buf2);
18281828
evbuffer_validate(buf1);
18291829
n = evbuffer_remove(buf2, tmp, sizeof(tmp)-1);
1830+
tt_int_op(n, >=, 0);
18301831
tmp[n]='\0';
18311832
tt_str_op(tmp,==,"Here is string 1000. Here is string 999. ");
18321833

test/regress_http.c

+22-14
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,7 @@ http_bad_request_test(void *arg)
584584
struct basic_test_data *data = arg;
585585
struct timeval tv;
586586
struct bufferevent *bev = NULL;
587-
evutil_socket_t fd;
587+
evutil_socket_t fd = -1;
588588
const char *http_request;
589589
ev_uint16_t port=0, port2=0;
590590

@@ -658,6 +658,8 @@ http_bad_request_test(void *arg)
658658
evhttp_free(http);
659659
if (bev)
660660
bufferevent_free(bev);
661+
if (fd >= 0)
662+
evutil_closesocket(fd);
661663
}
662664

663665
static struct evhttp_connection *delayed_client;
@@ -704,7 +706,7 @@ http_delete_test(void *arg)
704706
{
705707
struct basic_test_data *data = arg;
706708
struct bufferevent *bev;
707-
evutil_socket_t fd;
709+
evutil_socket_t fd = -1;
708710
const char *http_request;
709711
ev_uint16_t port = 0;
710712

@@ -737,7 +739,8 @@ http_delete_test(void *arg)
737739

738740
tt_int_op(test_ok, ==, 2);
739741
end:
740-
;
742+
if (fd >= 0)
743+
evutil_closesocket(fd);
741744
}
742745

743746
static void
@@ -785,7 +788,7 @@ http_on_complete_test(void *arg)
785788
{
786789
struct basic_test_data *data = arg;
787790
struct bufferevent *bev;
788-
evutil_socket_t fd;
791+
evutil_socket_t fd = -1;
789792
const char *http_request;
790793
ev_uint16_t port = 0;
791794

@@ -794,6 +797,7 @@ http_on_complete_test(void *arg)
794797
http = http_setup(&port, data->base, 0);
795798

796799
fd = http_connect("127.0.0.1", port);
800+
tt_int_op(fd, >=, 0);
797801

798802
/* Stupid thing to send a request */
799803
bev = bufferevent_socket_new(data->base, fd, 0);
@@ -811,13 +815,13 @@ http_on_complete_test(void *arg)
811815
event_base_dispatch(data->base);
812816

813817
bufferevent_free(bev);
814-
evutil_closesocket(fd);
815818

816819
evhttp_free(http);
817820

818821
tt_int_op(test_ok, ==, 4);
819822
end:
820-
;
823+
if (fd >= 0)
824+
evutil_closesocket(fd);
821825
}
822826

823827
static void
@@ -844,7 +848,7 @@ http_allowed_methods_test(void *arg)
844848
{
845849
struct basic_test_data *data = arg;
846850
struct bufferevent *bev1, *bev2, *bev3;
847-
evutil_socket_t fd1, fd2, fd3;
851+
evutil_socket_t fd1=-1, fd2=-1, fd3=-1;
848852
const char *http_request;
849853
char *result1=NULL, *result2=NULL, *result3=NULL;
850854
ev_uint16_t port = 0;
@@ -915,9 +919,6 @@ http_allowed_methods_test(void *arg)
915919
bufferevent_free(bev1);
916920
bufferevent_free(bev2);
917921
bufferevent_free(bev3);
918-
evutil_closesocket(fd1);
919-
evutil_closesocket(fd2);
920-
evutil_closesocket(fd3);
921922

922923
evhttp_free(http);
923924

@@ -940,6 +941,12 @@ http_allowed_methods_test(void *arg)
940941
free(result2);
941942
if (result3)
942943
free(result3);
944+
if (fd1 >= 0)
945+
evutil_closesocket(fd1);
946+
if (fd2 >= 0)
947+
evutil_closesocket(fd2);
948+
if (fd3 >= 0)
949+
evutil_closesocket(fd3);
943950
}
944951

945952
static void http_request_done(struct evhttp_request *, void *);
@@ -1851,7 +1858,7 @@ http_failure_test(void *arg)
18511858
{
18521859
struct basic_test_data *data = arg;
18531860
struct bufferevent *bev;
1854-
evutil_socket_t fd;
1861+
evutil_socket_t fd = -1;
18551862
const char *http_request;
18561863
ev_uint16_t port = 0;
18571864

@@ -1874,13 +1881,13 @@ http_failure_test(void *arg)
18741881
event_base_dispatch(data->base);
18751882

18761883
bufferevent_free(bev);
1877-
evutil_closesocket(fd);
18781884

18791885
evhttp_free(http);
18801886

18811887
tt_int_op(test_ok, ==, 2);
18821888
end:
1883-
;
1889+
if (fd >= 0)
1890+
evutil_closesocket(fd);
18841891
}
18851892

18861893
static void
@@ -2749,7 +2756,8 @@ http_incomplete_test_(struct basic_test_data *data, int use_timeout)
27492756

27502757
tt_int_op(test_ok, ==, 2);
27512758
end:
2752-
;
2759+
if (fd >= 0)
2760+
evutil_closesocket(fd);
27532761
}
27542762
static void
27552763
http_incomplete_test(void *arg)

0 commit comments

Comments
 (0)