From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44264) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V6PSN-0001kz-Pk for qemu-devel@nongnu.org; Mon, 05 Aug 2013 14:24:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V6PSJ-0007a2-Bo for qemu-devel@nongnu.org; Mon, 05 Aug 2013 14:24:35 -0400 From: Peter Maydell Date: Mon, 5 Aug 2013 19:24:27 +0100 Message-Id: <1375727067-22126-1-git-send-email-peter.maydell@linaro.org> Subject: [Qemu-devel] [PATCH] hw/openrisc/openrisc_sim: Avoid using uninitialised variable 'entry' List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org, Jia Liu , patches@linaro.org 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 --- hw/openrisc/openrisc_sim.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/openrisc/openrisc_sim.c b/hw/openrisc/openrisc_sim.c index a08f27c..4595fa9 100644 --- a/hw/openrisc/openrisc_sim.c +++ b/hw/openrisc/openrisc_sim.c @@ -86,9 +86,9 @@ 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) -- 1.7.9.5