Skip to contentSkip to conversation

block: remove redundant check before g_slist_find()

PATCH Applied Alberto Garcia 3 participants 3 messages Jun 29, 2015 – Jun 30, 2015 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 block: remove redundant check before g_slist_find()

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.

---
 block/io.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
block/io.c +1 -1
index e295992..2f7f889 100644
@@ -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);
         }
     }
Signature · 1 line
2.1.4
#1 lore raw
Quoted 14 lines · Alberto Garcia

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.

---
 block/io.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
block/io.c +0 -0
index e295992..2f7f889 100644

block/io.c void bdrv_drain_all(void) · line 289

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