]> git.karo-electronics.de Git - linux-beck.git/commitdiff
netfilter: nft_nat: Fix endianness issue reported by sparse
authorTomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Mon, 28 Oct 2013 10:19:45 +0000 (12:19 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 28 Oct 2013 16:41:49 +0000 (17:41 +0100)
This patch fixes this:

CHECK   net/netfilter/nft_nat.c
net/netfilter/nft_nat.c:50:43: warning: incorrect type in assignment (different base types)
net/netfilter/nft_nat.c:50:43:    expected restricted __be32 [addressable] [usertype] ip
net/netfilter/nft_nat.c:50:43:    got unsigned int [unsigned] [usertype] <noident>
net/netfilter/nft_nat.c:51:43: warning: incorrect type in assignment (different base types)
net/netfilter/nft_nat.c:51:43:    expected restricted __be32 [addressable] [usertype] ip
net/netfilter/nft_nat.c:51:43:    got unsigned int [unsigned] [usertype] <noident>
net/netfilter/nft_nat.c:65:37: warning: incorrect type in assignment (different base types)
net/netfilter/nft_nat.c:65:37:    expected restricted __be16 [addressable] [assigned] [usertype] all
net/netfilter/nft_nat.c:65:37:    got unsigned int [unsigned] <noident>
net/netfilter/nft_nat.c:66:37: warning: incorrect type in assignment (different base types)
net/netfilter/nft_nat.c:66:37:    expected restricted __be16 [addressable] [assigned] [usertype] all
net/netfilter/nft_nat.c:66:37:    got unsigned int [unsigned] <noident>

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nft_nat.c

index b0b87b2d2411a1646a8badb842e3c0b1f54f1952..d3b1ffe26181b22538ab29fefadd7a41d96b76f1 100644 (file)
@@ -47,8 +47,10 @@ static void nft_nat_eval(const struct nft_expr *expr,
        memset(&range, 0, sizeof(range));
        if (priv->sreg_addr_min) {
                if (priv->family == AF_INET) {
-                       range.min_addr.ip = data[priv->sreg_addr_min].data[0];
-                       range.max_addr.ip = data[priv->sreg_addr_max].data[0];
+                       range.min_addr.ip = (__force __be32)
+                                       data[priv->sreg_addr_min].data[0];
+                       range.max_addr.ip = (__force __be32)
+                                       data[priv->sreg_addr_max].data[0];
 
                } else {
                        memcpy(range.min_addr.ip6,
@@ -62,8 +64,10 @@ static void nft_nat_eval(const struct nft_expr *expr,
        }
 
        if (priv->sreg_proto_min) {
-               range.min_proto.all = data[priv->sreg_proto_min].data[0];
-               range.max_proto.all = data[priv->sreg_proto_max].data[0];
+               range.min_proto.all = (__force __be16)
+                                       data[priv->sreg_proto_min].data[0];
+               range.max_proto.all = (__force __be16)
+                                       data[priv->sreg_proto_max].data[0];
                range.flags |= NF_NAT_RANGE_PROTO_SPECIFIED;
        }