[openib-general] [PATCH 4/13] Re-write cma_work_handler error cases

Roland Dreier rdreier at cisco.com
Thu Oct 12 11:38:25 PDT 2006


What's the motivation here?  Lots of these patches look like a step
backwards, for example this:

 > -	if (!cma_comp_exch(id_priv, work->old_state, work->new_state))
 > -		goto out;
 > -
 > -	if (id_priv->id.event_handler(&id_priv->id, &work->event)) {
 > -		cma_exch(id_priv, CMA_DESTROYING);
 > -		destroy = 1;
 > +	if (cma_comp_exch(id_priv, work->old_state, work->new_state)) {
 > +		if (id_priv->id.event_handler(&id_priv->id, &work->event)) {
 > +			cma_exch(id_priv, CMA_DESTROYING);
 > +			destroy = 1;
 > +		}
 >  	}

I find it much easier to read code like:

	if (error_happens())
		goto err;

	if (another_error_happens())
		goto err;

	do_stuff();

rather than

	if (!error_happens())
		if (!another_error_happens())
			do_stuff();

I really think it's preferable to use gotos to move error paths
out-of-line and keep the common case as the main flow.

 - R.




More information about the general mailing list