linux/arch/x86/kvm
Michael S. Tsirkin 79f702a6d1 KVM: disable uninitialized var warning
I see this in 3.5-rc1:

arch/x86/kvm/mmu.c: In function ‘kvm_test_age_rmapp’:
arch/x86/kvm/mmu.c:1271: warning: ‘iter.desc’ may be used uninitialized in this function

The line in question was introduced by commit
1e3f42f03c

 static int kvm_test_age_rmapp(struct kvm *kvm, unsigned long *rmapp,
                              unsigned long data)
 {
-       u64 *spte;
+       u64 *sptep;
+       struct rmap_iterator iter;   <- line 1271
        int young = 0;

        /*

The reason I think is that the compiler assumes that
the rmap value could be 0, so

static u64 *rmap_get_first(unsigned long rmap, struct rmap_iterator
*iter)
{
        if (!rmap)
                return NULL;

        if (!(rmap & 1)) {
                iter->desc = NULL;
                return (u64 *)rmap;
        }

        iter->desc = (struct pte_list_desc *)(rmap & ~1ul);
        iter->pos = 0;
        return iter->desc->sptes[iter->pos];
}

will not initialize iter.desc, but the compiler isn't
smart enough to see that

        for (sptep = rmap_get_first(*rmapp, &iter); sptep;
             sptep = rmap_get_next(&iter)) {

will immediately exit in this case.
I checked by adding
        if (!*rmapp)
                goto out;
on top which is clearly equivalent but disables the warning.

This patch uses uninitialized_var to disable the warning without
increasing code size.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
2012-06-06 15:26:12 +03:00
..
cpuid.c KVM: fix cpuid eax for KVM leaf 2012-05-06 15:51:56 +03:00
cpuid.h KVM: SVM: Add support for AMD's OSVW feature in guests 2012-03-05 14:52:21 +02:00
emulate.c KVM: x86 emulator: convert bsf/bsr instructions to emulate_2op_SrcV_nobyte() 2012-05-14 11:32:38 +03:00
i8254.c KVM: x86: Run PIT work in own kthread 2012-04-27 19:40:29 -03:00
i8254.h KVM: x86: Run PIT work in own kthread 2012-04-27 19:40:29 -03:00
i8259.c KVM: x86: reset edge sense circuit of i8259 on init 2012-03-05 14:57:30 +02:00
irq.c KVM: fix typo in copyright notice 2010-10-24 10:53:14 +02:00
irq.h KVM: Intelligent device lookup on I/O bus 2011-09-25 19:17:59 +03:00
Kconfig KVM: Introduce direct MSI message injection for in-kernel irqchips 2012-04-24 15:59:47 +03:00
kvm_cache_regs.h KVM: MMU: Do not unconditionally read PDPTE from guest memory 2011-09-25 19:18:01 +03:00
kvm_timer.h KVM: emulate lapic tsc deadline timer for guest 2011-10-05 15:34:56 +02:00
lapic.c KVM: Introduce bitmask for apic attention reasons 2012-04-24 16:36:18 +03:00
lapic.h KVM: Expose kvm_lapic_local_deliver() 2011-12-27 11:23:39 +02:00
Makefile KVM: Expose a version 2 architectural PMU to a guests 2011-12-27 11:24:29 +02:00
mmu_audit.c KVM: MMU: Improve iteration through sptes from rmap 2012-04-08 16:08:27 +03:00
mmu.c KVM: disable uninitialized var warning 2012-06-06 15:26:12 +03:00
mmu.h KVM: MMU: mmio page fault support 2011-07-24 11:50:40 +03:00
mmutrace.h KVM: MMU: audit: replace mmu audit tracepoint with jump-label 2011-12-27 11:22:05 +02:00
paging_tmpl.h KVM: MMU: use page table level macro 2012-04-18 23:35:01 -03:00
pmu.c KVM: PMU emulation: GLOBAL_CTRL MSR should be enabled on reset 2012-04-10 15:34:10 +03:00
svm.c KVM: Cleanup the kvm_print functions and introduce pr_XX wrappers 2012-06-06 15:24:00 +03:00
timer.c KVM: x86: Simplify kvm timer handler 2011-12-27 11:17:05 +02:00
trace.h KVM: Use __print_symbolic() for vmexit tracepoints 2011-09-25 19:17:59 +03:00
tss.h KVM: x86: hardware task switching support 2008-04-27 12:00:39 +03:00
vmx.c KVM: Cleanup the kvm_print functions and introduce pr_XX wrappers 2012-06-06 15:24:00 +03:00
x86.c KVM: Cleanup the kvm_print functions and introduce pr_XX wrappers 2012-06-06 15:24:00 +03:00
x86.h KVM: x86: add paging gcc optimization 2012-04-08 14:03:13 +03:00