diff mbox

block: remove redundant check before g_slist_find()

Message ID 1435583533-5758-1-git-send-email-berto@igalia.com
State New
Headers show

Commit Message

Alberto Garcia June 29, 2015, 1:12 p.m. UTC
An empty GSList is represented by a NULL pointer, therefore it's a
perfectly valid argument for g_slist_find() and there's no need to
make any additional check.

Signed-off-by: Alberto Garcia <berto@igalia.com>
---
 block/io.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Alexander Yarygin June 29, 2015, 1:32 p.m. UTC | #1
Alberto Garcia <berto@igalia.com> writes:

> An empty GSList is represented by a NULL pointer, therefore it's a
> perfectly valid argument for g_slist_find() and there's no need to
> make any additional check.
>
> Signed-off-by: Alberto Garcia <berto@igalia.com>
> ---
>  block/io.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/block/io.c b/block/io.c
> index e295992..2f7f889 100644
> --- a/block/io.c
> +++ b/block/io.c
> @@ -283,7 +283,7 @@ void bdrv_drain_all(void)
>          }
>          aio_context_release(aio_context);
>
> -        if (!aio_ctxs || !g_slist_find(aio_ctxs, aio_context)) {
> +        if (!g_slist_find(aio_ctxs, aio_context)) {
>              aio_ctxs = g_slist_prepend(aio_ctxs, aio_context);
>          }
>      }

Seems ok to me.
Stefan Hajnoczi June 30, 2015, 12:54 p.m. UTC | #2
On Mon, Jun 29, 2015 at 04:12:13PM +0300, Alberto Garcia wrote:
> An empty GSList is represented by a NULL pointer, therefore it's a
> perfectly valid argument for g_slist_find() and there's no need to
> make any additional check.
> 
> Signed-off-by: Alberto Garcia <berto@igalia.com>
> ---
>  block/io.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Stefan
diff mbox

Patch

diff --git a/block/io.c b/block/io.c
index e295992..2f7f889 100644
--- a/block/io.c
+++ b/block/io.c
@@ -283,7 +283,7 @@  void bdrv_drain_all(void)
         }
         aio_context_release(aio_context);
 
-        if (!aio_ctxs || !g_slist_find(aio_ctxs, aio_context)) {
+        if (!g_slist_find(aio_ctxs, aio_context)) {
             aio_ctxs = g_slist_prepend(aio_ctxs, aio_context);
         }
     }