From c60b7e984e8907f15439d07e88dad8a23c86cf2b Mon Sep 17 00:00:00 2001 From: "/C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org" Date: Tue, 15 Jan 2008 14:35:06 +0000 Subject: use list_del_init() and list_empty() to check if a node is in the list --- ChangeLog | 1 + src/sync-ftfw.c | 15 +++++++-------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index f42234a..ec32db9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -42,6 +42,7 @@ o wake up the daemon iff there are real events to handle instead of polling o add support for tagged vlan interfaces in the config file, e.g. eth0.1 o improve alarm framework based on suggestions from Max Kellerman o constify queue_iterate() +o use list_del_init() and list_empty() to check if a node is in the list Max Kellermann : diff --git a/src/sync-ftfw.c b/src/sync-ftfw.c index 2d79293..ce58466 100644 --- a/src/sync-ftfw.c +++ b/src/sync-ftfw.c @@ -50,6 +50,7 @@ struct cache_ftfw { static void cache_ftfw_add(struct us_conntrack *u, void *data) { struct cache_ftfw *cn = data; + /* These nodes are not inserted in the list */ INIT_LIST_HEAD(&cn->rs_list); INIT_LIST_HEAD(&cn->tx_list); } @@ -58,10 +59,11 @@ static void cache_ftfw_del(struct us_conntrack *u, void *data) { struct cache_ftfw *cn = data; - if (cn->rs_list.next == &cn->rs_list && - cn->rs_list.prev == &cn->rs_list) + /* this node is already out of the list */ + if (list_empty(&cn->rs_list)) return; + /* no need for list_del_init since the entry is destroyed */ list_del(&cn->rs_list); } @@ -208,8 +210,7 @@ static void rs_list_empty(struct cache *c, unsigned int from, unsigned int to) u = cache_get_conntrack(STATE_SYNC(internal), cn); if (between(cn->seq, from, to)) { dp("queue: deleting from queue (seq=%u)\n", cn->seq); - list_del(&cn->rs_list); - INIT_LIST_HEAD(&cn->rs_list); + list_del_init(&cn->rs_list); } } } @@ -277,8 +278,7 @@ static void ftfw_send(struct nethdr *net, struct us_conntrack *u) cn->rs_list.prev == &cn->rs_list) goto insert; - list_del(&cn->rs_list); - INIT_LIST_HEAD(&cn->rs_list); + list_del_init(&cn->rs_list); insert: cn->seq = net->seq; list_add(&cn->rs_list, &rs_list); @@ -320,8 +320,7 @@ static int tx_list_xmit(struct list_head *i, struct us_conntrack *u) ntohl(net->seq), ntohs(net->flags), ntohs(net->len)); - list_del(i); - INIT_LIST_HEAD(i); + list_del_init(i); tx_list_len--; ret = mcast_buffered_send_netmsg(STATE_SYNC(mcast_client), net, len); -- cgit v1.2.3