[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] libxc: remove tests of alloca() return value
# HG changeset patch # User David Vrabel <david.vrabel@xxxxxxxxxx> # Date 1329759109 0 # Node ID 9cc7961d8f5cf04e85d659c843474ac922ff288d # Parent 1c631e9013368560ea2a38029ab709c2885aa1b3 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> --- diff -r 1c631e901336 -r 9cc7961d8f5c tools/libxc/xc_linux_osdep.c --- a/tools/libxc/xc_linux_osdep.c Mon Feb 20 17:30:18 2012 +0000 +++ b/tools/libxc/xc_linux_osdep.c Mon Feb 20 17:31:49 2012 +0000 @@ -243,63 +243,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; } } @@ -525,8 +516,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 |