[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] use qemu_malloc and friends consistently

From: Kevin Wolf
Subject: Re: [Qemu-devel] [PATCH] use qemu_malloc and friends consistently
Date: Fri, 29 May 2009 14:05:10 +0200
User-agent: Thunderbird (X11/20090320)

address@hidden schrieb:
> ----- "Kevin Wolf" <address@hidden> a écrit :
>> address@hidden schrieb:
>>> Kevin,
>>> I certainly understand your goal ... 
>>> Anyway, I will update my patche and resubmit.
>>> BTW it has to be noted that most of the time the return value of
>> malloc/qemu_malloc is not checked which can also prove problematic
>> whatever the qemu_malloc/malloc behavior is.
>> It doesn't need to be checked, qemu_malloc never returns if it fails.
>> If
>> malloc(0) returns NULL (on success!) checking it is even wrong in
>> places
>> where this can happen.
> I don't necessarily speak about the malloc(0) case.
> Up to now the qemu_io code (for example) was using malloc() without checking 
> for the returned value. If allocation fails, I believe it would be quite 
> wrong to pass the returned (NULL) pointer to memcpy/memset/memcmp whatever 
> platform you are considering ...
> So it seems to me you definitively need a way to dicriminate between the 
> value returned on succesfull malloc(0) and the value returned on a failed 
> malloc(1000).

I should not have mentioned the malloc(0) in this mail, it only adds to
the confusion.

What I wanted to say is that a failed qemu_malloc doesn't return
anything because it aborts (this code is in oom_check). So the caller
needs not and even cannot check for failure.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]