[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-4.1-testing] libxc: remove tests of alloca() return value
# HG changeset patch # User David Vrabel <david.vrabel@xxxxxxxxxx> # Date 1331113185 0 # Node ID bcf1250a14e8b5f7a63d7b9311687ee8d98b7853 # Parent b7efb9e1a041f46baa9816025d8bf33dd1976db8 libxc: remove tests of alloca() return value alloca() does not return NULL on an allocation failure on Linux so remove the unneccessary tests from this Linux-specific code. Signed-off-by: David Vrabel <david.vrabel@xxxxxxxxxx> Cc: Santosh Jodh <santosh.jodh@xxxxxxxxxx> Committed-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx> xen-unstable changeset: 24832:9cc7961d8f5c xen-unstable date: Mon Feb 20 17:31:49 2012 +0000 --- diff -r b7efb9e1a041 -r bcf1250a14e8 tools/libxc/xc_linux_osdep.c --- a/tools/libxc/xc_linux_osdep.c Wed Mar 07 09:39:10 2012 +0000 +++ b/tools/libxc/xc_linux_osdep.c Wed Mar 07 09:39:45 2012 +0000 @@ -218,63 +218,54 @@ * IOCTL_PRIVCMD_MMAPBATCH_V2 is not supported - fall back to * IOCTL_PRIVCMD_MMAPBATCH. */ + privcmd_mmapbatch_t ioctlx; xen_pfn_t *pfn = alloca(num * sizeof(*pfn)); - if ( pfn ) + memcpy(pfn, arr, num * sizeof(*arr)); + + ioctlx.num = num; + ioctlx.dom = dom; + ioctlx.addr = (unsigned long)addr; + ioctlx.arr = pfn; + + rc = ioctl(fd, IOCTL_PRIVCMD_MMAPBATCH, &ioctlx); + + rc = rc < 0 ? -errno : 0; + + for ( i = 0; i < num; ++i ) { - privcmd_mmapbatch_t ioctlx; + switch ( pfn[i] ^ arr[i] ) + { + case 0: + err[i] = rc != -ENOENT ? rc : 0; + continue; + default: + err[i] = -EINVAL; + continue; + case XEN_DOMCTL_PFINFO_PAGEDTAB: + if ( rc != -ENOENT ) + { + err[i] = rc ?: -EINVAL; + continue; + } + rc = xc_map_foreign_batch_single(fd, dom, pfn + i, + (unsigned long)addr + ((unsigned long)i<<XC_PAGE_SHIFT)); + if ( rc < 0 ) + { + rc = -errno; + break; + } + rc = -ENOENT; + continue; + } + break; + } - memcpy(pfn, arr, num * sizeof(*arr)); - - ioctlx.num = num; - ioctlx.dom = dom; - ioctlx.addr = (unsigned long)addr; - ioctlx.arr = pfn; - - rc = ioctl(fd, IOCTL_PRIVCMD_MMAPBATCH, &ioctlx); - - rc = rc < 0 ? -errno : 0; - - for ( i = 0; i < num; ++i ) - { - switch ( pfn[i] ^ arr[i] ) - { - case 0: - err[i] = rc != -ENOENT ? rc : 0; - continue; - default: - err[i] = -EINVAL; - continue; - case XEN_DOMCTL_PFINFO_PAGEDTAB: - if ( rc != -ENOENT ) - { - err[i] = rc ?: -EINVAL; - continue; - } - rc = xc_map_foreign_batch_single(fd, dom, pfn + i, - (unsigned long)addr + ((unsigned long)i<<XC_PAGE_SHIFT)); - if ( rc < 0 ) - { - rc = -errno; - break; - } - rc = -ENOENT; - continue; - } - break; - } - - if ( rc == -ENOENT && i == num ) - rc = 0; - else if ( rc ) - { - errno = -rc; - rc = -1; - } - } - else + if ( rc == -ENOENT && i == num ) + rc = 0; + else if ( rc ) { - errno = -ENOMEM; + errno = -rc; rc = -1; } } @@ -532,8 +523,6 @@ map = alloca(sizeof(*map) + (count - 1) * sizeof(struct ioctl_gntdev_map_grant_ref)); - if ( map == NULL ) - return NULL; for ( i = 0; i < count; i++ ) { _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |