Message ID | 20101118144434.3B68DF90AB@ochil.suse.de |
---|---|
State | New |
Headers | show |
On Thu, Nov 18, 2010 at 03:44:34PM +0100, Hannes Reinecke wrote: > > qemu_malloc doesn't check for zero argument, so we need to > check ourselves. I'm not sure if it's a that good idea to remove the implicit ->sg != NULL assumption. Any reason you can't simply call qemu_sglist_init later?
On 11/19/2010 07:28 PM, Christoph Hellwig wrote: > On Thu, Nov 18, 2010 at 03:44:34PM +0100, Hannes Reinecke wrote: >> >> qemu_malloc doesn't check for zero argument, so we need to >> check ourselves. > > I'm not sure if it's a that good idea to remove the implicit > ->sg != NULL assumption. Any reason you can't simply call > qemu_sglist_init later? > We can actually drop this. It's a leftover from the old interface. Cheers, Hannes
diff --git a/dma-helpers.c b/dma-helpers.c index 712ed89..877b2c3 100644 --- a/dma-helpers.c +++ b/dma-helpers.c @@ -12,7 +12,10 @@ void qemu_sglist_init(QEMUSGList *qsg, int alloc_hint) { - qsg->sg = qemu_malloc(alloc_hint * sizeof(ScatterGatherEntry)); + if (alloc_hint > 0) + qsg->sg = qemu_malloc(alloc_hint * sizeof(ScatterGatherEntry)); + else + qsg->sg = NULL; qsg->nsg = 0; qsg->nalloc = alloc_hint; qsg->size = 0;
qemu_malloc doesn't check for zero argument, so we need to check ourselves. Signed-off-by: Hannes Reinecke <hare@suse.de> --- dma-helpers.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)