]> Git Repo - qemu.git/commitdiff
target-tricore: check return value before using it
authorzhanghailiang <[email protected]>
Thu, 30 Oct 2014 02:03:28 +0000 (10:03 +0800)
committerMichael Tokarev <[email protected]>
Sun, 2 Nov 2014 07:04:34 +0000 (10:04 +0300)
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 <[email protected]>
Reviewed-by: Bastian Koppelmann <[email protected]>
Signed-off-by: Michael Tokarev <[email protected]>
hw/tricore/tricore_testboard.c

index eeb4922c4c0f08c35e8701722bdea4574acede26..a059a20a30f634701eb67c86e2813a50608f906f 100644 (file)
@@ -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);
This page took 0.025558 seconds and 4 git commands to generate.