[PATCH] cpus: Fix botched configure_icount() error API violation fix

Markus Armbruster posted 1 patch 4 years ago
Test docker-mingw@fedora passed
Test checkpatch passed
Test asan passed
Test docker-quick@centos7 passed
Test FreeBSD passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20200508104933.19051-1-armbru@redhat.com
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, Richard Henderson <rth@twiddle.net>
There is a newer version of this series
cpus.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] cpus: Fix botched configure_icount() error API violation fix
Posted by Markus Armbruster 4 years ago
Fixes: abc9bf69a66a11499a801ff545b8fe7adbb3a04c
Fixes: Coverity CID 1428754
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 cpus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/cpus.c b/cpus.c
index 5670c96bcf..b9275c672d 100644
--- a/cpus.c
+++ b/cpus.c
@@ -813,7 +813,7 @@ void configure_icount(QemuOpts *opts, Error **errp)
         return;
     }
 
-    if (strcmp(option, "auto") != 0) {
+    if (option && !strcmp(option, "auto")) {
         if (qemu_strtol(option, NULL, 0, &time_shift) < 0
             || time_shift < 0 || time_shift > MAX_ICOUNT_SHIFT) {
             error_setg(errp, "icount: Invalid shift value");
-- 
2.21.1


Re: [PATCH] cpus: Fix botched configure_icount() error API violation fix
Posted by Eric Blake 4 years ago
On 5/8/20 5:49 AM, Markus Armbruster wrote:
> Fixes: abc9bf69a66a11499a801ff545b8fe7adbb3a04c
> Fixes: Coverity CID 1428754
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>   cpus.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Eric Blake <eblake@redhat.com>

> 
> diff --git a/cpus.c b/cpus.c
> index 5670c96bcf..b9275c672d 100644
> --- a/cpus.c
> +++ b/cpus.c
> @@ -813,7 +813,7 @@ void configure_icount(QemuOpts *opts, Error **errp)
>           return;
>       }
>   
> -    if (strcmp(option, "auto") != 0) {
> +    if (option && !strcmp(option, "auto")) {

Another alternative would be using g_strcmp0, but this form is fine.

>           if (qemu_strtol(option, NULL, 0, &time_shift) < 0
>               || time_shift < 0 || time_shift > MAX_ICOUNT_SHIFT) {
>               error_setg(errp, "icount: Invalid shift value");
> 

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org


Re: [PATCH] cpus: Fix botched configure_icount() error API violation fix
Posted by Philippe Mathieu-Daudé 4 years ago
On 5/8/20 3:45 PM, Eric Blake wrote:
> On 5/8/20 5:49 AM, Markus Armbruster wrote:
>> Fixes: abc9bf69a66a11499a801ff545b8fe7adbb3a04c
>> Fixes: Coverity CID 1428754
>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>> ---
>>   cpus.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> Reviewed-by: Eric Blake <eblake@redhat.com>
> 
>>
>> diff --git a/cpus.c b/cpus.c
>> index 5670c96bcf..b9275c672d 100644
>> --- a/cpus.c
>> +++ b/cpus.c
>> @@ -813,7 +813,7 @@ void configure_icount(QemuOpts *opts, Error **errp)
>>           return;
>>       }
>> -    if (strcmp(option, "auto") != 0) {
>> +    if (option && !strcmp(option, "auto")) {
> 
> Another alternative would be using g_strcmp0, but this form is fine.

"Leading by example is the fastest way to train a team." ;)

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

> 
>>           if (qemu_strtol(option, NULL, 0, &time_shift) < 0
>>               || time_shift < 0 || time_shift > MAX_ICOUNT_SHIFT) {
>>               error_setg(errp, "icount: Invalid shift value");
>>
> 


Re: [PATCH] cpus: Fix botched configure_icount() error API violation fix
Posted by Paolo Bonzini 3 years, 11 months ago
On 08/05/20 12:49, Markus Armbruster wrote:
> Fixes: abc9bf69a66a11499a801ff545b8fe7adbb3a04c
> Fixes: Coverity CID 1428754
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>  cpus.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/cpus.c b/cpus.c
> index 5670c96bcf..b9275c672d 100644
> --- a/cpus.c
> +++ b/cpus.c
> @@ -813,7 +813,7 @@ void configure_icount(QemuOpts *opts, Error **errp)
>          return;
>      }
>  
> -    if (strcmp(option, "auto") != 0) {
> +    if (option && !strcmp(option, "auto")) {
>          if (qemu_strtol(option, NULL, 0, &time_shift) < 0
>              || time_shift < 0 || time_shift > MAX_ICOUNT_SHIFT) {
>              error_setg(errp, "icount: Invalid shift value");
> 

Queued, thanks.

Paolo


Re: [PATCH] cpus: Fix botched configure_icount() error API violation fix
Posted by Markus Armbruster 3 years, 11 months ago
Paolo Bonzini <pbonzini@redhat.com> writes:

> On 08/05/20 12:49, Markus Armbruster wrote:
>> Fixes: abc9bf69a66a11499a801ff545b8fe7adbb3a04c
>> Fixes: Coverity CID 1428754
>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>> ---
>>  cpus.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>> 
>> diff --git a/cpus.c b/cpus.c
>> index 5670c96bcf..b9275c672d 100644
>> --- a/cpus.c
>> +++ b/cpus.c
>> @@ -813,7 +813,7 @@ void configure_icount(QemuOpts *opts, Error **errp)
>>          return;
>>      }
>>  
>> -    if (strcmp(option, "auto") != 0) {
>> +    if (option && !strcmp(option, "auto")) {
>>          if (qemu_strtol(option, NULL, 0, &time_shift) < 0
>>              || time_shift < 0 || time_shift > MAX_ICOUNT_SHIFT) {
>>              error_setg(errp, "icount: Invalid shift value");
>> 
>
> Queued, thanks.

This one's wrong, please queue v2 instead.


Re: [PATCH] cpus: Fix botched configure_icount() error API violation fix
Posted by Paolo Bonzini 3 years, 11 months ago
On 25/05/20 07:44, Markus Armbruster wrote:
> Paolo Bonzini <pbonzini@redhat.com> writes:
> 
>> On 08/05/20 12:49, Markus Armbruster wrote:
>>> Fixes: abc9bf69a66a11499a801ff545b8fe7adbb3a04c
>>> Fixes: Coverity CID 1428754
>>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>>> ---
>>>  cpus.c | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/cpus.c b/cpus.c
>>> index 5670c96bcf..b9275c672d 100644
>>> --- a/cpus.c
>>> +++ b/cpus.c
>>> @@ -813,7 +813,7 @@ void configure_icount(QemuOpts *opts, Error **errp)
>>>          return;
>>>      }
>>>  
>>> -    if (strcmp(option, "auto") != 0) {
>>> +    if (option && !strcmp(option, "auto")) {
>>>          if (qemu_strtol(option, NULL, 0, &time_shift) < 0
>>>              || time_shift < 0 || time_shift > MAX_ICOUNT_SHIFT) {
>>>              error_setg(errp, "icount: Invalid shift value");
>>>
>>
>> Queued, thanks.
> 
> This one's wrong, please queue v2 instead.
> 

Yep, got there already.  Thanks!

Paolo


Re: [PATCH] cpus: Fix botched configure_icount() error API violation fix
Posted by Markus Armbruster 4 years ago
Markus Armbruster <armbru@redhat.com> writes:

> Fixes: abc9bf69a66a11499a801ff545b8fe7adbb3a04c
> Fixes: Coverity CID 1428754
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>  cpus.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/cpus.c b/cpus.c
> index 5670c96bcf..b9275c672d 100644
> --- a/cpus.c
> +++ b/cpus.c
> @@ -813,7 +813,7 @@ void configure_icount(QemuOpts *opts, Error **errp)
>          return;
>      }
>  
> -    if (strcmp(option, "auto") != 0) {
> +    if (option && !strcmp(option, "auto")) {
>          if (qemu_strtol(option, NULL, 0, &time_shift) < 0
>              || time_shift < 0 || time_shift > MAX_ICOUNT_SHIFT) {
>              error_setg(errp, "icount: Invalid shift value");

Nonsense.  I shouldn't multi-task.