<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2654.45">
<TITLE>Error code in "create" functions</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=2>Hi,</FONT>
</P>

<P><FONT SIZE=2>It appears that in some functions that perform allocation of objects, the new</FONT>
<BR><FONT SIZE=2>object pointer is being returned. For example:</FONT>
<BR>        <FONT SIZE=2>struct ib_pd *   (*alloc_pd)(struct ib_device *device);</FONT>
<BR>        <FONT SIZE=2>struct ib_ah *   (*create_ah)(struct ib_pd *pd,  struct ib_ah_attr *ah_attr);</FONT>
<BR>        <FONT SIZE=2>struct ib_qp *   (*create_qp)(struct ib_pd *pd,struct ib_qp_init_attr *qp_init_attr,  struct ib_qp_cap *qp_cap);</FONT></P>

<P>        <FONT SIZE=2>struct ib_srq *  (*create_srq)(struct ib_pd *pd, void *srq_context,  struct ib_srq_attr *srq_attr);</FONT>
</P>

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

<P><FONT SIZE=2>It's not so bad just to return NULL when the operation fails and drop</FONT>
<BR><FONT SIZE=2>the error code. But, even for the sake of debug and diagnostics, I'd </FONT>
<BR><FONT SIZE=2>consider allowing the propagation of a return code.</FONT>
</P>

<P><FONT SIZE=2>-Dror</FONT>
</P>

</BODY>
</HTML>