public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 01/30] ia64: Remove unnecessary cast of allocation return value in sn_hwperf_enum_objects()
       [not found] <Message-Id: <200708240135.56833.jesper.juhl@gmail.com>
@ 2007-08-23 23:40 ` Jesper Juhl
  2007-08-23 23:42   ` [PATCH 02/30] cris: Remove unnecessary cast of allocation return value in intmem.c Jesper Juhl
                     ` (26 more replies)
  0 siblings, 27 replies; 65+ messages in thread
From: Jesper Juhl @ 2007-08-23 23:40 UTC (permalink / raw)
  To: Linux Kernel Mailing List
  Cc: Mark Goodwin, Tony Luck, linux-ia64, Jes Sorensen, linux-altix,
	Jesper Juhl

vmalloc() returns a void pointer - no need to cast it.

Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---
 arch/ia64/sn/kernel/sn2/sn_hwperf.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/arch/ia64/sn/kernel/sn2/sn_hwperf.c b/arch/ia64/sn/kernel/sn2/sn_hwperf.c
index df8d5be..1a8e496 100644
--- a/arch/ia64/sn/kernel/sn2/sn_hwperf.c
+++ b/arch/ia64/sn/kernel/sn2/sn_hwperf.c
@@ -66,7 +66,8 @@ static int sn_hwperf_enum_objects(int *nobj, struct sn_hwperf_object_info **ret)
 	}
 
 	sz = sn_hwperf_obj_cnt * sizeof(struct sn_hwperf_object_info);
-	if ((objbuf = (struct sn_hwperf_object_info *) vmalloc(sz)) == NULL) {
+	objbuf = vmalloc(sz);
+	if (objbuf == NULL) {
 		printk("sn_hwperf_enum_objects: vmalloc(%d) failed\n", (int)sz);
 		e = -ENOMEM;
 		goto out;
-- 
1.5.2.2


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH 02/30] cris: Remove unnecessary cast of allocation return value in intmem.c
  2007-08-23 23:40 ` [PATCH 01/30] ia64: Remove unnecessary cast of allocation return value in sn_hwperf_enum_objects() Jesper Juhl
@ 2007-08-23 23:42   ` Jesper Juhl
  2007-08-23 23:43   ` [PATCH 03/30] um: Don't unnecessarily cast allocation return value in ubd_kern.c Jesper Juhl
                     ` (25 subsequent siblings)
  26 siblings, 0 replies; 65+ messages in thread
From: Jesper Juhl @ 2007-08-23 23:42 UTC (permalink / raw)
  To: Linux Kernel Mailing List; +Cc: Mikael Starvik, dev-etrax, Jesper Juhl

kmalloc() returns a void pointer so there's no need to cast the
return value.

Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---
 arch/cris/arch-v32/mm/intmem.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/arch/cris/arch-v32/mm/intmem.c b/arch/cris/arch-v32/mm/intmem.c
index 41ee7f7..691cf3b 100644
--- a/arch/cris/arch-v32/mm/intmem.c
+++ b/arch/cris/arch-v32/mm/intmem.c
@@ -27,8 +27,8 @@ static void crisv32_intmem_init(void)
 {
 	static int initiated = 0;
 	if (!initiated) {
-		struct intmem_allocation* alloc =
-		  (struct intmem_allocation*)kmalloc(sizeof *alloc, GFP_KERNEL);
+		struct intmem_allocation *alloc =
+			kmalloc(sizeof *alloc, GFP_KERNEL);
 		INIT_LIST_HEAD(&intmem_allocations);
 		intmem_virtual = ioremap(MEM_INTMEM_START, MEM_INTMEM_SIZE);
 		initiated = 1;
@@ -55,8 +55,7 @@ void* crisv32_intmem_alloc(unsigned size, unsigned align)
 		if (allocation->status == STATUS_FREE &&
 		    allocation->size >= size + alignment) {
 			if (allocation->size > size + alignment) {
-				struct intmem_allocation* alloc =
-					(struct intmem_allocation*)
+				struct intmem_allocation *alloc =
 					kmalloc(sizeof *alloc, GFP_ATOMIC);
 				alloc->status = STATUS_FREE;
 				alloc->size = allocation->size - size - alignment;
@@ -64,8 +63,7 @@ void* crisv32_intmem_alloc(unsigned size, unsigned align)
 				list_add(&alloc->entry, &allocation->entry);
 
 				if (alignment) {
-					struct intmem_allocation* tmp;
-					tmp = (struct intmem_allocation*)
+					struct intmem_allocation *tmp =
 						kmalloc(sizeof *tmp, GFP_ATOMIC);
 					tmp->offset = allocation->offset;
 					tmp->size = alignment;
-- 
1.5.2.2


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH 03/30] um: Don't unnecessarily cast allocation return value in ubd_kern.c
  2007-08-23 23:40 ` [PATCH 01/30] ia64: Remove unnecessary cast of allocation return value in sn_hwperf_enum_objects() Jesper Juhl
  2007-08-23 23:42   ` [PATCH 02/30] cris: Remove unnecessary cast of allocation return value in intmem.c Jesper Juhl
@ 2007-08-23 23:43   ` Jesper Juhl
  2007-08-24  0:22     ` Jeff Dike
  2007-08-23 23:45   ` [PATCH 04/30] powerpc: Don't cast kmalloc return value in ibmebus.c Jesper Juhl
                     ` (24 subsequent siblings)
  26 siblings, 1 reply; 65+ messages in thread
From: Jesper Juhl @ 2007-08-23 23:43 UTC (permalink / raw)
  To: Linux Kernel Mailing List; +Cc: Jeff Dike, user-mode-linux-devel, Jesper Juhl

vmalloc() returns a void pointer, so casting to (void *) is pretty pointless.

Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---
 arch/um/drivers/ubd_kern.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
index 0eabe73..25b248a 100644
--- a/arch/um/drivers/ubd_kern.c
+++ b/arch/um/drivers/ubd_kern.c
@@ -615,7 +615,7 @@ static int ubd_open_dev(struct ubd *ubd_dev)
 		blk_queue_max_sectors(ubd_dev->queue, 8 * sizeof(long));
 
 		err = -ENOMEM;
-		ubd_dev->cow.bitmap = (void *) vmalloc(ubd_dev->cow.bitmap_len);
+		ubd_dev->cow.bitmap = vmalloc(ubd_dev->cow.bitmap_len);
 		if(ubd_dev->cow.bitmap == NULL){
 			printk(KERN_ERR "Failed to vmalloc COW bitmap\n");
 			goto error;
-- 
1.5.2.2


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH 04/30] powerpc: Don't cast kmalloc return value in ibmebus.c
  2007-08-23 23:40 ` [PATCH 01/30] ia64: Remove unnecessary cast of allocation return value in sn_hwperf_enum_objects() Jesper Juhl
  2007-08-23 23:42   ` [PATCH 02/30] cris: Remove unnecessary cast of allocation return value in intmem.c Jesper Juhl
  2007-08-23 23:43   ` [PATCH 03/30] um: Don't unnecessarily cast allocation return value in ubd_kern.c Jesper Juhl
@ 2007-08-23 23:45   ` Jesper Juhl
  2007-08-24  0:37     ` Joachim Fenkes
  2007-08-23 23:46   ` [PATCH 05/30] atm: No need to cast vmalloc() return value Jesper Juhl
                     ` (23 subsequent siblings)
  26 siblings, 1 reply; 65+ messages in thread
From: Jesper Juhl @ 2007-08-23 23:45 UTC (permalink / raw)
  To: Linux Kernel Mailing List
  Cc: Paul Mackerras, linuxppc-dev, Joachim Fenkes, Heiko J Schick,
	Jesper Juhl

kmalloc() returns a void pointer so there is absolutely no need to
cast it in ibmebus_chomp().

Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---
 arch/powerpc/kernel/ibmebus.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/arch/powerpc/kernel/ibmebus.c b/arch/powerpc/kernel/ibmebus.c
index 9a8c9af..9514e66 100644
--- a/arch/powerpc/kernel/ibmebus.c
+++ b/arch/powerpc/kernel/ibmebus.c
@@ -383,7 +383,8 @@ static int ibmebus_match_path(struct device *dev, void *data)
 
 static char *ibmebus_chomp(const char *in, size_t count)
 {
-	char *out = (char*)kmalloc(count + 1, GFP_KERNEL);
+	char *out = kmalloc(count + 1, GFP_KERNEL);
+
 	if (!out)
 		return NULL;
 
-- 
1.5.2.2


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH 05/30] atm: No need to cast vmalloc() return value
  2007-08-23 23:40 ` [PATCH 01/30] ia64: Remove unnecessary cast of allocation return value in sn_hwperf_enum_objects() Jesper Juhl
                     ` (2 preceding siblings ...)
  2007-08-23 23:45   ` [PATCH 04/30] powerpc: Don't cast kmalloc return value in ibmebus.c Jesper Juhl
@ 2007-08-23 23:46   ` Jesper Juhl
  2007-08-23 23:48   ` [PATCH 06/30] i2o: No need to cast kmalloc() return value in cfg_open() Jesper Juhl
                     ` (22 subsequent siblings)
  26 siblings, 0 replies; 65+ messages in thread
From: Jesper Juhl @ 2007-08-23 23:46 UTC (permalink / raw)
  To: Linux Kernel Mailing List; +Cc: Chas Williams, Jesper Juhl

vmalloc() returns void*, no need to cast it in drivers/atm/lanai.c

Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---
 drivers/atm/lanai.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
index 144a49f..59e7dde 100644
--- a/drivers/atm/lanai.c
+++ b/drivers/atm/lanai.c
@@ -1459,7 +1459,7 @@ static int __devinit vcc_table_allocate(struct lanai_dev *lanai)
 	return (lanai->vccs == NULL) ? -ENOMEM : 0;
 #else
 	int bytes = (lanai->num_vci) * sizeof(struct lanai_vcc *);
-	lanai->vccs = (struct lanai_vcc **) vmalloc(bytes);
+	lanai->vccs = vmalloc(bytes);
 	if (unlikely(lanai->vccs == NULL))
 		return -ENOMEM;
 	memset(lanai->vccs, 0, bytes);
-- 
1.5.2.2


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH 06/30] i2o: No need to cast kmalloc() return value in cfg_open()
  2007-08-23 23:40 ` [PATCH 01/30] ia64: Remove unnecessary cast of allocation return value in sn_hwperf_enum_objects() Jesper Juhl
                     ` (3 preceding siblings ...)
  2007-08-23 23:46   ` [PATCH 05/30] atm: No need to cast vmalloc() return value Jesper Juhl
@ 2007-08-23 23:48   ` Jesper Juhl
  2007-08-23 23:50   ` [PATCH 07/30] mtd: Get rid of pointless cast of kzalloc() return value in AT26xxx driver Jesper Juhl
                     ` (21 subsequent siblings)
  26 siblings, 0 replies; 65+ messages in thread
From: Jesper Juhl @ 2007-08-23 23:48 UTC (permalink / raw)
  To: Linux Kernel Mailing List; +Cc: Alan Cox, Jesper Juhl

In drivers/message/i2o/i2o_config.c::cfg_open() there's a completely
pointless cast of kmalloc()'s return value. This patch removes it.

Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---
 drivers/message/i2o/i2o_config.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/message/i2o/i2o_config.c b/drivers/message/i2o/i2o_config.c
index 84e046e..fb8c668 100644
--- a/drivers/message/i2o/i2o_config.c
+++ b/drivers/message/i2o/i2o_config.c
@@ -1053,10 +1053,9 @@ static int i2o_cfg_ioctl(struct inode *inode, struct file *fp, unsigned int cmd,
 
 static int cfg_open(struct inode *inode, struct file *file)
 {
-	struct i2o_cfg_info *tmp =
-	    (struct i2o_cfg_info *)kmalloc(sizeof(struct i2o_cfg_info),
-					   GFP_KERNEL);
 	unsigned long flags;
+	struct i2o_cfg_info *tmp =
+		kmalloc(sizeof(struct i2o_cfg_info), GFP_KERNEL);
 
 	if (!tmp)
 		return -ENOMEM;
-- 
1.5.2.2


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH 07/30] mtd: Get rid of pointless cast of kzalloc() return value in AT26xxx driver
  2007-08-23 23:40 ` [PATCH 01/30] ia64: Remove unnecessary cast of allocation return value in sn_hwperf_enum_objects() Jesper Juhl
                     ` (4 preceding siblings ...)
  2007-08-23 23:48   ` [PATCH 06/30] i2o: No need to cast kmalloc() return value in cfg_open() Jesper Juhl
@ 2007-08-23 23:50   ` Jesper Juhl
  2007-08-23 23:51   ` [PATCH 08/30] mtd: Avoid a pointless kmalloc() return value cast in TQM8xxL mapping handling code Jesper Juhl
                     ` (20 subsequent siblings)
  26 siblings, 0 replies; 65+ messages in thread
From: Jesper Juhl @ 2007-08-23 23:50 UTC (permalink / raw)
  To: Linux Kernel Mailing List
  Cc: David Woodhouse, linux-mtd, Hans J Koch, Jesper Juhl

kzalloc() returns a void pointer - no need to cast it in
 drivers/mtd/devices/at91_dataflash26.c::add_dataflash()

Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---
 drivers/mtd/devices/at91_dataflash26.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/devices/at91_dataflash26.c b/drivers/mtd/devices/at91_dataflash26.c
index 64ce37f..9c4aac4 100644
--- a/drivers/mtd/devices/at91_dataflash26.c
+++ b/drivers/mtd/devices/at91_dataflash26.c
@@ -360,8 +360,7 @@ static int __init add_dataflash(int channel, char *name, int nr_pages,
 	device->read = at91_dataflash26_read;
 	device->write = at91_dataflash26_write;
 
-	priv = (struct dataflash_local *)kzalloc(sizeof(struct dataflash_local),
-		GFP_KERNEL);
+	priv = kzalloc(sizeof(struct dataflash_local), GFP_KERNEL);
 	if (!priv) {
 		kfree(device);
 		return -ENOMEM;
-- 
1.5.2.2


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH 08/30] mtd: Avoid a pointless kmalloc() return value cast in TQM8xxL mapping handling code
  2007-08-23 23:40 ` [PATCH 01/30] ia64: Remove unnecessary cast of allocation return value in sn_hwperf_enum_objects() Jesper Juhl
                     ` (5 preceding siblings ...)
  2007-08-23 23:50   ` [PATCH 07/30] mtd: Get rid of pointless cast of kzalloc() return value in AT26xxx driver Jesper Juhl
@ 2007-08-23 23:51   ` Jesper Juhl
  2007-08-23 23:52   ` [PATCH 09/30] mtd: Don't cast kmalloc() return value in drivers/mtd/maps/pmcmsp-flash.c Jesper Juhl
                     ` (19 subsequent siblings)
  26 siblings, 0 replies; 65+ messages in thread
From: Jesper Juhl @ 2007-08-23 23:51 UTC (permalink / raw)
  To: Linux Kernel Mailing List
  Cc: David Woodhouse, linux-mtd, Kirk Lee, Jesper Juhl

In drivers/mtd/maps/tqm8xxl.c::init_tqm_mtd() it is pointless casting
the return value of kmalloc() since it returns void*.

Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---
 drivers/mtd/maps/tqm8xxl.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/maps/tqm8xxl.c b/drivers/mtd/maps/tqm8xxl.c
index 37e4ded..1d75ce4 100644
--- a/drivers/mtd/maps/tqm8xxl.c
+++ b/drivers/mtd/maps/tqm8xxl.c
@@ -141,8 +141,7 @@ int __init init_tqm_mtd(void)
 			goto error_mem;
 		}
 
-		map_banks[idx]->name = (char *)kmalloc(16, GFP_KERNEL);
-
+		map_banks[idx]->name = kmalloc(16, GFP_KERNEL);
 		if (!map_banks[idx]->name) {
 			ret = -ENOMEM;
 			/* FIXME: What if some MTD devices were probed already? */
-- 
1.5.2.2


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH 09/30] mtd: Don't cast kmalloc() return value in drivers/mtd/maps/pmcmsp-flash.c
  2007-08-23 23:40 ` [PATCH 01/30] ia64: Remove unnecessary cast of allocation return value in sn_hwperf_enum_objects() Jesper Juhl
                     ` (6 preceding siblings ...)
  2007-08-23 23:51   ` [PATCH 08/30] mtd: Avoid a pointless kmalloc() return value cast in TQM8xxL mapping handling code Jesper Juhl
@ 2007-08-23 23:52   ` Jesper Juhl
  2007-08-24 10:41     ` Denys Vlasenko
  2007-08-23 23:54   ` [PATCH 10/30] irda: Do not do pointless kmalloc return value cast in KingSun driver Jesper Juhl
                     ` (18 subsequent siblings)
  26 siblings, 1 reply; 65+ messages in thread
From: Jesper Juhl @ 2007-08-23 23:52 UTC (permalink / raw)
  To: Linux Kernel Mailing List; +Cc: David Woodhouse, linux-mtd, Jesper Juhl

kmalloc() returns a void pointer.
No need to cast it.

Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---
 drivers/mtd/maps/pmcmsp-flash.c |   13 +++++--------
 1 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/drivers/mtd/maps/pmcmsp-flash.c b/drivers/mtd/maps/pmcmsp-flash.c
index 7e0377e..dfdb120 100644
--- a/drivers/mtd/maps/pmcmsp-flash.c
+++ b/drivers/mtd/maps/pmcmsp-flash.c
@@ -73,12 +73,9 @@ int __init init_msp_flash(void)
 		return -ENXIO;
 
 	printk(KERN_NOTICE "Found %d PMC flash devices\n", fcnt);
-	msp_flash = (struct mtd_info **)kmalloc(
-			fcnt * sizeof(struct map_info *), GFP_KERNEL);
-	msp_parts = (struct mtd_partition **)kmalloc(
-			fcnt * sizeof(struct mtd_partition *), GFP_KERNEL);
-	msp_maps = (struct map_info *)kmalloc(
-			fcnt * sizeof(struct mtd_info), GFP_KERNEL);
+	msp_flash = kmalloc(fcnt * sizeof(struct map_info *), GFP_KERNEL);
+	msp_parts = kmalloc(fcnt * sizeof(struct mtd_partition *), GFP_KERNEL);
+	msp_maps = kmalloc(fcnt * sizeof(struct mtd_info), GFP_KERNEL);
 	memset(msp_maps, 0, fcnt * sizeof(struct mtd_info));
 
 	/* loop over the flash devices, initializing each */
@@ -95,8 +92,8 @@ int __init init_msp_flash(void)
 			continue;
 		}
 
-		msp_parts[i] = (struct mtd_partition *)kmalloc(
-			pcnt * sizeof(struct mtd_partition), GFP_KERNEL);
+		msp_parts[i] = kmalloc(pcnt * sizeof(struct mtd_partition),
+			GFP_KERNEL);
 		memset(msp_parts[i], 0, pcnt * sizeof(struct mtd_partition));
 
 		/* now initialize the devices proper */
-- 
1.5.2.2


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH 10/30] irda: Do not do pointless kmalloc return value cast in KingSun driver
  2007-08-23 23:40 ` [PATCH 01/30] ia64: Remove unnecessary cast of allocation return value in sn_hwperf_enum_objects() Jesper Juhl
                     ` (7 preceding siblings ...)
  2007-08-23 23:52   ` [PATCH 09/30] mtd: Don't cast kmalloc() return value in drivers/mtd/maps/pmcmsp-flash.c Jesper Juhl
@ 2007-08-23 23:54   ` Jesper Juhl
  2007-08-25  6:23     ` David Miller
  2007-08-24  0:03   ` [PATCH 14/30] net: Kill some unneeded allocation return value casts in libertas Jesper Juhl
                     ` (17 subsequent siblings)
  26 siblings, 1 reply; 65+ messages in thread
From: Jesper Juhl @ 2007-08-23 23:54 UTC (permalink / raw)
  To: Linux Kernel Mailing List; +Cc: Samuel Ortiz, Alex V Lasso, Jesper Juhl

kmalloc() returns a void pointer, so there is no need to cast it in
 drivers/net/irda/kingsun-sir.c::kingsun_probe().

Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---
 drivers/net/irda/kingsun-sir.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/irda/kingsun-sir.c b/drivers/net/irda/kingsun-sir.c
index bdd5c97..4e5101a 100644
--- a/drivers/net/irda/kingsun-sir.c
+++ b/drivers/net/irda/kingsun-sir.c
@@ -509,12 +509,12 @@ static int kingsun_probe(struct usb_interface *intf,
 	spin_lock_init(&kingsun->lock);
 
 	/* Allocate input buffer */
-	kingsun->in_buf = (__u8 *)kmalloc(kingsun->max_rx, GFP_KERNEL);
+	kingsun->in_buf = kmalloc(kingsun->max_rx, GFP_KERNEL);
 	if (!kingsun->in_buf)
 		goto free_mem;
 
 	/* Allocate output buffer */
-	kingsun->out_buf = (__u8 *)kmalloc(KINGSUN_FIFO_SIZE, GFP_KERNEL);
+	kingsun->out_buf = kmalloc(KINGSUN_FIFO_SIZE, GFP_KERNEL);
 	if (!kingsun->out_buf)
 		goto free_mem;
 
-- 
1.5.2.2


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH 14/30] net: Kill some unneeded allocation return value casts in libertas
  2007-08-23 23:40 ` [PATCH 01/30] ia64: Remove unnecessary cast of allocation return value in sn_hwperf_enum_objects() Jesper Juhl
                     ` (8 preceding siblings ...)
  2007-08-23 23:54   ` [PATCH 10/30] irda: Do not do pointless kmalloc return value cast in KingSun driver Jesper Juhl
@ 2007-08-24  0:03   ` Jesper Juhl
  2007-08-24 15:50     ` Dan Williams
  2007-08-24  0:06   ` [PATCH 16/30] net: Avoid pointless allocation casts in BSD compression module Jesper Juhl
                     ` (16 subsequent siblings)
  26 siblings, 1 reply; 65+ messages in thread
From: Jesper Juhl @ 2007-08-24  0:03 UTC (permalink / raw)
  To: Linux Kernel Mailing List; +Cc: netdev, linux-wireless, Jesper Juhl

kmalloc() and friends return void*, no need to cast it.

Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---
 drivers/net/wireless/libertas/debugfs.c |    2 +-
 drivers/net/wireless/libertas/ethtool.c |    3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/libertas/debugfs.c b/drivers/net/wireless/libertas/debugfs.c
index 715cbda..6ade63e 100644
--- a/drivers/net/wireless/libertas/debugfs.c
+++ b/drivers/net/wireless/libertas/debugfs.c
@@ -1839,7 +1839,7 @@ static ssize_t wlan_debugfs_write(struct file *f, const char __user *buf,
 	char *p2;
 	struct debug_data *d = (struct debug_data *)f->private_data;
 
-	pdata = (char *)kmalloc(cnt, GFP_KERNEL);
+	pdata = kmalloc(cnt, GFP_KERNEL);
 	if (pdata == NULL)
 		return 0;
 
diff --git a/drivers/net/wireless/libertas/ethtool.c b/drivers/net/wireless/libertas/ethtool.c
index 96f1974..7dad493 100644
--- a/drivers/net/wireless/libertas/ethtool.c
+++ b/drivers/net/wireless/libertas/ethtool.c
@@ -60,8 +60,7 @@ static int libertas_ethtool_get_eeprom(struct net_device *dev,
 
 //      mutex_lock(&priv->mutex);
 
-	adapter->prdeeprom =
-		    (char *)kmalloc(eeprom->len+sizeof(regctrl), GFP_KERNEL);
+	adapter->prdeeprom = kmalloc(eeprom->len+sizeof(regctrl), GFP_KERNEL);
 	if (!adapter->prdeeprom)
 		return -ENOMEM;
 	memcpy(adapter->prdeeprom, &regctrl, sizeof(regctrl));
-- 
1.5.2.2


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH 16/30] net: Avoid pointless allocation casts in BSD compression module
  2007-08-23 23:40 ` [PATCH 01/30] ia64: Remove unnecessary cast of allocation return value in sn_hwperf_enum_objects() Jesper Juhl
                     ` (9 preceding siblings ...)
  2007-08-24  0:03   ` [PATCH 14/30] net: Kill some unneeded allocation return value casts in libertas Jesper Juhl
@ 2007-08-24  0:06   ` Jesper Juhl
  2007-08-25  6:25     ` David Miller
  2007-08-24  0:09   ` [PATCH 17/30] isdn: Get rid of some pointless allocation casts in common and bsd comp Jesper Juhl
                     ` (15 subsequent siblings)
  26 siblings, 1 reply; 65+ messages in thread
From: Jesper Juhl @ 2007-08-24  0:06 UTC (permalink / raw)
  To: Linux Kernel Mailing List; +Cc: netdev, davem, Jesper Juhl

The general kernel memory allocation functions return void pointers
and there is no need to cast their return values.

Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---
 drivers/net/bsd_comp.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/bsd_comp.c b/drivers/net/bsd_comp.c
index 202d4a4..88edb98 100644
--- a/drivers/net/bsd_comp.c
+++ b/drivers/net/bsd_comp.c
@@ -406,8 +406,7 @@ static void *bsd_alloc (unsigned char *options, int opt_len, int decomp)
  * Allocate space for the dictionary. This may be more than one page in
  * length.
  */
-    db->dict = (struct bsd_dict *) vmalloc (hsize *
-					    sizeof (struct bsd_dict));
+    db->dict = vmalloc(hsize * sizeof(struct bsd_dict));
     if (!db->dict)
       {
 	bsd_free (db);
@@ -426,8 +425,7 @@ static void *bsd_alloc (unsigned char *options, int opt_len, int decomp)
  */
     else
       {
-        db->lens = (unsigned short *) vmalloc ((maxmaxcode + 1) *
-					       sizeof (db->lens[0]));
+        db->lens = vmalloc((maxmaxcode + 1) * sizeof(db->lens[0]));
 	if (!db->lens)
 	  {
 	    bsd_free (db);
-- 
1.5.2.2


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH 17/30] isdn: Get rid of some pointless allocation casts in common and bsd comp.
  2007-08-23 23:40 ` [PATCH 01/30] ia64: Remove unnecessary cast of allocation return value in sn_hwperf_enum_objects() Jesper Juhl
                     ` (10 preceding siblings ...)
  2007-08-24  0:06   ` [PATCH 16/30] net: Avoid pointless allocation casts in BSD compression module Jesper Juhl
@ 2007-08-24  0:09   ` Jesper Juhl
  2007-08-24  9:23     ` Karsten Keil
  2007-08-25  6:25     ` David Miller
  2007-08-24  0:11   ` [PATCH 18/30] isdn: eicon - get rid of a pointless vmalloc() return value cast Jesper Juhl
                     ` (14 subsequent siblings)
  26 siblings, 2 replies; 65+ messages in thread
From: Jesper Juhl @ 2007-08-24  0:09 UTC (permalink / raw)
  To: Linux Kernel Mailing List
  Cc: Karsten Keil, Kai Germaschewski, isdn4linux, Michael Hipp,
	Jesper Juhl

vmalloc() returns a void pointer - no need to cast the return value.

Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---
 drivers/isdn/i4l/isdn_bsdcomp.c |    5 ++---
 drivers/isdn/i4l/isdn_common.c  |    2 +-
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/isdn/i4l/isdn_bsdcomp.c b/drivers/isdn/i4l/isdn_bsdcomp.c
index 90a2379..02d9918 100644
--- a/drivers/isdn/i4l/isdn_bsdcomp.c
+++ b/drivers/isdn/i4l/isdn_bsdcomp.c
@@ -341,7 +341,7 @@ static void *bsd_alloc (struct isdn_ppp_comp_data *data)
 	 * Allocate space for the dictionary. This may be more than one page in
 	 * length.
 	 */
-	db->dict = (struct bsd_dict *) vmalloc (hsize * sizeof (struct bsd_dict));
+	db->dict = vmalloc(hsize * sizeof(struct bsd_dict));
 	if (!db->dict) {
 		bsd_free (db);
 		return NULL;
@@ -354,8 +354,7 @@ static void *bsd_alloc (struct isdn_ppp_comp_data *data)
 	if (!decomp)
 		db->lens = NULL;
 	else {
-		db->lens = (unsigned short *) vmalloc ((maxmaxcode + 1) *
-			sizeof (db->lens[0]));
+		db->lens = vmalloc((maxmaxcode + 1) * sizeof(db->lens[0]));
 		if (!db->lens) {
 			bsd_free (db);
 			return (NULL);
diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c
index c97330b..ec5f404 100644
--- a/drivers/isdn/i4l/isdn_common.c
+++ b/drivers/isdn/i4l/isdn_common.c
@@ -2291,7 +2291,7 @@ static int __init isdn_init(void)
 	int i;
 	char tmprev[50];
 
-	if (!(dev = (isdn_dev *) vmalloc(sizeof(isdn_dev)))) {
+	if (!(dev = vmalloc(sizeof(isdn_dev)))) {
 		printk(KERN_WARNING "isdn: Could not allocate device-struct.\n");
 		return -EIO;
 	}
-- 
1.5.2.2


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH 18/30] isdn: eicon - get rid of a pointless vmalloc() return value cast
  2007-08-23 23:40 ` [PATCH 01/30] ia64: Remove unnecessary cast of allocation return value in sn_hwperf_enum_objects() Jesper Juhl
                     ` (11 preceding siblings ...)
  2007-08-24  0:09   ` [PATCH 17/30] isdn: Get rid of some pointless allocation casts in common and bsd comp Jesper Juhl
@ 2007-08-24  0:11   ` Jesper Juhl
  2007-08-24  6:47     ` Armin Schindler
  2007-08-24  0:12   ` [PATCH 19/30] scsi: Remove explicit casts of [kv]alloc return values in osst driver Jesper Juhl
                     ` (13 subsequent siblings)
  26 siblings, 1 reply; 65+ messages in thread
From: Jesper Juhl @ 2007-08-24  0:11 UTC (permalink / raw)
  To: Linux Kernel Mailing List
  Cc: Karsten Keil, Kai Germaschewski, isdn4linux, Armin Schindler,
	Jesper Juhl

vmalloc() returns void*.
No need to cast in drivers/isdn/hardware/eicon/platform.h::diva_os_malloc()

Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---
 drivers/isdn/hardware/eicon/platform.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/isdn/hardware/eicon/platform.h b/drivers/isdn/hardware/eicon/platform.h
index 15d4942..8756ef1 100644
--- a/drivers/isdn/hardware/eicon/platform.h
+++ b/drivers/isdn/hardware/eicon/platform.h
@@ -167,7 +167,7 @@ static __inline__ void* diva_os_malloc (unsigned long flags, unsigned long size)
 	void *ret = NULL;
 
 	if (size) {
-		ret = (void *) vmalloc((unsigned int) size);
+		ret = vmalloc((unsigned int)size);
 	}
 	return (ret);
 }
-- 
1.5.2.2


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH 19/30] scsi: Remove explicit casts of [kv]alloc return values in osst driver
  2007-08-23 23:40 ` [PATCH 01/30] ia64: Remove unnecessary cast of allocation return value in sn_hwperf_enum_objects() Jesper Juhl
                     ` (12 preceding siblings ...)
  2007-08-24  0:11   ` [PATCH 18/30] isdn: eicon - get rid of a pointless vmalloc() return value cast Jesper Juhl
@ 2007-08-24  0:12   ` Jesper Juhl
  2007-08-24  7:04     ` Rolf Eike Beer
  2007-08-24  0:16   ` [PATCH 20/30] scsi: In the Advansys driver, do not cast allocation function return values Jesper Juhl
                     ` (12 subsequent siblings)
  26 siblings, 1 reply; 65+ messages in thread
From: Jesper Juhl @ 2007-08-24  0:12 UTC (permalink / raw)
  To: Linux Kernel Mailing List
  Cc: linux-scsi, James Bottomley, Willem Riede, osst-users,
	Jesper Juhl

[kv]alloc() return void *. No need to cast the return value.

Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---
 drivers/scsi/osst.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c
index 08060fb..3ad9d49 100644
--- a/drivers/scsi/osst.c
+++ b/drivers/scsi/osst.c
@@ -1404,7 +1404,7 @@ static int osst_read_back_buffer_and_rewrite(struct osst_tape * STp, struct osst
 	int			dbg              = debugging;
 #endif
 
-	if ((buffer = (unsigned char *)vmalloc((nframes + 1) * OS_DATA_SIZE)) == NULL)
+	if ((buffer = vmalloc((nframes + 1) * OS_DATA_SIZE)) == NULL)
 		return (-EIO);
 
 	printk(KERN_INFO "%s:I: Reading back %d frames from drive buffer%s\n",
@@ -2216,7 +2216,7 @@ static int osst_write_header(struct osst_tape * STp, struct osst_request ** aSRp
 	if (STp->raw) return 0;
 
 	if (STp->header_cache == NULL) {
-		if ((STp->header_cache = (os_header_t *)vmalloc(sizeof(os_header_t))) == NULL) {
+		if ((STp->header_cache = vmalloc(sizeof(os_header_t))) == NULL) {
 			printk(KERN_ERR "%s:E: Failed to allocate header cache\n", name);
 			return (-ENOMEM);
 		}
@@ -2404,7 +2404,7 @@ static int __osst_analyze_headers(struct osst_tape * STp, struct osst_request **
 				   name, ppos, update_frame_cntr);
 #endif
 		if (STp->header_cache == NULL) {
-			if ((STp->header_cache = (os_header_t *)vmalloc(sizeof(os_header_t))) == NULL) {
+			if ((STp->header_cache = vmalloc(sizeof(os_header_t))) == NULL) {
 				printk(KERN_ERR "%s:E: Failed to allocate header cache\n", name);
 				return 0;
 			}
@@ -5756,7 +5756,7 @@ static int osst_probe(struct device *dev)
 	write_lock(&os_scsi_tapes_lock);
 	if (os_scsi_tapes == NULL) {
 		os_scsi_tapes =
-			(struct osst_tape **)kmalloc(osst_max_dev * sizeof(struct osst_tape *),
+			kmalloc(osst_max_dev * sizeof(struct osst_tape *),
 				   GFP_ATOMIC);
 		if (os_scsi_tapes == NULL) {
 			write_unlock(&os_scsi_tapes_lock);
-- 
1.5.2.2


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH 20/30] scsi: In the Advansys driver, do not cast allocation function return values
  2007-08-23 23:40 ` [PATCH 01/30] ia64: Remove unnecessary cast of allocation return value in sn_hwperf_enum_objects() Jesper Juhl
                     ` (13 preceding siblings ...)
  2007-08-24  0:12   ` [PATCH 19/30] scsi: Remove explicit casts of [kv]alloc return values in osst driver Jesper Juhl
@ 2007-08-24  0:16   ` Jesper Juhl
  2007-08-24  2:03     ` Matthew Wilcox
  2007-08-24  0:18   ` [PATCH 21/30] oss: Remove unneeded vmalloc() return value casts in OSS Jesper Juhl
                     ` (11 subsequent siblings)
  26 siblings, 1 reply; 65+ messages in thread
From: Jesper Juhl @ 2007-08-24  0:16 UTC (permalink / raw)
  To: Linux Kernel Mailing List; +Cc: linux-scsi, James Bottomley, linux, Jesper Juhl

There's no reason to cast void pointers returned by the generic
memory allocation functions.

Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---
 drivers/scsi/advansys.c |    9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/advansys.c b/drivers/scsi/advansys.c
index 79c0b6e..b28729c 100644
--- a/drivers/scsi/advansys.c
+++ b/drivers/scsi/advansys.c
@@ -18513,7 +18513,7 @@ advansys_board_found(int iop, struct device *dev, int bus_type)
 		 * Allocate buffer carrier structures. The total size
 		 * is about 4 KB, so allocate all at once.
 		 */
-		carrp = (ADV_CARR_T *) kmalloc(ADV_CARRIER_BUFSIZE, GFP_ATOMIC);
+		carrp = kmalloc(ADV_CARRIER_BUFSIZE, GFP_ATOMIC);
 		ASC_DBG1(1, "advansys_board_found: carrp 0x%lx\n", (ulong)carrp);
 
 		if (carrp == NULL) {
@@ -18529,8 +18529,7 @@ advansys_board_found(int iop, struct device *dev, int bus_type)
 		for (req_cnt = adv_dvc_varp->max_host_qng;
 		     req_cnt > 0; req_cnt--) {
 
-			reqp = (adv_req_t *)
-			    kmalloc(sizeof(adv_req_t) * req_cnt, GFP_ATOMIC);
+			reqp = kmalloc(sizeof(adv_req_t) * req_cnt, GFP_ATOMIC);
 
 			ASC_DBG3(1,
 				 "advansys_board_found: reqp 0x%lx, req_cnt %d, bytes %lu\n",
@@ -18552,9 +18551,7 @@ advansys_board_found(int iop, struct device *dev, int bus_type)
 		boardp->adv_sgblkp = NULL;
 		for (sg_cnt = 0; sg_cnt < ADV_TOT_SG_BLOCK; sg_cnt++) {
 
-			sgp = (adv_sgblk_t *)
-			    kmalloc(sizeof(adv_sgblk_t), GFP_ATOMIC);
-
+			sgp = kmalloc(sizeof(adv_sgblk_t), GFP_ATOMIC);
 			if (sgp == NULL) {
 				break;
 			}
-- 
1.5.2.2


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH 21/30] oss: Remove unneeded vmalloc() return value casts in OSS
  2007-08-23 23:40 ` [PATCH 01/30] ia64: Remove unnecessary cast of allocation return value in sn_hwperf_enum_objects() Jesper Juhl
                     ` (14 preceding siblings ...)
  2007-08-24  0:16   ` [PATCH 20/30] scsi: In the Advansys driver, do not cast allocation function return values Jesper Juhl
@ 2007-08-24  0:18   ` Jesper Juhl
  2007-08-24  0:20   ` [PATCH 22/30] ivtv: kzalloc() returns void pointer, no need to cast Jesper Juhl
                     ` (10 subsequent siblings)
  26 siblings, 0 replies; 65+ messages in thread
From: Jesper Juhl @ 2007-08-24  0:18 UTC (permalink / raw)
  To: Linux Kernel Mailing List; +Cc: Takashi Iwai, Hannu Savolainen, Jesper Juhl

vmalloc() returns a void pointer that we don't need to cast.
This patch should clean this up in sound/oss/.

Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---
 sound/oss/midibuf.c   |    4 ++--
 sound/oss/pss.c       |    6 +++---
 sound/oss/sequencer.c |    4 ++--
 sound/oss/sscape.c    |    2 +-
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/sound/oss/midibuf.c b/sound/oss/midibuf.c
index a40be0c..66f8a7f 100644
--- a/sound/oss/midibuf.c
+++ b/sound/oss/midibuf.c
@@ -177,7 +177,7 @@ int MIDIbuf_open(int dev, struct file *file)
 		return err;
 
 	parms[dev].prech_timeout = MAX_SCHEDULE_TIMEOUT;
-	midi_in_buf[dev] = (struct midi_buf *) vmalloc(sizeof(struct midi_buf));
+	midi_in_buf[dev] = vmalloc(sizeof(struct midi_buf));
 
 	if (midi_in_buf[dev] == NULL)
 	{
@@ -187,7 +187,7 @@ int MIDIbuf_open(int dev, struct file *file)
 	}
 	midi_in_buf[dev]->len = midi_in_buf[dev]->head = midi_in_buf[dev]->tail = 0;
 
-	midi_out_buf[dev] = (struct midi_buf *) vmalloc(sizeof(struct midi_buf));
+	midi_out_buf[dev] = vmalloc(sizeof(struct midi_buf));
 
 	if (midi_out_buf[dev] == NULL)
 	{
diff --git a/sound/oss/pss.c b/sound/oss/pss.c
index ece428b..b140584 100644
--- a/sound/oss/pss.c
+++ b/sound/oss/pss.c
@@ -872,7 +872,7 @@ static int pss_coproc_ioctl(void *dev_info, unsigned int cmd, void __user *arg,
 			return 0;
 
 		case SNDCTL_COPR_LOAD:
-			buf = (copr_buffer *) vmalloc(sizeof(copr_buffer));
+			buf = vmalloc(sizeof(copr_buffer));
 			if (buf == NULL)
 				return -ENOSPC;
 			if (copy_from_user(buf, arg, sizeof(copr_buffer))) {
@@ -884,7 +884,7 @@ static int pss_coproc_ioctl(void *dev_info, unsigned int cmd, void __user *arg,
 			return err;
 		
 		case SNDCTL_COPR_SENDMSG:
-			mbuf = (copr_msg *)vmalloc(sizeof(copr_msg));
+			mbuf = vmalloc(sizeof(copr_msg));
 			if (mbuf == NULL)
 				return -ENOSPC;
 			if (copy_from_user(mbuf, arg, sizeof(copr_msg))) {
@@ -908,7 +908,7 @@ static int pss_coproc_ioctl(void *dev_info, unsigned int cmd, void __user *arg,
 
 		case SNDCTL_COPR_RCVMSG:
 			err = 0;
-			mbuf = (copr_msg *)vmalloc(sizeof(copr_msg));
+			mbuf = vmalloc(sizeof(copr_msg));
 			if (mbuf == NULL)
 				return -ENOSPC;
 			data = (unsigned short *)mbuf->data;
diff --git a/sound/oss/sequencer.c b/sound/oss/sequencer.c
index 5c215f7..cfe3dd0 100644
--- a/sound/oss/sequencer.c
+++ b/sound/oss/sequencer.c
@@ -1649,13 +1649,13 @@ void sequencer_init(void)
 {
 	if (sequencer_ok)
 		return;
-	queue = (unsigned char *)vmalloc(SEQ_MAX_QUEUE * EV_SZ);
+	queue = vmalloc(SEQ_MAX_QUEUE * EV_SZ);
 	if (queue == NULL)
 	{
 		printk(KERN_ERR "sequencer: Can't allocate memory for sequencer output queue\n");
 		return;
 	}
-	iqueue = (unsigned char *)vmalloc(SEQ_MAX_QUEUE * IEV_SZ);
+	iqueue = vmalloc(SEQ_MAX_QUEUE * IEV_SZ);
 	if (iqueue == NULL)
 	{
 		printk(KERN_ERR "sequencer: Can't allocate memory for sequencer input queue\n");
diff --git a/sound/oss/sscape.c b/sound/oss/sscape.c
index 30c36d1..9d6b9b0 100644
--- a/sound/oss/sscape.c
+++ b/sound/oss/sscape.c
@@ -573,7 +573,7 @@ static int sscape_coproc_ioctl(void *dev_info, unsigned int cmd, void __user *ar
 			return 0;
 
 		case SNDCTL_COPR_LOAD:
-			buf = (copr_buffer *) vmalloc(sizeof(copr_buffer));
+			buf = vmalloc(sizeof(copr_buffer));
 			if (buf == NULL)
 				return -ENOSPC;
 			if (copy_from_user(buf, arg, sizeof(copr_buffer))) 
-- 
1.5.2.2


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH 22/30] ivtv: kzalloc() returns void pointer, no need to cast
  2007-08-23 23:40 ` [PATCH 01/30] ia64: Remove unnecessary cast of allocation return value in sn_hwperf_enum_objects() Jesper Juhl
                     ` (15 preceding siblings ...)
  2007-08-24  0:18   ` [PATCH 21/30] oss: Remove unneeded vmalloc() return value casts in OSS Jesper Juhl
@ 2007-08-24  0:20   ` Jesper Juhl
  2007-08-24  8:32     ` Hans Verkuil
  2007-08-24  0:22   ` [PATCH 23/30] video: Remove pointless kmalloc() return value cast in Zoran PCI controller driver Jesper Juhl
                     ` (9 subsequent siblings)
  26 siblings, 1 reply; 65+ messages in thread
From: Jesper Juhl @ 2007-08-24  0:20 UTC (permalink / raw)
  To: Linux Kernel Mailing List
  Cc: Kevin Thayer, Chris Kennedy, Hans Verkuil, video4linux-list,
	Jesper Juhl

Since kzalloc() returns a void pointer, we don't need to cast the
return value in drivers/media/video/ivtv/ivtv-queue.c

Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---
 drivers/media/video/ivtv/ivtv-queue.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/video/ivtv/ivtv-queue.c b/drivers/media/video/ivtv/ivtv-queue.c
index a04f938..45825b8 100644
--- a/drivers/media/video/ivtv/ivtv-queue.c
+++ b/drivers/media/video/ivtv/ivtv-queue.c
@@ -196,7 +196,7 @@ int ivtv_stream_alloc(struct ivtv_stream *s)
 		s->name, s->buffers, s->buf_size, s->buffers * s->buf_size / 1024);
 
 	if (ivtv_might_use_pio(s)) {
-		s->PIOarray = (struct ivtv_SG_element *)kzalloc(SGsize, GFP_KERNEL);
+		s->PIOarray = kzalloc(SGsize, GFP_KERNEL);
 		if (s->PIOarray == NULL) {
 			IVTV_ERR("Could not allocate PIOarray for %s stream\n", s->name);
 			return -ENOMEM;
@@ -204,7 +204,7 @@ int ivtv_stream_alloc(struct ivtv_stream *s)
 	}
 
 	/* Allocate DMA SG Arrays */
-	s->SGarray = (struct ivtv_SG_element *)kzalloc(SGsize, GFP_KERNEL);
+	s->SGarray = kzalloc(SGsize, GFP_KERNEL);
 	if (s->SGarray == NULL) {
 		IVTV_ERR("Could not allocate SGarray for %s stream\n", s->name);
 		if (ivtv_might_use_pio(s)) {
-- 
1.5.2.2


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH 23/30] video: Remove pointless kmalloc() return value cast in Zoran PCI controller driver
  2007-08-23 23:40 ` [PATCH 01/30] ia64: Remove unnecessary cast of allocation return value in sn_hwperf_enum_objects() Jesper Juhl
                     ` (16 preceding siblings ...)
  2007-08-24  0:20   ` [PATCH 22/30] ivtv: kzalloc() returns void pointer, no need to cast Jesper Juhl
@ 2007-08-24  0:22   ` Jesper Juhl
  2007-08-24  0:25   ` [PATCH 24/30] dvb: remove some unneeded vmalloc() return value casts from av7110 Jesper Juhl
                     ` (8 subsequent siblings)
  26 siblings, 0 replies; 65+ messages in thread
From: Jesper Juhl @ 2007-08-24  0:22 UTC (permalink / raw)
  To: Linux Kernel Mailing List
  Cc: video4linux-list, Ronald Bultje, mjpeg-users, Serguei Miridonov,
	Jesper Juhl

No need to cast the void pointer returned by kmalloc() in
drivers/media/video/zoran_driver.c::v4l_fbuffer_alloc().

Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---
 drivers/media/video/zoran_driver.c |    5 +----
 1 files changed, 1 insertions(+), 4 deletions(-)

diff --git a/drivers/media/video/zoran_driver.c b/drivers/media/video/zoran_driver.c
index 72a037b..bc2e5b3 100644
--- a/drivers/media/video/zoran_driver.c
+++ b/drivers/media/video/zoran_driver.c
@@ -347,10 +347,7 @@ v4l_fbuffer_alloc (struct file *file)
 		if (fh->v4l_buffers.buffer_size <= MAX_KMALLOC_MEM) {
 			/* Use kmalloc */
 
-			mem =
-			    (unsigned char *) kmalloc(fh->v4l_buffers.
-						      buffer_size,
-						      GFP_KERNEL);
+			mem = kmalloc(fh->v4l_buffers.buffer_size, GFP_KERNEL);
 			if (mem == 0) {
 				dprintk(1,
 					KERN_ERR
-- 
1.5.2.2


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* Re: [PATCH 03/30] um: Don't unnecessarily cast allocation return value in ubd_kern.c
  2007-08-23 23:43   ` [PATCH 03/30] um: Don't unnecessarily cast allocation return value in ubd_kern.c Jesper Juhl
@ 2007-08-24  0:22     ` Jeff Dike
  0 siblings, 0 replies; 65+ messages in thread
From: Jeff Dike @ 2007-08-24  0:22 UTC (permalink / raw)
  To: Jesper Juhl; +Cc: Linux Kernel Mailing List, user-mode-linux-devel

On Fri, Aug 24, 2007 at 01:43:49AM +0200, Jesper Juhl wrote:
> vmalloc() returns a void pointer, so casting to (void *) is pretty pointless.

Righto, I'll take care of this.

			Jeff

-- 
Work email - jdike at linux dot intel dot com

^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH 24/30] dvb: remove some unneeded vmalloc() return value casts from av7110
  2007-08-23 23:40 ` [PATCH 01/30] ia64: Remove unnecessary cast of allocation return value in sn_hwperf_enum_objects() Jesper Juhl
                     ` (17 preceding siblings ...)
  2007-08-24  0:22   ` [PATCH 23/30] video: Remove pointless kmalloc() return value cast in Zoran PCI controller driver Jesper Juhl
@ 2007-08-24  0:25   ` Jesper Juhl
  2007-08-24  0:28   ` [PATCH 25/30] tty: dont needlessly cast kmalloc() return value Jesper Juhl
                     ` (7 subsequent siblings)
  26 siblings, 0 replies; 65+ messages in thread
From: Jesper Juhl @ 2007-08-24  0:25 UTC (permalink / raw)
  To: Linux Kernel Mailing List
  Cc: video4linux-list, v4l-dvb-maintainer, Christian Theiss, mocm,
	Ralph Metzler, Holger Waechtler, Oliver Endriss, Jesper Juhl

vmalloc() returns void * - no need to cast it.

Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---
 drivers/media/dvb/ttpci/av7110.c    |    2 +-
 drivers/media/dvb/ttpci/av7110_ir.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/media/dvb/ttpci/av7110.c b/drivers/media/dvb/ttpci/av7110.c
index 8178832..27fa5f8 100644
--- a/drivers/media/dvb/ttpci/av7110.c
+++ b/drivers/media/dvb/ttpci/av7110.c
@@ -1543,7 +1543,7 @@ static int get_firmware(struct av7110* av7110)
 	}
 
 	/* check if the firmware is available */
-	av7110->bin_fw = (unsigned char *) vmalloc(fw->size);
+	av7110->bin_fw = vmalloc(fw->size);
 	if (NULL == av7110->bin_fw) {
 		dprintk(1, "out of memory\n");
 		release_firmware(fw);
diff --git a/drivers/media/dvb/ttpci/av7110_ir.c b/drivers/media/dvb/ttpci/av7110_ir.c
index 6322800..651863b 100644
--- a/drivers/media/dvb/ttpci/av7110_ir.c
+++ b/drivers/media/dvb/ttpci/av7110_ir.c
@@ -280,7 +280,7 @@ static int av7110_ir_write_proc(struct file *file, const char __user *buffer,
 	if (count < size)
 		return -EINVAL;
 
-	page = (char *) vmalloc(size);
+	page = vmalloc(size);
 	if (!page)
 		return -ENOMEM;
 
-- 
1.5.2.2


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH 25/30] tty: dont needlessly cast kmalloc() return value
  2007-08-23 23:40 ` [PATCH 01/30] ia64: Remove unnecessary cast of allocation return value in sn_hwperf_enum_objects() Jesper Juhl
                     ` (18 preceding siblings ...)
  2007-08-24  0:25   ` [PATCH 24/30] dvb: remove some unneeded vmalloc() return value casts from av7110 Jesper Juhl
@ 2007-08-24  0:28   ` Jesper Juhl
  2007-08-24  0:30   ` [PATCH 26/30] md: vmalloc() returns void pointer so we don't need to cast it in dm-ioctl Jesper Juhl
                     ` (6 subsequent siblings)
  26 siblings, 0 replies; 65+ messages in thread
From: Jesper Juhl @ 2007-08-24  0:28 UTC (permalink / raw)
  To: Linux Kernel Mailing List; +Cc: Alan Cox, Linus Torvalds, Jesper Juhl

kmalloc() hands us a void pointer, we don't need to cast it.

Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---
 drivers/char/tty_io.c |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index 51ea93c..9c867cf 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -2063,8 +2063,7 @@ static int init_dev(struct tty_driver *driver, int idx,
 	}
 
 	if (!*tp_loc) {
-		tp = (struct ktermios *) kmalloc(sizeof(struct ktermios),
-						GFP_KERNEL);
+		tp = kmalloc(sizeof(struct ktermios), GFP_KERNEL);
 		if (!tp)
 			goto free_mem_out;
 		*tp = driver->init_termios;
@@ -2094,8 +2093,7 @@ static int init_dev(struct tty_driver *driver, int idx,
 		}
 
 		if (!*o_tp_loc) {
-			o_tp = (struct ktermios *)
-				kmalloc(sizeof(struct ktermios), GFP_KERNEL);
+			o_tp = kmalloc(sizeof(struct ktermios), GFP_KERNEL);
 			if (!o_tp)
 				goto free_mem_out;
 			*o_tp = driver->other->init_termios;
-- 
1.5.2.2


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH 26/30] md: vmalloc() returns void pointer so we don't need to cast it in dm-ioctl
  2007-08-23 23:40 ` [PATCH 01/30] ia64: Remove unnecessary cast of allocation return value in sn_hwperf_enum_objects() Jesper Juhl
                     ` (19 preceding siblings ...)
  2007-08-24  0:28   ` [PATCH 25/30] tty: dont needlessly cast kmalloc() return value Jesper Juhl
@ 2007-08-24  0:30   ` Jesper Juhl
  2007-08-24  0:35   ` [PATCH 27/30] usb: avoid redundant cast of kmalloc() return value in OTi-6858 driver Jesper Juhl
                     ` (5 subsequent siblings)
  26 siblings, 0 replies; 65+ messages in thread
From: Jesper Juhl @ 2007-08-24  0:30 UTC (permalink / raw)
  To: Linux Kernel Mailing List; +Cc: Alasdair G Kergon, dm-devel, Jesper Juhl

In drivers/md/dm-ioctl.c::copy_params() there's a call to vmalloc()
where we currently cast the return value, but that's pretty pointles
given that vmalloc() returns "void *".

Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---
 drivers/md/dm-ioctl.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
index b441d82..efbf9b6 100644
--- a/drivers/md/dm-ioctl.c
+++ b/drivers/md/dm-ioctl.c
@@ -1358,7 +1358,7 @@ static int copy_params(struct dm_ioctl __user *user, struct dm_ioctl **param)
 	if (tmp.data_size < sizeof(tmp))
 		return -EINVAL;
 
-	dmi = (struct dm_ioctl *) vmalloc(tmp.data_size);
+	dmi = vmalloc(tmp.data_size);
 	if (!dmi)
 		return -ENOMEM;
 
-- 
1.5.2.2


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH 27/30] usb: avoid redundant cast of kmalloc() return value in OTi-6858 driver
  2007-08-23 23:40 ` [PATCH 01/30] ia64: Remove unnecessary cast of allocation return value in sn_hwperf_enum_objects() Jesper Juhl
                     ` (20 preceding siblings ...)
  2007-08-24  0:30   ` [PATCH 26/30] md: vmalloc() returns void pointer so we don't need to cast it in dm-ioctl Jesper Juhl
@ 2007-08-24  0:35   ` Jesper Juhl
  2007-08-25  4:43     ` patch usb-avoid-redundant-cast-of-kmalloc-return-value-in-oti-6858-driver.patch added to gregkh-2.6 tree gregkh
  2007-08-24  0:36   ` [PATCH 28/30] jfs: avoid pointless casts of kmalloc() return val Jesper Juhl
                     ` (4 subsequent siblings)
  26 siblings, 1 reply; 65+ messages in thread
From: Jesper Juhl @ 2007-08-24  0:35 UTC (permalink / raw)
  To: Linux Kernel Mailing List; +Cc: Greg Kroah-Hartman, Jesper Juhl

In drivers/usb/serial/oti6858.c::pl2303_buf_alloc() the return value
of kmalloc() is being cast to "struct pl2303_buf *", but that need
not be done here since kmalloc() returns "void *".

Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---
 drivers/usb/serial/oti6858.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/serial/oti6858.c b/drivers/usb/serial/oti6858.c
index d7db71e..fc5e808 100644
--- a/drivers/usb/serial/oti6858.c
+++ b/drivers/usb/serial/oti6858.c
@@ -1161,7 +1161,7 @@ static struct pl2303_buf *pl2303_buf_alloc(unsigned int size)
 	if (size == 0)
 		return NULL;
 
-	pb = (struct pl2303_buf *)kmalloc(sizeof(struct pl2303_buf), GFP_KERNEL);
+	pb = kmalloc(sizeof(struct pl2303_buf), GFP_KERNEL);
 	if (pb == NULL)
 		return NULL;
 
-- 
1.5.2.2


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH 28/30] jfs: avoid pointless casts of kmalloc() return val
  2007-08-23 23:40 ` [PATCH 01/30] ia64: Remove unnecessary cast of allocation return value in sn_hwperf_enum_objects() Jesper Juhl
                     ` (21 preceding siblings ...)
  2007-08-24  0:35   ` [PATCH 27/30] usb: avoid redundant cast of kmalloc() return value in OTi-6858 driver Jesper Juhl
@ 2007-08-24  0:36   ` Jesper Juhl
  2007-08-24  4:19     ` Dave Kleikamp
  2007-08-24  0:39   ` [PATCH 29/30] mm: No need to cast vmalloc() return value in zone_wait_table_init() Jesper Juhl
                     ` (3 subsequent siblings)
  26 siblings, 1 reply; 65+ messages in thread
From: Jesper Juhl @ 2007-08-24  0:36 UTC (permalink / raw)
  To: Linux Kernel Mailing List; +Cc: Dave Kleikamp, jfs-discussion, Jesper Juhl

There's no need to cast the, void *, return value of kmalloc() when
assigning to a pointer variable.

Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---
 fs/jfs/jfs_dtree.c |    8 ++------
 1 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/fs/jfs/jfs_dtree.c b/fs/jfs/jfs_dtree.c
index c14ba3c..3f15b36 100644
--- a/fs/jfs/jfs_dtree.c
+++ b/fs/jfs/jfs_dtree.c
@@ -592,9 +592,7 @@ int dtSearch(struct inode *ip, struct component_name * key, ino_t * data,
 	struct component_name ciKey;
 	struct super_block *sb = ip->i_sb;
 
-	ciKey.name =
-	    (wchar_t *) kmalloc((JFS_NAME_MAX + 1) * sizeof(wchar_t),
-				GFP_NOFS);
+	ciKey.name = kmalloc((JFS_NAME_MAX + 1) * sizeof(wchar_t), GFP_NOFS);
 	if (ciKey.name == 0) {
 		rc = -ENOMEM;
 		goto dtSearch_Exit2;
@@ -957,9 +955,7 @@ static int dtSplitUp(tid_t tid,
 	smp = split->mp;
 	sp = DT_PAGE(ip, smp);
 
-	key.name =
-	    (wchar_t *) kmalloc((JFS_NAME_MAX + 2) * sizeof(wchar_t),
-				GFP_NOFS);
+	key.name = kmalloc((JFS_NAME_MAX + 2) * sizeof(wchar_t), GFP_NOFS);
 	if (key.name == 0) {
 		DT_PUTPAGE(smp);
 		rc = -ENOMEM;
-- 
1.5.2.2


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* Re: [PATCH 04/30] powerpc: Don't cast kmalloc return value in ibmebus.c
  2007-08-23 23:45   ` [PATCH 04/30] powerpc: Don't cast kmalloc return value in ibmebus.c Jesper Juhl
@ 2007-08-24  0:37     ` Joachim Fenkes
  0 siblings, 0 replies; 65+ messages in thread
From: Joachim Fenkes @ 2007-08-24  0:37 UTC (permalink / raw)
  To: Jesper Juhl
  Cc: Heiko J Schick, Jesper Juhl, Linux Kernel Mailing List,
	linuxppc-dev, Paul Mackerras

> kmalloc() returns a void pointer so there is absolutely no need to
> cast it in ibmebus_chomp().
> 
> Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>

Acked-By: Joachim Fenkes <fenkes@de.ibm.com>


^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH 29/30] mm: No need to cast vmalloc() return value in zone_wait_table_init()
  2007-08-23 23:40 ` [PATCH 01/30] ia64: Remove unnecessary cast of allocation return value in sn_hwperf_enum_objects() Jesper Juhl
                     ` (22 preceding siblings ...)
  2007-08-24  0:36   ` [PATCH 28/30] jfs: avoid pointless casts of kmalloc() return val Jesper Juhl
@ 2007-08-24  0:39   ` Jesper Juhl
  2007-08-24  0:41   ` [PATCH 30/30] emu10k1: There's no need to cast vmalloc() return value in snd_emu10k1_create() Jesper Juhl
                     ` (2 subsequent siblings)
  26 siblings, 0 replies; 65+ messages in thread
From: Jesper Juhl @ 2007-08-24  0:39 UTC (permalink / raw)
  To: Linux Kernel Mailing List
  Cc: linux-mm, Andrew Morton, Ingo Molnar, Mel Gorman, Jesper Juhl

vmalloc() returns a void pointer, so there's no need to cast its
return value in mm/page_alloc.c::zone_wait_table_init().

Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---
 mm/page_alloc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 6427653..a8615c2 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -2442,7 +2442,7 @@ int zone_wait_table_init(struct zone *zone, unsigned long zone_size_pages)
 		 * To use this new node's memory, further consideration will be
 		 * necessary.
 		 */
-		zone->wait_table = (wait_queue_head_t *)vmalloc(alloc_size);
+		zone->wait_table = vmalloc(alloc_size);
 	}
 	if (!zone->wait_table)
 		return -ENOMEM;
-- 
1.5.2.2


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* [PATCH 30/30] emu10k1: There's no need to cast vmalloc() return value in snd_emu10k1_create()
  2007-08-23 23:40 ` [PATCH 01/30] ia64: Remove unnecessary cast of allocation return value in sn_hwperf_enum_objects() Jesper Juhl
                     ` (23 preceding siblings ...)
  2007-08-24  0:39   ` [PATCH 29/30] mm: No need to cast vmalloc() return value in zone_wait_table_init() Jesper Juhl
@ 2007-08-24  0:41   ` Jesper Juhl
  2007-08-28 13:22     ` Takashi Iwai
       [not found]   ` <c4e095af9df5ab47e7d1c8e4f3d256d74576a0c9.1187912217.git.jesper.juhl@gmail.com>
       [not found]   ` <d551047daed1cb4d9de1eff956268a468c9837f6.1187912217.git.jesper.juhl@gmail.com>
  26 siblings, 1 reply; 65+ messages in thread
From: Jesper Juhl @ 2007-08-24  0:41 UTC (permalink / raw)
  To: Linux Kernel Mailing List
  Cc: Takashi Iwai, Jaroslav Kysela, James Courtier-Dutton, Jesper Juhl

vmalloc() returns void *. no need to cast.

Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---
 sound/pci/emu10k1/emu10k1_main.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c
index 404ae1b..91d986b 100644
--- a/sound/pci/emu10k1/emu10k1_main.c
+++ b/sound/pci/emu10k1/emu10k1_main.c
@@ -1722,8 +1722,8 @@ int __devinit snd_emu10k1_create(struct snd_card *card,
 		goto error;
 	}
 
-	emu->page_ptr_table = (void **)vmalloc(emu->max_cache_pages * sizeof(void*));
-	emu->page_addr_table = (unsigned long*)vmalloc(emu->max_cache_pages * sizeof(unsigned long));
+	emu->page_ptr_table = vmalloc(emu->max_cache_pages * sizeof(void *));
+	emu->page_addr_table = vmalloc(emu->max_cache_pages * sizeof(unsigned long));
 	if (emu->page_ptr_table == NULL || emu->page_addr_table == NULL) {
 		err = -ENOMEM;
 		goto error;
-- 
1.5.2.2


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* Re: [PATCH 20/30] scsi: In the Advansys driver, do not cast allocation function return values
  2007-08-24  0:16   ` [PATCH 20/30] scsi: In the Advansys driver, do not cast allocation function return values Jesper Juhl
@ 2007-08-24  2:03     ` Matthew Wilcox
  2007-08-24  9:00       ` Jesper Juhl
  0 siblings, 1 reply; 65+ messages in thread
From: Matthew Wilcox @ 2007-08-24  2:03 UTC (permalink / raw)
  To: Jesper Juhl; +Cc: Linux Kernel Mailing List, linux-scsi, James Bottomley, linux

On Fri, Aug 24, 2007 at 02:16:12AM +0200, Jesper Juhl wrote:
> There's no reason to cast void pointers returned by the generic
> memory allocation functions.

I think I fixed all these already; please check scsi-misc.

-- 
"Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step."

^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH 28/30] jfs: avoid pointless casts of kmalloc() return val
  2007-08-24  0:36   ` [PATCH 28/30] jfs: avoid pointless casts of kmalloc() return val Jesper Juhl
@ 2007-08-24  4:19     ` Dave Kleikamp
  2007-08-24  8:48       ` Jesper Juhl
  0 siblings, 1 reply; 65+ messages in thread
From: Dave Kleikamp @ 2007-08-24  4:19 UTC (permalink / raw)
  To: Jesper Juhl; +Cc: Linux Kernel Mailing List, jfs-discussion

Thanks, but Jack Stone submitted the same patch a few weeks ago.  It's
already in the jfs git tree and the -mm kernel.

Shaggy

On Fri, 2007-08-24 at 02:36 +0200, Jesper Juhl wrote:
> There's no need to cast the, void *, return value of kmalloc() when
> assigning to a pointer variable.
> 
> Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
> ---
>  fs/jfs/jfs_dtree.c |    8 ++------
>  1 files changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/fs/jfs/jfs_dtree.c b/fs/jfs/jfs_dtree.c
> index c14ba3c..3f15b36 100644
> --- a/fs/jfs/jfs_dtree.c
> +++ b/fs/jfs/jfs_dtree.c
> @@ -592,9 +592,7 @@ int dtSearch(struct inode *ip, struct component_name * key, ino_t * data,
>  	struct component_name ciKey;
>  	struct super_block *sb = ip->i_sb;
>  
> -	ciKey.name =
> -	    (wchar_t *) kmalloc((JFS_NAME_MAX + 1) * sizeof(wchar_t),
> -				GFP_NOFS);
> +	ciKey.name = kmalloc((JFS_NAME_MAX + 1) * sizeof(wchar_t), GFP_NOFS);
>  	if (ciKey.name == 0) {
>  		rc = -ENOMEM;
>  		goto dtSearch_Exit2;
> @@ -957,9 +955,7 @@ static int dtSplitUp(tid_t tid,
>  	smp = split->mp;
>  	sp = DT_PAGE(ip, smp);
>  
> -	key.name =
> -	    (wchar_t *) kmalloc((JFS_NAME_MAX + 2) * sizeof(wchar_t),
> -				GFP_NOFS);
> +	key.name = kmalloc((JFS_NAME_MAX + 2) * sizeof(wchar_t), GFP_NOFS);
>  	if (key.name == 0) {
>  		DT_PUTPAGE(smp);
>  		rc = -ENOMEM;
-- 
David Kleikamp
IBM Linux Technology Center


^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH 18/30] isdn: eicon - get rid of a pointless vmalloc() return value cast
  2007-08-24  0:11   ` [PATCH 18/30] isdn: eicon - get rid of a pointless vmalloc() return value cast Jesper Juhl
@ 2007-08-24  6:47     ` Armin Schindler
  0 siblings, 0 replies; 65+ messages in thread
From: Armin Schindler @ 2007-08-24  6:47 UTC (permalink / raw)
  To: Jesper Juhl
  Cc: Linux Kernel Mailing List, Karsten Keil, Kai Germaschewski,
	isdn4linux

vmalloc() returns void*.
No need to cast in drivers/isdn/hardware/eicon/platform.h::diva_os_malloc()

Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
Acked-by: Armin Schindler <armin@melware.de>
---
 drivers/isdn/hardware/eicon/platform.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/isdn/hardware/eicon/platform.h b/drivers/isdn/hardware/eicon/platform.h
index 15d4942..8756ef1 100644
--- a/drivers/isdn/hardware/eicon/platform.h
+++ b/drivers/isdn/hardware/eicon/platform.h
@@ -167,7 +167,7 @@ static __inline__ void* diva_os_malloc (unsigned long flags, unsigned long size)
 	void *ret = NULL;
 
 	if (size) {
-		ret = (void *) vmalloc((unsigned int) size);
+		ret = vmalloc((unsigned int)size);
 	}
 	return (ret);
 }
-- 
1.5.2.2


^ permalink raw reply related	[flat|nested] 65+ messages in thread

* Re: [PATCH 19/30] scsi: Remove explicit casts of [kv]alloc return values in osst driver
  2007-08-24  0:12   ` [PATCH 19/30] scsi: Remove explicit casts of [kv]alloc return values in osst driver Jesper Juhl
@ 2007-08-24  7:04     ` Rolf Eike Beer
  2007-08-24  8:46       ` Jesper Juhl
  0 siblings, 1 reply; 65+ messages in thread
From: Rolf Eike Beer @ 2007-08-24  7:04 UTC (permalink / raw)
  To: linux-scsi
  Cc: Jesper Juhl, Linux Kernel Mailing List, James Bottomley,
	Willem Riede, osst-users

[-- Attachment #1: Type: text/plain, Size: 658 bytes --]

Jesper Juhl wrote:
> [kv]alloc() return void *. No need to cast the return value.

> @@ -5756,7 +5756,7 @@ static int osst_probe(struct device *dev)
>  	write_lock(&os_scsi_tapes_lock);
>  	if (os_scsi_tapes == NULL) {
>  		os_scsi_tapes =
> -			(struct osst_tape **)kmalloc(osst_max_dev * sizeof(struct osst_tape *),
> +			kmalloc(osst_max_dev * sizeof(struct osst_tape *),
>  				   GFP_ATOMIC);
>  		if (os_scsi_tapes == NULL) {
>  			write_unlock(&os_scsi_tapes_lock);

Three lines later:

		for (i=0; i < osst_max_dev; ++i) os_scsi_tapes[i] = NULL;

This wants to be

os_scsi_tapes = kcalloc(osst_max_dev, sizeof(struct osst_tape *), GFP_ATOMIC);

Eike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH 12/30] net: No point in casting kmalloc return values in Gianfar Ethernet Driver
       [not found]   ` <c4e095af9df5ab47e7d1c8e4f3d256d74576a0c9.1187912217.git.jesper.juhl@gmail.com>
@ 2007-08-24  7:25     ` Kumar Gala
  0 siblings, 0 replies; 65+ messages in thread
From: Kumar Gala @ 2007-08-24  7:25 UTC (permalink / raw)
  To: Jesper Juhl
  Cc: Linux Kernel Mailing List, netdev, David S. Miller, Andy Fleming


On Aug 23, 2007, at 6:59 PM, Jesper Juhl wrote:

> kmalloc() returns a void ptr, so there's no need to cast its return
> value in drivers/net/gianfar.c .
>
> Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>

Acked-by: Kumar Gala <galak@kernel.crashing.org>

- k

^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH 22/30] ivtv: kzalloc() returns void pointer, no need to cast
  2007-08-24  0:20   ` [PATCH 22/30] ivtv: kzalloc() returns void pointer, no need to cast Jesper Juhl
@ 2007-08-24  8:32     ` Hans Verkuil
  2007-08-24  8:44       ` Jesper Juhl
  0 siblings, 1 reply; 65+ messages in thread
From: Hans Verkuil @ 2007-08-24  8:32 UTC (permalink / raw)
  To: Jesper Juhl
  Cc: Linux Kernel Mailing List, Kevin Thayer, Chris Kennedy,
	video4linux-list

On Friday 24 August 2007 02:20:04 Jesper Juhl wrote:
> Since kzalloc() returns a void pointer, we don't need to cast the
> return value in drivers/media/video/ivtv/ivtv-queue.c
>
> Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>

Jesper,

Thanks for the patch. I've applied it to my latest tree and will ask 
Mauro to pull from it. The latest source is a bit different and has in 
fact a third cast which I've also removed.

Thanks,

	Hans

> ---
>  drivers/media/video/ivtv/ivtv-queue.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/media/video/ivtv/ivtv-queue.c
> b/drivers/media/video/ivtv/ivtv-queue.c index a04f938..45825b8 100644
> --- a/drivers/media/video/ivtv/ivtv-queue.c
> +++ b/drivers/media/video/ivtv/ivtv-queue.c
> @@ -196,7 +196,7 @@ int ivtv_stream_alloc(struct ivtv_stream *s)
>  		s->name, s->buffers, s->buf_size, s->buffers * s->buf_size /
> 1024);
>
>  	if (ivtv_might_use_pio(s)) {
> -		s->PIOarray = (struct ivtv_SG_element *)kzalloc(SGsize,
> GFP_KERNEL); +		s->PIOarray = kzalloc(SGsize, GFP_KERNEL);
>  		if (s->PIOarray == NULL) {
>  			IVTV_ERR("Could not allocate PIOarray for %s stream\n", s->name);
>  			return -ENOMEM;
> @@ -204,7 +204,7 @@ int ivtv_stream_alloc(struct ivtv_stream *s)
>  	}
>
>  	/* Allocate DMA SG Arrays */
> -	s->SGarray = (struct ivtv_SG_element *)kzalloc(SGsize, GFP_KERNEL);
> +	s->SGarray = kzalloc(SGsize, GFP_KERNEL);
>  	if (s->SGarray == NULL) {
>  		IVTV_ERR("Could not allocate SGarray for %s stream\n", s->name);
>  		if (ivtv_might_use_pio(s)) {



^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH 22/30] ivtv: kzalloc() returns void pointer, no need to cast
  2007-08-24  8:32     ` Hans Verkuil
@ 2007-08-24  8:44       ` Jesper Juhl
  0 siblings, 0 replies; 65+ messages in thread
From: Jesper Juhl @ 2007-08-24  8:44 UTC (permalink / raw)
  To: Hans Verkuil
  Cc: Linux Kernel Mailing List, Kevin Thayer, Chris Kennedy,
	video4linux-list

On 24/08/07, Hans Verkuil <hverkuil@xs4all.nl> wrote:
> On Friday 24 August 2007 02:20:04 Jesper Juhl wrote:
> > Since kzalloc() returns a void pointer, we don't need to cast the
> > return value in drivers/media/video/ivtv/ivtv-queue.c
> >
> > Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
>
> Jesper,
>
> Thanks for the patch. I've applied it to my latest tree and will ask
> Mauro to pull from it. The latest source is a bit different and has in
> fact a third cast which I've also removed.
>
Perfect, thanks.

> Thanks,
>
>         Hans

-- 
Jesper Juhl <jesper.juhl@gmail.com>
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please      http://www.expita.com/nomime.html

^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH 19/30] scsi: Remove explicit casts of [kv]alloc return values in osst driver
  2007-08-24  7:04     ` Rolf Eike Beer
@ 2007-08-24  8:46       ` Jesper Juhl
  0 siblings, 0 replies; 65+ messages in thread
From: Jesper Juhl @ 2007-08-24  8:46 UTC (permalink / raw)
  To: Rolf Eike Beer
  Cc: linux-scsi, Linux Kernel Mailing List, James Bottomley,
	Willem Riede, osst-users

On 24/08/07, Rolf Eike Beer <eike-kernel@sf-tec.de> wrote:
> Jesper Juhl wrote:
> > [kv]alloc() return void *. No need to cast the return value.
>
> > @@ -5756,7 +5756,7 @@ static int osst_probe(struct device *dev)
> >       write_lock(&os_scsi_tapes_lock);
> >       if (os_scsi_tapes == NULL) {
> >               os_scsi_tapes =
> > -                     (struct osst_tape **)kmalloc(osst_max_dev * sizeof(struct osst_tape *),
> > +                     kmalloc(osst_max_dev * sizeof(struct osst_tape *),
> >                                  GFP_ATOMIC);
> >               if (os_scsi_tapes == NULL) {
> >                       write_unlock(&os_scsi_tapes_lock);
>
> Three lines later:
>
>                 for (i=0; i < osst_max_dev; ++i) os_scsi_tapes[i] = NULL;
>
> This wants to be
>
> os_scsi_tapes = kcalloc(osst_max_dev, sizeof(struct osst_tape *), GFP_ATOMIC);
>

Thank you for pointing that out.

I plan to resend those patches that don't get picked up in about a
week or so. I'll address this issue then (or if it does get picked up
in its current form I'll submit a follow-on patch to address this).


> Eike

-- 
Jesper Juhl <jesper.juhl@gmail.com>
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please      http://www.expita.com/nomime.html

^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH 28/30] jfs: avoid pointless casts of kmalloc() return val
  2007-08-24  4:19     ` Dave Kleikamp
@ 2007-08-24  8:48       ` Jesper Juhl
  0 siblings, 0 replies; 65+ messages in thread
From: Jesper Juhl @ 2007-08-24  8:48 UTC (permalink / raw)
  To: Dave Kleikamp; +Cc: Linux Kernel Mailing List, jfs-discussion

On 24/08/07, Dave Kleikamp <shaggy@linux.vnet.ibm.com> wrote:
> Thanks, but Jack Stone submitted the same patch a few weeks ago.  It's
> already in the jfs git tree and the -mm kernel.
>
Ok, I wasn't aware of that, but that's perfect.
Sorry for the noise.


-- 
Jesper Juhl <jesper.juhl@gmail.com>
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please      http://www.expita.com/nomime.html

^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH 20/30] scsi: In the Advansys driver, do not cast allocation function return values
  2007-08-24  2:03     ` Matthew Wilcox
@ 2007-08-24  9:00       ` Jesper Juhl
  0 siblings, 0 replies; 65+ messages in thread
From: Jesper Juhl @ 2007-08-24  9:00 UTC (permalink / raw)
  To: Matthew Wilcox
  Cc: Linux Kernel Mailing List, linux-scsi, James Bottomley, linux

On 24/08/07, Matthew Wilcox <matthew@wil.cx> wrote:
> On Fri, Aug 24, 2007 at 02:16:12AM +0200, Jesper Juhl wrote:
> > There's no reason to cast void pointers returned by the generic
> > memory allocation functions.
>
> I think I fixed all these already; please check scsi-misc.
>
I just checked out the latest scsi-misc-2.6 tree and it does indeed
look like these have already been dealt with.
Sorry about the noise.

-- 
Jesper Juhl <jesper.juhl@gmail.com>
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please      http://www.expita.com/nomime.html

^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH 17/30] isdn: Get rid of some pointless allocation casts in common and bsd comp.
  2007-08-24  0:09   ` [PATCH 17/30] isdn: Get rid of some pointless allocation casts in common and bsd comp Jesper Juhl
@ 2007-08-24  9:23     ` Karsten Keil
  2007-08-25  6:25     ` David Miller
  1 sibling, 0 replies; 65+ messages in thread
From: Karsten Keil @ 2007-08-24  9:23 UTC (permalink / raw)
  To: Jesper Juhl
  Cc: Linux Kernel Mailing List, Kai Germaschewski, isdn4linux,
	Michael Hipp

On Fri, Aug 24, 2007 at 02:09:34AM +0200, Jesper Juhl wrote:
> vmalloc() returns a void pointer - no need to cast the return value.
> 
> Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>

Acked-by: Karsten Keil <kkeil@suse.de>
> ---
>  drivers/isdn/i4l/isdn_bsdcomp.c |    5 ++---
>  drivers/isdn/i4l/isdn_common.c  |    2 +-
>  2 files changed, 3 insertions(+), 4 deletions(-)
> 
...
-- 
Karsten Keil
SuSE Labs
ISDN and VOIP development
SUSE LINUX Products GmbH, Maxfeldstr.5 90409 Nuernberg, GF: Markus Rex, HRB 16746 (AG Nuernberg)

^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH 09/30] mtd: Don't cast kmalloc() return value in drivers/mtd/maps/pmcmsp-flash.c
  2007-08-23 23:52   ` [PATCH 09/30] mtd: Don't cast kmalloc() return value in drivers/mtd/maps/pmcmsp-flash.c Jesper Juhl
@ 2007-08-24 10:41     ` Denys Vlasenko
  2007-08-24 10:43       ` Robert P. J. Day
  2007-08-24 10:48       ` Jesper Juhl
  0 siblings, 2 replies; 65+ messages in thread
From: Denys Vlasenko @ 2007-08-24 10:41 UTC (permalink / raw)
  To: Jesper Juhl; +Cc: Linux Kernel Mailing List, David Woodhouse, linux-mtd

On Friday 24 August 2007 00:52, Jesper Juhl wrote:
> kmalloc() returns a void pointer.
> No need to cast it.

> -	msp_flash = (struct mtd_info **)kmalloc(
> -			fcnt * sizeof(struct map_info *), GFP_KERNEL);
> -	msp_parts = (struct mtd_partition **)kmalloc(
> -			fcnt * sizeof(struct mtd_partition *), GFP_KERNEL);
> -	msp_maps = (struct map_info *)kmalloc(
> -			fcnt * sizeof(struct mtd_info), GFP_KERNEL);
> +	msp_flash = kmalloc(fcnt * sizeof(struct map_info *), GFP_KERNEL);
> +	msp_parts = kmalloc(fcnt * sizeof(struct mtd_partition *), GFP_KERNEL);
> +	msp_maps = kmalloc(fcnt * sizeof(struct mtd_info), GFP_KERNEL);
>  	memset(msp_maps, 0, fcnt * sizeof(struct mtd_info));

This one wants kzalloc.

> -		msp_parts[i] = (struct mtd_partition *)kmalloc(
> -			pcnt * sizeof(struct mtd_partition), GFP_KERNEL);
> +		msp_parts[i] = kmalloc(pcnt * sizeof(struct mtd_partition),
> +			GFP_KERNEL);
>  		memset(msp_parts[i], 0, pcnt * sizeof(struct mtd_partition));
>
>  		/* now initialize the devices proper */

Same
--
vda

^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH 09/30] mtd: Don't cast kmalloc() return value in drivers/mtd/maps/pmcmsp-flash.c
  2007-08-24 10:41     ` Denys Vlasenko
@ 2007-08-24 10:43       ` Robert P. J. Day
  2007-08-25 22:27         ` Jesper Juhl
  2007-08-24 10:48       ` Jesper Juhl
  1 sibling, 1 reply; 65+ messages in thread
From: Robert P. J. Day @ 2007-08-24 10:43 UTC (permalink / raw)
  To: Denys Vlasenko
  Cc: Jesper Juhl, linux-mtd, David Woodhouse,
	Linux Kernel Mailing List

On Fri, 24 Aug 2007, Denys Vlasenko wrote:

> On Friday 24 August 2007 00:52, Jesper Juhl wrote:
> > kmalloc() returns a void pointer.
> > No need to cast it.
>
> > -	msp_flash = (struct mtd_info **)kmalloc(
> > -			fcnt * sizeof(struct map_info *), GFP_KERNEL);
> > -	msp_parts = (struct mtd_partition **)kmalloc(
> > -			fcnt * sizeof(struct mtd_partition *), GFP_KERNEL);
> > -	msp_maps = (struct map_info *)kmalloc(
> > -			fcnt * sizeof(struct mtd_info), GFP_KERNEL);
> > +	msp_flash = kmalloc(fcnt * sizeof(struct map_info *), GFP_KERNEL);
> > +	msp_parts = kmalloc(fcnt * sizeof(struct mtd_partition *), GFP_KERNEL);
> > +	msp_maps = kmalloc(fcnt * sizeof(struct mtd_info), GFP_KERNEL);
> >  	memset(msp_maps, 0, fcnt * sizeof(struct mtd_info));
>
> This one wants kzalloc.
>
> > -		msp_parts[i] = (struct mtd_partition *)kmalloc(
> > -			pcnt * sizeof(struct mtd_partition), GFP_KERNEL);
> > +		msp_parts[i] = kmalloc(pcnt * sizeof(struct mtd_partition),
> > +			GFP_KERNEL);
> >  		memset(msp_parts[i], 0, pcnt * sizeof(struct mtd_partition));
> >
> >  		/* now initialize the devices proper */
>
> Same

actually, i would think kcalloc would be more appropriate here, no?

rday
-- 
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA

http://crashcourse.ca
========================================================================

^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH 09/30] mtd: Don't cast kmalloc() return value in drivers/mtd/maps/pmcmsp-flash.c
  2007-08-24 10:41     ` Denys Vlasenko
  2007-08-24 10:43       ` Robert P. J. Day
@ 2007-08-24 10:48       ` Jesper Juhl
  1 sibling, 0 replies; 65+ messages in thread
From: Jesper Juhl @ 2007-08-24 10:48 UTC (permalink / raw)
  To: Denys Vlasenko; +Cc: Linux Kernel Mailing List, David Woodhouse, linux-mtd

On 24/08/07, Denys Vlasenko <vda.linux@googlemail.com> wrote:
> On Friday 24 August 2007 00:52, Jesper Juhl wrote:
> > kmalloc() returns a void pointer.
> > No need to cast it.
>
> > -     msp_flash = (struct mtd_info **)kmalloc(
> > -                     fcnt * sizeof(struct map_info *), GFP_KERNEL);
> > -     msp_parts = (struct mtd_partition **)kmalloc(
> > -                     fcnt * sizeof(struct mtd_partition *), GFP_KERNEL);
> > -     msp_maps = (struct map_info *)kmalloc(
> > -                     fcnt * sizeof(struct mtd_info), GFP_KERNEL);
> > +     msp_flash = kmalloc(fcnt * sizeof(struct map_info *), GFP_KERNEL);
> > +     msp_parts = kmalloc(fcnt * sizeof(struct mtd_partition *), GFP_KERNEL);
> > +     msp_maps = kmalloc(fcnt * sizeof(struct mtd_info), GFP_KERNEL);
> >       memset(msp_maps, 0, fcnt * sizeof(struct mtd_info));
>
> This one wants kzalloc.
>
> > -             msp_parts[i] = (struct mtd_partition *)kmalloc(
> > -                     pcnt * sizeof(struct mtd_partition), GFP_KERNEL);
> > +             msp_parts[i] = kmalloc(pcnt * sizeof(struct mtd_partition),
> > +                     GFP_KERNEL);
> >               memset(msp_parts[i], 0, pcnt * sizeof(struct mtd_partition));
> >
> >               /* now initialize the devices proper */
>
> Same

Ok, thank you for that feedback.
 I'll respin the patch with that change when I resubmit all the ones
that don't get picked up (probably next week).

-- 
Jesper Juhl <jesper.juhl@gmail.com>
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please      http://www.expita.com/nomime.html

^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH 14/30] net: Kill some unneeded allocation return value casts in libertas
  2007-08-24  0:03   ` [PATCH 14/30] net: Kill some unneeded allocation return value casts in libertas Jesper Juhl
@ 2007-08-24 15:50     ` Dan Williams
  0 siblings, 0 replies; 65+ messages in thread
From: Dan Williams @ 2007-08-24 15:50 UTC (permalink / raw)
  To: Jesper Juhl; +Cc: Linux Kernel Mailing List, netdev, linux-wireless

On Fri, 2007-08-24 at 02:03 +0200, Jesper Juhl wrote:
> kmalloc() and friends return void*, no need to cast it.

Applied to libertas-2.6 'for-linville' branch, thanks.

Dan

> Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
> ---
>  drivers/net/wireless/libertas/debugfs.c |    2 +-
>  drivers/net/wireless/libertas/ethtool.c |    3 +--
>  2 files changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/wireless/libertas/debugfs.c b/drivers/net/wireless/libertas/debugfs.c
> index 715cbda..6ade63e 100644
> --- a/drivers/net/wireless/libertas/debugfs.c
> +++ b/drivers/net/wireless/libertas/debugfs.c
> @@ -1839,7 +1839,7 @@ static ssize_t wlan_debugfs_write(struct file *f, const char __user *buf,
>  	char *p2;
>  	struct debug_data *d = (struct debug_data *)f->private_data;
>  
> -	pdata = (char *)kmalloc(cnt, GFP_KERNEL);
> +	pdata = kmalloc(cnt, GFP_KERNEL);
>  	if (pdata == NULL)
>  		return 0;
>  
> diff --git a/drivers/net/wireless/libertas/ethtool.c b/drivers/net/wireless/libertas/ethtool.c
> index 96f1974..7dad493 100644
> --- a/drivers/net/wireless/libertas/ethtool.c
> +++ b/drivers/net/wireless/libertas/ethtool.c
> @@ -60,8 +60,7 @@ static int libertas_ethtool_get_eeprom(struct net_device *dev,
>  
>  //      mutex_lock(&priv->mutex);
>  
> -	adapter->prdeeprom =
> -		    (char *)kmalloc(eeprom->len+sizeof(regctrl), GFP_KERNEL);
> +	adapter->prdeeprom = kmalloc(eeprom->len+sizeof(regctrl), GFP_KERNEL);
>  	if (!adapter->prdeeprom)
>  		return -ENOMEM;
>  	memcpy(adapter->prdeeprom, &regctrl, sizeof(regctrl));


^ permalink raw reply	[flat|nested] 65+ messages in thread

* patch usb-avoid-redundant-cast-of-kmalloc-return-value-in-oti-6858-driver.patch added to gregkh-2.6 tree
  2007-08-24  0:35   ` [PATCH 27/30] usb: avoid redundant cast of kmalloc() return value in OTi-6858 driver Jesper Juhl
@ 2007-08-25  4:43     ` gregkh
  0 siblings, 0 replies; 65+ messages in thread
From: gregkh @ 2007-08-25  4:43 UTC (permalink / raw)
  To: jesper.juhl, greg, gregkh, linux-kernel


This is a note to let you know that I've just added the patch titled

     Subject: usb: avoid redundant cast of kmalloc() return value in OTi-6858 driver

to my gregkh-2.6 tree.  Its filename is

     usb-avoid-redundant-cast-of-kmalloc-return-value-in-oti-6858-driver.patch

This tree can be found at 
    http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/


>From jesper.juhl@gmail.com Thu Aug 23 17:38:13 2007
From: Jesper Juhl <jesper.juhl@gmail.com>
Date: Fri, 24 Aug 2007 02:35:14 +0200
Subject: usb: avoid redundant cast of kmalloc() return value in OTi-6858 driver
To: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Cc: Greg Kroah-Hartman <greg@kroah.com>, Jesper Juhl <jesper.juhl@gmail.com>
Message-ID: <e71841eb1d00e260fea44d94a4c8a0f950debcfd.1187912217.git.jesper.juhl@gmail.com>
Content-Disposition: inline


In drivers/usb/serial/oti6858.c::pl2303_buf_alloc() the return value
of kmalloc() is being cast to "struct pl2303_buf *", but that need
not be done here since kmalloc() returns "void *".

Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
 drivers/usb/serial/oti6858.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/usb/serial/oti6858.c
+++ b/drivers/usb/serial/oti6858.c
@@ -1144,7 +1144,7 @@ static struct pl2303_buf *pl2303_buf_all
 	if (size == 0)
 		return NULL;
 
-	pb = (struct pl2303_buf *)kmalloc(sizeof(struct pl2303_buf), GFP_KERNEL);
+	pb = kmalloc(sizeof(struct pl2303_buf), GFP_KERNEL);
 	if (pb == NULL)
 		return NULL;
 


Patches currently in gregkh-2.6 which might be from jesper.juhl@gmail.com are

bad/speakup-kconfig-fix.patch
usb/usb-clean-up-duplicate-includes-in-drivers-usb.patch
usb/usb-avoid-redundant-cast-of-kmalloc-return-value-in-oti-6858-driver.patch

^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH 10/30] irda: Do not do pointless kmalloc return value cast in KingSun driver
  2007-08-23 23:54   ` [PATCH 10/30] irda: Do not do pointless kmalloc return value cast in KingSun driver Jesper Juhl
@ 2007-08-25  6:23     ` David Miller
  0 siblings, 0 replies; 65+ messages in thread
From: David Miller @ 2007-08-25  6:23 UTC (permalink / raw)
  To: jesper.juhl; +Cc: linux-kernel, samuel, a_villacis

From: Jesper Juhl <jesper.juhl@gmail.com>
Date: Fri, 24 Aug 2007 01:54:23 +0200

> kmalloc() returns a void pointer, so there is no need to cast it in
>  drivers/net/irda/kingsun-sir.c::kingsun_probe().
> 
> Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>

Applied.

^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH 16/30] net: Avoid pointless allocation casts in BSD compression module
  2007-08-24  0:06   ` [PATCH 16/30] net: Avoid pointless allocation casts in BSD compression module Jesper Juhl
@ 2007-08-25  6:25     ` David Miller
  0 siblings, 0 replies; 65+ messages in thread
From: David Miller @ 2007-08-25  6:25 UTC (permalink / raw)
  To: jesper.juhl; +Cc: linux-kernel, netdev

From: Jesper Juhl <jesper.juhl@gmail.com>
Date: Fri, 24 Aug 2007 02:06:58 +0200

> The general kernel memory allocation functions return void pointers
> and there is no need to cast their return values.
> 
> Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>

Applied.

^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH 17/30] isdn: Get rid of some pointless allocation casts in common and bsd comp.
  2007-08-24  0:09   ` [PATCH 17/30] isdn: Get rid of some pointless allocation casts in common and bsd comp Jesper Juhl
  2007-08-24  9:23     ` Karsten Keil
@ 2007-08-25  6:25     ` David Miller
  1 sibling, 0 replies; 65+ messages in thread
From: David Miller @ 2007-08-25  6:25 UTC (permalink / raw)
  To: jesper.juhl
  Cc: linux-kernel, kkeil, kai.germaschewski, isdn4linux, Michael.Hipp

From: Jesper Juhl <jesper.juhl@gmail.com>
Date: Fri, 24 Aug 2007 02:09:34 +0200

> vmalloc() returns a void pointer - no need to cast the return value.
> 
> Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>

Applied, thanks.

^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH 09/30] mtd: Don't cast kmalloc() return value in drivers/mtd/maps/pmcmsp-flash.c
  2007-08-24 10:43       ` Robert P. J. Day
@ 2007-08-25 22:27         ` Jesper Juhl
  2007-08-25 23:59           ` Robert P. J. Day
  0 siblings, 1 reply; 65+ messages in thread
From: Jesper Juhl @ 2007-08-25 22:27 UTC (permalink / raw)
  To: Robert P. J. Day
  Cc: Denys Vlasenko, linux-mtd, David Woodhouse,
	Linux Kernel Mailing List

On 24/08/07, Robert P. J. Day <rpjday@mindspring.com> wrote:
> On Fri, 24 Aug 2007, Denys Vlasenko wrote:
>
> > On Friday 24 August 2007 00:52, Jesper Juhl wrote:
> > > kmalloc() returns a void pointer.
> > > No need to cast it.
> >
> > > -   msp_flash = (struct mtd_info **)kmalloc(
> > > -                   fcnt * sizeof(struct map_info *), GFP_KERNEL);
> > > -   msp_parts = (struct mtd_partition **)kmalloc(
> > > -                   fcnt * sizeof(struct mtd_partition *), GFP_KERNEL);
> > > -   msp_maps = (struct map_info *)kmalloc(
> > > -                   fcnt * sizeof(struct mtd_info), GFP_KERNEL);
> > > +   msp_flash = kmalloc(fcnt * sizeof(struct map_info *), GFP_KERNEL);
> > > +   msp_parts = kmalloc(fcnt * sizeof(struct mtd_partition *), GFP_KERNEL);
> > > +   msp_maps = kmalloc(fcnt * sizeof(struct mtd_info), GFP_KERNEL);
> > >     memset(msp_maps, 0, fcnt * sizeof(struct mtd_info));
> >
> > This one wants kzalloc.
> >
> > > -           msp_parts[i] = (struct mtd_partition *)kmalloc(
> > > -                   pcnt * sizeof(struct mtd_partition), GFP_KERNEL);
> > > +           msp_parts[i] = kmalloc(pcnt * sizeof(struct mtd_partition),
> > > +                   GFP_KERNEL);
> > >             memset(msp_parts[i], 0, pcnt * sizeof(struct mtd_partition));
> > >
> > >             /* now initialize the devices proper */
> >
> > Same
>
> actually, i would think kcalloc would be more appropriate here, no?
>

Why?

msp_parts[i] = kzalloc(pcnt * sizeof(struct mtd_partition), GFP_KERNEL);

seems better to me than

msp_parts[i] = kcalloc(1, pcnt * sizeof(struct mtd_partition), GFP_KERNEL);


-- 
Jesper Juhl <jesper.juhl@gmail.com>
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please      http://www.expita.com/nomime.html

^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH 09/30] mtd: Don't cast kmalloc() return value in drivers/mtd/maps/pmcmsp-flash.c
  2007-08-25 22:27         ` Jesper Juhl
@ 2007-08-25 23:59           ` Robert P. J. Day
  2007-08-26  0:28             ` Jesper Juhl
  0 siblings, 1 reply; 65+ messages in thread
From: Robert P. J. Day @ 2007-08-25 23:59 UTC (permalink / raw)
  To: Jesper Juhl
  Cc: Denys Vlasenko, David Woodhouse, linux-mtd,
	Linux Kernel Mailing List

On Sun, 26 Aug 2007, Jesper Juhl wrote:

> On 24/08/07, Robert P. J. Day <rpjday@mindspring.com> wrote:

> > actually, i would think kcalloc would be more appropriate here, no?
> >
>
> Why?
>
> msp_parts[i] = kzalloc(pcnt * sizeof(struct mtd_partition), GFP_KERNEL);
>
> seems better to me than
>
> msp_parts[i] = kcalloc(1, pcnt * sizeof(struct mtd_partition), GFP_KERNEL);

i was thinking more along the lines of

msp_parts[i] = kcalloc(pcnt, sizeof(struct mtd_partition), GFP_KERNEL);

which was kind of the obvious implication, no?  unless there's a
reason kcalloc() wouldn't work here, this is pretty much what
kcalloc() was designed for.

rday

-- 
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA

http://crashcourse.ca
========================================================================

^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH 09/30] mtd: Don't cast kmalloc() return value in drivers/mtd/maps/pmcmsp-flash.c
  2007-08-26  0:28             ` Jesper Juhl
@ 2007-08-26  0:23               ` Robert P. J. Day
  2007-08-26  0:36                 ` Jesper Juhl
  2007-08-26 14:28                 ` Denys Vlasenko
  0 siblings, 2 replies; 65+ messages in thread
From: Robert P. J. Day @ 2007-08-26  0:23 UTC (permalink / raw)
  To: Jesper Juhl
  Cc: Denys Vlasenko, linux-mtd, David Woodhouse,
	Linux Kernel Mailing List

On Sun, 26 Aug 2007, Jesper Juhl wrote:

> On 26/08/07, Robert P. J. Day <rpjday@mindspring.com> wrote:

> > i was thinking more along the lines of
> >
> > msp_parts[i] = kcalloc(pcnt, sizeof(struct mtd_partition), GFP_KERNEL);
> >
> > which was kind of the obvious implication, no?
>
> I guess
>
> > unless there's a reason kcalloc() wouldn't work here, this is
> > pretty much what kcalloc() was designed for.
> >
> When Denys brought up the zeroing thing and mentioned kzalloc() I
> did consider kcalloc() instead, but kzalloc() makes this allocation
> nicely look like the preceding ones visually and I couldn't convince
> myself that kcalloc() would give us any real benefit here.
>
> What exactely would using kcalloc() over kzalloc() here buy us?

technically, nothing.  but if you're not going to use kcalloc() when
you're explicitly allocating an array of identical objects (that you
want zero-filled, as a bonus), then what's the point of ever having
defined a kcalloc() routine in the first place?

rday
-- 
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA

http://crashcourse.ca
========================================================================

^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH 09/30] mtd: Don't cast kmalloc() return value in drivers/mtd/maps/pmcmsp-flash.c
  2007-08-25 23:59           ` Robert P. J. Day
@ 2007-08-26  0:28             ` Jesper Juhl
  2007-08-26  0:23               ` Robert P. J. Day
  0 siblings, 1 reply; 65+ messages in thread
From: Jesper Juhl @ 2007-08-26  0:28 UTC (permalink / raw)
  To: Robert P. J. Day
  Cc: Denys Vlasenko, David Woodhouse, linux-mtd,
	Linux Kernel Mailing List

On 26/08/07, Robert P. J. Day <rpjday@mindspring.com> wrote:
> On Sun, 26 Aug 2007, Jesper Juhl wrote:
>
> > On 24/08/07, Robert P. J. Day <rpjday@mindspring.com> wrote:
>
> > > actually, i would think kcalloc would be more appropriate here, no?
> > >
> >
> > Why?
> >
> > msp_parts[i] = kzalloc(pcnt * sizeof(struct mtd_partition), GFP_KERNEL);
> >
> > seems better to me than
> >
> > msp_parts[i] = kcalloc(1, pcnt * sizeof(struct mtd_partition), GFP_KERNEL);
>
> i was thinking more along the lines of
>
> msp_parts[i] = kcalloc(pcnt, sizeof(struct mtd_partition), GFP_KERNEL);
>
> which was kind of the obvious implication, no?

I guess

> unless there's a
> reason kcalloc() wouldn't work here, this is pretty much what
> kcalloc() was designed for.
>
When Denys brought up the zeroing thing and mentioned kzalloc() I did
consider kcalloc() instead, but kzalloc() makes this allocation nicely
look like the preceding ones visually and I couldn't convince myself
that kcalloc() would give us any real benefit here.

What exactely would using kcalloc() over kzalloc() here buy us?

-- 
Jesper Juhl <jesper.juhl@gmail.com>
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please      http://www.expita.com/nomime.html

^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH 09/30] mtd: Don't cast kmalloc() return value in drivers/mtd/maps/pmcmsp-flash.c
  2007-08-26  0:23               ` Robert P. J. Day
@ 2007-08-26  0:36                 ` Jesper Juhl
  2007-08-26  1:52                   ` Kyle Moffett
  2007-08-26 14:28                 ` Denys Vlasenko
  1 sibling, 1 reply; 65+ messages in thread
From: Jesper Juhl @ 2007-08-26  0:36 UTC (permalink / raw)
  To: Robert P. J. Day
  Cc: Denys Vlasenko, linux-mtd, David Woodhouse,
	Linux Kernel Mailing List

On 26/08/07, Robert P. J. Day <rpjday@mindspring.com> wrote:
> On Sun, 26 Aug 2007, Jesper Juhl wrote:
>
> > On 26/08/07, Robert P. J. Day <rpjday@mindspring.com> wrote:
>
> > > i was thinking more along the lines of
> > >
> > > msp_parts[i] = kcalloc(pcnt, sizeof(struct mtd_partition), GFP_KERNEL);
> > >
> > > which was kind of the obvious implication, no?
> >
> > I guess
> >
> > > unless there's a reason kcalloc() wouldn't work here, this is
> > > pretty much what kcalloc() was designed for.
> > >
> > When Denys brought up the zeroing thing and mentioned kzalloc() I
> > did consider kcalloc() instead, but kzalloc() makes this allocation
> > nicely look like the preceding ones visually and I couldn't convince
> > myself that kcalloc() would give us any real benefit here.
> >
> > What exactely would using kcalloc() over kzalloc() here buy us?
>
> technically, nothing.  but if you're not going to use kcalloc() when
> you're explicitly allocating an array of identical objects (that you
> want zero-filled, as a bonus), then what's the point of ever having
> defined a kcalloc() routine in the first place?
>
I wonder a bit about that myself...

I have found some other issues in that function that I want to fix, so
I'll be respinning the patch as a patch series instead - and why not;
I'll just go with kcalloc() and see what the maintainers have to say,
it's not like I personally care much one way or the other.

-- 
Jesper Juhl <jesper.juhl@gmail.com>
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please      http://www.expita.com/nomime.html

^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH 09/30] mtd: Don't cast kmalloc() return value in drivers/mtd/maps/pmcmsp-flash.c
  2007-08-26  0:36                 ` Jesper Juhl
@ 2007-08-26  1:52                   ` Kyle Moffett
  0 siblings, 0 replies; 65+ messages in thread
From: Kyle Moffett @ 2007-08-26  1:52 UTC (permalink / raw)
  To: Jesper Juhl
  Cc: Robert P. J. Day, Denys Vlasenko, linux-mtd, David Woodhouse,
	Linux Kernel Mailing List

On Aug 25, 2007, at 20:36:32, Jesper Juhl wrote:
> On 26/08/07, Robert P. J. Day <rpjday@mindspring.com> wrote:
>> technically, nothing.  but if you're not going to use kcalloc()  
>> when you're explicitly allocating an array of identical objects  
>> (that you want zero-filled, as a bonus), then what's the point of  
>> ever having defined a kcalloc() routine in the first place?
>>
> I wonder a bit about that myself...
>
> I have found some other issues in that function that I want to fix,  
> so I'll be respinning the patch as a patch series instead - and why  
> not; I'll just go with kcalloc() and see what the maintainers have  
> to say, it's not like I personally care much one way or the other.

I think the original reasoning behind kcalloc() was that it did some  
extra input checking, so that if the product of the two numbers  
overflowed, it would fail with NULL instead of allocating  
insufficient space.  In the kernel it doesn't matter in practice  
since you MUST have additional checking on the size of allocated  
memory anyways, not even considering the fact that >PAGE_SIZE  
allocations are probably going to fail with decent frequency regardless.

Cheers,
Kyle Moffett



^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH 09/30] mtd: Don't cast kmalloc() return value in drivers/mtd/maps/pmcmsp-flash.c
  2007-08-26  0:23               ` Robert P. J. Day
  2007-08-26  0:36                 ` Jesper Juhl
@ 2007-08-26 14:28                 ` Denys Vlasenko
  2007-08-26 14:37                   ` Jan Engelhardt
  1 sibling, 1 reply; 65+ messages in thread
From: Denys Vlasenko @ 2007-08-26 14:28 UTC (permalink / raw)
  To: Robert P. J. Day
  Cc: Jesper Juhl, linux-mtd, David Woodhouse,
	Linux Kernel Mailing List

On Sunday 26 August 2007 01:23, Robert P. J. Day wrote:
> On Sun, 26 Aug 2007, Jesper Juhl wrote:
> > On 26/08/07, Robert P. J. Day <rpjday@mindspring.com> wrote:
> > > i was thinking more along the lines of
> > >
> > > msp_parts[i] = kcalloc(pcnt, sizeof(struct mtd_partition), GFP_KERNEL);
> > >
> > > which was kind of the obvious implication, no?
> >
> > I guess
> >
> > > unless there's a reason kcalloc() wouldn't work here, this is
> > > pretty much what kcalloc() was designed for.
> >
> > When Denys brought up the zeroing thing and mentioned kzalloc() I
> > did consider kcalloc() instead, but kzalloc() makes this allocation
> > nicely look like the preceding ones visually and I couldn't convince
> > myself that kcalloc() would give us any real benefit here.
> >
> > What exactely would using kcalloc() over kzalloc() here buy us?
>
> technically, nothing.

The idea of calloc is that it can check for underflow in parameter.

calloc(-1, 10000000) => easy to detect
malloc(-1 * 10000000) => malloc(-10000000) => not so trivial
--
vda

^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH 09/30] mtd: Don't cast kmalloc() return value in drivers/mtd/maps/pmcmsp-flash.c
  2007-08-26 14:28                 ` Denys Vlasenko
@ 2007-08-26 14:37                   ` Jan Engelhardt
  2007-08-26 22:10                     ` Jesper Juhl
  0 siblings, 1 reply; 65+ messages in thread
From: Jan Engelhardt @ 2007-08-26 14:37 UTC (permalink / raw)
  To: Denys Vlasenko
  Cc: Robert P. J. Day, Jesper Juhl, linux-mtd, David Woodhouse,
	Linux Kernel Mailing List


On Aug 26 2007 15:28, Denys Vlasenko wrote:
>> >
>> > What exactely would using kcalloc() over kzalloc() here buy us?
>>
>> technically, nothing.
>
>The idea of calloc is that it can check for underflow in parameter.

Actually, overflow.

calloc(0xFFFF0000,  0x1000) => will return NULL
malloc(0xFFFF0000 * 0x1000) => silent 32 bit multiplication/truncation,
will allocate less than requested.

>calloc(-1, 10000000) => easy to detect
>malloc(-1 * 10000000) => malloc(-10000000) => not so trivial


	Jan
-- 

^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH 09/30] mtd: Don't cast kmalloc() return value in drivers/mtd/maps/pmcmsp-flash.c
  2007-08-26 14:37                   ` Jan Engelhardt
@ 2007-08-26 22:10                     ` Jesper Juhl
  0 siblings, 0 replies; 65+ messages in thread
From: Jesper Juhl @ 2007-08-26 22:10 UTC (permalink / raw)
  To: Jan Engelhardt
  Cc: Denys Vlasenko, Robert P. J. Day, linux-mtd, David Woodhouse,
	Linux Kernel Mailing List

On 26/08/07, Jan Engelhardt <jengelh@computergmbh.de> wrote:
>
> On Aug 26 2007 15:28, Denys Vlasenko wrote:
> >> >
> >> > What exactely would using kcalloc() over kzalloc() here buy us?
> >>
> >> technically, nothing.
> >
> >The idea of calloc is that it can check for underflow in parameter.
>
> Actually, overflow.
>
> calloc(0xFFFF0000,  0x1000) => will return NULL
> malloc(0xFFFF0000 * 0x1000) => silent 32 bit multiplication/truncation,
> will allocate less than requested.
>
> >calloc(-1, 10000000) => easy to detect
> >malloc(-1 * 10000000) => malloc(-10000000) => not so trivial
>
Ok, that makes a bit of sense. Thank you.


-- 
Jesper Juhl <jesper.juhl@gmail.com>
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please      http://www.expita.com/nomime.html

^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH 30/30] emu10k1: There's no need to cast vmalloc() return value in snd_emu10k1_create()
  2007-08-24  0:41   ` [PATCH 30/30] emu10k1: There's no need to cast vmalloc() return value in snd_emu10k1_create() Jesper Juhl
@ 2007-08-28 13:22     ` Takashi Iwai
  0 siblings, 0 replies; 65+ messages in thread
From: Takashi Iwai @ 2007-08-28 13:22 UTC (permalink / raw)
  To: Jesper Juhl
  Cc: Linux Kernel Mailing List, Jaroslav Kysela, James Courtier-Dutton

At Fri, 24 Aug 2007 02:41:04 +0200,
Jesper Juhl wrote:
> 
> vmalloc() returns void *. no need to cast.
> 
> Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
> ---
>  sound/pci/emu10k1/emu10k1_main.c |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)

Thanks, applied to ALSA tree.


Takashi

^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH 13/30] net: Don't do pointless kmalloc return value casts in zd1211 driver
       [not found]   ` <d551047daed1cb4d9de1eff956268a468c9837f6.1187912217.git.jesper.juhl@gmail.com>
@ 2007-08-30 17:54     ` Daniel Drake
  2007-08-30 20:20       ` Jesper Juhl
  0 siblings, 1 reply; 65+ messages in thread
From: Daniel Drake @ 2007-08-30 17:54 UTC (permalink / raw)
  To: Jesper Juhl
  Cc: Linux Kernel Mailing List, netdev, David S. Miller, Ulrich Kunitz,
	linux-wireless

Jesper Juhl wrote:
> Since kmalloc() returns a void pointer there is no reason to cast
> its return value.
> This patch also removes a pointless initialization of a variable.

NAK: adds a sparse warning
zd_chip.c:116:15: warning: implicit cast to nocast type

> Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
> ---
>  drivers/net/wireless/zd1211rw/zd_chip.c |    5 ++---
>  1 files changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/wireless/zd1211rw/zd_chip.c b/drivers/net/wireless/zd1211rw/zd_chip.c
> index c39f198..4942e5c 100644
> --- a/drivers/net/wireless/zd1211rw/zd_chip.c
> +++ b/drivers/net/wireless/zd1211rw/zd_chip.c
> @@ -106,8 +106,8 @@ int zd_ioread32v_locked(struct zd_chip *chip, u32 *values, const zd_addr_t *addr
>  {
>  	int r;
>  	int i;
> -	zd_addr_t *a16 = (zd_addr_t *)NULL;
>  	u16 *v16;
> +	zd_addr_t *a16;
>  	unsigned int count16;
>  
>  	if (count > USB_MAX_IOREAD32_COUNT)
> @@ -115,8 +115,7 @@ int zd_ioread32v_locked(struct zd_chip *chip, u32 *values, const zd_addr_t *addr
>  
>  	/* Allocate a single memory block for values and addresses. */
>  	count16 = 2*count;
> -	a16 = (zd_addr_t *) kmalloc(count16 * (sizeof(zd_addr_t) + sizeof(u16)),
> -		                   GFP_KERNEL);
> +	a16 = kmalloc(count16 * (sizeof(zd_addr_t) + sizeof(u16)), GFP_KERNEL);
>  	if (!a16) {
>  		dev_dbg_f(zd_chip_dev(chip),
>  			  "error ENOMEM in allocation of a16\n");


^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH 13/30] net: Don't do pointless kmalloc return value casts in zd1211 driver
  2007-08-30 17:54     ` [PATCH 13/30] net: Don't do pointless kmalloc return value casts in zd1211 driver Daniel Drake
@ 2007-08-30 20:20       ` Jesper Juhl
  2007-08-30 22:19         ` Joe Perches
                           ` (2 more replies)
  0 siblings, 3 replies; 65+ messages in thread
From: Jesper Juhl @ 2007-08-30 20:20 UTC (permalink / raw)
  To: Daniel Drake
  Cc: Linux Kernel Mailing List, netdev, David S. Miller, Ulrich Kunitz,
	linux-wireless

On 30/08/2007, Daniel Drake <dsd@gentoo.org> wrote:
> Jesper Juhl wrote:
> > Since kmalloc() returns a void pointer there is no reason to cast
> > its return value.
> > This patch also removes a pointless initialization of a variable.
>
> NAK: adds a sparse warning
> zd_chip.c:116:15: warning: implicit cast to nocast type
>
Ok, I must admit I didn't check with sparse since it seemed pointless
- we usually never cast void pointers to other pointer types,
specifically because the C language nicely guarantees that the right
thing will happen without the cast.  Sometimes we have to cast them to
integer types, su sure we need the cast there.   But what on earth
makes a "zd_addr_t *" so special that we have to explicitly cast a
"void *" to that type?

I see it's defined as
  typedef u32 __nocast zd_addr_t;
in drivers/net/wireless/zd1211rw/zd_types.h , but why the __nocast ?

What would be wrong in applying my patch that removes the cast of the
kmalloc() return value and then also remove the "__nocast" here?


-- 
Jesper Juhl <jesper.juhl@gmail.com>
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please      http://www.expita.com/nomime.html

^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH 13/30] net: Don't do pointless kmalloc return value casts in zd1211 driver
  2007-08-30 20:20       ` Jesper Juhl
@ 2007-08-30 22:19         ` Joe Perches
  2007-08-30 22:30           ` [PATCH] Don't needlessly initialize variable to NULL in zd_chip (was: Re: [PATCH 13/30] net: Don't do pointless kmalloc return value casts in zd1211 driver) Jesper Juhl
  2007-08-30 23:47         ` [PATCH 13/30] net: Don't do pointless kmalloc return value casts in zd1211 driver Daniel Drake
  2007-08-31  9:30         ` Herbert Xu
  2 siblings, 1 reply; 65+ messages in thread
From: Joe Perches @ 2007-08-30 22:19 UTC (permalink / raw)
  To: Jesper Juhl
  Cc: Daniel Drake, Linux Kernel Mailing List, netdev, David S. Miller,
	Ulrich Kunitz, linux-wireless

On Thu, 2007-08-30 at 22:20 +0200, Jesper Juhl wrote:
> Ok, I must admit I didn't check with sparse since it seemed pointless
> - we usually never cast void pointers to other pointer types,
> specifically because the C language nicely guarantees that the right
> thing will happen without the cast.  Sometimes we have to cast them to
> integer types, su sure we need the cast there.   But what on earth
> makes a "zd_addr_t *" so special that we have to explicitly cast a
> "void *" to that type?

http://marc.info/?l=linux-netdev&m=117113743902549&w=1


^ permalink raw reply	[flat|nested] 65+ messages in thread

* [PATCH] Don't needlessly initialize variable to NULL in zd_chip   (was: Re: [PATCH 13/30] net: Don't do pointless kmalloc return value casts in zd1211 driver)
  2007-08-30 22:19         ` Joe Perches
@ 2007-08-30 22:30           ` Jesper Juhl
  2007-08-30 22:42             ` Randy Dunlap
  0 siblings, 1 reply; 65+ messages in thread
From: Jesper Juhl @ 2007-08-30 22:30 UTC (permalink / raw)
  To: Joe Perches
  Cc: Daniel Drake, Linux Kernel Mailing List, netdev, David S. Miller,
	Ulrich Kunitz, linux-wireless, Jesper Juhl

On Friday 31 August 2007 00:19:53 Joe Perches wrote:
> On Thu, 2007-08-30 at 22:20 +0200, Jesper Juhl wrote:
> > Ok, I must admit I didn't check with sparse since it seemed pointless
> > - we usually never cast void pointers to other pointer types,
> > specifically because the C language nicely guarantees that the right
> > thing will happen without the cast.  Sometimes we have to cast them to
> > integer types, su sure we need the cast there.   But what on earth
> > makes a "zd_addr_t *" so special that we have to explicitly cast a
> > "void *" to that type?
> 
> http://marc.info/?l=linux-netdev&m=117113743902549&w=1
> 

Thank you for that link Joe.

I'm not sure I agree with the __nocast, but I respect that this is 
the maintainers choice.

But, I still think the first chunk of the patch that removes the 
initial variable initialization makes sense. 
Initializing the variable to NULL is pointless since it'll never be
used before the kmalloc() call. So here's a revised patch that just
gets rid of that little detail.



No need to initialize to NULL when variable is never used before 
it's assigned the return value of a kmalloc() call.

Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---

diff --git a/drivers/net/wireless/zd1211rw/zd_chip.c b/drivers/net/wireless/zd1211rw/zd_chip.c
index c39f198..30872fe 100644
--- a/drivers/net/wireless/zd1211rw/zd_chip.c
+++ b/drivers/net/wireless/zd1211rw/zd_chip.c
@@ -106,7 +106,7 @@ int zd_ioread32v_locked(struct zd_chip *chip, u32 *values, const zd_addr_t *addr
 {
 	int r;
 	int i;
-	zd_addr_t *a16 = (zd_addr_t *)NULL;
+	zd_addr_t *a16;
 	u16 *v16;
 	unsigned int count16;
 



^ permalink raw reply related	[flat|nested] 65+ messages in thread

* Re: [PATCH] Don't needlessly initialize variable to NULL in zd_chip (was: Re: [PATCH 13/30] net: Don't do pointless kmalloc return value casts in zd1211 driver)
  2007-08-30 22:30           ` [PATCH] Don't needlessly initialize variable to NULL in zd_chip (was: Re: [PATCH 13/30] net: Don't do pointless kmalloc return value casts in zd1211 driver) Jesper Juhl
@ 2007-08-30 22:42             ` Randy Dunlap
  2007-08-30 23:04               ` Jesper Juhl
  0 siblings, 1 reply; 65+ messages in thread
From: Randy Dunlap @ 2007-08-30 22:42 UTC (permalink / raw)
  To: Jesper Juhl
  Cc: Joe Perches, Daniel Drake, Linux Kernel Mailing List, netdev,
	David S. Miller, Ulrich Kunitz, linux-wireless

On Fri, 31 Aug 2007 00:30:31 +0200 Jesper Juhl wrote:

> On Friday 31 August 2007 00:19:53 Joe Perches wrote:
> > On Thu, 2007-08-30 at 22:20 +0200, Jesper Juhl wrote:
> > > Ok, I must admit I didn't check with sparse since it seemed pointless
> > > - we usually never cast void pointers to other pointer types,
> > > specifically because the C language nicely guarantees that the right
> > > thing will happen without the cast.  Sometimes we have to cast them to
> > > integer types, su sure we need the cast there.   But what on earth
> > > makes a "zd_addr_t *" so special that we have to explicitly cast a
> > > "void *" to that type?
> > 
> > http://marc.info/?l=linux-netdev&m=117113743902549&w=1
> > 
> 
> Thank you for that link Joe.
> 
> I'm not sure I agree with the __nocast, but I respect that this is 
> the maintainers choice.
> 
> But, I still think the first chunk of the patch that removes the 
> initial variable initialization makes sense. 
> Initializing the variable to NULL is pointless since it'll never be
> used before the kmalloc() call. So here's a revised patch that just
> gets rid of that little detail.


BTW:  http://marc.info/?l=linux-wireless&m=118831813500769&w=2


> No need to initialize to NULL when variable is never used before 
> it's assigned the return value of a kmalloc() call.
> 
> Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
> ---
> 
> diff --git a/drivers/net/wireless/zd1211rw/zd_chip.c b/drivers/net/wireless/zd1211rw/zd_chip.c
> index c39f198..30872fe 100644
> --- a/drivers/net/wireless/zd1211rw/zd_chip.c
> +++ b/drivers/net/wireless/zd1211rw/zd_chip.c
> @@ -106,7 +106,7 @@ int zd_ioread32v_locked(struct zd_chip *chip, u32 *values, const zd_addr_t *addr
>  {
>  	int r;
>  	int i;
> -	zd_addr_t *a16 = (zd_addr_t *)NULL;
> +	zd_addr_t *a16;
>  	u16 *v16;
>  	unsigned int count16;


---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***

^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH] Don't needlessly initialize variable to NULL in zd_chip (was: Re: [PATCH 13/30] net: Don't do pointless kmalloc return value casts in zd1211 driver)
  2007-08-30 22:42             ` Randy Dunlap
@ 2007-08-30 23:04               ` Jesper Juhl
  0 siblings, 0 replies; 65+ messages in thread
From: Jesper Juhl @ 2007-08-30 23:04 UTC (permalink / raw)
  To: Randy Dunlap
  Cc: Joe Perches, Daniel Drake, Linux Kernel Mailing List, netdev,
	David S. Miller, Ulrich Kunitz, linux-wireless

On 31/08/2007, Randy Dunlap <randy.dunlap@oracle.com> wrote:
...
>
> BTW:  http://marc.info/?l=linux-wireless&m=118831813500769&w=2
>
...

Heh, thanks Randy.

All too often patches get missed since I don't happen to include the
right magic person to Cc. So I generally take a "better to have one Cc
too many than miss one" approach when sending patches - otherwise I
just end up resending it several times and eventually have to bother
Andrew to move it through -mm.

I see the point of people not getting things twice, but too many
patches slip through the cracks already (and not just my patches,
that's a general problem) so I'd rather inconvenience a few people
with one extra email than missing the proper maintainer by not Cc'ing
the right list.    Picking the right list/set of people to Cc is hard!


(whoops, mistakenly didn't do a reply-to-all initially; sorry Randy,
now you'll get this mail twice ;)


--
Jesper Juhl <jesper.juhl@gmail.com>
Don't top-post  http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please      http://www.expita.com/nomime.html

^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH 13/30] net: Don't do pointless kmalloc return value casts in zd1211 driver
  2007-08-30 20:20       ` Jesper Juhl
  2007-08-30 22:19         ` Joe Perches
@ 2007-08-30 23:47         ` Daniel Drake
  2007-08-31  9:30         ` Herbert Xu
  2 siblings, 0 replies; 65+ messages in thread
From: Daniel Drake @ 2007-08-30 23:47 UTC (permalink / raw)
  To: Jesper Juhl
  Cc: Linux Kernel Mailing List, netdev, David S. Miller, Ulrich Kunitz,
	linux-wireless

Jesper Juhl wrote:
> What would be wrong in applying my patch that removes the cast of the
> kmalloc() return value and then also remove the "__nocast" here?

We use it as a safety measure when coding. For example the write 
register function takes an address and a value. We got one of these the 
wrong way round once, and had a non-obvious bug.

nocast and sparse helps us prevent this.

Daniel


^ permalink raw reply	[flat|nested] 65+ messages in thread

* Re: [PATCH 13/30] net: Don't do pointless kmalloc return value casts in zd1211 driver
  2007-08-30 20:20       ` Jesper Juhl
  2007-08-30 22:19         ` Joe Perches
  2007-08-30 23:47         ` [PATCH 13/30] net: Don't do pointless kmalloc return value casts in zd1211 driver Daniel Drake
@ 2007-08-31  9:30         ` Herbert Xu
  2 siblings, 0 replies; 65+ messages in thread
From: Herbert Xu @ 2007-08-31  9:30 UTC (permalink / raw)
  To: Jesper Juhl, Al Viro
  Cc: dsd, linux-kernel, netdev, davem, kune, linux-wireless

Jesper Juhl <jesper.juhl@gmail.com> wrote:
> On 30/08/2007, Daniel Drake <dsd@gentoo.org> wrote:
>> Jesper Juhl wrote:
>> > Since kmalloc() returns a void pointer there is no reason to cast
>> > its return value.
>> > This patch also removes a pointless initialization of a variable.
>>
>> NAK: adds a sparse warning
>> zd_chip.c:116:15: warning: implicit cast to nocast type
>>
> Ok, I must admit I didn't check with sparse since it seemed pointless
> - we usually never cast void pointers to other pointer types,
> specifically because the C language nicely guarantees that the right
> thing will happen without the cast.  Sometimes we have to cast them to
> integer types, su sure we need the cast there.   But what on earth
> makes a "zd_addr_t *" so special that we have to explicitly cast a
> "void *" to that type?
> 
> I see it's defined as
>  typedef u32 __nocast zd_addr_t;
> in drivers/net/wireless/zd1211rw/zd_types.h , but why the __nocast ?

Nevermind the __nocast, this looks like a bug in sparse.  Just
because a base type is __nocast, sparse shouldn't infer that a
pointer to it should also be __nocast.

Cheers,
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 65+ messages in thread

end of thread, other threads:[~2007-08-31  9:31 UTC | newest]

Thread overview: 65+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <Message-Id: <200708240135.56833.jesper.juhl@gmail.com>
2007-08-23 23:40 ` [PATCH 01/30] ia64: Remove unnecessary cast of allocation return value in sn_hwperf_enum_objects() Jesper Juhl
2007-08-23 23:42   ` [PATCH 02/30] cris: Remove unnecessary cast of allocation return value in intmem.c Jesper Juhl
2007-08-23 23:43   ` [PATCH 03/30] um: Don't unnecessarily cast allocation return value in ubd_kern.c Jesper Juhl
2007-08-24  0:22     ` Jeff Dike
2007-08-23 23:45   ` [PATCH 04/30] powerpc: Don't cast kmalloc return value in ibmebus.c Jesper Juhl
2007-08-24  0:37     ` Joachim Fenkes
2007-08-23 23:46   ` [PATCH 05/30] atm: No need to cast vmalloc() return value Jesper Juhl
2007-08-23 23:48   ` [PATCH 06/30] i2o: No need to cast kmalloc() return value in cfg_open() Jesper Juhl
2007-08-23 23:50   ` [PATCH 07/30] mtd: Get rid of pointless cast of kzalloc() return value in AT26xxx driver Jesper Juhl
2007-08-23 23:51   ` [PATCH 08/30] mtd: Avoid a pointless kmalloc() return value cast in TQM8xxL mapping handling code Jesper Juhl
2007-08-23 23:52   ` [PATCH 09/30] mtd: Don't cast kmalloc() return value in drivers/mtd/maps/pmcmsp-flash.c Jesper Juhl
2007-08-24 10:41     ` Denys Vlasenko
2007-08-24 10:43       ` Robert P. J. Day
2007-08-25 22:27         ` Jesper Juhl
2007-08-25 23:59           ` Robert P. J. Day
2007-08-26  0:28             ` Jesper Juhl
2007-08-26  0:23               ` Robert P. J. Day
2007-08-26  0:36                 ` Jesper Juhl
2007-08-26  1:52                   ` Kyle Moffett
2007-08-26 14:28                 ` Denys Vlasenko
2007-08-26 14:37                   ` Jan Engelhardt
2007-08-26 22:10                     ` Jesper Juhl
2007-08-24 10:48       ` Jesper Juhl
2007-08-23 23:54   ` [PATCH 10/30] irda: Do not do pointless kmalloc return value cast in KingSun driver Jesper Juhl
2007-08-25  6:23     ` David Miller
2007-08-24  0:03   ` [PATCH 14/30] net: Kill some unneeded allocation return value casts in libertas Jesper Juhl
2007-08-24 15:50     ` Dan Williams
2007-08-24  0:06   ` [PATCH 16/30] net: Avoid pointless allocation casts in BSD compression module Jesper Juhl
2007-08-25  6:25     ` David Miller
2007-08-24  0:09   ` [PATCH 17/30] isdn: Get rid of some pointless allocation casts in common and bsd comp Jesper Juhl
2007-08-24  9:23     ` Karsten Keil
2007-08-25  6:25     ` David Miller
2007-08-24  0:11   ` [PATCH 18/30] isdn: eicon - get rid of a pointless vmalloc() return value cast Jesper Juhl
2007-08-24  6:47     ` Armin Schindler
2007-08-24  0:12   ` [PATCH 19/30] scsi: Remove explicit casts of [kv]alloc return values in osst driver Jesper Juhl
2007-08-24  7:04     ` Rolf Eike Beer
2007-08-24  8:46       ` Jesper Juhl
2007-08-24  0:16   ` [PATCH 20/30] scsi: In the Advansys driver, do not cast allocation function return values Jesper Juhl
2007-08-24  2:03     ` Matthew Wilcox
2007-08-24  9:00       ` Jesper Juhl
2007-08-24  0:18   ` [PATCH 21/30] oss: Remove unneeded vmalloc() return value casts in OSS Jesper Juhl
2007-08-24  0:20   ` [PATCH 22/30] ivtv: kzalloc() returns void pointer, no need to cast Jesper Juhl
2007-08-24  8:32     ` Hans Verkuil
2007-08-24  8:44       ` Jesper Juhl
2007-08-24  0:22   ` [PATCH 23/30] video: Remove pointless kmalloc() return value cast in Zoran PCI controller driver Jesper Juhl
2007-08-24  0:25   ` [PATCH 24/30] dvb: remove some unneeded vmalloc() return value casts from av7110 Jesper Juhl
2007-08-24  0:28   ` [PATCH 25/30] tty: dont needlessly cast kmalloc() return value Jesper Juhl
2007-08-24  0:30   ` [PATCH 26/30] md: vmalloc() returns void pointer so we don't need to cast it in dm-ioctl Jesper Juhl
2007-08-24  0:35   ` [PATCH 27/30] usb: avoid redundant cast of kmalloc() return value in OTi-6858 driver Jesper Juhl
2007-08-25  4:43     ` patch usb-avoid-redundant-cast-of-kmalloc-return-value-in-oti-6858-driver.patch added to gregkh-2.6 tree gregkh
2007-08-24  0:36   ` [PATCH 28/30] jfs: avoid pointless casts of kmalloc() return val Jesper Juhl
2007-08-24  4:19     ` Dave Kleikamp
2007-08-24  8:48       ` Jesper Juhl
2007-08-24  0:39   ` [PATCH 29/30] mm: No need to cast vmalloc() return value in zone_wait_table_init() Jesper Juhl
2007-08-24  0:41   ` [PATCH 30/30] emu10k1: There's no need to cast vmalloc() return value in snd_emu10k1_create() Jesper Juhl
2007-08-28 13:22     ` Takashi Iwai
     [not found]   ` <c4e095af9df5ab47e7d1c8e4f3d256d74576a0c9.1187912217.git.jesper.juhl@gmail.com>
2007-08-24  7:25     ` [PATCH 12/30] net: No point in casting kmalloc return values in Gianfar Ethernet Driver Kumar Gala
     [not found]   ` <d551047daed1cb4d9de1eff956268a468c9837f6.1187912217.git.jesper.juhl@gmail.com>
2007-08-30 17:54     ` [PATCH 13/30] net: Don't do pointless kmalloc return value casts in zd1211 driver Daniel Drake
2007-08-30 20:20       ` Jesper Juhl
2007-08-30 22:19         ` Joe Perches
2007-08-30 22:30           ` [PATCH] Don't needlessly initialize variable to NULL in zd_chip (was: Re: [PATCH 13/30] net: Don't do pointless kmalloc return value casts in zd1211 driver) Jesper Juhl
2007-08-30 22:42             ` Randy Dunlap
2007-08-30 23:04               ` Jesper Juhl
2007-08-30 23:47         ` [PATCH 13/30] net: Don't do pointless kmalloc return value casts in zd1211 driver Daniel Drake
2007-08-31  9:30         ` Herbert Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox