summaryrefslogtreecommitdiff
path: root/src/alarm.c
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 14:49:12 +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 14:49:12 +0000
commite8c9c3c477d68e10719d829ede6f4cb3087f0efd (patch)
tree5b284e2af115632158b761f698421b19e8f22bed /src/alarm.c
parentc60b7e984e8907f15439d07e88dad8a23c86cf2b (diff)
downloadconntrack-tools-e8c9c3c477d68e10719d829ede6f4cb3087f0efd.tar.gz
conntrack-tools-e8c9c3c477d68e10719d829ede6f4cb3087f0efd.zip
more list_empty() use instead of directly check the header
Diffstat (limited to 'src/alarm.c')
-rw-r--r--src/alarm.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/alarm.c b/src/alarm.c
index 25075ef..0fe80ee 100644
--- a/src/alarm.c
+++ b/src/alarm.c
@@ -31,6 +31,8 @@ void init_alarm(struct alarm_list *t,
void *data,
void (*fcn)(struct alarm_list *a, void *data))
{
+ /* initialize the head to check whether a node is inserted */
+ INIT_LIST_HEAD(&t->head);
timerclear(&t->tv);
t->data = data;
t->function = fcn;
@@ -61,12 +63,14 @@ void add_alarm(struct alarm_list *alarm)
void del_alarm(struct alarm_list *alarm)
{
- list_del(&alarm->head);
+ /* don't remove a non-inserted node */
+ if (!list_empty(&alarm->head))
+ list_del_init(&alarm->head);
}
void mod_alarm(struct alarm_list *alarm, unsigned long sc, unsigned long usc)
{
- list_del(&alarm->head);
+ list_del_init(&alarm->head);
set_alarm_expiration(alarm, sc, usc);
add_alarm(alarm);
}