From: Zhang Yanfei <zhangyanfei@xxxxxxxxxxxxxx> If size is zero, it is unnecessary to do the malloc operation. So checking size first is better than doing malloc first. Signed-off-by: Zhang Yanfei <zhangyanfei at cn.fujitsu.com> --- kexec/kexec.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/kexec/kexec.c b/kexec/kexec.c index 3ef6f0d..494c5b3 100644 --- a/kexec/kexec.c +++ b/kexec/kexec.c @@ -76,9 +76,9 @@ static char *xstrdup(const char *str) void *xmalloc(size_t size) { void *buf; - buf = malloc(size); if (!size) return NULL; + buf = malloc(size); if (!buf) { die("Cannot malloc %ld bytes: %s\n", size + 0UL, strerror(errno)); -- 1.7.1