Skip to contentSkip to conversation

Allow zero alloc_hint in qemu_sglist_init()

PATCH In review Hannes Reinecke 2 participants 3 messages Nov 18, 2010 – Nov 22, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/16 Allow zero alloc_hint in qemu_sglist_init()

qemu_malloc doesn't check for zero argument, so we need to check ourselves.

---
 dma-helpers.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
dma-helpers.c +4 -1
index 712ed89..877b2c3 100644
@@ -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;
Signature · 1 line
1.7.1
#1 lore raw
Quoted 3 lines · Hannes Reinecke

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?

#2 lore raw
Quoted 9 lines · Christoph Hellwig
Quoted 3 lines · Hannes Reinecke

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

Signature · 4 lines
Dr. Hannes Reinecke		      zSeries & Storage
[email protected]			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Markus Rex, HRB 16746 (AG Nürnberg)