Skip to contentSkip to conversation

dgnc: remove useless cast on kzalloc()

PATCH In review Fengguang Wu 2 participants 3 messages Sep 26, 2013 – Sep 27, 2013 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dgnc: remove useless cast on kzalloc()

drivers/staging/dgnc/dgnc_driver.c:510:3-7: WARNING: casting value returned by k[cmz]alloc to (char *) is useless. drivers/staging/dgnc/dgnc_driver.c:502:2-19: WARNING: casting value returned by k[cmz]alloc to (struct dgnc_board *) is useless.

Casting (void *) value returned by kmalloc is useless as mentioned in Documentation/CodingStyle, Chap 14.

Generated by: coccinelle/api/alloc/drop_kmalloc_cast.cocci

CC Lidza Louina <[email protected]>
CC Greg Kroah-Hartman <[email protected]>

---

 drivers/staging/dgnc/dgnc_driver.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/dgnc/dgnc_driver.c +2 -2
@@ -499,7 +499,7 @@ static int dgnc_found_board(struct pci_d
 
 	/* get the board structure and prep it */
 	brd = dgnc_Board[dgnc_NumBoards] =
-	(struct board_t *) kzalloc(sizeof(struct board_t), GFP_KERNEL);
+		kzalloc(sizeof(struct board_t), GFP_KERNEL);
 	if (!brd) {
 		APR(("memory allocation for board structure failed\n"));
 		return(-ENOMEM);
@@ -507,7 +507,7 @@ static int dgnc_found_board(struct pci_d
 
 	/* make a temporary message buffer for the boot messages */
 	brd->msgbuf = brd->msgbuf_head =
-		(char *) kzalloc(sizeof(char) * 8192, GFP_KERNEL);
+		kzalloc(sizeof(char) * 8192, GFP_KERNEL);
 	if (!brd->msgbuf) {
 		kfree(brd);
 		APR(("memory allocation for board msgbuf failed\n"));
#1 lore raw
Quoted 8 lines · Fengguang Wu

drivers/staging/dgnc/dgnc_driver.c:510:3-7: WARNING: casting value returned by k[cmz]alloc to (char *) is useless. drivers/staging/dgnc/dgnc_driver.c:502:2-19: WARNING: casting value returned by k[cmz]alloc to (struct dgnc_board *) is useless.

Casting (void *) value returned by kmalloc is useless as mentioned in Documentation/CodingStyle, Chap 14.

Generated by: coccinelle/api/alloc/drop_kmalloc_cast.cocci

Quoted 7 lines
CC Lidza Louina <[email protected]>
CC Greg Kroah-Hartman <[email protected]>

---

 drivers/staging/dgnc/dgnc_driver.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

As Jingoo sent this a few minutes before you did, and also cleaned up another cast that you missed, I've added your signed-off-by to his patch, as they were the same (although yours didn't apply and his did...)

thanks,

greg k-h

#2 lore raw
Quoted 14 lines · Greg KH
Quoted 13 lines · Fengguang Wu

drivers/staging/dgnc/dgnc_driver.c:510:3-7: WARNING: casting value returned by k[cmz]alloc to (char *) is useless. drivers/staging/dgnc/dgnc_driver.c:502:2-19: WARNING: casting value returned by k[cmz]alloc to (struct dgnc_board *) is useless.

Casting (void *) value returned by kmalloc is useless as mentioned in Documentation/CodingStyle, Chap 14.

Generated by: coccinelle/api/alloc/drop_kmalloc_cast.cocci

CC Lidza Louina <[email protected]>
CC Greg Kroah-Hartman <[email protected]>

---

Quoted 7 lines
Quoted 2 lines
 drivers/staging/dgnc/dgnc_driver.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

As Jingoo sent this a few minutes before you did, and also cleaned up another cast that you missed, I've added your signed-off-by to his patch, as they were the same (although yours didn't apply and his did...)

That'd be good, thanks!

Regards,
Fengguang