Skip to contentSkip to conversation

staging: rdma: hfi1: Drop void pointer cast

PATCH In review Janani Ravichandran 2 participants 3 messages Feb 25, 2016 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: rdma: hfi1: Drop void pointer cast

Void pointers need not be cast to other pointer types. Semantic patch used:

@r@
expression x;
void *e;
type T;
identifier f;
@@

(
*((T *)e)
|
((T *)x) [...]
|
((T *)x)->f
|
- (T *)
e
)

---
 drivers/staging/rdma/hfi1/hfi.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rdma/hfi1/hfi.h +1 -1
index d4826a9..838459f 100644
@@ -1173,7 +1173,7 @@ int handle_receive_interrupt_dma_rtail(struct hfi1_ctxtdata *, int);
 /* calculate the current RHF address */
 static inline __le32 *get_rhf_addr(struct hfi1_ctxtdata *rcd)
 {
-	return (__le32 *)rcd->rcvhdrq + rcd->head + rcd->dd->rhf_offset;
+	return rcd->rcvhdrq + rcd->head + rcd->dd->rhf_offset;
 }
 
 int hfi1_reset_device(int);
Signature · 1 line
2.5.0
#1 lore raw
Quoted 31 lines · Janani Ravichandran

Void pointers need not be cast to other pointer types. Semantic patch used:

@r@
expression x;
void *e;
type T;
identifier f;
@@

(
*((T *)e)
|
((T *)x) [...]
|
((T *)x)->f
|
- (T *)
e
)

---
 drivers/staging/rdma/hfi1/hfi.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/rdma/hfi1/hfi.h +0 -0
index d4826a9..838459f 100644

drivers/staging/rdma/hfi1/hfi.h int handle_receive_interrupt_dma_rtail(struct hfi1_ctxtdata *, int); · line 1176

Quoted 5 lines
drivers/staging/rdma/hfi1/hfi.h +1 -1
@@ -1173,7 +1173,7 @@ int handle_receive_interrupt_dma_rtail(struct hfi1_ctxtdata *, int);
 /* calculate the current RHF address */
 static inline __le32 *get_rhf_addr(struct hfi1_ctxtdata *rcd)
 {
-	return (__le32 *)rcd->rcvhdrq + rcd->head + rcd->dd->rhf_offset;
+	return rcd->rcvhdrq + rcd->head + rcd->dd->rhf_offset;

I'm not sure at all about this. I think your semantic patch needs a case for pointer arithmetic too... Pointer addition of eg 1 adds 1 * the size of the pointed object.

julia

Quoted 13 lines
drivers/staging/rdma/hfi1/hfi.h +0 -1
 }
 
 int hfi1_reset_device(int);
--

2.5.0

--
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/20160225200301.GA8020%40janani-Inspiron-3521.
For more options, visit https://groups.google.com/d/optout.

#2 lore raw
Quoted 43 lines · Julia Lawall
Quoted 21 lines · Janani Ravichandran

Void pointers need not be cast to other pointer types. Semantic patch used:

@r@
expression x;
void *e;
type T;
identifier f;
@@

(
*((T *)e)
|
((T *)x) [...]
|
((T *)x)->f
|
- (T *)
e
)

Review

Quoted 6 lines
---
 drivers/staging/rdma/hfi1/hfi.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/staging/rdma/hfi1/hfi.h

drivers/staging/rdma/hfi1/hfi.h int handle_receive_interrupt_dma_rtail(struct

Quoted 4 lines

index d4826a9..838459f 100644

drivers/staging/rdma/hfi1/hfi.h +0 -0
@@ -1173,7 +1173,7 @@ int handle_receive_interrupt_dma_rtail(struct

hfi1_ctxtdata *, int);

drivers/staging/rdma/hfi1/hfi.h int handle_receive_interrupt_dma_rtail(struct hfi1_ctxtdata *, int); · line 1176

Quoted 5 lines
drivers/staging/rdma/hfi1/hfi.h +1 -1
 /* calculate the current RHF address */
 static inline __le32 *get_rhf_addr(struct hfi1_ctxtdata *rcd)
 {
-     return (__le32 *)rcd->rcvhdrq + rcd->head + rcd->dd->rhf_offset;
+     return rcd->rcvhdrq + rcd->head + rcd->dd->rhf_offset;
Quoted 5 lines

I'm not sure at all about this. I think your semantic patch needs a case for pointer arithmetic too... Pointer addition of eg 1 adds 1 * the size of the pointed object.

Oh yes. This is not right. Thanks for bringing it to my attention.

Janani.

Quoted 20 lines

julia

Quoted 8 lines
drivers/staging/rdma/hfi1/hfi.h +0 -1
 }
 
 int hfi1_reset_device(int);
--

2.5.0

--
You received this message because you are subscribed to the Google

Groups "outreachy-kernel" group.

Quoted 1 line

To unsubscribe from this group and stop receiving emails from it, send

an email to [email protected].

Quoted 2 lines

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/20160225200301.GA8020%40janani-Inspiron-3521
.

Quoted 2 lines

For more options, visit https://groups.google.com/d/optout.