From: zhanghailiang <zhang.zhanghailiang@huawei.com>
To: qemu-trivial@nongnu.org
Cc: kbastian@mail.uni-paderborn.de,
zhanghailiang <zhang.zhanghailiang@huawei.com>,
qemu-devel@nongnu.org, peter.huangpeng@huawei.com
Subject: [Qemu-devel] [PATCH] target-tricore: check return value before using it
Date: Thu, 30 Oct 2014 10:03:28 +0800 [thread overview]
Message-ID: <1414634608-31292-1-git-send-email-zhang.zhanghailiang@huawei.com> (raw)
We reference the return value of cpu before checking whether it is NULL,
The checking code is after that which violates code style.
It makes no difference if the cpu is NULL, qemu process will terminate.
But one will be 'Segmentation fault' and the other will report a error
which is what we want.
Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
---
hw/tricore/tricore_testboard.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/tricore/tricore_testboard.c b/hw/tricore/tricore_testboard.c
index eeb4922..a059a20 100644
--- a/hw/tricore/tricore_testboard.c
+++ b/hw/tricore/tricore_testboard.c
@@ -71,11 +71,11 @@ static void tricore_testboard_init(MachineState *machine, int board_id)
machine->cpu_model = "tc1796";
}
cpu = cpu_tricore_init(machine->cpu_model);
- env = &cpu->env;
if (!cpu) {
error_report("Unable to find CPU definition");
exit(1);
}
+ env = &cpu->env;
memory_region_init_ram(ext_cram, NULL, "powerlink_ext_c.ram", 2*1024*1024, &error_abort);
vmstate_register_ram_global(ext_cram);
memory_region_init_ram(ext_dram, NULL, "powerlink_ext_d.ram", 4*1024*1024, &error_abort);
--
1.7.12.4
next reply other threads:[~2014-10-30 2:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-30 2:03 zhanghailiang [this message]
2014-10-30 6:59 ` [Qemu-devel] [Qemu-trivial] [PATCH] target-tricore: check return value before using it Michael Tokarev
2014-10-30 8:14 ` [Qemu-devel] " Bastian Koppelmann
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=1414634608-31292-1-git-send-email-zhang.zhanghailiang@huawei.com \
--to=zhang.zhanghailiang@huawei.com \
--cc=kbastian@mail.uni-paderborn.de \
--cc=peter.huangpeng@huawei.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-trivial@nongnu.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;
as well as URLs for NNTP newsgroup(s).