From: Jia Liu Date: Wed, 21 Aug 2013 00:54:29 +0000 (+0800) Subject: hw/openrisc: Avoid using uninitialised variable 'entry' X-Git-Tag: TizenStudio_2.0_p2.3.2~208^2~1397^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b6d9766ddf5453e79e0c66c9348728ba44ba115f;p=sdk%2Femulator%2Fqemu.git hw/openrisc: Avoid using uninitialised variable 'entry' clang warns that cpu_openrisc_load_kernel() can use 'entry' uninitialized: hw/openrisc/openrisc_sim.c:69:9: error: variable 'entry' is used uninitialized whenever '&&' condition is false [-Werror,-Wsometimes-uninitialized] if (kernel_filename && !qtest_enabled()) { ^~~~~~~~~~~~~~~ hw/openrisc/openrisc_sim.c:91:19: note: uninitialized use occurs here cpu->env.pc = entry; ^~~~~ Fix this by not attempting to change the CPU's starting PC unless we actually loaded a kernel. Signed-off-by: Peter Maydell Reviewed-by: Jia Liu --- diff --git a/hw/openrisc/openrisc_sim.c b/hw/openrisc/openrisc_sim.c index a08f27c..28fa41d 100644 --- a/hw/openrisc/openrisc_sim.c +++ b/hw/openrisc/openrisc_sim.c @@ -86,9 +86,8 @@ static void cpu_openrisc_load_kernel(ram_addr_t ram_size, kernel_filename); exit(1); } + cpu->env.pc = entry; } - - cpu->env.pc = entry; } static void openrisc_sim_init(QEMUMachineInitArgs *args)