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

Martin Kletzander posted 1 patch 5 years ago
Test syntax-check passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/c123d7e143bd061f46e12a3827e767feef56815e.1555320487.git.mkletzan@redhat.com
examples/domtop/domtop.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[libvirt] [PATCH] examples: Initialize @pos in domtop.c
Posted by Martin Kletzander 5 years ago
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

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] examples: Initialize @pos in domtop.c
Posted by Daniel P. Berrangé 5 years ago
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 :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] examples: Initialize @pos in domtop.c
Posted by Martin Kletzander 5 years ago
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 :|
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list