Commit 076b925d authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Radim Krčmář

kvm: avoid uninitialized-variable warnings

When PAGE_OFFSET is not a compile-time constant, we run into
warnings from the use of kvm_is_error_hva() that the compiler
cannot optimize out:

arch/arm/kvm/../../../virt/kvm/kvm_main.c: In function '__kvm_gfn_to_hva_cache_init':
arch/arm/kvm/../../../virt/kvm/kvm_main.c:1978:14: error: 'nr_pages_avail' may be used uninitialized in this function [-Werror=maybe-uninitialized]
arch/arm/kvm/../../../virt/kvm/kvm_main.c: In function 'gfn_to_page_many_atomic':
arch/arm/kvm/../../../virt/kvm/kvm_main.c:1660:5: error: 'entry' may be used uninitialized in this function [-Werror=maybe-uninitialized]

This adds fake initializations to the two instances I ran into.
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Signed-off-by: default avatarRadim Krčmář <rkrcmar@redhat.com>
parent d3802286
...@@ -1651,7 +1651,7 @@ int gfn_to_page_many_atomic(struct kvm_memory_slot *slot, gfn_t gfn, ...@@ -1651,7 +1651,7 @@ int gfn_to_page_many_atomic(struct kvm_memory_slot *slot, gfn_t gfn,
struct page **pages, int nr_pages) struct page **pages, int nr_pages)
{ {
unsigned long addr; unsigned long addr;
gfn_t entry; gfn_t entry = 0;
addr = gfn_to_hva_many(slot, gfn, &entry); addr = gfn_to_hva_many(slot, gfn, &entry);
if (kvm_is_error_hva(addr)) if (kvm_is_error_hva(addr))
...@@ -1970,6 +1970,7 @@ static int __kvm_gfn_to_hva_cache_init(struct kvm_memslots *slots, ...@@ -1970,6 +1970,7 @@ static int __kvm_gfn_to_hva_cache_init(struct kvm_memslots *slots,
* verify that the entire region is valid here. * verify that the entire region is valid here.
*/ */
while (start_gfn <= end_gfn) { while (start_gfn <= end_gfn) {
nr_pages_avail = 0;
ghc->memslot = __gfn_to_memslot(slots, start_gfn); ghc->memslot = __gfn_to_memslot(slots, start_gfn);
ghc->hva = gfn_to_hva_many(ghc->memslot, start_gfn, ghc->hva = gfn_to_hva_many(ghc->memslot, start_gfn,
&nr_pages_avail); &nr_pages_avail);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment