The line if ((reqp = nrreq_free))  is the same as:

reqp = nrreq_free;
if (reqp != NULL) {

David

On Aug 15, 2006, at 4:58 AM, Aneesh Kumar wrote:

I am bit confused with this function.  The function is marked below.
Is thecheck for
reqp == nrreq_free valid ? reqp is a local variable. Same is the case
with mhsvrallocnode. Any thing i am missing.

STATIC struct nrreq *
allocnrreq(void)
{
       struct nrreq *reqp;

       LOCK_SPIN_LOCK(&nrreq_free_lock);
       if ((reqp = nrreq_free)) {
               nrreq_free = reqp->req_next;
               nrreq_free_count--;
       }
       UNLOCK_SPIN_LOCK(&nrreq_free_lock);
#ifdef DEBUG
       SSI_ASSERT(reqp== NULL || reqp->req_agent == 0);
#endif
       if (reqp == NULL) {
               nrreq_malloc_count++;
               reqp = (struct nrreq *)malloc(sizeof(struct nrreq));
               if (reqp == NULL)
                       panic("allocnrreq: Can't malloc request struct\n");
#ifdef __KERNEL__
               INIT_EVENT(&reqp->req_done);
#endif
       }
       return reqp;
}

David B. Zafman

mailto:david@zafman.com

-Microsoft and the BSA, the BEST advocates to get companies to switch to Linux! 

Thanks Microsoft!