Skip to contentSkip to conversation

colo-compare: Remove superfluous NULL-pointer checks for s->iothread

PATCH Applied Lukas Straub 5 participants 5 messages Jul 31, 2020 – Aug 4, 2020 Networking

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 colo-compare: Remove superfluous NULL-pointer checks for s->iothread

s->iothread is checked for NULL on object creation in colo_compare_complete, so it's guaranteed not to be NULL.
This resolves a false alert from Coverity (CID 1429969).

---
 net/colo-compare.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
net/colo-compare.c +2 -6
index cc15f23dea..2c20de1537 100644
@@ -1442,9 +1442,7 @@ static void colo_compare_finalize(Object *obj)
         qemu_chr_fe_deinit(&s->chr_notify_dev, false);
     }
 
-    if (s->iothread) {
-        colo_compare_timer_del(s);
-    }
+    colo_compare_timer_del(s);
 
     qemu_bh_delete(s->event_bh);
 
@@ -1470,9 +1468,7 @@ static void colo_compare_finalize(Object *obj)
         g_hash_table_destroy(s->connection_track_table);
     }
 
-    if (s->iothread) {
-        object_unref(OBJECT(s->iothread));
-    }
+    object_unref(OBJECT(s->iothread));
 
     g_free(s->pri_indev);
     g_free(s->sec_indev);
Signature · 1 line
2.20.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Lukas Straub

s->iothread is checked for NULL on object creation in colo_compare_complete, so it's guaranteed not to be NULL.
This resolves a false alert from Coverity (CID 1429969).

Quoted 31 lines
---
 net/colo-compare.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
net/colo-compare.c +2 -6
index cc15f23dea..2c20de1537 100644
@@ -1442,9 +1442,7 @@ static void colo_compare_finalize(Object *obj)
         qemu_chr_fe_deinit(&s->chr_notify_dev, false);
     }
 
-    if (s->iothread) {
-        colo_compare_timer_del(s);
-    }
+    colo_compare_timer_del(s);
 
     qemu_bh_delete(s->event_bh);
 
@@ -1470,9 +1468,7 @@ static void colo_compare_finalize(Object *obj)
         g_hash_table_destroy(s->connection_track_table);
     }
 
-    if (s->iothread) {
-        object_unref(OBJECT(s->iothread));
-    }
+    object_unref(OBJECT(s->iothread));
 
     g_free(s->pri_indev);
     g_free(s->sec_indev);
Reviewed-by on v1 1/1
#2 lore raw
In reply to Lukas Straub
Quoted 6 lines · Lukas Straub <[email protected]> 于2020年7月31日周五 下午1:09写道:

s->iothread is checked for NULL on object creation in colo_compare_complete, so it's guaranteed not to be NULL.
This resolves a false alert from Coverity (CID 1429969).

Quoted 32 lines
---
 net/colo-compare.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
net/colo-compare.c +2 -7
index cc15f23dea..2c20de1537 100644
@@ -1442,9 +1442,7 @@ static void colo_compare_finalize(Object *obj)
         qemu_chr_fe_deinit(&s->chr_notify_dev, false);
     }
 
-    if (s->iothread) {
-        colo_compare_timer_del(s);
-    }
+    colo_compare_timer_del(s);
 
     qemu_bh_delete(s->event_bh);
 
@@ -1470,9 +1468,7 @@ static void colo_compare_finalize(Object *obj)
         g_hash_table_destroy(s->connection_track_table);
     }
 
-    if (s->iothread) {
-        object_unref(OBJECT(s->iothread));
-    }
+    object_unref(OBJECT(s->iothread));
 
     g_free(s->pri_indev);
     g_free(s->sec_indev);
--

2.20.1

Reviewed-by on v1 1/1
#3 lore raw
In reply to Lukas Straub
Quoted 11 lines

-----Original Message-----
From: Lukas Straub <[email protected]>
Sent: Friday, July 31, 2020 1:06 PM
To: qemu-devel <[email protected]>
Cc: Peter Maydell <[email protected]>; Jason Wang <[email protected]>; Zhang, Chen <[email protected]>
Subject: [PATCH] colo-compare: Remove superfluous NULL-pointer checks for s->iothread

Quoted 5 lines

s->iothread is checked for NULL on object creation in s->colo_compare_complete,
so it's guaranteed not to be NULL.
This resolves a false alert from Coverity (CID 1429969).

Quoted 33 lines
---
 net/colo-compare.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
net/colo-compare.c index renamed from net/colo-compare.c +0 -0

cc15f23dea..2c20de1537 100644

net/colo-compare.c +2 -7
@@ -1442,9 +1442,7 @@ static void colo_compare_finalize(Object *obj)
         qemu_chr_fe_deinit(&s->chr_notify_dev, false);
     }
 
-    if (s->iothread) {
-        colo_compare_timer_del(s);
-    }
+    colo_compare_timer_del(s);
 
     qemu_bh_delete(s->event_bh);
 
@@ -1470,9 +1468,7 @@ static void colo_compare_finalize(Object *obj)
         g_hash_table_destroy(s->connection_track_table);
     }
 
-    if (s->iothread) {
-        object_unref(OBJECT(s->iothread));
-    }
+    object_unref(OBJECT(s->iothread));
 
     g_free(s->pri_indev);
     g_free(s->sec_indev);
--

2.20.1

Applied
#4 lore raw
In reply to Lukas Straub
Quoted 25 lines · Lukas Straub

s->iothread is checked for NULL on object creation in colo_compare_complete, so it's guaranteed not to be NULL.
This resolves a false alert from Coverity (CID 1429969).

---
  net/colo-compare.c | 8 ++------
  1 file changed, 2 insertions(+), 6 deletions(-)
net/colo-compare.c +1 -3
index cc15f23dea..2c20de1537 100644
@@ -1442,9 +1442,7 @@ static void colo_compare_finalize(Object *obj)
          qemu_chr_fe_deinit(&s->chr_notify_dev, false);
      }
 
-    if (s->iothread) {
-        colo_compare_timer_del(s);
-    }
+    colo_compare_timer_del(s);
 
      qemu_bh_delete(s->event_bh);
 

net/colo-compare.c static void colo_compare_finalize(Object *obj) · line 1474

Quoted 10 lines
net/colo-compare.c +1 -3
@@ -1470,9 +1468,7 @@ static void colo_compare_finalize(Object *obj)
          g_hash_table_destroy(s->connection_track_table);
      }
 
-    if (s->iothread) {
-        object_unref(OBJECT(s->iothread));
-    }
+    object_unref(OBJECT(s->iothread));
 
      g_free(s->pri_indev);
      g_free(s->sec_indev);

Applied.

Thanks