qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] accel/kvm: ensure ret always set
@ 2019-10-02 10:22 Alex Bennée
  2019-10-02 11:08 ` Paolo Bonzini
  0 siblings, 1 reply; 5+ messages in thread
From: Alex Bennée @ 2019-10-02 10:22 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paolo Bonzini, Alex Bennée, open list:Overall KVM CPUs

Some of the cross compilers rightly complain there are cases where ret
may not be set. 0 seems to be the reasonable default unless particular
slot explicitly returns -1.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 accel/kvm/kvm-all.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index aabe097c41..d2d96d73e8 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -712,11 +712,11 @@ static int kvm_physical_log_clear(KVMMemoryListener *kml,
     KVMState *s = kvm_state;
     uint64_t start, size, offset, count;
     KVMSlot *mem;
-    int ret, i;
+    int ret = 0, i;
 
     if (!s->manual_dirty_log_protect) {
         /* No need to do explicit clear */
-        return 0;
+        return ret;
     }
 
     start = section->offset_within_address_space;
@@ -724,7 +724,7 @@ static int kvm_physical_log_clear(KVMMemoryListener *kml,
 
     if (!size) {
         /* Nothing more we can do... */
-        return 0;
+        return ret;
     }
 
     kvm_slots_lock(kml);
-- 
2.20.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] accel/kvm: ensure ret always set
  2019-10-02 10:22 [PATCH] accel/kvm: ensure ret always set Alex Bennée
@ 2019-10-02 11:08 ` Paolo Bonzini
  2019-10-03  9:22   ` Stefano Garzarella
  0 siblings, 1 reply; 5+ messages in thread
From: Paolo Bonzini @ 2019-10-02 11:08 UTC (permalink / raw)
  To: Alex Bennée, qemu-devel; +Cc: open list:Overall KVM CPUs

On 02/10/19 12:22, Alex Bennée wrote:
> Some of the cross compilers rightly complain there are cases where ret
> may not be set. 0 seems to be the reasonable default unless particular
> slot explicitly returns -1.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  accel/kvm/kvm-all.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
> index aabe097c41..d2d96d73e8 100644
> --- a/accel/kvm/kvm-all.c
> +++ b/accel/kvm/kvm-all.c
> @@ -712,11 +712,11 @@ static int kvm_physical_log_clear(KVMMemoryListener *kml,
>      KVMState *s = kvm_state;
>      uint64_t start, size, offset, count;
>      KVMSlot *mem;
> -    int ret, i;
> +    int ret = 0, i;
>  
>      if (!s->manual_dirty_log_protect) {
>          /* No need to do explicit clear */
> -        return 0;
> +        return ret;
>      }
>  
>      start = section->offset_within_address_space;
> @@ -724,7 +724,7 @@ static int kvm_physical_log_clear(KVMMemoryListener *kml,
>  
>      if (!size) {
>          /* Nothing more we can do... */
> -        return 0;
> +        return ret;
>      }
>  
>      kvm_slots_lock(kml);
> 

Queued, thanks.

Paolo



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] accel/kvm: ensure ret always set
  2019-10-02 11:08 ` Paolo Bonzini
@ 2019-10-03  9:22   ` Stefano Garzarella
  2019-10-03 10:18     ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 5+ messages in thread
From: Stefano Garzarella @ 2019-10-03  9:22 UTC (permalink / raw)
  To: Paolo Bonzini, Alex Bennée; +Cc: qemu-devel, open list:Overall KVM CPUs

On Wed, Oct 02, 2019 at 01:08:40PM +0200, Paolo Bonzini wrote:
> On 02/10/19 12:22, Alex Bennée wrote:
> > Some of the cross compilers rightly complain there are cases where ret
> > may not be set. 0 seems to be the reasonable default unless particular
> > slot explicitly returns -1.
> > 

Even Coverity reported it (CID 1405857).

> > Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> > ---
> >  accel/kvm/kvm-all.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> > 
> > diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
> > index aabe097c41..d2d96d73e8 100644
> > --- a/accel/kvm/kvm-all.c
> > +++ b/accel/kvm/kvm-all.c
> > @@ -712,11 +712,11 @@ static int kvm_physical_log_clear(KVMMemoryListener *kml,
> >      KVMState *s = kvm_state;
> >      uint64_t start, size, offset, count;
> >      KVMSlot *mem;
> > -    int ret, i;
> > +    int ret = 0, i;
> >  
> >      if (!s->manual_dirty_log_protect) {
> >          /* No need to do explicit clear */
> > -        return 0;
> > +        return ret;
> >      }
> >  
> >      start = section->offset_within_address_space;
> > @@ -724,7 +724,7 @@ static int kvm_physical_log_clear(KVMMemoryListener *kml,
> >  
> >      if (!size) {
> >          /* Nothing more we can do... */
> > -        return 0;
> > +        return ret;
> >      }
> >  
> >      kvm_slots_lock(kml);
> > 
> 
> Queued, thanks.
> 
> Paolo
> 

-- 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] accel/kvm: ensure ret always set
  2019-10-03  9:22   ` Stefano Garzarella
@ 2019-10-03 10:18     ` Philippe Mathieu-Daudé
  2019-10-03 12:15       ` Alex Bennée
  0 siblings, 1 reply; 5+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-10-03 10:18 UTC (permalink / raw)
  To: Stefano Garzarella, Paolo Bonzini, Alex Bennée
  Cc: qemu-devel, open list:Overall KVM CPUs

On 10/3/19 11:22 AM, Stefano Garzarella wrote:
> On Wed, Oct 02, 2019 at 01:08:40PM +0200, Paolo Bonzini wrote:
>> On 02/10/19 12:22, Alex Bennée wrote:
>>> Some of the cross compilers rightly complain there are cases where ret
>>> may not be set. 0 seems to be the reasonable default unless particular
>>> slot explicitly returns -1.
>>>
> 
> Even Coverity reported it (CID 1405857).

And GCC ;)

/home/phil/source/qemu/accel/kvm/kvm-all.c: In function ‘kvm_log_clear’:
/home/phil/source/qemu/accel/kvm/kvm-all.c:1121:8: error: ‘ret’ may be 
used uninitialized in this function [-Werror=maybe-uninitialized]
      if (r < 0) {
         ^
cc1: all warnings being treated as errors
make[1]: *** [/home/phil/source/qemu/rules.mak:69: accel/kvm/kvm-all.o] 
Error 1

Fixes: 4222147dfb7

>>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>>> ---
>>>   accel/kvm/kvm-all.c | 6 +++---
>>>   1 file changed, 3 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
>>> index aabe097c41..d2d96d73e8 100644
>>> --- a/accel/kvm/kvm-all.c
>>> +++ b/accel/kvm/kvm-all.c
>>> @@ -712,11 +712,11 @@ static int kvm_physical_log_clear(KVMMemoryListener *kml,
>>>       KVMState *s = kvm_state;
>>>       uint64_t start, size, offset, count;
>>>       KVMSlot *mem;
>>> -    int ret, i;
>>> +    int ret = 0, i;
>>>   
>>>       if (!s->manual_dirty_log_protect) {
>>>           /* No need to do explicit clear */
>>> -        return 0;
>>> +        return ret;
>>>       }
>>>   
>>>       start = section->offset_within_address_space;
>>> @@ -724,7 +724,7 @@ static int kvm_physical_log_clear(KVMMemoryListener *kml,
>>>   
>>>       if (!size) {
>>>           /* Nothing more we can do... */
>>> -        return 0;
>>> +        return ret;
>>>       }
>>>   
>>>       kvm_slots_lock(kml);
>>>
>>
>> Queued, thanks.
>>
>> Paolo
>>
> 


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] accel/kvm: ensure ret always set
  2019-10-03 10:18     ` Philippe Mathieu-Daudé
@ 2019-10-03 12:15       ` Alex Bennée
  0 siblings, 0 replies; 5+ messages in thread
From: Alex Bennée @ 2019-10-03 12:15 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé
  Cc: Paolo Bonzini, qemu-devel, open list:Overall KVM CPUs,
	Stefano Garzarella


Philippe Mathieu-Daudé <philmd@redhat.com> writes:

> On 10/3/19 11:22 AM, Stefano Garzarella wrote:
>> On Wed, Oct 02, 2019 at 01:08:40PM +0200, Paolo Bonzini wrote:
>>> On 02/10/19 12:22, Alex Bennée wrote:
>>>> Some of the cross compilers rightly complain there are cases where ret
>>>> may not be set. 0 seems to be the reasonable default unless particular
>>>> slot explicitly returns -1.
>>>>
>> Even Coverity reported it (CID 1405857).
>
> And GCC ;)

So my normal gcc didn't catch that - which is odd as I didn't expect the
shippable gcc's to be ahead of my local buster install.

>
> /home/phil/source/qemu/accel/kvm/kvm-all.c: In function ‘kvm_log_clear’:
> /home/phil/source/qemu/accel/kvm/kvm-all.c:1121:8: error: ‘ret’ may be
> used uninitialized in this function [-Werror=maybe-uninitialized]
>      if (r < 0) {
>         ^
> cc1: all warnings being treated as errors
> make[1]: *** [/home/phil/source/qemu/rules.mak:69:
> accel/kvm/kvm-all.o] Error 1
>
> Fixes: 4222147dfb7
>
>>>> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
>>>> ---
>>>>   accel/kvm/kvm-all.c | 6 +++---
>>>>   1 file changed, 3 insertions(+), 3 deletions(-)
>>>>
>>>> diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
>>>> index aabe097c41..d2d96d73e8 100644
>>>> --- a/accel/kvm/kvm-all.c
>>>> +++ b/accel/kvm/kvm-all.c
>>>> @@ -712,11 +712,11 @@ static int kvm_physical_log_clear(KVMMemoryListener *kml,
>>>>       KVMState *s = kvm_state;
>>>>       uint64_t start, size, offset, count;
>>>>       KVMSlot *mem;
>>>> -    int ret, i;
>>>> +    int ret = 0, i;
>>>>         if (!s->manual_dirty_log_protect) {
>>>>           /* No need to do explicit clear */
>>>> -        return 0;
>>>> +        return ret;
>>>>       }
>>>>         start = section->offset_within_address_space;
>>>> @@ -724,7 +724,7 @@ static int kvm_physical_log_clear(KVMMemoryListener *kml,
>>>>         if (!size) {
>>>>           /* Nothing more we can do... */
>>>> -        return 0;
>>>> +        return ret;
>>>>       }
>>>>         kvm_slots_lock(kml);
>>>>
>>>
>>> Queued, thanks.
>>>
>>> Paolo
>>>
>>


--
Alex Bennée


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-10-03 12:17 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-02 10:22 [PATCH] accel/kvm: ensure ret always set Alex Bennée
2019-10-02 11:08 ` Paolo Bonzini
2019-10-03  9:22   ` Stefano Garzarella
2019-10-03 10:18     ` Philippe Mathieu-Daudé
2019-10-03 12:15       ` Alex Bennée

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).