From: Jason Lunz Date: Wed, 21 Feb 2007 07:19:54 +0000 (-0800) Subject: [AF_PACKET]: Remove unnecessary casts. X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=ad930650c0e694233971c56e8de8e78b896e2613;p=GitHub%2FLineageOS%2Fandroid_kernel_samsung_universal7580.git [AF_PACKET]: Remove unnecessary casts. packet_lookup_frame() always returns tpacket_hdr*, so there's no reason to return char* and require casting by callers. Also, remove a cast of void*. Signed-off-by: Jason Lunz Signed-off-by: David S. Miller --- diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index bf269907477..28d47e8f287 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c @@ -227,17 +227,14 @@ struct packet_skb_cb { #ifdef CONFIG_PACKET_MMAP -static inline char *packet_lookup_frame(struct packet_sock *po, unsigned int position) +static inline struct tpacket_hdr *packet_lookup_frame(struct packet_sock *po, unsigned int position) { unsigned int pg_vec_pos, frame_offset; - char *frame; pg_vec_pos = position / po->frames_per_block; frame_offset = position % po->frames_per_block; - frame = po->pg_vec[pg_vec_pos] + (frame_offset * po->frame_size); - - return frame; + return (struct tpacket_hdr *)(po->pg_vec[pg_vec_pos] + (frame_offset * po->frame_size)); } #endif @@ -639,7 +636,7 @@ static int tpacket_rcv(struct sk_buff *skb, struct net_device *dev, struct packe } spin_lock(&sk->sk_receive_queue.lock); - h = (struct tpacket_hdr *)packet_lookup_frame(po, po->head); + h = packet_lookup_frame(po, po->head); if (h->tp_status) goto ring_is_full; @@ -1473,7 +1470,7 @@ static int packet_notifier(struct notifier_block *this, unsigned long msg, void { struct sock *sk; struct hlist_node *node; - struct net_device *dev = (struct net_device*)data; + struct net_device *dev = data; read_lock(&packet_sklist_lock); sk_for_each(sk, node, &packet_sklist) { @@ -1588,7 +1585,7 @@ static unsigned int packet_poll(struct file * file, struct socket *sock, unsigned last = po->head ? po->head-1 : po->frame_max; struct tpacket_hdr *h; - h = (struct tpacket_hdr *)packet_lookup_frame(po, last); + h = packet_lookup_frame(po, last); if (h->tp_status) mask |= POLLIN | POLLRDNORM;