Skip to contentSkip to conversation

drivers/net: Remove unnecessary [kv][mcz]alloc casts

PATCH In review Joe Perches 3 participants 13 messages Nov 28, 2010 – Nov 29, 2010

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover drivers/net: Remove unnecessary [kv][mcz]alloc casts

These are the last remaining alloc casts in drivers/net...

Joe Perches (4):
netxen: remove unnecessary [kv][mcz]alloc casts
qlcnic: remove unnecessary [kv][mcz]alloc casts
vxge: remove unnecessary [kv][mcz]alloc casts
zd1211rw: remove unnecessary [kv][mcz]alloc casts

 drivers/net/netxen/netxen_nic_init.c    |    3 +--
 drivers/net/qlcnic/qlcnic_init.c        |    3 +--
 drivers/net/vxge/vxge-config.c          |   24 +++++++++---------------
 drivers/net/vxge/vxge-main.c            |    4 +---
 drivers/net/wireless/zd1211rw/zd_chip.c |    3 +--
 5 files changed, 13 insertions(+), 24 deletions(-)
Signature · 1 line
1.7.3.2.245.g03276.dirty
#1 lore raw

PATCH 1/4 netxen: remove unnecessary [kv][mcz]alloc casts

---
 drivers/net/netxen/netxen_nic_init.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
drivers/net/netxen/netxen_nic_init.c +1 -2
index f946de2..731077d 100644
@@ -278,8 +278,7 @@ int netxen_alloc_sw_resources(struct netxen_adapter *adapter)
 			break;
 
 		}
-		rds_ring->rx_buf_arr = (struct netxen_rx_buffer *)
-			vzalloc(RCV_BUFF_RINGSIZE(rds_ring));
+		rds_ring->rx_buf_arr = vzalloc(RCV_BUFF_RINGSIZE(rds_ring));
 		if (rds_ring->rx_buf_arr == NULL) {
 			printk(KERN_ERR "%s: Failed to allocate "
 				"rx buffer ring %d\n",
Signature · 1 line
1.7.3.2.245.g03276.dirty
#2 lore raw

PATCH 2/4 qlcnic: remove unnecessary [kv][mcz]alloc casts

In reply to Joe Perches
---
 drivers/net/qlcnic/qlcnic_init.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
drivers/net/qlcnic/qlcnic_init.c +1 -2
index 3f97018..c5ea2f4 100644
@@ -274,8 +274,7 @@ int qlcnic_alloc_sw_resources(struct qlcnic_adapter *adapter)
 				rds_ring->dma_size + NET_IP_ALIGN;
 			break;
 		}
-		rds_ring->rx_buf_arr = (struct qlcnic_rx_buffer *)
-			vzalloc(RCV_BUFF_RINGSIZE(rds_ring));
+		rds_ring->rx_buf_arr = vzalloc(RCV_BUFF_RINGSIZE(rds_ring));
 		if (rds_ring->rx_buf_arr == NULL) {
 			dev_err(&netdev->dev, "Failed to allocate "
 				"rx buffer ring %d\n", ring);
Signature · 1 line
1.7.3.2.245.g03276.dirty
#3 lore raw

PATCH 3/4 vxge: remove unnecessary [kv][mcz]alloc casts

In reply to Joe Perches
---
 drivers/net/vxge/vxge-config.c |   24 +++++++++---------------
 drivers/net/vxge/vxge-main.c   |    4 +---
 2 files changed, 10 insertions(+), 18 deletions(-)
drivers/net/vxge/vxge-config.c +9 -15
index 44d3ddd..a0241fe 100644
@@ -1219,8 +1219,7 @@ vxge_hw_device_initialize(
 	if (status != VXGE_HW_OK)
 		goto exit;
 
-	hldev = (struct __vxge_hw_device *)
-			vzalloc(sizeof(struct __vxge_hw_device));
+	hldev = vzalloc(sizeof(struct __vxge_hw_device));
 	if (hldev == NULL) {
 		status = VXGE_HW_ERR_OUT_OF_MEMORY;
 		goto exit;
@@ -2140,8 +2139,7 @@ __vxge_hw_mempool_create(
 		goto exit;
 	}
 
-	mempool = (struct vxge_hw_mempool *)
-			vzalloc(sizeof(struct vxge_hw_mempool));
+	mempool = vzalloc(sizeof(struct vxge_hw_mempool));
 	if (mempool == NULL) {
 		status = VXGE_HW_ERR_OUT_OF_MEMORY;
 		goto exit;
@@ -2165,7 +2163,7 @@ __vxge_hw_mempool_create(
 
 	/* allocate array of memblocks */
 	mempool->memblocks_arr =
-		(void **) vzalloc(sizeof(void *) * mempool->memblocks_max);
+		vzalloc(sizeof(void *) * mempool->memblocks_max);
 	if (mempool->memblocks_arr == NULL) {
 		__vxge_hw_mempool_destroy(mempool);
 		status = VXGE_HW_ERR_OUT_OF_MEMORY;
@@ -2175,7 +2173,7 @@ __vxge_hw_mempool_create(
 
 	/* allocate array of private parts of items per memblocks */
 	mempool->memblocks_priv_arr =
-		(void **) vzalloc(sizeof(void *) * mempool->memblocks_max);
+		vzalloc(sizeof(void *) * mempool->memblocks_max);
 	if (mempool->memblocks_priv_arr == NULL) {
 		__vxge_hw_mempool_destroy(mempool);
 		status = VXGE_HW_ERR_OUT_OF_MEMORY;
@@ -2184,7 +2182,7 @@ __vxge_hw_mempool_create(
 	}
 
 	/* allocate array of memblocks DMA objects */
-	mempool->memblocks_dma_arr = (struct vxge_hw_mempool_dma *)
+	mempool->memblocks_dma_arr =
 		vzalloc(sizeof(struct vxge_hw_mempool_dma) *
 			mempool->memblocks_max);
 
@@ -2196,8 +2194,7 @@ __vxge_hw_mempool_create(
 	}
 
 	/* allocate hash array of items */
-	mempool->items_arr =
-		(void **) vzalloc(sizeof(void *) * mempool->items_max);
+	mempool->items_arr = vzalloc(sizeof(void *) * mempool->items_max);
 	if (mempool->items_arr == NULL) {
 		__vxge_hw_mempool_destroy(mempool);
 		status = VXGE_HW_ERR_OUT_OF_MEMORY;
@@ -4258,8 +4255,7 @@ vxge_hw_vpath_open(struct __vxge_hw_device *hldev,
 	if (status != VXGE_HW_OK)
 		goto vpath_open_exit1;
 
-	vp = (struct __vxge_hw_vpath_handle *)
-		vzalloc(sizeof(struct __vxge_hw_vpath_handle));
+	vp = vzalloc(sizeof(struct __vxge_hw_vpath_handle));
 	if (vp == NULL) {
 		status = VXGE_HW_ERR_OUT_OF_MEMORY;
 		goto vpath_open_exit2;
@@ -5065,8 +5061,7 @@ static void vxge_hw_blockpool_block_add(struct __vxge_hw_device *devh,
 				item);
 
 	if (entry == NULL)
-		entry = (struct __vxge_hw_blockpool_entry *)
-			vmalloc(sizeof(struct __vxge_hw_blockpool_entry));
+		entry = vmalloc(sizeof(struct __vxge_hw_blockpool_entry));
 	else
 		list_del(&entry->item);
 
@@ -5182,8 +5177,7 @@ __vxge_hw_blockpool_free(struct __vxge_hw_device *devh,
 					item);
 
 		if (entry == NULL)
-			entry = (struct __vxge_hw_blockpool_entry *)
-				vmalloc(sizeof(
+			entry = vmalloc(sizeof(
 					struct __vxge_hw_blockpool_entry));
 		else
 			list_del(&entry->item);
drivers/net/vxge/vxge-main.c +1 -3
index 5cba4a6..a21dae1 100644
@@ -4602,9 +4602,7 @@ vxge_probe(struct pci_dev *pdev, const struct pci_device_id *pre)
 
 	/* Copy the station mac address to the list */
 	for (i = 0; i < vdev->no_of_vpath; i++) {
-		entry =	(struct vxge_mac_addrs *)
-				kzalloc(sizeof(struct vxge_mac_addrs),
-					GFP_KERNEL);
+		entry =	kzalloc(sizeof(struct vxge_mac_addrs), GFP_KERNEL);
 		if (NULL == entry) {
 			vxge_debug_init(VXGE_ERR,
 				"%s: mac_addr_list : memory allocation failed",
Signature · 1 line
1.7.3.2.245.g03276.dirty
#4 lore raw

PATCH 4/4 zd1211rw: remove unnecessary [kv][mcz]alloc casts

In reply to Joe Perches
---
 drivers/net/wireless/zd1211rw/zd_chip.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
drivers/net/wireless/zd1211rw/zd_chip.c +1 -2
index 87a95bc..dfcebed 100644
@@ -117,8 +117,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");
Signature · 6 lines
1.7.3.2.245.g03276.dirty

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
maintainer
#5 lore raw

Re: [PATCH 4/4] zd1211rw: remove unnecessary [kv][mcz]alloc casts

Quoted 10 lines · Joe Perches
---
 drivers/net/wireless/zd1211rw/zd_chip.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
drivers/net/wireless/zd1211rw/zd_chip.c +0 -0
index 87a95bc..dfcebed 100644

drivers/net/wireless/zd1211rw/zd_chip.c int zd_ioread32v_locked(struct zd_chip *chip, u32 *values, const zd_addr_t *addr · line 120

Quoted 6 lines
drivers/net/wireless/zd1211rw/zd_chip.c +1 -2
@@ -117,8 +117,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);

I believe this is on purpose for sparse.

johannes

#6 lore raw

Re: [PATCH 4/4] zd1211rw: remove unnecessary [kv][mcz]alloc casts

Quoted 10 lines · Johannes Berg

drivers/net/wireless/zd1211rw/zd_chip.c int zd_ioread32v_locked(struct zd_chip *chip, u32 *values, const zd_addr_t *addr · line 120

Quoted 8 lines · Joe Perches
drivers/net/wireless/zd1211rw/zd_chip.c +1 -2
@@ -117,8 +117,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);

I believe this is on purpose for sparse.

Perhaps in a previous version, but not now.

$ make C=1 drivers/net/wireless/zd1211rw/zd_chip.o
  CHK     include/linux/version.h
  CHK     include/generated/utsrelease.h
  CALL    scripts/checksyscalls.sh
  CHECK   drivers/net/wireless/zd1211rw/zd_chip.c
include/trace/events/kmem.h:45:1: error: Expected ( after asm
include/trace/events/kmem.h:45:1: error: got goto
include/trace/events/kmem.h:53:1: error: Expected ( after asm
include/trace/events/kmem.h:53:1: error: got goto
include/trace/events/kmem.h:99:1: error: Expected ( after asm
include/trace/events/kmem.h:99:1: error: got goto
include/trace/events/kmem.h:108:1: error: Expected ( after asm
include/trace/events/kmem.h:108:1: error: got goto
include/trace/events/kmem.h:136:1: error: Expected ( after asm
include/trace/events/kmem.h:136:1: error: got goto
include/trace/events/kmem.h:143:1: error: Expected ( after asm
include/trace/events/kmem.h:143:1: error: got goto
include/trace/events/kmem.h:150:1: error: Expected ( after asm
include/trace/events/kmem.h:150:1: error: got goto
include/trace/events/kmem.h:172:1: error: Expected ( after asm
include/trace/events/kmem.h:172:1: error: got goto
include/trace/events/kmem.h:194:1: error: Expected ( after asm
include/trace/events/kmem.h:194:1: error: got goto
include/trace/events/kmem.h:249:1: error: Expected ( after asm
include/trace/events/kmem.h:249:1: error: got goto
include/trace/events/kmem.h:256:1: error: Expected ( after asm
include/trace/events/kmem.h:256:1: error: got goto
include/trace/events/kmem.h:267:1: error: Expected ( after asm
include/trace/events/kmem.h:267:1: error: got goto
include/trace/events/module.h:18:1: error: Expected ( after asm
include/trace/events/module.h:18:1: error: got goto
include/trace/events/module.h:37:1: error: Expected ( after asm
include/trace/events/module.h:37:1: error: got goto
include/trace/events/module.h:79:1: error: Expected ( after asm
include/trace/events/module.h:79:1: error: got goto
include/trace/events/module.h:86:1: error: Expected ( after asm
include/trace/events/module.h:86:1: error: got goto
include/trace/events/module.h:94:1: error: Expected ( after asm
include/trace/events/module.h:94:1: error: got goto
/home/joe/linux/net-next-2.6-2/arch/x86/include/asm/uaccess_32.h:197:9: error: attribute 'error': unknown attribute
include/trace/events/irq.h:37:1: error: Expected ( after asm
include/trace/events/irq.h:37:1: error: got goto
include/trace/events/irq.h:67:1: error: Expected ( after asm
include/trace/events/irq.h:67:1: error: got goto
include/trace/events/irq.h:112:1: error: Expected ( after asm
include/trace/events/irq.h:112:1: error: got goto
include/trace/events/irq.h:126:1: error: Expected ( after asm
include/trace/events/irq.h:126:1: error: got goto
include/trace/events/irq.h:140:1: error: Expected ( after asm
include/trace/events/irq.h:140:1: error: got goto
include/trace/events/kmem.h:45:1: error: need constant string for inline asm
include/trace/events/kmem.h:45:1: error: incompatible types in comparison expression (different address spaces)
include/trace/events/kmem.h:45:1: error: need constant string for inline asm
include/trace/events/kmem.h:45:1: error: incompatible types in comparison expression (different address spaces)
include/trace/events/kmem.h:45:1: error: need constant string for inline asm
include/trace/events/kmem.h:45:1: error: incompatible types in comparison expression (different address spaces)
include/trace/events/kmem.h:45:1: error: need constant string for inline asm
include/trace/events/kmem.h:45:1: error: incompatible types in comparison expression (different address spaces)
  CC      drivers/net/wireless/zd1211rw/zd_chip.o
$ 
maintainer
#7 lore raw

Re: [PATCH 4/4] zd1211rw: remove unnecessary [kv][mcz]alloc casts

Quoted 14 lines · Joe Perches
Quoted 10 lines · Johannes Berg

drivers/net/wireless/zd1211rw/zd_chip.c int zd_ioread32v_locked(struct zd_chip *chip, u32 *values, const zd_addr_t *addr · line 120

Quoted 8 lines · Joe Perches
drivers/net/wireless/zd1211rw/zd_chip.c +1 -2
@@ -117,8 +117,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);

I believe this is on purpose for sparse.

Perhaps in a previous version, but not now.

Quoted 7 lines
$ make C=1 drivers/net/wireless/zd1211rw/zd_chip.o
  CHK     include/linux/version.h
  CHK     include/generated/utsrelease.h
  CALL    scripts/checksyscalls.sh
  CHECK   drivers/net/wireless/zd1211rw/zd_chip.c
include/trace/events/kmem.h:45:1: error: Expected ( after asm
include/trace/events/kmem.h:45:1: error: got goto

How do you know? I thought sparse was pretty much not reliable after the first error it prints.

johannes

#8 lore raw

Re: [PATCH 4/4] zd1211rw: remove unnecessary [kv][mcz]alloc casts

Quoted 11 lines · Johannes Berg
Quoted 10 lines · Joe Perches
Quoted 9 lines · Johannes Berg

drivers/net/wireless/zd1211rw/zd_chip.c int zd_ioread32v_locked(struct zd_chip *chip, u32 *values, const zd_addr_t *addr · line 119

Quoted 7 lines · Joe Perches
drivers/net/wireless/zd1211rw/zd_chip.c +1 -2
@@ -117,8 +117,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);

I believe this is on purpose for sparse.

Quoted 3 lines
Quoted 1 line

Perhaps in a previous version, but not now.

How do you know? I thought sparse was pretty much not reliable after the first error it prints.

Good memory you have Johannes...

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

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#9 lore raw

Re: [PATCH 4/4] zd1211rw: remove unnecessary [kv][mcz]alloc casts

Quoted 12 lines · Joe Perches
Quoted 11 lines · Johannes Berg
Quoted 10 lines · Joe Perches
Quoted 9 lines · Johannes Berg

drivers/net/wireless/zd1211rw/zd_chip.c int zd_ioread32v_locked(struct zd_chip *chip, u32 *values, const zd_addr_t *addr · line 119

Quoted 7 lines · Joe Perches
drivers/net/wireless/zd1211rw/zd_chip.c +1 -2
@@ -117,8 +117,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);

I believe this is on purpose for sparse.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Perhaps in a previous version, but not now.

How do you know? I thought sparse was pretty much not reliable after the first error it prints.

Good memory you have Johannes...

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

I, err, not really, all this isn't making a whole lot of sense to me right now :-)
The only thing I remembered was that there was something weird with zd_addr_t ...

Did sparse become more reliable in face of errors?

johannes

#10 lore raw

Re: [PATCH 4/4] zd1211rw: remove unnecessary [kv][mcz]alloc casts

Quoted 7 lines · Johannes Berg
Quoted 2 lines · Joe Perches

Good memory you have Johannes...
http://marc.info/?l=linux-netdev&m=117113743902549&w=3

I, err, not really, all this isn't making a whole lot of sense to me right now :-)
The only thing I remembered was that there was something weird with zd_addr_t ...

Yes. It's marked __nocast.

Quoted 1 line

Did sparse become more reliable in face of errors?

Apparently not.

If the kmalloc cast in zd_chip is removed:

$ make C=1 drivers/net/wireless/zd1211rw/zd_chip.o
  CHK     include/linux/version.h
  CHK     include/generated/utsrelease.h
  CALL    scripts/checksyscalls.sh
  CHECK   drivers/net/wireless/zd1211rw/zd_chip.c
arch/x86/include/asm/uaccess_32.h:197:9: error: attribute 'error': unknown attribute
  CC      drivers/net/wireless/zd1211rw/zd_chip.o
$

If the __compiletime_<foo> uses in uaccess_32.h are removed, and the kmalloc cast in zd_chip is also removed:

$ make C=1 drivers/net/wireless/zd1211rw/zd_chip.o
  CHK     include/linux/version.h
  CHK     include/generated/utsrelease.h
  CC      arch/x86/kernel/asm-offsets.s
  GEN     include/generated/asm-offsets.h
  CALL    scripts/checksyscalls.sh
  CHECK   drivers/net/wireless/zd1211rw/zd_chip.c
drivers/net/wireless/zd1211rw/zd_chip.c:121:22: warning: implicit cast to nocast type
  CC      drivers/net/wireless/zd1211rw/zd_chip.o
$

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#11 lore raw

PATCH v2 4/4 zd1211rw: document need for kmalloc cast

In reply to Johannes Berg

---

V2: Just document the need for the cast

drivers/net/wireless/zd1211rw/zd_chip.c +1 -0
index 87a95bc..dd0bb0c 100644
@@ -117,6 +117,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;
+	/* zd_addr_t is __nocast, so the kmalloc needs an explicit cast */
 	a16 = (zd_addr_t *) kmalloc(count16 * (sizeof(zd_addr_t) + sizeof(u16)),
 		                   GFP_KERNEL);
 	if (!a16) {
maintainer
#12 lore raw
In reply to Joe Perches

From: Joe Perches <[email protected]>
Date: Sun, 28 Nov 2010 01:05:42 -0800

Quoted 7 lines

These are the last remaining alloc casts in drivers/net...

Joe Perches (4):
netxen: remove unnecessary [kv][mcz]alloc casts
qlcnic: remove unnecessary [kv][mcz]alloc casts
vxge: remove unnecessary [kv][mcz]alloc casts
zd1211rw: remove unnecessary [kv][mcz]alloc casts

All applied, using v2 of patch #4.

Thanks.