[libvirt] [PATCH] examples: domtop: fix build error

Bjoern Walk posted 1 patch 4 years, 11 months ago
Test syntax-check passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20190415101818.173034-1-bwalk@linux.ibm.com
examples/domtop/domtop.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[libvirt] [PATCH] examples: domtop: fix build error
Posted by Bjoern Walk 4 years, 11 months ago
GCC version 8.2.1 has problems seeing the the correct flow of control,
so manually initialize the temporary variable.

    ../../examples/domtop/domtop.c: In function 'print_cpu_usage':
    ../../examples/domtop/domtop.c:242:28: error: 'pos' may be used uninitialized in this function [-Werror=maybe-uninitialized]
             usage = (now_params[pos].value.ul - then_params[pos].value.ul) /

    cc1: all warnings being treated as errors

Signed-off-by: Bjoern Walk <bwalk@linux.ibm.com>
---
 examples/domtop/domtop.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/examples/domtop/domtop.c b/examples/domtop/domtop.c
index c9b51aed..e463e287 100644
--- a/examples/domtop/domtop.c
+++ b/examples/domtop/domtop.c
@@ -206,7 +206,7 @@ print_cpu_usage(size_t cpu,
     }
 
     for (i = 0; i < ncpus; i++) {
-        size_t pos;
+        size_t pos = 0;
         double usage;
 
         /* check if the vCPU is in the maps */
-- 
2.19.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] examples: domtop: fix build error
Posted by Bjoern Walk 4 years, 11 months ago
Nevermind, Martin was faster.

-- 
IBM Systems
Linux on Z & Virtualization Development
--------------------------------------------------
IBM Deutschland Research & Development GmbH
Schönaicher Str. 220, 71032 Böblingen
Phone: +49 7031 16 1819
--------------------------------------------------
Vorsitzende des Aufsichtsrats: Matthias Hartmann
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list