From: Kevin Wolf <kwolf@redhat.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com
Subject: [Qemu-devel] [PATCH] block: Avoid unchecked casts for AIOCBs
Date: Wed, 5 May 2010 11:51:58 +0200 [thread overview]
Message-ID: <1273053118-14001-1-git-send-email-kwolf@redhat.com> (raw)
Use container_of for one direction and &acb->common for the other one.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
block.c | 3 ++-
block/blkdebug.c | 4 ++--
block/qcow.c | 2 +-
block/qcow2.c | 2 +-
block/vdi.c | 2 +-
5 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/block.c b/block.c
index 7e3552d..10a2b31 100644
--- a/block.c
+++ b/block.c
@@ -2119,7 +2119,8 @@ typedef struct BlockDriverAIOCBSync {
static void bdrv_aio_cancel_em(BlockDriverAIOCB *blockacb)
{
- BlockDriverAIOCBSync *acb = (BlockDriverAIOCBSync *)blockacb;
+ BlockDriverAIOCBSync *acb =
+ container_of(blockacb, BlockDriverAIOCBSync, common);
qemu_bh_delete(acb->bh);
acb->bh = NULL;
qemu_aio_release(acb);
diff --git a/block/blkdebug.c b/block/blkdebug.c
index bb4a91a..8325f75 100644
--- a/block/blkdebug.c
+++ b/block/blkdebug.c
@@ -320,7 +320,7 @@ static void error_callback_bh(void *opaque)
static void blkdebug_aio_cancel(BlockDriverAIOCB *blockacb)
{
- BlkdebugAIOCB *acb = (BlkdebugAIOCB*) blockacb;
+ BlkdebugAIOCB *acb = container_of(blockacb, BlkdebugAIOCB, common);
qemu_aio_release(acb);
}
@@ -347,7 +347,7 @@ static BlockDriverAIOCB *inject_error(BlockDriverState *bs,
acb->bh = bh;
qemu_bh_schedule(bh);
- return (BlockDriverAIOCB*) acb;
+ return &acb->common;
}
static BlockDriverAIOCB *blkdebug_aio_readv(BlockDriverState *bs,
diff --git a/block/qcow.c b/block/qcow.c
index 2883c40..449858f 100644
--- a/block/qcow.c
+++ b/block/qcow.c
@@ -502,7 +502,7 @@ typedef struct QCowAIOCB {
static void qcow_aio_cancel(BlockDriverAIOCB *blockacb)
{
- QCowAIOCB *acb = (QCowAIOCB *)blockacb;
+ QCowAIOCB *acb = container_of(blockacb, QCowAIOCB, common);
if (acb->hd_aiocb)
bdrv_aio_cancel(acb->hd_aiocb);
qemu_aio_release(acb);
diff --git a/block/qcow2.c b/block/qcow2.c
index 21ed6f8..40bd32a 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -340,7 +340,7 @@ typedef struct QCowAIOCB {
static void qcow_aio_cancel(BlockDriverAIOCB *blockacb)
{
- QCowAIOCB *acb = (QCowAIOCB *)blockacb;
+ QCowAIOCB *acb = container_of(blockacb, QCowAIOCB, common);
if (acb->hd_aiocb)
bdrv_aio_cancel(acb->hd_aiocb);
qemu_aio_release(acb);
diff --git a/block/vdi.c b/block/vdi.c
index 1d257b4..2b4d2c2 100644
--- a/block/vdi.c
+++ b/block/vdi.c
@@ -469,7 +469,7 @@ static int vdi_is_allocated(BlockDriverState *bs, int64_t sector_num,
static void vdi_aio_cancel(BlockDriverAIOCB *blockacb)
{
/* TODO: This code is untested. How can I get it executed? */
- VdiAIOCB *acb = (VdiAIOCB *)blockacb;
+ VdiAIOCB *acb = container_of(blockacb, VdiAIOCB, common);
logout("\n");
if (acb->hd_aiocb) {
bdrv_aio_cancel(acb->hd_aiocb);
--
1.6.6.1
next reply other threads:[~2010-05-05 9:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-05 9:51 Kevin Wolf [this message]
2010-05-05 18:48 ` [Qemu-devel] [PATCH] block: Avoid unchecked casts for AIOCBs Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1273053118-14001-1-git-send-email-kwolf@redhat.com \
--to=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).