Skip to content

Commit

Permalink
arch/avr32: Eliminate NULL test and memset after alloc_bootmem
Browse files Browse the repository at this point in the history
As noted by Akinobu Mita in patch b1fceac,
alloc_bootmem and related functions never return NULL and always return a
zeroed region of memory.  Thus a NULL test or memset after calls to these
functions is unnecessary.

This was fixed using the following semantic patch.
(http://www.emn.fr/x-info/coccinelle/)

// <smpl>
@@
expression E;
statement S;
@@

E = \(alloc_bootmem\|alloc_bootmem_low\|alloc_bootmem_pages\|alloc_bootmem_low_pages\|alloc_bootmem_node\|alloc_bootmem_low_pages_node\|alloc_bootmem_pages_node\)(...)
... when != E
(
- BUG_ON (E == NULL);
|
- if (E == NULL) S
)

@@
expression E,E1;
@@

E = \(alloc_bootmem\|alloc_bootmem_low\|alloc_bootmem_pages\|alloc_bootmem_low_pages\|alloc_bootmem_node\|alloc_bootmem_low_pages_node\|alloc_bootmem_pages_node\)(...)
... when != E
- memset(E,0,E1);
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
  • Loading branch information
Julia Lawall authored and Haavard Skinnemoen committed Jan 6, 2009
1 parent adde42b commit e245001
Showing 1 changed file with 0 additions and 1 deletion.
1 change: 0 additions & 1 deletion arch/avr32/mm/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ void __init paging_init(void)

mem_map = NODE_DATA(0)->node_mem_map;

memset(zero_page, 0, PAGE_SIZE);
empty_zero_page = virt_to_page(zero_page);
flush_dcache_page(empty_zero_page);
}
Expand Down

0 comments on commit e245001

Please sign in to comment.