Subject: Re: m_get(), MGET(), and MGETHDR() with M_WAIT
To: Chris G Demetriou <>
From: Thorsten Lockert <tholo@SigmaSoft.COM>
List: tech-kern
Date: 06/05/1996 15:59:24
> > > What i'm wondering is, in their 'well-documented' definitions, are
> > > they ever allowed to return NULL in that case?
> > 
> > Well, Stevens says that the return value of m_get() should always be checked,
> > but his argument for this seems rather off the mark.
> > 
> > Looking at the definition of MGET() and m_retry(), it's obvious that the
> > answer depends on whether `malloc(.., M_WAIT)'  can ever return NULL.
> > It appears that it can, given that kmem_malloc() in vm_kern.c can.
> no, malloc(... M_WAIT) _cannot_ return NULL.  Like i noted, that's the
> current implementation, and i'm not as much concerned about that as I
> am about what the code using m_get(... M_WAIT ...) _should_ be doing.

malloc(..., M_WAIT) is not allowed to return NULL.  Checking for a NULL
return when called with M_WAIT is superflous.  However, perhaps some of
the cases that now use _MWAIT and do check should be changed to M_NOWAIT?

Thorsten Lockert        | | Universe, n.:
1238B Page Street       | |         The problem.
San Francisco, CA 94117 |      |