[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 Thu, Dec 03, 2015 at 11:22:17AM +0000, Ian Campbell wrote: > The existing xc_map_foreign_bulk-like interface encourages callers to > miss error checking for partial failure (by forgetting to scan the err > array). > > Add support for passing err==NULL which behaves in a > xc_map_foreign_pages-like manner and returns a global error for any > failure. > > While documenting this also clarify the overall behaviour and the > behaviour with err!=NULL. > > With this the compat wrapper of xc_map_foreign_pages() can be > simplified. > > Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx> > --- > v6: New > --- > tools/libs/foreignmemory/core.c | 30 > +++++++++++++++++++++- > .../libs/foreignmemory/include/xenforeignmemory.h | 24 ++++++++++++++--- > tools/libxc/xc_foreign_memory.c | 22 +--------------- > 3 files changed, 51 insertions(+), 25 deletions(-) > > 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? Wei. _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |