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

Daniel P. Berrangé berrange at redhat.com
Mon Apr 15 09:33:10 UTC 2019


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 at 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 at 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 :|




More information about the libvir-list mailing list