From: Himangi Saraogi <himangi774@gmail.com>
To: Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
x86@kernel.org, linux-kernel@vger.kernel.org
Cc: Julia Lawall <julia.lawall@lip6.fr>
Subject: [PATCH] x86, olpc: Eliminate BUG_ON and memset after alloc_bootmem
Date: Sat, 19 Jul 2014 17:06:37 +0530 [thread overview]
Message-ID: <20140719113637.GA23621@himangi-Dell> (raw)
alloc_bootmem and related functions never return NULL and always return
a zeroed region of memory. Thus a BUG_ON the NULL test or memset after
calls to these functions is unnecessary.
The following Coccinelle semantic patch was used for making the change:
@@
expression E;
statement S;
@@
E = \(alloc_bootmem\|alloc_bootmem_low\|alloc_bootmem_pages\|alloc_bootmem_low_pages\)(...)
... when != E
- BUG_ON (E == NULL);
@@
expression E,E1;
@@
E = \(alloc_bootmem\|alloc_bootmem_low\|alloc_bootmem_pages\|alloc_bootmem_low_pages\)(...)
... when != E
- memset(E,0,E1);
Signed-off-by: Himangi Saraogi <himangi774@gmail.com>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
---
arch/x86/platform/olpc/olpc_dt.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
index d6ee929..280645d 100644
--- a/arch/x86/platform/olpc/olpc_dt.c
+++ b/arch/x86/platform/olpc/olpc_dt.c
@@ -142,9 +142,7 @@ void * __init prom_early_alloc(unsigned long size)
* wasted bootmem) and hand off chunks of it to callers.
*/
res = alloc_bootmem(chunk_size);
- BUG_ON(!res);
prom_early_allocated += chunk_size;
- memset(res, 0, chunk_size);
free_mem = chunk_size;
mem = res;
}
--
1.9.1
next reply other threads:[~2014-07-19 11:36 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-19 11:36 Himangi Saraogi [this message]
2014-07-21 22:56 ` [PATCH] x86, olpc: Eliminate BUG_ON and memset after alloc_bootmem David Rientjes
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140719113637.GA23621@himangi-Dell \
--to=himangi774@gmail.com \
--cc=hpa@zytor.com \
--cc=julia.lawall@lip6.fr \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox