[openib-general] Error code in "create" functions

Dror Goldenberg gdror at mellanox.co.il
Tue Aug 17 14:19:34 PDT 2004


Hi,

It appears that in some functions that perform allocation of objects, the
new
object pointer is being returned. For example:
	struct ib_pd *	 (*alloc_pd)(struct ib_device *device);
	struct ib_ah *	 (*create_ah)(struct ib_pd *pd,  struct ib_ah_attr
*ah_attr);
	struct ib_qp *	 (*create_qp)(struct ib_pd *pd,struct
ib_qp_init_attr *qp_init_attr,  struct ib_qp_cap *qp_cap);
	struct ib_srq *	 (*create_srq)(struct ib_pd *pd, void *srq_context,
struct ib_srq_attr *srq_attr);

My concern is about the ability to return error status. The failure may be
due
to lack of resources, in which case, returning NULL makes sense. However,
some may fail because of bad parameters being passed in. This is mainly
because these functions not only deal with memory allocation of the object,
they also deal with initialization of the object and configuration of the
HW.

It's not so bad just to return NULL when the operation fails and drop
the error code. But, even for the sake of debug and diagnostics, I'd 
consider allowing the propagation of a return code.

-Dror
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openfabrics.org/pipermail/general/attachments/20040818/692a1526/attachment.html>


More information about the general mailing list