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 <peter.maydell@linaro.org>
Reviewed-by: Jia Liu <proljc@gmail.com>
hw/openrisc: Fix masking in openrisc_pic_cpu_handler()

Consider the masking of PICSR and PICMR:

    ((cpu->env.picsr && (1 << i)) && (cpu->env.picmr && (1 << i)))

To correctly mask bits, we should use the bitwise AND "&" rather than
the logical AND "&&".  Also, the loop is not necessary for masking.
Simply use (cpu->env.picsr & cpu->env.picmr).

Signed-off-by: Xi Wang <xi.wang@gmail.com>
Acked-by: Jia Liu <proljc@gmail.com>
hw/openrisc: Avoid undefined shift in openrisc_pic_cpu_handler()

In C99 signed shift (1 << 31) is undefined behavior, since the result
exceeds INT_MAX.  Use 1U instead and move the shift after the check.

Signed-off-by: Xi Wang <xi.wang@gmail.com>
Acked-by: Jia Liu <proljc@gmail.com>
Merge remote-tracking branch 'jliu/or32' into staging

# By Jia Liu
# Via Jia Liu
* jliu/or32:
  hw/openrisc: Avoid undefined shift in openrisc_pic_cpu_handler()
  hw/openrisc: Fix masking in openrisc_pic_cpu_handler()
  hw/openrisc: Avoid using uninitialised variable 'entry'

Message-id: 1377050811-11116-1-git-send-email-proljc@gmail.com
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>