qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH v2] hw/i386/amd_iommu: Fix maybe-uninitialized error with GCC


From: Philippe Mathieu-Daudé
Subject: Re: [PATCH v2] hw/i386/amd_iommu: Fix maybe-uninitialized error with GCC 12
Date: Mon, 21 Mar 2022 15:35:29 +0100
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.7.0

On 21/3/22 15:33, Paolo Bonzini wrote:
Be more explicit that the loop must roll at least once.  Avoids the
following warning:

   FAILED: libqemu-x86_64-softmmu.fa.p/hw_i386_amd_iommu.c.o
   In function 'pte_get_page_mask',
       inlined from 'amdvi_page_walk' at hw/i386/amd_iommu.c:945:25,
       inlined from 'amdvi_do_translate' at hw/i386/amd_iommu.c:989:5,
       inlined from 'amdvi_translate' at hw/i386/amd_iommu.c:1038:5:
   hw/i386/amd_iommu.c:877:38: error: 'oldlevel' may be used uninitialized 
[-Werror=maybe-uninitialized]
     877 |     return ~((1UL << ((oldlevel * 9) + 3)) - 1);
         |                      ~~~~~~~~~~~~~~~~^~~~
   hw/i386/amd_iommu.c: In function 'amdvi_translate':
   hw/i386/amd_iommu.c:906:41: note: 'oldlevel' was declared here
     906 |     unsigned level, present, pte_perms, oldlevel;
         |                                         ^~~~~~~~
   cc1: all warnings being treated as errors

Having:

   $ gcc --version
   gcc (Debian 12-20220313-1) 12.0.1 20220314 (experimental)

Reported-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
  hw/i386/amd_iommu.c | 7 ++-----
  1 file changed, 2 insertions(+), 5 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

Thanks!



reply via email to

[Prev in Thread] Current Thread [Next in Thread]