[libvirt] [PATCH] examples: Initialize @pos in domtop.c

This is a zero-cost workaround for a bug in GCC 8.3.0 which causes the compilation to fail, because the compiler thinks that the value might be used uninitialized even though it clearly cannot be. Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- This is technically a fix for a build-breaker, but I'm sending it for review as it is not that big of a deal it being in examples/ 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 c9b51aed510d..e463e2873f42 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.21.0

On Mon, Apr 15, 2019 at 11:30:54AM +0200, Martin Kletzander wrote:
This is a zero-cost workaround for a bug in GCC 8.3.0 which causes the compilation to fail, because the compiler thinks that the value might be used uninitialized even though it clearly cannot be.
Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- This is technically a fix for a build-breaker, but I'm sending it for review as it is not that big of a deal it being in examples/
This is due to me enabling all the compiler warnings in examples/ recently
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 c9b51aed510d..e463e2873f42 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 */
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

On Mon, Apr 15, 2019 at 10:33:10AM +0100, Daniel P. Berrangé wrote:
On Mon, Apr 15, 2019 at 11:30:54AM +0200, Martin Kletzander wrote:
This is a zero-cost workaround for a bug in GCC 8.3.0 which causes the compilation to fail, because the compiler thinks that the value might be used uninitialized even though it clearly cannot be.
Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- This is technically a fix for a build-breaker, but I'm sending it for review as it is not that big of a deal it being in examples/
This is due to me enabling all the compiler warnings in examples/ recently
I know, I just wanted someone to see this before pushing.
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 c9b51aed510d..e463e2873f42 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 */
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Oh, I forgot to add this R-b to the commit message. Sorry.
Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
participants (2)
-
Daniel P. Berrangé
-
Martin Kletzander