On Mon, Mar 16, 2015 at 09:16:31AM +0100, Olaf Hering wrote:
> On Fri, Mar 13, Wei Liu wrote:
> 
> > On Fri, Mar 13, 2015 at 02:45:28PM +0100, Olaf Hering wrote:
> > > On Thu, Mar 12, Ian Campbell wrote:
> > > 
> > > > On Thu, 2015-03-12 at 17:07 +0100, Olaf Hering wrote:
> > > > > Related: I see libxl_device_vscsi_dispose does now a pointer check, 
> > > > > so I
> > > > > assume its required to validate input in libxl_device_vscsi_get_host.
> > > > Not sure what you mean, you should call libxl_device_vcsci_init before
> > > > using the object and then _dispose when you are done.
> > > 
> > > I mean NULL pointer checks, will do that for at least *vscsi_host.
> > > 
> > 
> > That is only to make _dispose function NULL-tolerant. Why does that
> > affect your implementation?
> 
> I have not checked other code pats in libxl, but does libxl expect valid
> input? At least glibc for example expects valid input, str*(NULL) crashes.
> 

At the very least that's not the reason _dispose checks for NULL.
Dispose function checks for NULL so that you don't need to do the extra
check in caller like  "if(xx) _dispose(xx);"

Most if not all libxl APIs assume that the input is valid, because
following our paradigm, you must call _init function before using a
type. At the point you pass a type to libxl functions it should already
be initialised (which means it is valid).

Wei.

> Olaf

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

Reply via email to