[ofw] __cleanup_cep() oddity

Fab Tillier ftillier at microsoft.com
Sun Dec 6 17:08:22 PST 2009


Hi Sean

Sean Hefty wrote on Thu, 3 Dec 2009 at 15:06:20

> __cleanup_cep() in al_cm_cep.c has the following fragment:
> 
> 	/* If we've already come through here, we're done. */
> 	if( p_cep->state == CEP_STATE_DESTROY ||
> 		p_cep->state == CEP_STATE_DREQ_DESTROY )
> 	{
> 		AL_EXIT( AL_DBG_CM );
> 		return -1;
> 	}
> 
> Does anyone know *why* this check is here returns -1?
>
> The other return path from this call decrements p_cep->ref_cnt and
> returns that as the result.  This is used in a couple of places to
> determine whether or not the destroy callback should be invoked.
> 
> It seems odd that the code allows calling cleanup twice, with different
> behavior and meaning to the return value.

I'd guess this is to trap an error case that can't happen.  Probably safe to put an assert there, or if running with a debug build is too slow, put an explicit bugcheck and then run tests and see if you hit it.

-Fab



More information about the ofw mailing list