Skip to contentSkip to conversation

cpus: Fix botched configure_icount() error API violation fix

PATCH Applied Markus Armbruster 4 participants 7 messages May 8, 2020 – May 25, 2020

v1 of 2 Applied Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cpus: Fix botched configure_icount() error API violation fix

Fixes abc9bf69a66a11499a801ff545b8fe7adbb3a04c
Fixes Coverity CID 1428754
---
 cpus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
cpus.c +1 -1
index 5670c96bcf..b9275c672d 100644
@@ -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");
Signature · 1 line
2.21.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Markus Armbruster
Fixes abc9bf69a66a11499a801ff545b8fe7adbb3a04c
Fixes Coverity CID 1428754
---
  cpus.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

cpus.c void configure_icount(QemuOpts *opts, Error **errp) · line 816

Quoted 11 lines
cpus.c +1 -1
index 5670c96bcf..b9275c672d 100644
@@ -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.

Quoted 4 lines
cpus.c +0 -0
          if (qemu_strtol(option, NULL, 0, &time_shift) < 0
              || time_shift < 0 || time_shift > MAX_ICOUNT_SHIFT) {
              error_setg(errp, "icount: Invalid shift value");
Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org
#2 lore raw
Quoted 11 lines · Eric Blake
Quoted 6 lines · Markus Armbruster
Fixes abc9bf69a66a11499a801ff545b8fe7adbb3a04c
Fixes Coverity CID 1428754

---
  cpus.c | 2 +-

  1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 1 line
Quoted 11 lines

cpus.c void configure_icount(QemuOpts *opts, Error **errp) · line 815

Quoted 9 lines
cpus.c +1 -1
index 5670c96bcf..b9275c672d 100644
@@ -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." ;)

Quoted 6 lines
Quoted 5 lines

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

#3 lore raw
In reply to Markus Armbruster
Quoted 12 lines · Markus Armbruster
Fixes abc9bf69a66a11499a801ff545b8fe7adbb3a04c
Fixes Coverity CID 1428754
---
 cpus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
cpus.c +0 -0
index 5670c96bcf..b9275c672d 100644

cpus.c void configure_icount(QemuOpts *opts, Error **errp) · line 819

Quoted 8 lines
cpus.c +1 -1
@@ -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.

#4 lore raw
In reply to Markus Armbruster
Quoted 13 lines · Markus Armbruster
Fixes abc9bf69a66a11499a801ff545b8fe7adbb3a04c
Fixes Coverity CID 1428754
---
 cpus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
cpus.c +0 -0
index 5670c96bcf..b9275c672d 100644

cpus.c void configure_icount(QemuOpts *opts, Error **errp) · line 819

Quoted 8 lines
cpus.c +1 -1
@@ -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

#5 lore raw
Quoted 16 lines · Paolo Bonzini
Quoted 15 lines · Markus Armbruster
Fixes abc9bf69a66a11499a801ff545b8fe7adbb3a04c
Fixes Coverity CID 1428754
---
 cpus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
cpus.c +0 -0
index 5670c96bcf..b9275c672d 100644
@@ -813,7 +813,7 @@ void configure_icount(QemuOpts *opts, Error **errp)
         return;
     }
 
Quoted 8 lines

cpus.c void configure_icount(QemuOpts *opts, Error **errp) · line 819

Quoted 6 lines
cpus.c +1 -1
-    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.

#6 lore raw
Quoted 27 lines · Markus Armbruster
Quoted 16 lines · Paolo Bonzini
Quoted 15 lines · Markus Armbruster
Fixes abc9bf69a66a11499a801ff545b8fe7adbb3a04c
Fixes Coverity CID 1428754
---
 cpus.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
cpus.c +0 -0
index 5670c96bcf..b9275c672d 100644
@@ -813,7 +813,7 @@ void configure_icount(QemuOpts *opts, Error **errp)
         return;
     }
 
Quoted 8 lines

cpus.c void configure_icount(QemuOpts *opts, Error **errp) · line 819

Quoted 6 lines
cpus.c +1 -1
-    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.

Quoted 2 lines

This one's wrong, please queue v2 instead.

Yep, got there already. Thanks!

Paolo