[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <871e801d-10dc-f1d5-a4a5-efc6824ebd21@redhat.com>
Date: Tue, 5 May 2020 09:20:27 +1000
From: Gavin Shan <gshan@...hat.com>
To: Peter Xu <peterx@...hat.com>, kvm@...r.kernel.org,
linux-kernel@...r.kernel.org
Cc: Paolo Bonzini <pbonzini@...hat.com>
Subject: Re: [PATCH] KVM: Fix a warning in __kvm_gfn_to_hva_cache_init()
On 5/5/20 5:05 AM, Peter Xu wrote:
> GCC 10.0.1 gives me this warning when building KVM:
>
> warning: ‘nr_pages_avail’ may be used uninitialized in this function [-Wmaybe-uninitialized]
> 2442 | for ( ; start_gfn <= end_gfn; start_gfn += nr_pages_avail) {
>
> It should not happen, but silent it.
>
> Signed-off-by: Peter Xu <peterx@...hat.com>
> ---
> virt/kvm/kvm_main.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
Reviewed-by: Gavin Shan <gshan@...hat.com>
> diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
> index 74bdb7bf3295..2da293885a67 100644
> --- a/virt/kvm/kvm_main.c
> +++ b/virt/kvm/kvm_main.c
> @@ -2425,7 +2425,7 @@ static int __kvm_gfn_to_hva_cache_init(struct kvm_memslots *slots,
> gfn_t start_gfn = gpa >> PAGE_SHIFT;
> gfn_t end_gfn = (gpa + len - 1) >> PAGE_SHIFT;
> gfn_t nr_pages_needed = end_gfn - start_gfn + 1;
> - gfn_t nr_pages_avail;
> + gfn_t nr_pages_avail = 0;
>
> /* Update ghc->generation before performing any error checks. */
> ghc->generation = slots->generation;
>
Powered by blists - more mailing lists