Skip to contentSkip to conversation

remove explicit memset to memory allocated with k[zc]alloc

PATCH In review Christophe Jaillet 2 participants 2 messages Dec 19, 2007 Kernel janitors

lore
Share & tools
lore
#0 lore raw

PATCH 3/3 remove explicit memset to memory allocated with k[zc]alloc

1) Remove an explicit memset(.., 0, ...) to a varialable allocated with kzalloc.

2) Allocate 'src' with kmalloc instead of kzalloc as all elements of the 'src' buffer are initialized in a 'for(...)' loop.

3) remove useless 'sizeof(u8)', which always returns 1, when computing the size of the memory to be allocated.

---

--- linux-2.6.24-rc5/drivers/dma/iop-adma.c 2007-12-16 11:15:52.000000000 +0100
+++ linux-2.6.24-rc5/drivers/dma/iop-adma.c.cj 2007-12-19 20:44:58.000000000 +0100
@@ -858,10 +858,10 @@ static int __devinit iop_adma_memcpy_sel

  dev_dbg(device->common.dev, "%s\n", __FUNCTION__);

- src = kzalloc(sizeof(u8) * IOP_ADMA_TEST_SIZE, GFP_KERNEL);
+ src = kmalloc(IOP_ADMA_TEST_SIZE, GFP_KERNEL);
if (!src)
return -ENOMEM;
- dest = kzalloc(sizeof(u8) * IOP_ADMA_TEST_SIZE, GFP_KERNEL);
+ dest = kzalloc(IOP_ADMA_TEST_SIZE, GFP_KERNEL);
if (!dest) {
kfree(src);
return -ENOMEM;
@@ -871,8 +871,6 @@ static int __devinit iop_adma_memcpy_sel
for (i = 0; i < IOP_ADMA_TEST_SIZE; i++)
((u8 *) src)[i] = (u8)i;

- memset(dest, 0, IOP_ADMA_TEST_SIZE);
-
/* Start copy, using first DMA channel */ dma_chan = container_of(device->common.channels.next,
struct dma_chan,

#1 lore raw

Hi!

Quoted 2 lines

3) remove useless 'sizeof(u8)', which always returns 1, when computing the size of the memory to be allocated.

Thanks for including my proposal.

However, it seems as if your mailclient wraps lines and converts tabs into spaces. The patch doesn't apply. Please have a look at Documentation/email-clients.txt and check the other patches aswell. A good way to check if everything is right is to send the patchset to yourself and then try to apply it. If it works, send it to the mailing list.

Quoted 2 lines

--- linux-2.6.24-rc5/drivers/dma/iop-adma.c 2007-12-16 11:15:52.000000000 +0100

This line is wrapped...

Quoted 2 lines

+++ linux-2.6.24-rc5/drivers/dma/iop-adma.c.cj 2007-12-19 20:44:58.000000000 +0100

dito.

Review static int __devinit iop_adma_memcpy_sel · line 861

Quoted 6 lines
(quoted diff) +1 -1
@@ -858,10 +858,10 @@ static int __devinit iop_adma_memcpy_sel
 
  dev_dbg(device->common.dev, "%s\n", __FUNCTION__);
 
- src = kzalloc(sizeof(u8) * IOP_ADMA_TEST_SIZE, GFP_KERNEL);
+ src = kmalloc(IOP_ADMA_TEST_SIZE, GFP_KERNEL);

The tabs were replaced by a single tab (the same goes for the rest of the patch).

Quoted 8 lines
(quoted diff) +1 -1
  if (!src)
   return -ENOMEM;
- dest = kzalloc(sizeof(u8) * IOP_ADMA_TEST_SIZE, GFP_KERNEL);
+ dest = kzalloc(IOP_ADMA_TEST_SIZE, GFP_KERNEL);
  if (!dest) {
   kfree(src);
   return -ENOMEM;

Review static int __devinit iop_adma_memcpy_sel · line 876

Quoted 8 lines
(quoted diff) +0 -2
@@ -871,8 +871,6 @@ static int __devinit iop_adma_memcpy_sel
  for (i = 0; i < IOP_ADMA_TEST_SIZE; i++)
   ((u8 *) src)[i] = (u8)i;
 
- memset(dest, 0, IOP_ADMA_TEST_SIZE);
-
  /* Start copy, using first DMA channel */
  dma_chan = container_of(device->common.channels.next,
     struct dma_chan,

CCing the Maintainer would also increase the chance for an merge.

Regards,
Andi