From: David Vrabel Date: Wed, 7 Mar 2012 09:39:45 +0000 (+0000) Subject: libxc: remove tests of alloca() return value X-Git-Tag: 4.1.3-rc1~31 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=425917b9d0a74f062d96fa94630fb81b7eb30cda;p=xen.git 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 Cc: Santosh Jodh Committed-by: Ian Jackson xen-unstable changeset: 24832:9cc7961d8f5c xen-unstable date: Mon Feb 20 17:31:49 2012 +0000 --- diff --git a/tools/libxc/xc_linux_osdep.c b/tools/libxc/xc_linux_osdep.c index 5ef5cd63f5..6477ad8607 100644 --- a/tools/libxc/xc_linux_osdep.c +++ b/tools/libxc/xc_linux_osdep.c @@ -218,63 +218,54 @@ static void *linux_privcmd_map_foreign_bulk(xc_interface *xch, xc_osdep_handle h * 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 ) - { - privcmd_mmapbatch_t ioctlx; - - memcpy(pfn, arr, num * sizeof(*arr)); + memcpy(pfn, arr, num * sizeof(*arr)); - ioctlx.num = num; - ioctlx.dom = dom; - ioctlx.addr = (unsigned long)addr; - ioctlx.arr = pfn; + ioctlx.num = num; + ioctlx.dom = dom; + ioctlx.addr = (unsigned long)addr; + ioctlx.arr = pfn; - rc = ioctl(fd, IOCTL_PRIVCMD_MMAPBATCH, &ioctlx); + rc = ioctl(fd, IOCTL_PRIVCMD_MMAPBATCH, &ioctlx); - rc = rc < 0 ? -errno : 0; + rc = rc < 0 ? -errno : 0; - for ( i = 0; i < num; ++i ) + for ( i = 0; i < num; ++i ) + { + switch ( pfn[i] ^ arr[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 ) { - case 0: - err[i] = rc != -ENOENT ? rc : 0; + err[i] = rc ?: -EINVAL; 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, + } + rc = xc_map_foreign_batch_single(fd, dom, pfn + i, (unsigned long)addr + ((unsigned long)i<