summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author/C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org </C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org>2008-01-15 12:50:37 +0000
committer/C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org </C=EU/ST=EU/CN=Pablo Neira Ayuso/emailAddress=pablo@netfilter.org>2008-01-15 12:50:37 +0000
commitb861a707522e8625b4a5b4145b97a8825037572f (patch)
tree99c8e48bc690579af3177a6fb4f375f464dfa0bc
parent41f3e135db165fff931a07ef79e7731037d22941 (diff)
downloadconntrack-tools-b861a707522e8625b4a5b4145b97a8825037572f.tar.gz
conntrack-tools-b861a707522e8625b4a5b4145b97a8825037572f.zip
Max Kellermann <max@duempel.org>
Use list_for_each_entry() instead of list_for_each()
-rw-r--r--ChangeLog1
-rw-r--r--src/alarm.c16
-rw-r--r--src/conntrack.c4
-rw-r--r--src/sync-ftfw.c19
4 files changed, 13 insertions, 27 deletions
diff --git a/ChangeLog b/ChangeLog
index aea2a00..dcbe694 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -46,6 +46,7 @@ Max Kellermann <max@duempel.org>:
= conntrackd =
o resolve global variable "alarm" conflict with alarm() function in unistd.h.
o enable gcc warnings, including -Werror
+o use list_for_each_entry() instead of list_for_each()
version 0.9.5 (2007/07/29)
------------------------------
diff --git a/src/alarm.c b/src/alarm.c
index a64c37a..8d3ae48 100644
--- a/src/alarm.c
+++ b/src/alarm.c
@@ -48,12 +48,9 @@ void init_alarm(struct alarm_list *t)
void __add_alarm(struct alarm_list *alarm)
{
- struct list_head *i;
struct alarm_list *t;
- list_for_each(i, &alarm_list) {
- t = (struct alarm_list *) i;
-
+ list_for_each_entry(t, &alarm_list, head) {
if (timercmp(&alarm->tv, &t->tv, <)) {
list_add_tail(&alarm->head, &t->head);
return;
@@ -89,11 +86,9 @@ void mod_alarm(struct alarm_list *alarm, unsigned long sc, unsigned long usc)
int get_next_alarm(struct timeval *tv, struct timeval *next_alarm)
{
- struct list_head *i;
struct alarm_list *t;
- list_for_each(i, &alarm_list) {
- t = (struct alarm_list *) i;
+ list_for_each_entry(t, &alarm_list, head) {
timersub(&t->tv, tv, next_alarm);
return 1;
}
@@ -102,15 +97,12 @@ int get_next_alarm(struct timeval *tv, struct timeval *next_alarm)
int do_alarm_run(struct timeval *next_alarm)
{
- struct list_head *i, *tmp;
- struct alarm_list *t;
+ struct alarm_list *t, *tmp;
struct timeval tv;
gettimeofday(&tv, NULL);
- list_for_each_safe(i, tmp, &alarm_list) {
- t = (struct alarm_list *) i;
-
+ list_for_each_entry_safe(t, tmp, &alarm_list, head) {
if (timercmp(&t->tv, &tv, >)) {
timersub(&t->tv, &tv, next_alarm);
return 1;
diff --git a/src/conntrack.c b/src/conntrack.c
index 20d86f9..4f5fd0b 100644
--- a/src/conntrack.c
+++ b/src/conntrack.c
@@ -161,14 +161,12 @@ void register_proto(struct ctproto_handler *h)
static struct ctproto_handler *findproto(char *name)
{
- struct list_head *i;
struct ctproto_handler *cur = NULL, *handler = NULL;
if (!name)
return handler;
- list_for_each(i, &proto_list) {
- cur = (struct ctproto_handler *) i;
+ list_for_each_entry(cur, &proto_list, head) {
if (strcmp(cur->name, name) == 0) {
handler = cur;
break;
diff --git a/src/sync-ftfw.c b/src/sync-ftfw.c
index 23095c4..8452e2e 100644
--- a/src/sync-ftfw.c
+++ b/src/sync-ftfw.c
@@ -185,11 +185,9 @@ static int rs_queue_empty(void *data1, void *data2)
static void rs_list_to_tx(struct cache *c, unsigned int from, unsigned int to)
{
- struct list_head *n;
- struct us_conntrack *u;
+ struct cache_ftfw *cn;
- list_for_each(n, &rs_list) {
- struct cache_ftfw *cn = (struct cache_ftfw *) n;
+ list_for_each_entry(cn, &rs_list, rs_list) {
struct us_conntrack *u;
u = cache_get_conntrack(STATE_SYNC(internal), cn);
@@ -203,10 +201,9 @@ static void rs_list_to_tx(struct cache *c, unsigned int from, unsigned int to)
static void rs_list_empty(struct cache *c, unsigned int from, unsigned int to)
{
- struct list_head *n, *tmp;
+ struct cache_ftfw *cn, *tmp;
- list_for_each_safe(n, tmp, &rs_list) {
- struct cache_ftfw *cn = (struct cache_ftfw *) n;
+ list_for_each_entry_safe(cn, tmp, &rs_list, rs_list) {
struct us_conntrack *u;
u = cache_get_conntrack(STATE_SYNC(internal), cn);
@@ -337,19 +334,17 @@ static int tx_list_xmit(struct list_head *i, struct us_conntrack *u)
static void ftfw_run()
{
- struct list_head *i, *tmp;
+ struct cache_ftfw *cn, *tmp;
/* send messages in the tx_queue */
queue_iterate(tx_queue, NULL, tx_queue_xmit);
/* send conntracks in the tx_list */
- list_for_each_safe(i, tmp, &tx_list) {
- struct cache_ftfw *cn;
+ list_for_each_entry_safe(cn, tmp, &tx_list, tx_list) {
struct us_conntrack *u;
- cn = container_of(i, struct cache_ftfw, tx_list);
u = cache_get_conntrack(STATE_SYNC(internal), cn);
- tx_list_xmit(i, u);
+ tx_list_xmit(&cn->tx_list, u);
}
mod_alarm(&alive_alarm, 1, 0);