Skip to contentSkip to conversation

staging: rtl8188eu: core: Remove casts of pointer to same type

PATCH In review Bhaktipriya Shridhar 2 participants 3 messages Feb 25, 2016 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: rtl8188eu: core: Remove casts of pointer to same type

Casting a pointer to a pointer of the same type is unnecessary, so remove these unnecessary casts.

This was done with Coccinelle:

@@
type T;
T *ptr;
@@
- (T *)ptr
+ ptr

---
 drivers/staging/rtl8188eu/core/rtw_recv.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/staging/rtl8188eu/core/rtw_recv.c +5 -5
index 40b7a30..d3c9ded 100644
@@ -141,7 +141,7 @@ struct recv_frame *_rtw_alloc_recvframe(struct __queue *pfree_recv_queue)
 		}
 	}
 
-	return (struct recv_frame *)hdr;
+	return hdr;
 }
 
 struct recv_frame *rtw_alloc_recvframe(struct __queue *pfree_recv_queue)
@@ -240,7 +240,7 @@ void rtw_free_recvframe_queue(struct __queue *pframequeue,  struct __queue *pfre
 
 		plist = plist->next;
 
-		rtw_free_recvframe((struct recv_frame *)hdr, pfree_recv_queue);
+		rtw_free_recvframe(hdr, pfree_recv_queue);
 	}
 
 	spin_unlock(&pframequeue->lock);
@@ -1417,7 +1417,7 @@ static struct recv_frame *recvframe_defrag(struct adapter *adapter,
 	phead = get_list_head(defrag_q);
 	plist = phead->next;
 	pfhdr = container_of(plist, struct recv_frame, list);
-	prframe = (struct recv_frame *)pfhdr;
+	prframe = pfhdr;
 	list_del_init(&(prframe->list));
 
 	if (curfragnum != pfhdr->attrib.frag_num) {
@@ -1437,7 +1437,7 @@ static struct recv_frame *recvframe_defrag(struct adapter *adapter,
 
 	while (phead != plist) {
 		pnfhdr = container_of(plist, struct recv_frame, list);
-		pnextrframe = (struct recv_frame *)pnfhdr;
+		pnextrframe = pnfhdr;
 
 		/* check the fragment sequence  (2nd ~n fragment frame) */
 
@@ -1780,7 +1780,7 @@ static int recv_indicatepkts_in_order(struct adapter *padapter, struct recv_reor
 	/*  Check if there is any packet need indicate. */
 	while (!list_empty(phead)) {
 		prhdr = container_of(plist, struct recv_frame, list);
-		prframe = (struct recv_frame *)prhdr;
+		prframe = prhdr;
 		pattrib = &prframe->attrib;
 
 		if (!SN_LESS(preorder_ctrl->indicate_seq, pattrib->seq_num)) {

--
2.1.4

#1 lore raw
Quoted 11 lines · Bhaktipriya Shridhar

Casting a pointer to a pointer of the same type is unnecessary, so remove these unnecessary casts.

This was done with Coccinelle:

@@
type T;
T *ptr;
@@
- (T *)ptr
+ ptr

Good idea :)

julia

Quoted 65 lines
---
 drivers/staging/rtl8188eu/core/rtw_recv.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/staging/rtl8188eu/core/rtw_recv.c +5 -6
index 40b7a30..d3c9ded 100644
@@ -141,7 +141,7 @@ struct recv_frame *_rtw_alloc_recvframe(struct __queue *pfree_recv_queue)
 		}
 	}
 
-	return (struct recv_frame *)hdr;
+	return hdr;
 }
 
 struct recv_frame *rtw_alloc_recvframe(struct __queue *pfree_recv_queue)
@@ -240,7 +240,7 @@ void rtw_free_recvframe_queue(struct __queue *pframequeue,  struct __queue *pfre
 
 		plist = plist->next;
 
-		rtw_free_recvframe((struct recv_frame *)hdr, pfree_recv_queue);
+		rtw_free_recvframe(hdr, pfree_recv_queue);
 	}
 
 	spin_unlock(&pframequeue->lock);
@@ -1417,7 +1417,7 @@ static struct recv_frame *recvframe_defrag(struct adapter *adapter,
 	phead = get_list_head(defrag_q);
 	plist = phead->next;
 	pfhdr = container_of(plist, struct recv_frame, list);
-	prframe = (struct recv_frame *)pfhdr;
+	prframe = pfhdr;
 	list_del_init(&(prframe->list));
 
 	if (curfragnum != pfhdr->attrib.frag_num) {
@@ -1437,7 +1437,7 @@ static struct recv_frame *recvframe_defrag(struct adapter *adapter,
 
 	while (phead != plist) {
 		pnfhdr = container_of(plist, struct recv_frame, list);
-		pnextrframe = (struct recv_frame *)pnfhdr;
+		pnextrframe = pnfhdr;
 
 		/* check the fragment sequence  (2nd ~n fragment frame) */
 
@@ -1780,7 +1780,7 @@ static int recv_indicatepkts_in_order(struct adapter *padapter, struct recv_reor
 	/*  Check if there is any packet need indicate. */
 	while (!list_empty(phead)) {
 		prhdr = container_of(plist, struct recv_frame, list);
-		prframe = (struct recv_frame *)prhdr;
+		prframe = prhdr;
 		pattrib = &prframe->attrib;
 
 		if (!SN_LESS(preorder_ctrl->indicate_seq, pattrib->seq_num)) {
--

2.1.4

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20160225124135.GA7636%40Karyakshetra.
For more options, visit https://groups.google.com/d/optout.

#2 lore raw
Quoted 14 lines · Julia Lawall
Quoted 11 lines · Bhaktipriya Shridhar

Casting a pointer to a pointer of the same type is unnecessary, so remove these unnecessary casts.

This was done with Coccinelle:

@@
type T;
T *ptr;
@@
- (T *)ptr
+ ptr

Quoted 3 lines

Good idea :)

julia

Thanks! :D

Quoted 66 lines
Quoted 66 lines
---
 drivers/staging/rtl8188eu/core/rtw_recv.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/staging/rtl8188eu/core/rtw_recv.c +5 -6
index 40b7a30..d3c9ded 100644
@@ -141,7 +141,7 @@ struct recv_frame *_rtw_alloc_recvframe(struct __queue *pfree_recv_queue)
              }
      }
 
-     return (struct recv_frame *)hdr;
+     return hdr;
 }
 
 struct recv_frame *rtw_alloc_recvframe(struct __queue *pfree_recv_queue)
@@ -240,7 +240,7 @@ void rtw_free_recvframe_queue(struct __queue *pframequeue,  struct __queue *pfre
 
              plist = plist->next;
 
-             rtw_free_recvframe((struct recv_frame *)hdr, pfree_recv_queue);
+             rtw_free_recvframe(hdr, pfree_recv_queue);
      }
 
      spin_unlock(&pframequeue->lock);
@@ -1417,7 +1417,7 @@ static struct recv_frame *recvframe_defrag(struct adapter *adapter,
      phead = get_list_head(defrag_q);
      plist = phead->next;
      pfhdr = container_of(plist, struct recv_frame, list);
-     prframe = (struct recv_frame *)pfhdr;
+     prframe = pfhdr;
      list_del_init(&(prframe->list));
 
      if (curfragnum != pfhdr->attrib.frag_num) {
@@ -1437,7 +1437,7 @@ static struct recv_frame *recvframe_defrag(struct adapter *adapter,
 
      while (phead != plist) {
              pnfhdr = container_of(plist, struct recv_frame, list);
-             pnextrframe = (struct recv_frame *)pnfhdr;
+             pnextrframe = pnfhdr;
 
              /* check the fragment sequence  (2nd ~n fragment frame) */
 
@@ -1780,7 +1780,7 @@ static int recv_indicatepkts_in_order(struct adapter *padapter, struct recv_reor
      /*  Check if there is any packet need indicate. */
      while (!list_empty(phead)) {
              prhdr = container_of(plist, struct recv_frame, list);
-             prframe = (struct recv_frame *)prhdr;
+             prframe = prhdr;
              pattrib = &prframe->attrib;
 
              if (!SN_LESS(preorder_ctrl->indicate_seq, pattrib->seq_num)) {
--

2.1.4

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20160225124135.GA7636%40Karyakshetra.
For more options, visit https://groups.google.com/d/optout.