Patchwork [1.1,4/6] dma: the passed io_func does not return NULL

login
register
mail settings
Submitter Paolo Bonzini
Date Nov. 14, 2011, 4:50 p.m.
Message ID <1321289454-9219-5-git-send-email-pbonzini@redhat.com>
Download mbox | patch
Permalink /patch/125562/
State New
Headers show

Comments

Paolo Bonzini - Nov. 14, 2011, 4:50 p.m.
Initially found with the following semantic patch:

@ type @
BlockDriverAIOCB *x;
expression E;
@@
  x = E;
- if (x == NULL) { ... }

@ acb1 @
expression E, E1;
@@
  E1->acb = E;
- if (E1->acb == NULL) { ... }

@ aiocb1 @
expression E, E1;
@@
  E1->aiocb = E;
- if (E1->aiocb == NULL) { ... }

@ acb @
expression E, E1;
@@
  E1.acb = E;
- if (E1.acb == NULL) { ... }

@ aiocb @
expression E, E1;
@@
  E1.aiocb = E;
- if (E1.aiocb == NULL) { ... }

but changed manually to include an assert.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 dma-helpers.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)

Patch

diff --git a/dma-helpers.c b/dma-helpers.c
index bdcd38c..a79a2f9 100644
--- a/dma-helpers.c
+++ b/dma-helpers.c
@@ -136,9 +136,7 @@  static void dma_bdrv_cb(void *opaque, int ret)
 
     dbs->acb = dbs->io_func(dbs->bs, dbs->sector_num, &dbs->iov,
                             dbs->iov.size / 512, dma_bdrv_cb, dbs);
-    if (!dbs->acb) {
-        dma_complete(dbs, -EIO);
-    }
+    assert(dbs->acb);
 }
 
 static void dma_aio_cancel(BlockDriverAIOCB *acb)