[NETFILTER]: add some consts, remove some casts
[safe/jmp/linux-2.6] / net / ipv4 / netfilter / ipt_recent.c
index 81f1a01..d03e6a6 100644 (file)
@@ -169,7 +169,7 @@ static void recent_table_flush(struct recent_table *t)
        }
 }
 
-static int
+static bool
 ipt_recent_match(const struct sk_buff *skb,
                 const struct net_device *in, const struct net_device *out,
                 const struct xt_match *match, const void *matchinfo,
@@ -180,7 +180,7 @@ ipt_recent_match(const struct sk_buff *skb,
        struct recent_entry *e;
        __be32 addr;
        u_int8_t ttl;
-       int ret = info->invert;
+       bool ret = info->invert;
 
        if (info->side == IPT_RECENT_DEST)
                addr = ip_hdr(skb)->daddr;
@@ -202,15 +202,15 @@ ipt_recent_match(const struct sk_buff *skb,
                e = recent_entry_init(t, addr, ttl);
                if (e == NULL)
                        *hotdrop = true;
-               ret ^= 1;
+               ret = !ret;
                goto out;
        }
 
        if (info->check_set & IPT_RECENT_SET)
-               ret ^= 1;
+               ret = !ret;
        else if (info->check_set & IPT_RECENT_REMOVE) {
                recent_entry_remove(t, e);
-               ret ^= 1;
+               ret = !ret;
        } else if (info->check_set & (IPT_RECENT_CHECK | IPT_RECENT_UPDATE)) {
                unsigned long t = jiffies - info->seconds * HZ;
                unsigned int i, hits = 0;
@@ -219,7 +219,7 @@ ipt_recent_match(const struct sk_buff *skb,
                        if (info->seconds && time_after(t, e->stamps[i]))
                                continue;
                        if (++hits >= info->hit_count) {
-                               ret ^= 1;
+                               ret = !ret;
                                break;
                        }
                }
@@ -235,7 +235,7 @@ out:
        return ret;
 }
 
-static int
+static bool
 ipt_recent_checkentry(const char *tablename, const void *ip,
                      const struct xt_match *match, void *matchinfo,
                      unsigned int hook_mask)
@@ -243,24 +243,24 @@ ipt_recent_checkentry(const char *tablename, const void *ip,
        const struct ipt_recent_info *info = matchinfo;
        struct recent_table *t;
        unsigned i;
-       int ret = 0;
+       bool ret = false;
 
        if (hweight8(info->check_set &
                     (IPT_RECENT_SET | IPT_RECENT_REMOVE |
                      IPT_RECENT_CHECK | IPT_RECENT_UPDATE)) != 1)
-               return 0;
+               return false;
        if ((info->check_set & (IPT_RECENT_SET | IPT_RECENT_REMOVE)) &&
            (info->seconds || info->hit_count))
-               return 0;
+               return false;
        if (info->name[0] == '\0' ||
            strnlen(info->name, IPT_RECENT_NAME_LEN) == IPT_RECENT_NAME_LEN)
-               return 0;
+               return false;
 
        mutex_lock(&recent_mutex);
        t = recent_table_lookup(info->name);
        if (t != NULL) {
                t->refcnt++;
-               ret = 1;
+               ret = true;
                goto out;
        }
 
@@ -287,7 +287,7 @@ ipt_recent_checkentry(const char *tablename, const void *ip,
        spin_lock_bh(&recent_lock);
        list_add_tail(&t->list, &tables);
        spin_unlock_bh(&recent_lock);
-       ret = 1;
+       ret = true;
 out:
        mutex_unlock(&recent_mutex);
        return ret;
@@ -323,7 +323,7 @@ struct recent_iter_state {
 static void *recent_seq_start(struct seq_file *seq, loff_t *pos)
 {
        struct recent_iter_state *st = seq->private;
-       struct recent_table *t = st->table;
+       const struct recent_table *t = st->table;
        struct recent_entry *e;
        loff_t p = *pos;