xcp-1.6-updates/xen-4.1.hg
changeset 23257:bcf1250a14e8
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@citrix.com>
Cc: Santosh Jodh <santosh.jodh@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
xen-unstable changeset: 24832:9cc7961d8f5c
xen-unstable date: Mon Feb 20 17:31:49 2012 +0000
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@citrix.com>
Cc: Santosh Jodh <santosh.jodh@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
xen-unstable changeset: 24832:9cc7961d8f5c
xen-unstable date: Mon Feb 20 17:31:49 2012 +0000
author | David Vrabel <david.vrabel@citrix.com> |
---|---|
date | Wed Mar 07 09:39:45 2012 +0000 (2012-03-07) |
parents | b7efb9e1a041 |
children | dc7fc50b3594 |
files | tools/libxc/xc_linux_osdep.c |
line diff
1.1 --- a/tools/libxc/xc_linux_osdep.c Wed Mar 07 09:39:10 2012 +0000 1.2 +++ b/tools/libxc/xc_linux_osdep.c Wed Mar 07 09:39:45 2012 +0000 1.3 @@ -218,63 +218,54 @@ static void *linux_privcmd_map_foreign_b 1.4 * IOCTL_PRIVCMD_MMAPBATCH_V2 is not supported - fall back to 1.5 * IOCTL_PRIVCMD_MMAPBATCH. 1.6 */ 1.7 + privcmd_mmapbatch_t ioctlx; 1.8 xen_pfn_t *pfn = alloca(num * sizeof(*pfn)); 1.9 1.10 - if ( pfn ) 1.11 - { 1.12 - privcmd_mmapbatch_t ioctlx; 1.13 + memcpy(pfn, arr, num * sizeof(*arr)); 1.14 1.15 - memcpy(pfn, arr, num * sizeof(*arr)); 1.16 + ioctlx.num = num; 1.17 + ioctlx.dom = dom; 1.18 + ioctlx.addr = (unsigned long)addr; 1.19 + ioctlx.arr = pfn; 1.20 1.21 - ioctlx.num = num; 1.22 - ioctlx.dom = dom; 1.23 - ioctlx.addr = (unsigned long)addr; 1.24 - ioctlx.arr = pfn; 1.25 + rc = ioctl(fd, IOCTL_PRIVCMD_MMAPBATCH, &ioctlx); 1.26 + 1.27 + rc = rc < 0 ? -errno : 0; 1.28 1.29 - rc = ioctl(fd, IOCTL_PRIVCMD_MMAPBATCH, &ioctlx); 1.30 - 1.31 - rc = rc < 0 ? -errno : 0; 1.32 - 1.33 - for ( i = 0; i < num; ++i ) 1.34 + for ( i = 0; i < num; ++i ) 1.35 + { 1.36 + switch ( pfn[i] ^ arr[i] ) 1.37 { 1.38 - switch ( pfn[i] ^ arr[i] ) 1.39 + case 0: 1.40 + err[i] = rc != -ENOENT ? rc : 0; 1.41 + continue; 1.42 + default: 1.43 + err[i] = -EINVAL; 1.44 + continue; 1.45 + case XEN_DOMCTL_PFINFO_PAGEDTAB: 1.46 + if ( rc != -ENOENT ) 1.47 { 1.48 - case 0: 1.49 - err[i] = rc != -ENOENT ? rc : 0; 1.50 - continue; 1.51 - default: 1.52 - err[i] = -EINVAL; 1.53 + err[i] = rc ?: -EINVAL; 1.54 continue; 1.55 - case XEN_DOMCTL_PFINFO_PAGEDTAB: 1.56 - if ( rc != -ENOENT ) 1.57 - { 1.58 - err[i] = rc ?: -EINVAL; 1.59 - continue; 1.60 - } 1.61 - rc = xc_map_foreign_batch_single(fd, dom, pfn + i, 1.62 + } 1.63 + rc = xc_map_foreign_batch_single(fd, dom, pfn + i, 1.64 (unsigned long)addr + ((unsigned long)i<<XC_PAGE_SHIFT)); 1.65 - if ( rc < 0 ) 1.66 - { 1.67 - rc = -errno; 1.68 - break; 1.69 - } 1.70 - rc = -ENOENT; 1.71 - continue; 1.72 + if ( rc < 0 ) 1.73 + { 1.74 + rc = -errno; 1.75 + break; 1.76 } 1.77 - break; 1.78 + rc = -ENOENT; 1.79 + continue; 1.80 } 1.81 + break; 1.82 + } 1.83 1.84 - if ( rc == -ENOENT && i == num ) 1.85 - rc = 0; 1.86 - else if ( rc ) 1.87 - { 1.88 - errno = -rc; 1.89 - rc = -1; 1.90 - } 1.91 - } 1.92 - else 1.93 + if ( rc == -ENOENT && i == num ) 1.94 + rc = 0; 1.95 + else if ( rc ) 1.96 { 1.97 - errno = -ENOMEM; 1.98 + errno = -rc; 1.99 rc = -1; 1.100 } 1.101 } 1.102 @@ -532,8 +523,6 @@ static void *do_gnttab_map_grant_refs(xc 1.103 1.104 map = alloca(sizeof(*map) + 1.105 (count - 1) * sizeof(struct ioctl_gntdev_map_grant_ref)); 1.106 - if ( map == NULL ) 1.107 - return NULL; 1.108 1.109 for ( i = 0; i < count; i++ ) 1.110 {