summaryrefslogtreecommitdiffstats
path: root/kernel/net/netfilter/ipset/ip_set_hash_netiface.c
diff options
context:
space:
mode:
authorJozsef Kadlecsik <kadlec@blackhole.kfki.hu>2014-12-10 07:27:35 +0100
committerJozsef Kadlecsik <kadlec@blackhole.kfki.hu>2014-12-10 07:27:35 +0100
commiteac16dba5972d6727c41c6a6133b3dd7e6a07653 (patch)
treefa66696392e7b447402fb12ef134e9edea6a257c /kernel/net/netfilter/ipset/ip_set_hash_netiface.c
parent01149ecc157609f5ff5d95d1b38480107848b1d2 (diff)
Resolve the STREQ macro to make the code more readable, and use nla_strlcpy where possible
Diffstat (limited to 'kernel/net/netfilter/ipset/ip_set_hash_netiface.c')
-rw-r--r--kernel/net/netfilter/ipset/ip_set_hash_netiface.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/kernel/net/netfilter/ipset/ip_set_hash_netiface.c b/kernel/net/netfilter/ipset/ip_set_hash_netiface.c
index d7bdb06..8a182ad 100644
--- a/kernel/net/netfilter/ipset/ip_set_hash_netiface.c
+++ b/kernel/net/netfilter/ipset/ip_set_hash_netiface.c
@@ -41,8 +41,7 @@ MODULE_ALIAS("ip_set_hash:net,iface");
#define IP_SET_HASH_WITH_MULTI
#define IP_SET_HASH_WITH_NET0
-#define STREQ(a, b) (strcmp(a, b) == 0)
-#define IFNAMCPY(a, b) strncpy(a, b, IFNAMSIZ)
+#define IFNAMCPY(a, b) strlcpy(a, b, IFNAMSIZ)
/* IPv4 variant */
@@ -75,7 +74,7 @@ hash_netiface4_data_equal(const struct hash_netiface4_elem *ip1,
ip1->cidr == ip2->cidr &&
(++*multi) &&
ip1->physdev == ip2->physdev &&
- STREQ(ip1->iface, ip2->iface);
+ strcmp(ip1->iface, ip2->iface) == 0;
}
static inline int
@@ -214,7 +213,7 @@ hash_netiface4_uadt(struct ip_set *set, struct nlattr *tb[],
if (e.cidr > HOST_MASK)
return -IPSET_ERR_INVALID_CIDR;
}
- IFNAMCPY(e.iface, nla_data(tb[IPSET_ATTR_IFACE]));
+ nla_strlcpy(e.iface, tb[IPSET_ATTR_IFACE], IFNAMSIZ);
if (tb[IPSET_ATTR_CADT_FLAGS]) {
u32 cadt_flags = ip_set_get_h32(tb[IPSET_ATTR_CADT_FLAGS]);
@@ -288,7 +287,7 @@ hash_netiface6_data_equal(const struct hash_netiface6_elem *ip1,
ip1->cidr == ip2->cidr &&
(++*multi) &&
ip1->physdev == ip2->physdev &&
- STREQ(ip1->iface, ip2->iface);
+ strcmp(ip1->iface, ip2->iface) == 0;
}
static inline int
@@ -430,7 +429,7 @@ hash_netiface6_uadt(struct ip_set *set, struct nlattr *tb[],
return -IPSET_ERR_INVALID_CIDR;
ip6_netmask(&e.ip, e.cidr);
- IFNAMCPY(e.iface, nla_data(tb[IPSET_ATTR_IFACE]));
+ nla_strlcpy(e.iface, tb[IPSET_ATTR_IFACE], IFNAMSIZ);
if (tb[IPSET_ATTR_CADT_FLAGS]) {
u32 cadt_flags = ip_set_get_h32(tb[IPSET_ATTR_CADT_FLAGS]);