qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] target-tricore: check return value before using


From: Bastian Koppelmann
Subject: Re: [Qemu-devel] [PATCH] target-tricore: check return value before using it
Date: Thu, 30 Oct 2014 08:14:29 +0000
User-agent: Mozilla/5.0 (X11; Linux i686; rv:31.0) Gecko/20100101 Thunderbird/31.2.0

Geez, thanks. I wonder how I missed that.

Reviewed-by: Bastian Koppelmann <address@hidden>

On 10/30/2014 02:03 AM, zhanghailiang wrote:
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 <address@hidden>
---
  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);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]