[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] pc_q35/i440fx: uses uninitialized variable 'ram_memory' if
From: |
Peter Maydell |
Subject: |
[Qemu-devel] pc_q35/i440fx: uses uninitialized variable 'ram_memory' if !xen_enabled() |
Date: |
Mon, 29 Jul 2013 12:44:12 +0100 |
Building QEMU with clang 3.3 results in the following warning:
hw/i386/pc_q35.c:115:9: error: variable 'ram_memory' is used
uninitialized whenever 'if' condition is false
[-Werror,-Wsometimes-uninitialized]
if (!xen_enabled()) {
^~~~~~~~~~~~~~
hw/i386/pc_q35.c:134:32: note: uninitialized use occurs here
q35_host->mch.ram_memory = ram_memory;
^~~~~~~~~~
hw/i386/pc_q35.c:115:5: note: remove the 'if' if its condition is always
true
if (!xen_enabled()) {
^~~~~~~~~~~~~~~~~~~~
hw/i386/pc_q35.c:71:29: note: initialize the variable 'ram_memory' to
silence this warning
MemoryRegion *ram_memory;
^
= NULL
1 error generated.
This looks correct -- if xen_enabled() is true, we skip the call
to pc_memory_init() which is what initializes ram_memory, but
then later on we still stuff it into the q35_host->mch field,
and as far as I can tell hw/pci-host/q35.c:mch_init() then uses
the ram_memory value whether xen is enabled or not.
There also seems to be a similar use-of-uninitialized which
clang doesn't spot in i440fx: hw/i386_pc_piix.c:pc_init1()
doesn't init ram_memory if xen_enabled() is true, but we
then pass ram_memory through i440fx_init()->i440fx_common_init()
->init_pam() which then tries to use it.
Can anybody who knows more about the x86 hw models and/or Xen
suggest the correct fix for this?
thanks
-- PMM
- [Qemu-devel] pc_q35/i440fx: uses uninitialized variable 'ram_memory' if !xen_enabled(),
Peter Maydell <=