Skip to content

Commit

Permalink
arch/m68k/mm/sun3mmu.c: Eliminate NULL test and memset after alloc_bo…
Browse files Browse the repository at this point in the history
…otmem

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\)(...)
.. 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\)(...)
.. when != E
- memset(E,0,E1);
// </smpl>

Signed-off-by: Julia Lawall <[email protected]>
Signed-off-by: Geert Uytterhoeven <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Julia Lawall authored and torvalds committed Jul 21, 2008
1 parent 7b6b948 commit 93026e2
Showing 1 changed file with 0 additions and 1 deletion.
1 change: 0 additions & 1 deletion arch/m68k/mm/sun3mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ void __init paging_init(void)
wp_works_ok = 0;
#endif
empty_zero_page = alloc_bootmem_pages(PAGE_SIZE);
memset(empty_zero_page, 0, PAGE_SIZE);

address = PAGE_OFFSET;
pg_dir = swapper_pg_dir;
Expand Down

0 comments on commit 93026e2

Please sign in to comment.