aboutsummaryrefslogtreecommitdiffstats
path: root/net/packet
diff options
context:
space:
mode:
authorDaniel Borkmann <dborkman@redhat.com>2014-01-19 05:46:53 -0500
committerDavid S. Miller <davem@davemloft.net>2014-01-21 19:51:42 -0500
commitf0d4eb29d18f732ed80cea4bf0f6bbee9c03ed62 (patch)
treefb2c0728e785efdb22acce9b48fbfc38d85a5e4a /net/packet
parent967680e02724afe9bb4bf0b0c20d0a55de315fcb (diff)
packet: fix a couple of cppcheck warnings
Doesn't bring much, but also doesn't hurt us to fix 'em: 1) In tpacket_rcv() flush dcache page we can restirct the scope for start and end and remove one layer of indent. 2) In tpacket_destruct_skb() we can restirct the scope for ph. 3) In alloc_one_pg_vec_page() we can remove the NULL assignment and change spacing a bit. Signed-off-by: Daniel Borkmann <dborkman@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/packet')
-rw-r--r--net/packet/af_packet.c37
1 files changed, 15 insertions, 22 deletions
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index d711ecbbb9d3..59fb3db2e713 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -2009,19 +2009,20 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev,
2009 sll->sll_ifindex = dev->ifindex; 2009 sll->sll_ifindex = dev->ifindex;
2010 2010
2011 smp_mb(); 2011 smp_mb();
2012
2012#if ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE == 1 2013#if ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE == 1
2013 { 2014 if (po->tp_version <= TPACKET_V2) {
2014 u8 *start, *end; 2015 u8 *start, *end;
2015 2016
2016 if (po->tp_version <= TPACKET_V2) { 2017 end = (u8 *) PAGE_ALIGN((unsigned long) h.raw +
2017 end = (u8 *)PAGE_ALIGN((unsigned long)h.raw 2018 macoff + snaplen);
2018 + macoff + snaplen); 2019
2019 for (start = h.raw; start < end; start += PAGE_SIZE) 2020 for (start = h.raw; start < end; start += PAGE_SIZE)
2020 flush_dcache_page(pgv_to_page(start)); 2021 flush_dcache_page(pgv_to_page(start));
2021 }
2022 smp_wmb();
2023 } 2022 }
2023 smp_wmb();
2024#endif 2024#endif
2025
2025 if (po->tp_version <= TPACKET_V2) 2026 if (po->tp_version <= TPACKET_V2)
2026 __packet_set_status(po, h.raw, status); 2027 __packet_set_status(po, h.raw, status);
2027 else 2028 else
@@ -2050,9 +2051,9 @@ ring_is_full:
2050static void tpacket_destruct_skb(struct sk_buff *skb) 2051static void tpacket_destruct_skb(struct sk_buff *skb)
2051{ 2052{
2052 struct packet_sock *po = pkt_sk(skb->sk); 2053 struct packet_sock *po = pkt_sk(skb->sk);
2053 void *ph;
2054 2054
2055 if (likely(po->tx_ring.pg_vec)) { 2055 if (likely(po->tx_ring.pg_vec)) {
2056 void *ph;
2056 __u32 ts; 2057 __u32 ts;
2057 2058
2058 ph = skb_shinfo(skb)->destructor_arg; 2059 ph = skb_shinfo(skb)->destructor_arg;
@@ -3649,34 +3650,26 @@ static void free_pg_vec(struct pgv *pg_vec, unsigned int order,
3649 3650
3650static char *alloc_one_pg_vec_page(unsigned long order) 3651static char *alloc_one_pg_vec_page(unsigned long order)
3651{ 3652{
3652 char *buffer = NULL; 3653 char *buffer;
3653 gfp_t gfp_flags = GFP_KERNEL | __GFP_COMP | 3654 gfp_t gfp_flags = GFP_KERNEL | __GFP_COMP |
3654 __GFP_ZERO | __GFP_NOWARN | __GFP_NORETRY; 3655 __GFP_ZERO | __GFP_NOWARN | __GFP_NORETRY;
3655 3656
3656 buffer = (char *) __get_free_pages(gfp_flags, order); 3657 buffer = (char *) __get_free_pages(gfp_flags, order);
3657
3658 if (buffer) 3658 if (buffer)
3659 return buffer; 3659 return buffer;
3660 3660
3661 /* 3661 /* __get_free_pages failed, fall back to vmalloc */
3662 * __get_free_pages failed, fall back to vmalloc
3663 */
3664 buffer = vzalloc((1 << order) * PAGE_SIZE); 3662 buffer = vzalloc((1 << order) * PAGE_SIZE);
3665
3666 if (buffer) 3663 if (buffer)
3667 return buffer; 3664 return buffer;
3668 3665
3669 /* 3666 /* vmalloc failed, lets dig into swap here */
3670 * vmalloc failed, lets dig into swap here
3671 */
3672 gfp_flags &= ~__GFP_NORETRY; 3667 gfp_flags &= ~__GFP_NORETRY;
3673 buffer = (char *)__get_free_pages(gfp_flags, order); 3668 buffer = (char *) __get_free_pages(gfp_flags, order);
3674 if (buffer) 3669 if (buffer)
3675 return buffer; 3670 return buffer;
3676 3671
3677 /* 3672 /* complete and utter failure */
3678 * complete and utter failure
3679 */
3680 return NULL; 3673 return NULL;
3681} 3674}
3682 3675