diff options
author | Pavel Emelyanov <xemul@openvz.org> | 2008-02-13 01:37:19 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-02-13 01:37:19 -0500 |
commit | 56628b1d8964eb7ac924154d60b5d874bfb2b1e8 (patch) | |
tree | aa613aac941bdffe6b328d23aac3d3d97a46ec1e /net | |
parent | 94de7feb2dee6d0039ecbe98ae8b63bbb63808b6 (diff) |
[NETLABEL]: Don't produce unused variables when IPv6 is off.
Some code declares variables on the stack, but uses them
under #ifdef CONFIG_IPV6, so thay become unused when ipv6
is off. Fortunately, they are used in a switch's case
branches, so the fix is rather simple.
Is it OK from coding style POV to add braces inside "cases",
or should I better avoid such style and rework the patch?
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/netlabel/netlabel_unlabeled.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/net/netlabel/netlabel_unlabeled.c b/net/netlabel/netlabel_unlabeled.c index 42e81fd8cc49..3587874d64ec 100644 --- a/net/netlabel/netlabel_unlabeled.c +++ b/net/netlabel/netlabel_unlabeled.c | |||
@@ -617,8 +617,6 @@ static int netlbl_unlhsh_add(struct net *net, | |||
617 | int ifindex; | 617 | int ifindex; |
618 | struct net_device *dev; | 618 | struct net_device *dev; |
619 | struct netlbl_unlhsh_iface *iface; | 619 | struct netlbl_unlhsh_iface *iface; |
620 | struct in_addr *addr4, *mask4; | ||
621 | struct in6_addr *addr6, *mask6; | ||
622 | struct audit_buffer *audit_buf = NULL; | 620 | struct audit_buffer *audit_buf = NULL; |
623 | char *secctx = NULL; | 621 | char *secctx = NULL; |
624 | u32 secctx_len; | 622 | u32 secctx_len; |
@@ -651,7 +649,9 @@ static int netlbl_unlhsh_add(struct net *net, | |||
651 | audit_buf = netlbl_audit_start_common(AUDIT_MAC_UNLBL_STCADD, | 649 | audit_buf = netlbl_audit_start_common(AUDIT_MAC_UNLBL_STCADD, |
652 | audit_info); | 650 | audit_info); |
653 | switch (addr_len) { | 651 | switch (addr_len) { |
654 | case sizeof(struct in_addr): | 652 | case sizeof(struct in_addr): { |
653 | struct in_addr *addr4, *mask4; | ||
654 | |||
655 | addr4 = (struct in_addr *)addr; | 655 | addr4 = (struct in_addr *)addr; |
656 | mask4 = (struct in_addr *)mask; | 656 | mask4 = (struct in_addr *)mask; |
657 | ret_val = netlbl_unlhsh_add_addr4(iface, addr4, mask4, secid); | 657 | ret_val = netlbl_unlhsh_add_addr4(iface, addr4, mask4, secid); |
@@ -661,8 +661,11 @@ static int netlbl_unlhsh_add(struct net *net, | |||
661 | addr4->s_addr, | 661 | addr4->s_addr, |
662 | mask4->s_addr); | 662 | mask4->s_addr); |
663 | break; | 663 | break; |
664 | } | ||
664 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | 665 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) |
665 | case sizeof(struct in6_addr): | 666 | case sizeof(struct in6_addr): { |
667 | struct in6_addr *addr6, *mask6; | ||
668 | |||
666 | addr6 = (struct in6_addr *)addr; | 669 | addr6 = (struct in6_addr *)addr; |
667 | mask6 = (struct in6_addr *)mask; | 670 | mask6 = (struct in6_addr *)mask; |
668 | ret_val = netlbl_unlhsh_add_addr6(iface, addr6, mask6, secid); | 671 | ret_val = netlbl_unlhsh_add_addr6(iface, addr6, mask6, secid); |
@@ -671,6 +674,7 @@ static int netlbl_unlhsh_add(struct net *net, | |||
671 | dev_name, | 674 | dev_name, |
672 | addr6, mask6); | 675 | addr6, mask6); |
673 | break; | 676 | break; |
677 | } | ||
674 | #endif /* IPv6 */ | 678 | #endif /* IPv6 */ |
675 | default: | 679 | default: |
676 | ret_val = -EINVAL; | 680 | ret_val = -EINVAL; |
@@ -1741,10 +1745,6 @@ int netlbl_unlabel_getattr(const struct sk_buff *skb, | |||
1741 | u16 family, | 1745 | u16 family, |
1742 | struct netlbl_lsm_secattr *secattr) | 1746 | struct netlbl_lsm_secattr *secattr) |
1743 | { | 1747 | { |
1744 | struct iphdr *hdr4; | ||
1745 | struct ipv6hdr *hdr6; | ||
1746 | struct netlbl_unlhsh_addr4 *addr4; | ||
1747 | struct netlbl_unlhsh_addr6 *addr6; | ||
1748 | struct netlbl_unlhsh_iface *iface; | 1748 | struct netlbl_unlhsh_iface *iface; |
1749 | 1749 | ||
1750 | rcu_read_lock(); | 1750 | rcu_read_lock(); |
@@ -1752,21 +1752,29 @@ int netlbl_unlabel_getattr(const struct sk_buff *skb, | |||
1752 | if (iface == NULL) | 1752 | if (iface == NULL) |
1753 | goto unlabel_getattr_nolabel; | 1753 | goto unlabel_getattr_nolabel; |
1754 | switch (family) { | 1754 | switch (family) { |
1755 | case PF_INET: | 1755 | case PF_INET: { |
1756 | struct iphdr *hdr4; | ||
1757 | struct netlbl_unlhsh_addr4 *addr4; | ||
1758 | |||
1756 | hdr4 = ip_hdr(skb); | 1759 | hdr4 = ip_hdr(skb); |
1757 | addr4 = netlbl_unlhsh_search_addr4(hdr4->saddr, iface); | 1760 | addr4 = netlbl_unlhsh_search_addr4(hdr4->saddr, iface); |
1758 | if (addr4 == NULL) | 1761 | if (addr4 == NULL) |
1759 | goto unlabel_getattr_nolabel; | 1762 | goto unlabel_getattr_nolabel; |
1760 | secattr->attr.secid = addr4->secid; | 1763 | secattr->attr.secid = addr4->secid; |
1761 | break; | 1764 | break; |
1765 | } | ||
1762 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | 1766 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) |
1763 | case PF_INET6: | 1767 | case PF_INET6: { |
1768 | struct ipv6hdr *hdr6; | ||
1769 | struct netlbl_unlhsh_addr6 *addr6; | ||
1770 | |||
1764 | hdr6 = ipv6_hdr(skb); | 1771 | hdr6 = ipv6_hdr(skb); |
1765 | addr6 = netlbl_unlhsh_search_addr6(&hdr6->saddr, iface); | 1772 | addr6 = netlbl_unlhsh_search_addr6(&hdr6->saddr, iface); |
1766 | if (addr6 == NULL) | 1773 | if (addr6 == NULL) |
1767 | goto unlabel_getattr_nolabel; | 1774 | goto unlabel_getattr_nolabel; |
1768 | secattr->attr.secid = addr6->secid; | 1775 | secattr->attr.secid = addr6->secid; |
1769 | break; | 1776 | break; |
1777 | } | ||
1770 | #endif /* IPv6 */ | 1778 | #endif /* IPv6 */ |
1771 | default: | 1779 | default: |
1772 | goto unlabel_getattr_nolabel; | 1780 | goto unlabel_getattr_nolabel; |