[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] hw/openrisc/openrisc_sim: Avoid using uninitial
From: |
Jia Liu |
Subject: |
Re: [Qemu-devel] [PATCH] hw/openrisc/openrisc_sim: Avoid using uninitialised variable 'entry' |
Date: |
Tue, 6 Aug 2013 09:24:20 +0800 |
Hi Peter,
On Tue, Aug 6, 2013 at 2:24 AM, Peter Maydell <address@hidden> wrote:
> 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 <address@hidden>
> ---
> 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)
Thank you for using clang test it.
Reviewed-by: Jia Liu <address@hidden>
> --
> 1.7.9.5
>
Regards,
Jia