qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 01/16] Allow zero alloc_hint in qemu_sglist_init()
@ 2010-11-18 14:44 Hannes Reinecke
  2010-11-19 18:28 ` Christoph Hellwig
  0 siblings, 1 reply; 3+ messages in thread
From: Hannes Reinecke @ 2010-11-18 14:44 UTC (permalink / raw)
  To: qemu-devel; +Cc: stefanha, nab, kraxel


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(-)

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;
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH 01/16] Allow zero alloc_hint in qemu_sglist_init()
  2010-11-18 14:44 [Qemu-devel] [PATCH 01/16] Allow zero alloc_hint in qemu_sglist_init() Hannes Reinecke
@ 2010-11-19 18:28 ` Christoph Hellwig
  2010-11-22  9:01   ` Hannes Reinecke
  0 siblings, 1 reply; 3+ messages in thread
From: Christoph Hellwig @ 2010-11-19 18:28 UTC (permalink / raw)
  To: Hannes Reinecke; +Cc: stefanha, qemu-devel, nab, kraxel

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?

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH 01/16] Allow zero alloc_hint in qemu_sglist_init()
  2010-11-19 18:28 ` Christoph Hellwig
@ 2010-11-22  9:01   ` Hannes Reinecke
  0 siblings, 0 replies; 3+ messages in thread
From: Hannes Reinecke @ 2010-11-22  9:01 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: stefanha, qemu-devel, nab, kraxel

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
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Markus Rex, HRB 16746 (AG Nürnberg)

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-11-22  8:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-18 14:44 [Qemu-devel] [PATCH 01/16] Allow zero alloc_hint in qemu_sglist_init() Hannes Reinecke
2010-11-19 18:28 ` Christoph Hellwig
2010-11-22  9:01   ` Hannes Reinecke

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).