ctdbd_conn: Fix ctdbd_connection_destructor
authorVolker Lendecke <vl@samba.org>
Fri, 9 Jun 2017 06:41:49 +0000 (08:41 +0200)
committerVolker Lendecke <vl@samba.org>
Sat, 10 Jun 2017 01:33:13 +0000 (03:33 +0200)
clang had complained with

../source3/lib/ctdbd_conn.c:1784:34: warning: variable 'send_state' used in loop condition
      not modified in loop body [-Wfor-loop-analysis]
        for (send_state = c->send_list; send_state != NULL;) {
                                        ^~~~~~~~~~
../source3/lib/ctdbd_conn.c:1791:34: warning: variable 'recv_state' used in loop condition
      not modified in loop body [-Wfor-loop-analysis]
        for (recv_state = c->recv_list; recv_state != NULL;) {
                                        ^~~~~~~~~~

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Sat Jun 10 03:33:13 CEST 2017 on sn-devel-144

source3/lib/ctdbd_conn.c

index fc7b81fc872e5042d4d2ca4e6b28724854f0704a..048e36413dc7b819fa399505c0460a33ca4e38b3 100644 (file)
@@ -1761,9 +1761,6 @@ static int ctdb_pkt_recv_recv(struct tevent_req *req,
 
 static int ctdbd_connection_destructor(struct ctdbd_connection *c)
 {
-       struct ctdb_pkt_recv_state *recv_state = NULL;
-       struct ctdb_pkt_send_state *send_state = NULL;
-
        TALLOC_FREE(c->fde);
        if (c->fd != -1) {
                close(c->fd);
@@ -1773,14 +1770,16 @@ static int ctdbd_connection_destructor(struct ctdbd_connection *c)
        TALLOC_FREE(c->read_state.hdr);
        ZERO_STRUCT(c->read_state);
 
-       for (send_state = c->send_list; send_state != NULL;) {
+       while (c->send_list != NULL) {
+               struct ctdb_pkt_send_state *send_state = c->send_list;
                DLIST_REMOVE(c->send_list, send_state);
                send_state->conn = NULL;
                tevent_req_defer_callback(send_state->req, send_state->ev);
                tevent_req_error(send_state->req, EIO);
        }
 
-       for (recv_state = c->recv_list; recv_state != NULL;) {
+       while (c->recv_list != NULL) {
+               struct ctdb_pkt_recv_state *recv_state = c->recv_list;
                DLIST_REMOVE(c->recv_list, recv_state);
                recv_state->conn = NULL;
                tevent_req_defer_callback(recv_state->req, recv_state->ev);