kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gavin Shan <gshan@redhat.com>
To: Peter Xu <peterx@redhat.com>,
	kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH] KVM: Fix a warning in __kvm_gfn_to_hva_cache_init()
Date: Tue, 5 May 2020 09:20:27 +1000	[thread overview]
Message-ID: <871e801d-10dc-f1d5-a4a5-efc6824ebd21@redhat.com> (raw)
In-Reply-To: <20200504190526.84456-1-peterx@redhat.com>

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@redhat.com>
> ---
>   virt/kvm/kvm_main.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 

Reviewed-by: Gavin Shan <gshan@redhat.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;
> 


  reply	other threads:[~2020-05-04 23:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-04 19:05 [PATCH] KVM: Fix a warning in __kvm_gfn_to_hva_cache_init() Peter Xu
2020-05-04 23:20 ` Gavin Shan [this message]
2020-05-05  1:39 ` Sean Christopherson
2020-05-05 14:12   ` Peter Xu
2020-05-11 16:05     ` Sean Christopherson
2020-05-11 17:04       ` Oliver Upton
2020-05-11 17:10         ` Sean Christopherson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871e801d-10dc-f1d5-a4a5-efc6824ebd21@redhat.com \
    --to=gshan@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=peterx@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).