Message ID | 50A0D09B.5080202@redhat.com |
---|---|
State | New |
Headers | show |
Il 12/11/2012 11:34, Kevin Wolf ha scritto: >> Note that the change from g_malloc0() to g_slice_alloc() should be safe >> since the freelist reuse case doesn't zero the AIOCB either. > > Of course the real reason is that all fields are set anyway. This doesn't necessarily apply for "subclasses", though. (It does for the reason Stefan mentioned, but it is not possible to make it apparent in the code). Paolo > diff --git a/block.c b/block.c > index 854ebd6..6f5a0e7 100644 > --- a/block.c > +++ b/block.c > @@ -3910,10 +3910,13 @@ void *qemu_aio_get(const AIOCBInfo *aiocb_info, > BlockDriverState *bs, > BlockDriverAIOCB *acb; > > acb = g_slice_alloc(aiocb_info->aiocb_size); > - acb->aiocb_info = aiocb_info; > - acb->bs = bs; > - acb->cb = cb; > - acb->opaque = opaque; > + *acb = (BlockDriverAIOCB) { > + .aiocb_info = aiocb_info, > + .bs = bs, > + .cb = cb, > + .opaque = opaque, > + }; > + > return acb; > } > > If you agree, I'll commit this on top of your series. > > Kevin >
Am 12.11.2012 11:37, schrieb Paolo Bonzini: > Il 12/11/2012 11:34, Kevin Wolf ha scritto: >>> Note that the change from g_malloc0() to g_slice_alloc() should be safe >>> since the freelist reuse case doesn't zero the AIOCB either. >> >> Of course the real reason is that all fields are set anyway. > > This doesn't necessarily apply for "subclasses", though. (It does for > the reason Stefan mentioned, but it is not possible to make it apparent > in the code). See? I really shouldn't review code any more. :-) Kevin
diff --git a/block.c b/block.c index 854ebd6..6f5a0e7 100644 --- a/block.c +++ b/block.c @@ -3910,10 +3910,13 @@ void *qemu_aio_get(const AIOCBInfo *aiocb_info, BlockDriverState *bs, BlockDriverAIOCB *acb; acb = g_slice_alloc(aiocb_info->aiocb_size); - acb->aiocb_info = aiocb_info; - acb->bs = bs; - acb->cb = cb; - acb->opaque = opaque; + *acb = (BlockDriverAIOCB) { + .aiocb_info = aiocb_info, + .bs = bs, + .cb = cb, + .opaque = opaque, + }; + return acb; }