]> granicus.if.org Git - ipset/commitdiff
Fix coding styles reported by the most recent checkpatch.pl.
authorJozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Fri, 17 Apr 2015 18:39:34 +0000 (20:39 +0200)
committerJozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Fri, 17 Apr 2015 18:39:34 +0000 (20:39 +0200)
16 files changed:
configure.ac
kernel/include/linux/netfilter/ipset/ip_set_compat.h.in
kernel/net/netfilter/ipset/ip_set_bitmap_ip.c
kernel/net/netfilter/ipset/ip_set_bitmap_ipmac.c
kernel/net/netfilter/ipset/ip_set_core.c
kernel/net/netfilter/ipset/ip_set_getport.c
kernel/net/netfilter/ipset/ip_set_hash_gen.h
kernel/net/netfilter/ipset/ip_set_hash_ip.c
kernel/net/netfilter/ipset/ip_set_hash_ipmark.c
kernel/net/netfilter/ipset/ip_set_hash_ipport.c
kernel/net/netfilter/ipset/ip_set_hash_ipportip.c
kernel/net/netfilter/ipset/ip_set_hash_ipportnet.c
kernel/net/netfilter/ipset/ip_set_hash_mac.c
kernel/net/netfilter/ipset/ip_set_hash_netnet.c
kernel/net/netfilter/ipset/ip_set_list_set.c
kernel/net/netfilter/xt_set.c

index 0e9d054e28a798e79b688ebb695968f366212feb..a6b86a95321e3000b1a747caf4e2401d1ed9c128 100644 (file)
@@ -396,6 +396,16 @@ else
        AC_SUBST(HAVE_LIST_NEXT_ENTRY, undef)
 fi
 
+AC_MSG_CHECKING([kernel source for ether_addr_copy])
+if test -f $ksourcedir/include/linux/etherdevice.h && \
+   $GREP -q 'ether_addr_copy' $ksourcedir/include/linux/etherdevice.h; then
+       AC_MSG_RESULT(yes)
+       AC_SUBST(HAVE_ETHER_ADDR_COPY, define)
+else
+       AC_MSG_RESULT(no)
+       AC_SUBST(HAVE_ETHER_ADDR_COPY, undef)
+fi
+
 AC_MSG_CHECKING([kernel source for struct net_generic])
 if test -f $ksourcedir/include/net/netns/generic.h && \
    $GREP -q 'struct net_generic' $ksourcedir/include/net/netns/generic.h; then
index a0a74365bdd2436a761d152b43d48b2c63ff4edc..5938d8f5b5aa8269491b581cf81eaa07a61885e2 100644 (file)
@@ -42,6 +42,7 @@
 #@HAVE_TCF_EMATCH_STRUCT_NET@ HAVE_TCF_EMATCH_STRUCT_NET
 #@HAVE_LIST_LAST_ENTRY@ HAVE_LIST_LAST_ENTRY
 #@HAVE_LIST_NEXT_ENTRY@ HAVE_LIST_NEXT_ENTRY
+#@HAVE_ETHER_ADDR_COPY@ HAVE_ETHER_ADDR_COPY
 
 /* Not everything could be moved here. Compatibility stuffs can be found in
  * xt_set.c, ip_set_core.c, ip_set_getport.c, pfxlen.c too.
@@ -204,6 +205,10 @@ static inline int nla_put_net32(struct sk_buff *skb, int attrtype, __be32 value)
        list_entry((pos)->member.prev, typeof(*(pos)), member)
 #endif
 
+#ifndef HAVE_ETHER_ADDR_COPY
+#define ether_addr_copy(dst, src)      memcpy(dst, src, ETH_ALEN)
+#endif
+
 #ifndef smp_mb__before_atomic
 #define smp_mb__before_atomic()        smp_mb()
 #define smp_mb__after_atomic() smp_mb()
index 1f4a20bf5dd7cdc92ce28a57f26e065dc178a398..8d15aa39092f45da3767f10d0fbc3f5bd5e7598c 100644 (file)
@@ -59,7 +59,7 @@ struct bitmap_ip_adt_elem {
 static inline u32
 ip_to_id(const struct bitmap_ip *m, u32 ip)
 {
-       return ((ip & ip_set_hostmask(m->netmask)) - m->first_ip)/m->hosts;
+       return ((ip & ip_set_hostmask(m->netmask)) - m->first_ip) / m->hosts;
 }
 
 /* Common functions */
index 3e60d3fa20dbebfa8d0b23e8bd4a36112805c32c..d350cf15cb5b2ed16b8c4bf0371fc1a4eea175fd 100644 (file)
@@ -64,7 +64,7 @@ struct bitmap_ipmac_adt_elem {
 struct bitmap_ipmac_elem {
        unsigned char ether[ETH_ALEN];
        unsigned char filled;
-} __attribute__ ((aligned));
+} __aligned(8);
 
 static inline u32
 ip_to_id(const struct bitmap_ipmac *m, u32 ip)
@@ -90,7 +90,7 @@ bitmap_ipmac_do_test(const struct bitmap_ipmac_adt_elem *e,
                return 0;
        elem = get_elem(map->extensions, e->id, dsize);
        if (elem->filled == MAC_FILLED)
-               return e->ether == NULL ||
+               return !e->ether ||
                       ether_addr_equal(e->ether, elem->ether);
        /* Trigger kernel to fill out the ethernet address */
        return -EAGAIN;
@@ -156,7 +156,7 @@ bitmap_ipmac_do_add(const struct bitmap_ipmac_adt_elem *e,
                                /* memcpy isn't atomic */
                                clear_bit(e->id, map->members);
                                smp_mb__after_atomic();
-                               memcpy(elem->ether, e->ether, ETH_ALEN);
+                               ether_addr_copy(elem->ether, e->ether);
                        }
                        return IPSET_ADD_FAILED;
                } else if (!e->ether)
@@ -165,19 +165,18 @@ bitmap_ipmac_do_add(const struct bitmap_ipmac_adt_elem *e,
                /* Fill the MAC address and trigger the timer activation */
                clear_bit(e->id, map->members);
                smp_mb__after_atomic();
-               memcpy(elem->ether, e->ether, ETH_ALEN);
+               ether_addr_copy(elem->ether, e->ether);
                elem->filled = MAC_FILLED;
                return IPSET_ADD_START_STORED_TIMEOUT;
        } else if (e->ether) {
                /* We can store MAC too */
-               memcpy(elem->ether, e->ether, ETH_ALEN);
+               ether_addr_copy(elem->ether, e->ether);
                elem->filled = MAC_FILLED;
                return 0;
-       } else {
-               elem->filled = MAC_UNSET;
-               /* MAC is not stored yet, don't start timer */
-               return IPSET_ADD_STORE_PLAIN_TIMEOUT;
        }
+       elem->filled = MAC_UNSET;
+       /* MAC is not stored yet, don't start timer */
+       return IPSET_ADD_STORE_PLAIN_TIMEOUT;
 }
 
 static inline int
index 5319896b0d8a93690408d3372773ae1a512ece5c..b22da001e6a8fcc0204d494da307a33693432b45 100644 (file)
@@ -296,7 +296,7 @@ static const struct nla_policy ipaddr_policy[IPSET_ATTR_IPADDR_MAX + 1] = {
 int
 ip_set_get_ipaddr4(struct nlattr *nla,  __be32 *ipaddr)
 {
-       struct nlattr *tb[IPSET_ATTR_IPADDR_MAX+1];
+       struct nlattr *tb[IPSET_ATTR_IPADDR_MAX + 1];
 
        if (unlikely(!flag_nested(nla)))
                return -IPSET_ERR_PROTOCOL;
@@ -313,7 +313,7 @@ EXPORT_SYMBOL_GPL(ip_set_get_ipaddr4);
 int
 ip_set_get_ipaddr6(struct nlattr *nla, union nf_inet_addr *ipaddr)
 {
-       struct nlattr *tb[IPSET_ATTR_IPADDR_MAX+1];
+       struct nlattr *tb[IPSET_ATTR_IPADDR_MAX + 1];
 
        if (unlikely(!flag_nested(nla)))
                return -IPSET_ERR_PROTOCOL;
@@ -389,7 +389,6 @@ ip_set_elem_len(struct ip_set *set, struct nlattr *tb[], size_t len)
        }
        return offset;
 }
-
 EXPORT_SYMBOL_GPL(ip_set_elem_len);
 
 int
@@ -504,7 +503,7 @@ ip_set_test(ip_set_id_t index, const struct sk_buff *skb,
                        dev_net(par->in ? par->in : par->out), index);
        int ret = 0;
 
-       BUG_ON(set == NULL);
+       BUG_ON(!set);
        pr_debug("set %s, index %u\n", set->name, index);
 
        if (opt->dim < set->type->dimension ||
@@ -543,7 +542,7 @@ ip_set_add(ip_set_id_t index, const struct sk_buff *skb,
                        dev_net(par->in ? par->in : par->out), index);
        int ret;
 
-       BUG_ON(set == NULL);
+       BUG_ON(!set);
        pr_debug("set %s, index %u\n", set->name, index);
 
        if (opt->dim < set->type->dimension ||
@@ -566,7 +565,7 @@ ip_set_del(ip_set_id_t index, const struct sk_buff *skb,
                        dev_net(par->in ? par->in : par->out), index);
        int ret = 0;
 
-       BUG_ON(set == NULL);
+       BUG_ON(!set);
        pr_debug("set %s, index %u\n", set->name, index);
 
        if (opt->dim < set->type->dimension ||
@@ -595,7 +594,7 @@ ip_set_get_byname(struct net *net, const char *name, struct ip_set **set)
        rcu_read_lock();
        for (i = 0; i < inst->ip_set_max; i++) {
                s = rcu_dereference(inst->ip_set_list)[i];
-               if (s != NULL && STRNCMP(s->name, name)) {
+               if (s && STRNCMP(s->name, name)) {
                        __ip_set_get(s);
                        index = i;
                        *set = s;
@@ -621,7 +620,7 @@ __ip_set_put_byindex(struct ip_set_net *inst, ip_set_id_t index)
 
        rcu_read_lock();
        set = rcu_dereference(inst->ip_set_list)[index];
-       if (set != NULL)
+       if (set)
                __ip_set_put(set);
        rcu_read_unlock();
 }
@@ -646,7 +645,7 @@ ip_set_name_byindex(struct net *net, ip_set_id_t index)
 {
        const struct ip_set *set = ip_set_rcu_get(net, index);
 
-       BUG_ON(set == NULL);
+       BUG_ON(!set);
        BUG_ON(set->ref == 0);
 
        /* Referenced, so it's safe */
@@ -699,7 +698,7 @@ ip_set_nfnl_put(struct net *net, ip_set_id_t index)
        nfnl_lock(NFNL_SUBSYS_IPSET);
        if (!inst->is_deleted) { /* already deleted from ip_set_net_exit() */
                set = ip_set(inst, index);
-               if (set != NULL)
+               if (set)
                        __ip_set_put(set);
        }
        nfnl_unlock(NFNL_SUBSYS_IPSET);
@@ -733,7 +732,7 @@ start_msg(struct sk_buff *skb, u32 portid, u32 seq, unsigned int flags,
 
        nlh = nlmsg_put(skb, portid, seq, cmd | (NFNL_SUBSYS_IPSET << 8),
                        sizeof(*nfmsg), flags);
-       if (nlh == NULL)
+       if (!nlh)
                return NULL;
 
        nfmsg = nlmsg_data(nlh);
@@ -766,7 +765,7 @@ find_set_and_id(struct ip_set_net *inst, const char *name, ip_set_id_t *id)
        *id = IPSET_INVALID_ID;
        for (i = 0; i < inst->ip_set_max; i++) {
                set = ip_set(inst, i);
-               if (set != NULL && STRNCMP(set->name, name)) {
+               if (set && STRNCMP(set->name, name)) {
                        *id = i;
                        break;
                }
@@ -792,7 +791,7 @@ find_free_id(struct ip_set_net *inst, const char *name, ip_set_id_t *index,
        *index = IPSET_INVALID_ID;
        for (i = 0;  i < inst->ip_set_max; i++) {
                s = ip_set(inst, i);
-               if (s == NULL) {
+               if (!s) {
                        if (*index == IPSET_INVALID_ID)
                                *index = i;
                } else if (STRNCMP(name, s->name)) {
@@ -824,18 +823,18 @@ ip_set_create(struct sock *ctnl, struct sk_buff *skb,
        struct ip_set_net *inst = ip_set_pernet(net);
        struct ip_set *set, *clash = NULL;
        ip_set_id_t index = IPSET_INVALID_ID;
-       struct nlattr *tb[IPSET_ATTR_CREATE_MAX+1] = {};
+       struct nlattr *tb[IPSET_ATTR_CREATE_MAX + 1] = {};
        const char *name, *typename;
        u8 family, revision;
        u32 flags = flag_exist(nlh);
        int ret = 0;
 
        if (unlikely(protocol_failed(attr) ||
-                    attr[IPSET_ATTR_SETNAME] == NULL ||
-                    attr[IPSET_ATTR_TYPENAME] == NULL ||
-                    attr[IPSET_ATTR_REVISION] == NULL ||
-                    attr[IPSET_ATTR_FAMILY] == NULL ||
-                    (attr[IPSET_ATTR_DATA] != NULL &&
+                    !attr[IPSET_ATTR_SETNAME] ||
+                    !attr[IPSET_ATTR_TYPENAME] ||
+                    !attr[IPSET_ATTR_REVISION] ||
+                    !attr[IPSET_ATTR_FAMILY] ||
+                    (attr[IPSET_ATTR_DATA] &&
                      !flag_nested(attr[IPSET_ATTR_DATA]))))
                return -IPSET_ERR_PROTOCOL;
 
@@ -988,7 +987,7 @@ ip_set_destroy(struct sock *ctnl, struct sk_buff *skb,
        if (!attr[IPSET_ATTR_SETNAME]) {
                for (i = 0; i < inst->ip_set_max; i++) {
                        s = ip_set(inst, i);
-                       if (s != NULL && s->ref) {
+                       if (s && s->ref) {
                                ret = -IPSET_ERR_BUSY;
                                goto out;
                        }
@@ -997,7 +996,7 @@ ip_set_destroy(struct sock *ctnl, struct sk_buff *skb,
                read_unlock_bh(&ip_set_ref_lock);
                for (i = 0; i < inst->ip_set_max; i++) {
                        s = ip_set(inst, i);
-                       if (s != NULL)
+                       if (s)
                                ip_set_destroy_set(inst, i);
                }
                /* Modified by ip_set_destroy() only, which is serialized */
@@ -1005,7 +1004,7 @@ ip_set_destroy(struct sock *ctnl, struct sk_buff *skb,
        } else {
                s = find_set_and_id(inst, nla_data(attr[IPSET_ATTR_SETNAME]),
                                    &i);
-               if (s == NULL) {
+               if (!s) {
                        ret = -ENOENT;
                        goto out;
                } else if (s->ref) {
@@ -1049,12 +1048,12 @@ ip_set_flush(struct sock *ctnl, struct sk_buff *skb,
        if (!attr[IPSET_ATTR_SETNAME]) {
                for (i = 0; i < inst->ip_set_max; i++) {
                        s = ip_set(inst, i);
-                       if (s != NULL)
+                       if (s)
                                ip_set_flush_set(s);
                }
        } else {
                s = find_set(inst, nla_data(attr[IPSET_ATTR_SETNAME]));
-               if (s == NULL)
+               if (!s)
                        return -ENOENT;
 
                ip_set_flush_set(s);
@@ -1086,12 +1085,12 @@ ip_set_rename(struct sock *ctnl, struct sk_buff *skb,
        int ret = 0;
 
        if (unlikely(protocol_failed(attr) ||
-                    attr[IPSET_ATTR_SETNAME] == NULL ||
-                    attr[IPSET_ATTR_SETNAME2] == NULL))
+                    !attr[IPSET_ATTR_SETNAME] ||
+                    !attr[IPSET_ATTR_SETNAME2]))
                return -IPSET_ERR_PROTOCOL;
 
        set = find_set(inst, nla_data(attr[IPSET_ATTR_SETNAME]));
-       if (set == NULL)
+       if (!set)
                return -ENOENT;
 
        read_lock_bh(&ip_set_ref_lock);
@@ -1103,7 +1102,7 @@ ip_set_rename(struct sock *ctnl, struct sk_buff *skb,
        name2 = nla_data(attr[IPSET_ATTR_SETNAME2]);
        for (i = 0; i < inst->ip_set_max; i++) {
                s = ip_set(inst, i);
-               if (s != NULL && STRNCMP(s->name, name2)) {
+               if (s && STRNCMP(s->name, name2)) {
                        ret = -IPSET_ERR_EXIST_SETNAME2;
                        goto out;
                }
@@ -1135,18 +1134,18 @@ ip_set_swap(struct sock *ctnl, struct sk_buff *skb,
        char from_name[IPSET_MAXNAMELEN];
 
        if (unlikely(protocol_failed(attr) ||
-                    attr[IPSET_ATTR_SETNAME] == NULL ||
-                    attr[IPSET_ATTR_SETNAME2] == NULL))
+                    !attr[IPSET_ATTR_SETNAME] ||
+                    !attr[IPSET_ATTR_SETNAME2]))
                return -IPSET_ERR_PROTOCOL;
 
        from = find_set_and_id(inst, nla_data(attr[IPSET_ATTR_SETNAME]),
                               &from_id);
-       if (from == NULL)
+       if (!from)
                return -ENOENT;
 
        to = find_set_and_id(inst, nla_data(attr[IPSET_ATTR_SETNAME2]),
                             &to_id);
-       if (to == NULL)
+       if (!to)
                return -IPSET_ERR_EXIST_SETNAME2;
 
        /* Features must not change.
@@ -1214,7 +1213,7 @@ dump_init(struct netlink_callback *cb, struct ip_set_net *inst)
 {
        struct nlmsghdr *nlh = nlmsg_hdr(cb->skb);
        int min_len = nlmsg_total_size(sizeof(struct nfgenmsg));
-       struct nlattr *cda[IPSET_ATTR_CMD_MAX+1];
+       struct nlattr *cda[IPSET_ATTR_CMD_MAX + 1];
        struct nlattr *attr = (void *)nlh + min_len;
        u32 dump_type;
        ip_set_id_t index;
@@ -1228,7 +1227,7 @@ dump_init(struct netlink_callback *cb, struct ip_set_net *inst)
 
                set = find_set_and_id(inst, nla_data(cda[IPSET_ATTR_SETNAME]),
                                      &index);
-               if (set == NULL)
+               if (!set)
                        return -ENOENT;
 
                dump_type = DUMP_ONE;
@@ -1288,7 +1287,7 @@ dump_last:
                write_lock_bh(&ip_set_ref_lock);
                set = ip_set(inst, index);
                is_destroyed = inst->is_destroyed;
-               if (set == NULL || is_destroyed) {
+               if (!set || is_destroyed) {
                        write_unlock_bh(&ip_set_ref_lock);
                        if (dump_type == DUMP_ONE) {
                                ret = -ENOENT;
@@ -1461,12 +1460,12 @@ call_ad(struct sock *ctnl, struct sk_buff *skb, struct ip_set *set,
                size_t payload = min(SIZE_MAX,
                                     sizeof(*errmsg) + nlmsg_len(nlh));
                int min_len = nlmsg_total_size(sizeof(struct nfgenmsg));
-               struct nlattr *cda[IPSET_ATTR_CMD_MAX+1];
+               struct nlattr *cda[IPSET_ATTR_CMD_MAX + 1];
                struct nlattr *cmdattr;
                u32 *errline;
 
                skb2 = nlmsg_new(payload, GFP_KERNEL);
-               if (skb2 == NULL)
+               if (!skb2)
                        return -ENOMEM;
                rep = __nlmsg_put(skb2, NETLINK_PORTID(skb),
                                  nlh->nlmsg_seq, NLMSG_ERROR, payload, 0);
@@ -1483,7 +1482,8 @@ call_ad(struct sock *ctnl, struct sk_buff *skb, struct ip_set *set,
 
                *errline = lineno;
 
-               netlink_unicast(ctnl, skb2, NETLINK_PORTID(skb), MSG_DONTWAIT);
+               netlink_unicast(ctnl, skb2, NETLINK_PORTID(skb),
+                               MSG_DONTWAIT);
                /* Signal netlink not to send its ACK/errmsg.  */
                return -EINTR;
        }
@@ -1498,25 +1498,25 @@ ip_set_uadd(struct sock *ctnl, struct sk_buff *skb,
 {
        struct ip_set_net *inst = ip_set_pernet(sock_net(ctnl));
        struct ip_set *set;
-       struct nlattr *tb[IPSET_ATTR_ADT_MAX+1] = {};
+       struct nlattr *tb[IPSET_ATTR_ADT_MAX + 1] = {};
        const struct nlattr *nla;
        u32 flags = flag_exist(nlh);
        bool use_lineno;
        int ret = 0;
 
        if (unlikely(protocol_failed(attr) ||
-                    attr[IPSET_ATTR_SETNAME] == NULL ||
+                    !attr[IPSET_ATTR_SETNAME] ||
                     !((attr[IPSET_ATTR_DATA] != NULL) ^
                       (attr[IPSET_ATTR_ADT] != NULL)) ||
-                    (attr[IPSET_ATTR_DATA] != NULL &&
+                    (attr[IPSET_ATTR_DATA] &&
                      !flag_nested(attr[IPSET_ATTR_DATA])) ||
-                    (attr[IPSET_ATTR_ADT] != NULL &&
+                    (attr[IPSET_ATTR_ADT] &&
                      (!flag_nested(attr[IPSET_ATTR_ADT]) ||
-                      attr[IPSET_ATTR_LINENO] == NULL))))
+                      !attr[IPSET_ATTR_LINENO]))))
                return -IPSET_ERR_PROTOCOL;
 
        set = find_set(inst, nla_data(attr[IPSET_ATTR_SETNAME]));
-       if (set == NULL)
+       if (!set)
                return -ENOENT;
 
        use_lineno = !!attr[IPSET_ATTR_LINENO];
@@ -1553,25 +1553,25 @@ ip_set_udel(struct sock *ctnl, struct sk_buff *skb,
 {
        struct ip_set_net *inst = ip_set_pernet(sock_net(ctnl));
        struct ip_set *set;
-       struct nlattr *tb[IPSET_ATTR_ADT_MAX+1] = {};
+       struct nlattr *tb[IPSET_ATTR_ADT_MAX + 1] = {};
        const struct nlattr *nla;
        u32 flags = flag_exist(nlh);
        bool use_lineno;
        int ret = 0;
 
        if (unlikely(protocol_failed(attr) ||
-                    attr[IPSET_ATTR_SETNAME] == NULL ||
+                    !attr[IPSET_ATTR_SETNAME] ||
                     !((attr[IPSET_ATTR_DATA] != NULL) ^
                       (attr[IPSET_ATTR_ADT] != NULL)) ||
-                    (attr[IPSET_ATTR_DATA] != NULL &&
+                    (attr[IPSET_ATTR_DATA] &&
                      !flag_nested(attr[IPSET_ATTR_DATA])) ||
-                    (attr[IPSET_ATTR_ADT] != NULL &&
+                    (attr[IPSET_ATTR_ADT] &&
                      (!flag_nested(attr[IPSET_ATTR_ADT]) ||
-                      attr[IPSET_ATTR_LINENO] == NULL))))
+                      !attr[IPSET_ATTR_LINENO]))))
                return -IPSET_ERR_PROTOCOL;
 
        set = find_set(inst, nla_data(attr[IPSET_ATTR_SETNAME]));
-       if (set == NULL)
+       if (!set)
                return -ENOENT;
 
        use_lineno = !!attr[IPSET_ATTR_LINENO];
@@ -1608,17 +1608,17 @@ ip_set_utest(struct sock *ctnl, struct sk_buff *skb,
 {
        struct ip_set_net *inst = ip_set_pernet(sock_net(ctnl));
        struct ip_set *set;
-       struct nlattr *tb[IPSET_ATTR_ADT_MAX+1] = {};
+       struct nlattr *tb[IPSET_ATTR_ADT_MAX + 1] = {};
        int ret = 0;
 
        if (unlikely(protocol_failed(attr) ||
-                    attr[IPSET_ATTR_SETNAME] == NULL ||
-                    attr[IPSET_ATTR_DATA] == NULL ||
+                    !attr[IPSET_ATTR_SETNAME] ||
+                    !attr[IPSET_ATTR_DATA] ||
                     !flag_nested(attr[IPSET_ATTR_DATA])))
                return -IPSET_ERR_PROTOCOL;
 
        set = find_set(inst, nla_data(attr[IPSET_ATTR_SETNAME]));
-       if (set == NULL)
+       if (!set)
                return -ENOENT;
 
        if (nla_parse_nested(tb, IPSET_ATTR_ADT_MAX, attr[IPSET_ATTR_DATA],
@@ -1649,15 +1649,15 @@ ip_set_header(struct sock *ctnl, struct sk_buff *skb,
        int ret = 0;
 
        if (unlikely(protocol_failed(attr) ||
-                    attr[IPSET_ATTR_SETNAME] == NULL))
+                    !attr[IPSET_ATTR_SETNAME]))
                return -IPSET_ERR_PROTOCOL;
 
        set = find_set(inst, nla_data(attr[IPSET_ATTR_SETNAME]));
-       if (set == NULL)
+       if (!set)
                return -ENOENT;
 
        skb2 = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
-       if (skb2 == NULL)
+       if (!skb2)
                return -ENOMEM;
 
        nlh2 = start_msg(skb2, NETLINK_PORTID(skb), nlh->nlmsg_seq, 0,
@@ -1706,8 +1706,8 @@ ip_set_type(struct sock *ctnl, struct sk_buff *skb,
        int ret = 0;
 
        if (unlikely(protocol_failed(attr) ||
-                    attr[IPSET_ATTR_TYPENAME] == NULL ||
-                    attr[IPSET_ATTR_FAMILY] == NULL))
+                    !attr[IPSET_ATTR_TYPENAME] ||
+                    !attr[IPSET_ATTR_FAMILY]))
                return -IPSET_ERR_PROTOCOL;
 
        family = nla_get_u8(attr[IPSET_ATTR_FAMILY]);
@@ -1717,7 +1717,7 @@ ip_set_type(struct sock *ctnl, struct sk_buff *skb,
                return ret;
 
        skb2 = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
-       if (skb2 == NULL)
+       if (!skb2)
                return -ENOMEM;
 
        nlh2 = start_msg(skb2, NETLINK_PORTID(skb), nlh->nlmsg_seq, 0,
@@ -1762,11 +1762,11 @@ ip_set_protocol(struct sock *ctnl, struct sk_buff *skb,
        struct nlmsghdr *nlh2;
        int ret = 0;
 
-       if (unlikely(attr[IPSET_ATTR_PROTOCOL] == NULL))
+       if (unlikely(!attr[IPSET_ATTR_PROTOCOL]))
                return -IPSET_ERR_PROTOCOL;
 
        skb2 = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL);
-       if (skb2 == NULL)
+       if (!skb2)
                return -ENOMEM;
 
        nlh2 = start_msg(skb2, NETLINK_PORTID(skb), nlh->nlmsg_seq, 0,
@@ -2049,7 +2049,7 @@ ip_set_net_exit(struct net *net)
 
        for (i = 0; i < inst->ip_set_max; i++) {
                set = ip_set(inst, i);
-               if (set != NULL)
+               if (set)
                        ip_set_destroy_set(inst, i);
        }
        kfree(rcu_dereference_protected(inst->ip_set_list, 1));
index 267144abef56c5c40a16dfcc101f5dd7933f6774..b82f7690630a83828636109e5978febceb45887f 100644 (file)
@@ -34,7 +34,7 @@ get_port(const struct sk_buff *skb, int protocol, unsigned int protooff,
                const struct tcphdr *th;
 
                th = skb_header_pointer(skb, protooff, sizeof(_tcph), &_tcph);
-               if (th == NULL)
+               if (!th)
                        /* No choice either */
                        return false;
 
@@ -46,7 +46,7 @@ get_port(const struct sk_buff *skb, int protocol, unsigned int protooff,
                const sctp_sctphdr_t *sh;
 
                sh = skb_header_pointer(skb, protooff, sizeof(_sh), &_sh);
-               if (sh == NULL)
+               if (!sh)
                        /* No choice either */
                        return false;
 
@@ -59,7 +59,7 @@ get_port(const struct sk_buff *skb, int protocol, unsigned int protooff,
                const struct udphdr *uh;
 
                uh = skb_header_pointer(skb, protooff, sizeof(_udph), &_udph);
-               if (uh == NULL)
+               if (!uh)
                        /* No choice either */
                        return false;
 
@@ -71,7 +71,7 @@ get_port(const struct sk_buff *skb, int protocol, unsigned int protooff,
                const struct icmphdr *ic;
 
                ic = skb_header_pointer(skb, protooff, sizeof(_ich), &_ich);
-               if (ic == NULL)
+               if (!ic)
                        return false;
 
                *port = (__force __be16)htons((ic->type << 8) | ic->code);
@@ -82,7 +82,7 @@ get_port(const struct sk_buff *skb, int protocol, unsigned int protooff,
                const struct icmp6hdr *ic;
 
                ic = skb_header_pointer(skb, protooff, sizeof(_ich), &_ich);
-               if (ic == NULL)
+               if (!ic)
                        return false;
 
                *port = (__force __be16)
index 61a1ce7a775de1345c885bc9226c4369a209d094..878d35f4601939bde304fc5c8d6a91fa223f20a2 100644 (file)
@@ -35,7 +35,7 @@
 /* Number of elements to store in an initial array block */
 #define AHASH_INIT_SIZE                        4
 /* Max number of elements to store in an array block */
-#define AHASH_MAX_SIZE                 (3*AHASH_INIT_SIZE)
+#define AHASH_MAX_SIZE                 (3 * AHASH_INIT_SIZE)
 /* Max muber of elements in the array block when tuned */
 #define AHASH_MAX_TUNED                        64
 
@@ -105,7 +105,7 @@ htable_size(u8 hbits)
        if (hbits > 31)
                return 0;
        hsize = jhash_size(hbits);
-       if ((((size_t)-1) - sizeof(struct htable))/sizeof(struct hbucket *)
+       if ((((size_t)-1) - sizeof(struct htable)) / sizeof(struct hbucket *)
            < hsize)
                return 0;
 
@@ -257,7 +257,7 @@ htable_bits(u32 hashsize)
 #endif
 
 #define HKEY(data, initval, htable_bits)                       \
-(jhash2((u32 *)(data), HKEY_DATALEN/sizeof(u32), initval)      \
+(jhash2((u32 *)(data), HKEY_DATALEN / sizeof(u32), initval)    \
        & jhash_mask(htable_bits))
 
 #ifndef htype
@@ -350,7 +350,7 @@ mtype_ahash_memsize(const struct htype *h, const struct htable *t,
 #endif
        for (i = 0; i < jhash_size(t->htable_bits); i++) {
                n = rcu_dereference_bh(hbucket(t, i));
-               if (n == NULL)
+               if (!n)
                        continue;
                memsize += sizeof(struct hbucket) + n->size * dsize;
        }
@@ -384,7 +384,7 @@ mtype_flush(struct ip_set *set)
        t = ipset_dereference_protected(h->table, set);
        for (i = 0; i < jhash_size(t->htable_bits); i++) {
                n = __ipset_dereference_protected(hbucket(t, i), 1);
-               if (n == NULL)
+               if (!n)
                        continue;
                if (set->extensions & IPSET_EXT_DESTROY)
                        mtype_ext_cleanup(set, n);
@@ -407,7 +407,7 @@ mtype_ahash_destroy(struct ip_set *set, struct htable *t, bool ext_destroy)
 
        for (i = 0; i < jhash_size(t->htable_bits); i++) {
                n = __ipset_dereference_protected(hbucket(t, i), 1);
-               if (n == NULL)
+               if (!n)
                        continue;
                if (set->extensions & IPSET_EXT_DESTROY && ext_destroy)
                        mtype_ext_cleanup(set, n);
@@ -481,7 +481,7 @@ mtype_expire(struct ip_set *set, struct htype *h, u8 nets_length, size_t dsize)
        t = ipset_dereference_protected(h->table, set);
        for (i = 0; i < jhash_size(t->htable_bits); i++) {
                n = __ipset_dereference_protected(hbucket(t, i), 1);
-               if (n == NULL)
+               if (!n)
                        continue;
                for (j = 0, d = 0; j < n->pos; j++) {
                        if (!test_bit(j, n->used)) {
@@ -599,7 +599,7 @@ retry:
                 set->name, orig->htable_bits, htable_bits, orig);
        for (i = 0; i < jhash_size(orig->htable_bits); i++) {
                n = __ipset_dereference_protected(hbucket(orig, i), 1);
-               if (n == NULL)
+               if (!n)
                        continue;
                for (j = 0; j < n->pos; j++) {
                        if (!test_bit(j, n->used))
@@ -711,7 +711,7 @@ mtype_add(struct ip_set *set, void *value, const struct ip_set_ext *ext,
        t = ipset_dereference_protected(h->table, set);
        key = HKEY(value, h->initval, t->htable_bits);
        n = __ipset_dereference_protected(hbucket(t, key), 1);
-       if (n == NULL) {
+       if (!n) {
                if (forceadd) {
                        if (net_ratelimit())
                                pr_warn("Set %s is full, maxelem %u reached\n",
@@ -723,7 +723,7 @@ mtype_add(struct ip_set *set, void *value, const struct ip_set_ext *ext,
                old = NULL;
                n = kzalloc(sizeof(*n) + AHASH_INIT_SIZE * set->dsize,
                            GFP_ATOMIC);
-               if (n == NULL)
+               if (!n)
                        return -ENOMEM;
                n->size = AHASH_INIT_SIZE;
                goto copy_elem;
@@ -958,7 +958,7 @@ mtype_test_cidrs(struct ip_set *set, struct mtype_elem *d,
 #endif
                key = HKEY(d, h->initval, t->htable_bits);
                n =  rcu_dereference_bh(hbucket(t, key));
-               if (n == NULL)
+               if (!n)
                        continue;
                for (i = 0; i < n->pos; i++) {
                        if (!test_bit(i, n->used))
@@ -1016,7 +1016,7 @@ mtype_test(struct ip_set *set, void *value, const struct ip_set_ext *ext,
 
        key = HKEY(d, h->initval, t->htable_bits);
        n = rcu_dereference_bh(hbucket(t, key));
-       if (n == NULL) {
+       if (!n) {
                ret = 0;
                goto out;
        }
@@ -1090,10 +1090,10 @@ mtype_uref(struct ip_set *set, struct netlink_callback *cb, bool start)
                rcu_read_lock_bh();
                t = rcu_dereference_bh_nfnl(h->table);
                atomic_inc(&t->uref);
-               cb->args[IPSET_CB_PRIVATE] = (unsigned long) t;
+               cb->args[IPSET_CB_PRIVATE] = (unsigned long)t;
                rcu_read_unlock_bh();
        } else if (cb->args[IPSET_CB_PRIVATE]) {
-               t = (struct htable *) cb->args[IPSET_CB_PRIVATE];
+               t = (struct htable *)cb->args[IPSET_CB_PRIVATE];
                if (atomic_dec_and_test(&t->uref) && atomic_read(&t->ref)) {
                        /* Resizing didn't destroy the hash table */
                        pr_debug("Table destroy by dump: %p\n", t);
@@ -1122,7 +1122,7 @@ mtype_list(const struct ip_set *set,
                return -EMSGSIZE;
 
        pr_debug("list hash set %s\n", set->name);
-       t = (const struct htable *) cb->args[IPSET_CB_PRIVATE];
+       t = (const struct htable *)cb->args[IPSET_CB_PRIVATE];
        /* Expire may replace a hbucket with another one */
        rcu_read_lock();
        for (; cb->args[IPSET_CB_ARG0] < jhash_size(t->htable_bits);
@@ -1131,7 +1131,7 @@ mtype_list(const struct ip_set *set,
                n = rcu_dereference(hbucket(t, cb->args[IPSET_CB_ARG0]));
                pr_debug("cb->arg bucket: %lu, t %p n %p\n",
                         cb->args[IPSET_CB_ARG0], t, n);
-               if (n == NULL)
+               if (!n)
                        continue;
                for (i = 0; i < n->pos; i++) {
                        if (!test_bit(i, n->used))
index 967b6e624c6a5c6ea872ca1324903bfedb573eec..9d6bf19f7b78046fa093e2f58940fe795c779b15 100644 (file)
@@ -249,6 +249,7 @@ hash_ip6_uadt(struct ip_set *set, struct nlattr *tb[],
                return -IPSET_ERR_HASH_RANGE_UNSUPPORTED;
        if (unlikely(tb[IPSET_ATTR_CIDR])) {
                u8 cidr = nla_get_u8(tb[IPSET_ATTR_CIDR]);
+
                if (cidr != HOST_MASK)
                        return -IPSET_ERR_INVALID_CIDR;
        }
index 6e6dbd2c4e577ee8489b6acd6fe603175377b076..a0695a2ab585cb219dc946570553040cf93aedde 100644 (file)
@@ -243,6 +243,7 @@ hash_ipmark6_uadt(struct ip_set *set, struct nlattr *tb[],
                return -IPSET_ERR_HASH_RANGE_UNSUPPORTED;
        if (unlikely(tb[IPSET_ATTR_CIDR])) {
                u8 cidr = nla_get_u8(tb[IPSET_ATTR_CIDR]);
+
                if (cidr != HOST_MASK)
                        return -IPSET_ERR_INVALID_CIDR;
        }
index fcde7bc54da58130b5f78db91c7b35518519978d..9d84b3dff603c98a9aa5a917b4c1314e8fd99044 100644 (file)
@@ -285,6 +285,7 @@ hash_ipport6_uadt(struct ip_set *set, struct nlattr *tb[],
                return -IPSET_ERR_HASH_RANGE_UNSUPPORTED;
        if (unlikely(tb[IPSET_ATTR_CIDR])) {
                u8 cidr = nla_get_u8(tb[IPSET_ATTR_CIDR]);
+
                if (cidr != HOST_MASK)
                        return -IPSET_ERR_INVALID_CIDR;
        }
index 44e75bfd4424fcddf1363524cc36217a78e8da67..215b7b942038a63e33fe40c2df52a1e61d8c20b0 100644 (file)
@@ -296,6 +296,7 @@ hash_ipportip6_uadt(struct ip_set *set, struct nlattr *tb[],
                return -IPSET_ERR_HASH_RANGE_UNSUPPORTED;
        if (unlikely(tb[IPSET_ATTR_CIDR])) {
                u8 cidr = nla_get_u8(tb[IPSET_ATTR_CIDR]);
+
                if (cidr != HOST_MASK)
                        return -IPSET_ERR_INVALID_CIDR;
        }
index c03d35bf83800f13b56ff894d79678d32e4d18c7..9ca719625ea339522c10154da684b63278e57845 100644 (file)
@@ -435,6 +435,7 @@ hash_ipportnet6_uadt(struct ip_set *set, struct nlattr *tb[],
                return -IPSET_ERR_HASH_RANGE_UNSUPPORTED;
        if (unlikely(tb[IPSET_ATTR_CIDR])) {
                u8 cidr = nla_get_u8(tb[IPSET_ATTR_CIDR]);
+
                if (cidr != HOST_MASK)
                        return -IPSET_ERR_INVALID_CIDR;
        }
index b0294997a6508af72d88393f51234bea0de07a87..f1e7d2c0f68531421189b38d251148bdc4d12c95 100644 (file)
@@ -92,7 +92,7 @@ hash_mac4_kadt(struct ip_set *set, const struct sk_buff *skb,
            (skb_mac_header(skb) + ETH_HLEN) > skb->data)
                return -EINVAL;
 
-       memcpy(e.ether, eth_hdr(skb)->h_source, ETH_ALEN);
+       ether_addr_copy(e.ether, eth_hdr(skb)->h_source);
        if (memcmp(e.ether, invalid_ether, ETH_ALEN) == 0)
                return -EINVAL;
        return adtfn(set, &e, &ext, &opt->ext, opt->cmdflags);
@@ -116,7 +116,7 @@ hash_mac4_uadt(struct ip_set *set, struct nlattr *tb[],
        ret = ip_set_get_extensions(set, tb, &ext);
        if (ret)
                return ret;
-       memcpy(e.ether, nla_data(tb[IPSET_ATTR_ETHER]), ETH_ALEN);
+       ether_addr_copy(e.ether, nla_data(tb[IPSET_ATTR_ETHER]));
        if (memcmp(e.ether, invalid_ether, ETH_ALEN) == 0)
                return -IPSET_ERR_HASH_ELEM;
 
index 8160870cd5f7b9fce1ddd47af799d5c1365a211e..3c862c0a76d1eac5fcb2d94675e4c3a7fe498d89 100644 (file)
@@ -370,7 +370,7 @@ hash_netnet6_kadt(struct ip_set *set, const struct sk_buff *skb,
        e.cidr[0] = INIT_CIDR(h->nets[0].cidr[0], HOST_MASK);
        e.cidr[1] = INIT_CIDR(h->nets[0].cidr[1], HOST_MASK);
        if (adt == IPSET_TEST)
-               e.ccmp = (HOST_MASK << (sizeof(u8)*8)) | HOST_MASK;
+               e.ccmp = (HOST_MASK << (sizeof(u8) * 8)) | HOST_MASK;
 
        ip6addrptr(skb, opt->flags & IPSET_DIM_ONE_SRC, &e.ip[0].in6);
        ip6addrptr(skb, opt->flags & IPSET_DIM_TWO_SRC, &e.ip[1].in6);
index 0b88000d4b669fe5741022f746345f32989511bb..a1fe5377a2b3376d29f29b18d77ebfe08fc988e1 100644 (file)
@@ -213,7 +213,7 @@ list_set_utest(struct ip_set *set, void *value, const struct ip_set_ext *ext,
                        ret = !list_is_last(&e->list, &map->members) &&
                              next->id == d->refid;
                } else {
-                       ret = prev != NULL && prev->id == d->refid;
+                       ret = prev && prev->id == d->refid;
                }
                return ret;
        }
@@ -292,7 +292,7 @@ list_set_uadd(struct ip_set *set, void *value, const struct ip_set_ext *ext,
                        n = list_prev_entry(prev, list);
        }
        /* Can we replace a timed out entry? */
-       if (n != NULL &&
+       if (n &&
            !(SET_WITH_TIMEOUT(set) &&
              ip_set_timeout_expired(ext_timeout(n, set))))
                n =  NULL;
@@ -338,7 +338,7 @@ list_set_udel(struct ip_set *set, void *value, const struct ip_set_ext *ext,
                            next->id != d->refid)
                                return -IPSET_ERR_REF_EXIST;
                } else if (d->before < 0) {
-                       if (prev == NULL || prev->id != d->refid)
+                       if (!prev || prev->id != d->refid)
                                return -IPSET_ERR_REF_EXIST;
                }
                list_set_del(set, e);
index 43ed031bd740878a48829cd66578c350a78e29d6..f0596b3acf5563818ab8a1a1014d1eb489a6b0e3 100644 (file)
@@ -9,7 +9,8 @@
  */
 
 /* Kernel module which implements the set match and SET target
- * for netfilter/iptables. */
+ * for netfilter/iptables.
+ */
 
 #include <linux/module.h>
 #include <linux/skbuff.h>
@@ -87,10 +88,10 @@ compat_flags(struct xt_set_info_v0 *info)
        info->u.compat.dim = IPSET_DIM_ZERO;
        if (info->u.flags[0] & IPSET_MATCH_INV)
                info->u.compat.flags |= IPSET_INV_MATCH;
-       for (i = 0; i < IPSET_DIM_MAX-1 && info->u.flags[i]; i++) {
+       for (i = 0; i < IPSET_DIM_MAX - 1 && info->u.flags[i]; i++) {
                info->u.compat.dim++;
                if (info->u.flags[i] & IPSET_SRC)
-                       info->u.compat.flags |= (1<<info->u.compat.dim);
+                       info->u.compat.flags |= (1 << info->u.compat.dim);
        }
 }
 
@@ -103,11 +104,11 @@ set_match_v0_checkentry(const struct xt_mtchk_param *par)
        index = ip_set_nfnl_get_byindex(XT_PAR_NET(par), info->match_set.index);
 
        if (index == IPSET_INVALID_ID) {
-               pr_warn("Cannot find set indentified by id %u to match\n",
+               pr_warn("Cannot find set identified by id %u to match\n",
                        info->match_set.index);
                return CHECK_FAIL(-ENOENT);
        }
-       if (info->match_set.u.flags[IPSET_DIM_MAX-1] != 0) {
+       if (info->match_set.u.flags[IPSET_DIM_MAX - 1] != 0) {
                pr_warn("Protocol error: set match dimension is over the limit!\n");
                ip_set_nfnl_put(XT_PAR_NET(par), info->match_set.index);
                return CHECK_FAIL(-ERANGE);
@@ -153,7 +154,7 @@ set_match_v1_checkentry(const struct xt_mtchk_param *par)
        index = ip_set_nfnl_get_byindex(XT_PAR_NET(par), info->match_set.index);
 
        if (index == IPSET_INVALID_ID) {
-               pr_warn("Cannot find set indentified by id %u to match\n",
+               pr_warn("Cannot find set identified by id %u to match\n",
                        info->match_set.index);
                return CHECK_FAIL(-ENOENT);
        }
@@ -245,6 +246,7 @@ static bool
 set_match_v4(const struct sk_buff *skb, CONST struct xt_action_param *par)
 {
        const struct xt_set_info_match_v4 *info = par->matchinfo;
+
        ADT_OPT(opt, par->family, info->match_set.dim,
                info->match_set.flags, info->flags, UINT_MAX);
        int ret;
@@ -325,8 +327,8 @@ set_target_v0_checkentry(const struct xt_tgchk_param *par)
                        return CHECK_FAIL(-ENOENT);
                }
        }
-       if (info->add_set.u.flags[IPSET_DIM_MAX-1] != 0 ||
-           info->del_set.u.flags[IPSET_DIM_MAX-1] != 0) {
+       if (info->add_set.u.flags[IPSET_DIM_MAX - 1] != 0 ||
+           info->del_set.u.flags[IPSET_DIM_MAX - 1] != 0) {
                pr_warn("Protocol error: SET target dimension is over the limit!\n");
                if (info->add_set.index != IPSET_INVALID_ID)
                        ip_set_nfnl_put(XT_PAR_NET(par), info->add_set.index);
@@ -441,8 +443,8 @@ set_target_v2(struct sk_buff *skb, const struct xt_action_param *par)
 
        /* Normalize to fit into jiffies */
        if (add_opt.ext.timeout != IPSET_NO_TIMEOUT &&
-           add_opt.ext.timeout > UINT_MAX/MSEC_PER_SEC)
-               add_opt.ext.timeout = UINT_MAX/MSEC_PER_SEC;
+           add_opt.ext.timeout > UINT_MAX / MSEC_PER_SEC)
+               add_opt.ext.timeout = UINT_MAX / MSEC_PER_SEC;
        if (info->add_set.index != IPSET_INVALID_ID)
                ip_set_add(info->add_set.index, skb, CAST_TO_MATCH par,
                           &add_opt);
@@ -474,8 +476,8 @@ set_target_v3(struct sk_buff *skb, const struct xt_action_param *par)
 
        /* Normalize to fit into jiffies */
        if (add_opt.ext.timeout != IPSET_NO_TIMEOUT &&
-           add_opt.ext.timeout > UINT_MAX/MSEC_PER_SEC)
-               add_opt.ext.timeout = UINT_MAX/MSEC_PER_SEC;
+           add_opt.ext.timeout > UINT_MAX / MSEC_PER_SEC)
+               add_opt.ext.timeout = UINT_MAX / MSEC_PER_SEC;
        if (info->add_set.index != IPSET_INVALID_ID)
                ip_set_add(info->add_set.index, skb, CAST_TO_MATCH par,
                           &add_opt);
@@ -504,7 +506,6 @@ set_target_v3(struct sk_buff *skb, const struct xt_action_param *par)
        return XT_CONTINUE;
 }
 
-
 static FTYPE
 set_target_v3_checkentry(const struct xt_tgchk_param *par)
 {
@@ -591,7 +592,6 @@ set_target_v3_destroy(const struct xt_tgdtor_param *par)
                ip_set_nfnl_put(XT_PAR_NET(par), info->map_set.index);
 }
 
-
 static struct xt_match set_matches[] __read_mostly = {
        {
                .name           = "set",