tech-kern archive

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

Re: kmem_alloc(0, f)



joerg%bec.de@localhost (Joerg Sonnenberger) writes:

>On Sun, Jul 30, 2017 at 03:23:50PM -0000, Michael van Elst wrote:
>> martin%duskware.de@localhost (Martin Husemann) writes:
>> 
>> >On Sat, Jul 29, 2017 at 02:04:42PM +0000, Taylor R Campbell wrote:
>> >> This seems like a foot-oriented panic gun, and it's been a source of
>> >> problems in the past.  Can we change it?
>> 
>> >I think it is a valuable tool to catch driver bugs early during
>> >developement, but wouldn't mind to reduce it to a KASSERT.
>> 
>> So what does kmem_alloc(0, KM_SLEEP) do? fail where KM_SLEEP says it
>> cannot fail? I don't think that it can return a zero sized allocation
>> (i.e. ptr != NULL that cannot be dereferenced).

>Just return a NULL pointer? That said, I do prefer just declaring it
>invalid...

Returning a NULL pointer (currently equivalent to return failure) is
what KM_SLEEP guarantees will not happen. By declaring a NULL pointer
a failure if that flag was given (and a failure if that flag is missing)
you open a can of worms.

Declaring a zero sized allocation invalid (as is now) is indeed preferrable.

-- 
-- 
                                Michael van Elst
Internet: mlelstv%serpens.de@localhost
                                "A potential Snark may lurk in every tree."


Home | Main Index | Thread Index | Old Index