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

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

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

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).

Signed-off-by: Lukas Straub <[hidden email]>
---
 net/colo-compare.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/net/colo-compare.c b/net/colo-compare.c
index cc15f23dea..2c20de1537 100644
--- a/net/colo-compare.c
+++ b/net/colo-compare.c
@@ -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

attachment0 (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] colo-compare: Remove superfluous NULL-pointer checks for s->iothread

Philippe Mathieu-Daudé-3
On 7/31/20 7:06 AM, Lukas Straub wrote:
> 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).
>
> Signed-off-by: Lukas Straub <[hidden email]>

Reviewed-by: Philippe Mathieu-Daudé <[hidden email]>

> ---
>  net/colo-compare.c | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/net/colo-compare.c b/net/colo-compare.c
> index cc15f23dea..2c20de1537 100644
> --- a/net/colo-compare.c
> +++ b/net/colo-compare.c
> @@ -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);
>


Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] colo-compare: Remove superfluous NULL-pointer checks for s->iothread

Li Qiang-2
In reply to this post by Lukas Straub
Lukas Straub <[hidden email]> 于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).
>
> Signed-off-by: Lukas Straub <[hidden email]>

Reviewed-by: Li Qiang <[hidden email]>

> ---
>  net/colo-compare.c | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/net/colo-compare.c b/net/colo-compare.c
> index cc15f23dea..2c20de1537 100644
> --- a/net/colo-compare.c
> +++ b/net/colo-compare.c
> @@ -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

Reply | Threaded
Open this post in threaded view
|

RE: [PATCH] colo-compare: Remove superfluous NULL-pointer checks for s->iothread

Zhang Chen-3
In reply to this post by Lukas Straub


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

Reviewed-by: Zhang Chen <[hidden email]>

> Signed-off-by: Lukas Straub <[hidden email]>
> ---
>  net/colo-compare.c | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/net/colo-compare.c b/net/colo-compare.c index
> cc15f23dea..2c20de1537 100644
> --- a/net/colo-compare.c
> +++ b/net/colo-compare.c
> @@ -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

Reply | Threaded
Open this post in threaded view
|

Re: [PATCH] colo-compare: Remove superfluous NULL-pointer checks for s->iothread

Jason Wang-8
In reply to this post by Lukas Straub

On 2020/7/31 下午1:06, Lukas Straub wrote:

> 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).
>
> Signed-off-by: Lukas Straub <[hidden email]>
> ---
>   net/colo-compare.c | 8 ++------
>   1 file changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/net/colo-compare.c b/net/colo-compare.c
> index cc15f23dea..2c20de1537 100644
> --- a/net/colo-compare.c
> +++ b/net/colo-compare.c
> @@ -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);


Applied.

Thanks