[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH XEN v6 20/32] tools/libs/foreignmemory: Support err == NULL to map.



On Wed, 2015-12-09 at 12:22 +0000, Wei Liu wrote:
> > diff --git a/tools/libs/foreignmemory/core.c
> > b/tools/libs/foreignmemory/core.c
> > index 21dc7ee..91bea55 100644
> > --- a/tools/libs/foreignmemory/core.c
> > +++ b/tools/libs/foreignmemory/core.c
> > @@ -14,6 +14,8 @@
> > Â */
> > Â
> > Â#include <stdlib.h>
> > +#include <assert.h>
> > +#include <errno.h>
> > Â
> > Â#include "private.h"
> > Â
> > @@ -64,7 +66,33 @@ void *xenforeignmemory_map(xenforeignmemory_handle
> > *fmem,
> > ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂuint32_t dom, int prot,
> > ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂconst xen_pfn_t *arr, int *err, size_t num)
> > Â{
> > -ÂÂÂÂreturn osdep_xenforeignmemory_map(fmem, dom, prot, arr, err, num);
> > +ÂÂÂÂvoid *ret;
> > +ÂÂÂÂint *err_to_free = NULL;
> > +
> > +ÂÂÂÂif ( err == NULL )
> > +ÂÂÂÂÂÂÂÂerr = err_to_free = malloc(num * sizeof(int));
> > +
> 
> malloc can fail, which means when user passes in err==NULL there is two
> possible behaviours of this function?

Partially/Full success and "fail entirely reporting an error" you mean?
There are always those two possibilities, yes, regardless of err==NULL. I
think that's inline with the doc comment too.

If that's not what you were asking then I'm afraid I don't see what you are
getting at.

Ian.

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

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.