Skip to content

Commit f0d4eb2

Browse files
Daniel Borkmanndavem330
authored andcommitted
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>
1 parent 967680e commit f0d4eb2

1 file changed

Lines changed: 15 additions & 22 deletions

File tree

‎net/packet/af_packet.c‎

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2009,19 +2009,20 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev,
20092009
sll->sll_ifindex = dev->ifindex;
20102010

20112011
smp_mb();
2012+
20122013
#if ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE == 1
2013-
{
2014+
if (po->tp_version <= TPACKET_V2) {
20142015
u8 *start, *end;
20152016

2016-
if (po->tp_version <= TPACKET_V2) {
2017-
end = (u8 *)PAGE_ALIGN((unsigned long)h.raw
2018-
+ macoff + snaplen);
2019-
for (start = h.raw; start < end; start += PAGE_SIZE)
2020-
flush_dcache_page(pgv_to_page(start));
2021-
}
2022-
smp_wmb();
2017+
end = (u8 *) PAGE_ALIGN((unsigned long) h.raw +
2018+
macoff + snaplen);
2019+
2020+
for (start = h.raw; start < end; start += PAGE_SIZE)
2021+
flush_dcache_page(pgv_to_page(start));
20232022
}
2023+
smp_wmb();
20242024
#endif
2025+
20252026
if (po->tp_version <= TPACKET_V2)
20262027
__packet_set_status(po, h.raw, status);
20272028
else
@@ -2050,9 +2051,9 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev,
20502051
static void tpacket_destruct_skb(struct sk_buff *skb)
20512052
{
20522053
struct packet_sock *po = pkt_sk(skb->sk);
2053-
void *ph;
20542054

20552055
if (likely(po->tx_ring.pg_vec)) {
2056+
void *ph;
20562057
__u32 ts;
20572058

20582059
ph = skb_shinfo(skb)->destructor_arg;
@@ -3649,34 +3650,26 @@ static void free_pg_vec(struct pgv *pg_vec, unsigned int order,
36493650

36503651
static char *alloc_one_pg_vec_page(unsigned long order)
36513652
{
3652-
char *buffer = NULL;
3653+
char *buffer;
36533654
gfp_t gfp_flags = GFP_KERNEL | __GFP_COMP |
36543655
__GFP_ZERO | __GFP_NOWARN | __GFP_NORETRY;
36553656

36563657
buffer = (char *) __get_free_pages(gfp_flags, order);
3657-
36583658
if (buffer)
36593659
return buffer;
36603660

3661-
/*
3662-
* __get_free_pages failed, fall back to vmalloc
3663-
*/
3661+
/* __get_free_pages failed, fall back to vmalloc */
36643662
buffer = vzalloc((1 << order) * PAGE_SIZE);
3665-
36663663
if (buffer)
36673664
return buffer;
36683665

3669-
/*
3670-
* vmalloc failed, lets dig into swap here
3671-
*/
3666+
/* vmalloc failed, lets dig into swap here */
36723667
gfp_flags &= ~__GFP_NORETRY;
3673-
buffer = (char *)__get_free_pages(gfp_flags, order);
3668+
buffer = (char *) __get_free_pages(gfp_flags, order);
36743669
if (buffer)
36753670
return buffer;
36763671

3677-
/*
3678-
* complete and utter failure
3679-
*/
3672+
/* complete and utter failure */
36803673
return NULL;
36813674
}
36823675

0 commit comments

Comments
 (0)