* [PATCH] libxc: remove tests of alloca() return value
@ 2012-02-17 12:10 David Vrabel
2012-02-17 13:24 ` Tim Deegan
2012-02-20 17:31 ` Ian Jackson
0 siblings, 2 replies; 5+ messages in thread
From: David Vrabel @ 2012-02-17 12:10 UTC (permalink / raw)
To: xen-devel; +Cc: David Vrabel, Santosh Jodh
From: David Vrabel <david.vrabel@citrix.com>
alloca() does not return NULL on an allocation failure so remove the
unneccessary tests.
Signed-off-by: David Vrabel <david.vrabel@citrix.com>
Cc: Santosh Jodh <santosh.jodh@citrix.com>
---
tools/libxc/xc_linux_osdep.c | 79 ++++++++++++++++++------------------------
1 files changed, 34 insertions(+), 45 deletions(-)
diff --git a/tools/libxc/xc_linux_osdep.c b/tools/libxc/xc_linux_osdep.c
index 779fcd7..896f5c1 100644
--- a/tools/libxc/xc_linux_osdep.c
+++ b/tools/libxc/xc_linux_osdep.c
@@ -243,63 +243,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<<XC_PAGE_SHIFT));
- if ( rc < 0 )
- {
- rc = -errno;
- break;
- }
- rc = -ENOENT;
- continue;
+ if ( rc < 0 )
+ {
+ rc = -errno;
+ break;
}
- break;
- }
-
- if ( rc == -ENOENT && i == num )
- rc = 0;
- else if ( rc )
- {
- errno = -rc;
- rc = -1;
+ rc = -ENOENT;
+ continue;
}
+ break;
}
- else
+
+ if ( rc == -ENOENT && i == num )
+ rc = 0;
+ else if ( rc )
{
- errno = -ENOMEM;
+ errno = -rc;
rc = -1;
}
}
@@ -525,8 +516,6 @@ static void *linux_gnttab_grant_map(xc_gnttab *xch, xc_osdep_handle h,
map = alloca(sizeof(*map) +
(count - 1) * sizeof(struct ioctl_gntdev_map_grant_ref));
- if ( map == NULL )
- return NULL;
for ( i = 0; i < count; i++ )
{
--
1.7.2.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] libxc: remove tests of alloca() return value
2012-02-17 12:10 [PATCH] libxc: remove tests of alloca() return value David Vrabel
@ 2012-02-17 13:24 ` Tim Deegan
2012-02-17 13:32 ` David Vrabel
2012-02-20 17:31 ` Ian Jackson
1 sibling, 1 reply; 5+ messages in thread
From: Tim Deegan @ 2012-02-17 13:24 UTC (permalink / raw)
To: David Vrabel; +Cc: xen-devel, Santosh Jodh
At 12:10 +0000 on 17 Feb (1329480642), David Vrabel wrote:
> From: David Vrabel <david.vrabel@citrix.com>
>
> alloca() does not return NULL on an allocation failure
Nack: on some BSD systems it does.
Tim.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] libxc: remove tests of alloca() return value
2012-02-17 13:24 ` Tim Deegan
@ 2012-02-17 13:32 ` David Vrabel
2012-02-17 13:38 ` Tim Deegan
0 siblings, 1 reply; 5+ messages in thread
From: David Vrabel @ 2012-02-17 13:32 UTC (permalink / raw)
To: Tim Deegan; +Cc: xen-devel@lists.xensource.com, Santosh Jodh
On 17/02/12 13:24, Tim Deegan wrote:
> At 12:10 +0000 on 17 Feb (1329480642), David Vrabel wrote:
>> From: David Vrabel <david.vrabel@citrix.com>
>>
>> alloca() does not return NULL on an allocation failure
>
> Nack: on some BSD systems it does.
xc_linux_osdep.c is only built if CONFIG_Linux is set.
David
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] libxc: remove tests of alloca() return value
2012-02-17 13:32 ` David Vrabel
@ 2012-02-17 13:38 ` Tim Deegan
0 siblings, 0 replies; 5+ messages in thread
From: Tim Deegan @ 2012-02-17 13:38 UTC (permalink / raw)
To: David Vrabel; +Cc: xen-devel@lists.xensource.com, Santosh Jodh
At 13:32 +0000 on 17 Feb (1329485571), David Vrabel wrote:
> On 17/02/12 13:24, Tim Deegan wrote:
> > At 12:10 +0000 on 17 Feb (1329480642), David Vrabel wrote:
> >> From: David Vrabel <david.vrabel@citrix.com>
> >>
> >> alloca() does not return NULL on an allocation failure
> >
> > Nack: on some BSD systems it does.
>
> xc_linux_osdep.c is only built if CONFIG_Linux is set.
My apologies - I didn't see that this was in os-specific code.
Tim.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] libxc: remove tests of alloca() return value
2012-02-17 12:10 [PATCH] libxc: remove tests of alloca() return value David Vrabel
2012-02-17 13:24 ` Tim Deegan
@ 2012-02-20 17:31 ` Ian Jackson
1 sibling, 0 replies; 5+ messages in thread
From: Ian Jackson @ 2012-02-20 17:31 UTC (permalink / raw)
To: David Vrabel; +Cc: xen-devel, Santosh Jodh
David Vrabel writes ("[Xen-devel] [PATCH] libxc: remove tests of alloca() return value"):
> alloca() does not return NULL on an allocation failure so remove the
> unneccessary tests.
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-02-20 17:31 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-17 12:10 [PATCH] libxc: remove tests of alloca() return value David Vrabel
2012-02-17 13:24 ` Tim Deegan
2012-02-17 13:32 ` David Vrabel
2012-02-17 13:38 ` Tim Deegan
2012-02-20 17:31 ` Ian Jackson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).