From patchwork Thu Aug 10 12:14:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9893485 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id C76A9603F2 for ; Thu, 10 Aug 2017 12:16:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B568328AFA for ; Thu, 10 Aug 2017 12:16:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AA33328AFB; Thu, 10 Aug 2017 12:16:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1022C28B01 for ; Thu, 10 Aug 2017 12:16:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753128AbdHJMQX (ORCPT ); Thu, 10 Aug 2017 08:16:23 -0400 Received: from mout.kundenserver.de ([212.227.126.133]:53214 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752745AbdHJMQT (ORCPT ); Thu, 10 Aug 2017 08:16:19 -0400 Received: from wuerfel.lan ([95.208.155.18]) by mrelayeu.kundenserver.de (mreue004 [212.227.15.129]) with ESMTPA (Nemesis) id 0Ldqqt-1dGNQW1tBb-00izHr; Thu, 10 Aug 2017 14:14:51 +0200 From: Arnd Bergmann To: Paolo Bonzini , =?UTF-8?q?Radim=20Kr=C4=8Dm=C3=A1=C5=99?= Cc: Arnd Bergmann , Christian Borntraeger , Michal Hocko , David Hildenbrand , Lorenzo Stoakes , Suraj Jitindar Singh , Ingo Molnar , Claudio Imbrenda , Luiz Capitulino , Markus Elfring , "Cao, Lei" , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] kvm: avoid uninitialized-variable warnings Date: Thu, 10 Aug 2017 14:14:39 +0200 Message-Id: <20170810121449.2610298-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:8v9otAKeJ/jEY2RuAzJ3tIWGkxlwLYP6tBBYG5WR4L7lWHFV0Nv NtYNi1pJv8/a0I1GpIDidcTJCPiCw2BYzr3vX+nhC12zsLr7aFncMaLdmEPdg/bEX9SXxMU 6Hz/pC9+UWPI3KPlJURMRhIpUDoy8C2dePTJwDdleXnicTI7HVsHP20YH4SPh5tXnqxm+8h iXXADPXDBlV+fZ1xEaYZg== X-UI-Out-Filterresults: notjunk:1; V01:K0:Pobpu3+fY1k=:qgHkG98k8gUmo9dewlX7Sq LR2sLHzp+NWvkHuUkhORk74u+PIOP/4t3MdT+YpAidG/IftVMWdoAiicodjZLYYIs2w4GeXI4 4p0CtBL4MENTBvKGf2XAnAJMId7rkx+xec8Bn0O07VX16RrAQwL8PK0XaNktTpkLepke5VeHe eCoAJrsqLGOIXaXDhexf3H35ZTXB7jDXiCe9GIhP2LIi8VzBYvci4GlAIbelf30EYqkZgklEc dOrguxJlVC8UZOGGARoAtWaFAMSDn1Gn0eWCnmnVuIaXCeZ5K+r8Fn1Syo+L8Ao6AO0sFg9hr OqX0+rB+fwX7l/oifnrENiisQSwXhA9esFwU4oK/nbAGy9UBLi/4dGUpbL++z3cLGZtVLVyAj tr+MgyF2Sy1cx9/axSxNo8bOQlBEdtDA+gneCHdv6MaZacnkZxjT0RwKO06ZubhsuxdJqHImI 1IQuoAyl+CNfhxCTAGTkqe4sdpDFqrCthtzADHojPRFJ9uenslx0O8hy6hCRP+BkPFHKoZxAG DsH3ZXlgxpYVHFRzRsVFgTlkE7PnRPt3Q5Q/NLFnOHoheDGbwotO4M6BrBcfaqCfCnpbbQW1D dtf11eRhYDKm4+dau1vgw2szHJ8kLdE0sRvKj2f8S5GzcAS5svVlIaptEujzmiVAM3D7Z7n8Z Yiiy4LgqTthNOWmaCnsPe4fUbUeMQxHBeWaKUct3QYvnQVSKOK3dokRPPpPpfpZdzatbVUjub +vADJuKQP3+tUX1r8B0QVz+ScVecsmkryD7/lA== Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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: Arnd Bergmann --- virt/kvm/kvm_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 15252d723b54..c812b40dc8de 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -1651,7 +1651,7 @@ int gfn_to_page_many_atomic(struct kvm_memory_slot *slot, gfn_t gfn, struct page **pages, int nr_pages) { unsigned long addr; - gfn_t entry; + gfn_t entry = 0; addr = gfn_to_hva_many(slot, gfn, &entry); if (kvm_is_error_hva(addr)) @@ -1970,6 +1970,7 @@ static int __kvm_gfn_to_hva_cache_init(struct kvm_memslots *slots, * verify that the entire region is valid here. */ while (start_gfn <= end_gfn) { + nr_pages_avail = 0; ghc->memslot = __gfn_to_memslot(slots, start_gfn); ghc->hva = gfn_to_hva_many(ghc->memslot, start_gfn, &nr_pages_avail);