Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/lib/librumpuser Check return value of posix_memalign ... alw...
details: https://anonhg.NetBSD.org/src/rev/f5bfc8031c25
branches: trunk
changeset: 755355:f5bfc8031c25
user: pooka <pooka%NetBSD.org@localhost>
date: Wed Jun 02 18:15:35 2010 +0000
description:
Check return value of posix_memalign ... always helpful to not return
garbage memory in case of failure.
diffstat:
lib/librumpuser/rumpuser.c | 15 ++++++++++++---
1 files changed, 12 insertions(+), 3 deletions(-)
diffs (40 lines):
diff -r 62f1d2421d7d -r f5bfc8031c25 lib/librumpuser/rumpuser.c
--- a/lib/librumpuser/rumpuser.c Wed Jun 02 18:05:28 2010 +0000
+++ b/lib/librumpuser/rumpuser.c Wed Jun 02 18:15:35 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rumpuser.c,v 1.5 2010/06/01 20:11:33 pooka Exp $ */
+/* $NetBSD: rumpuser.c,v 1.6 2010/06/02 18:15:35 pooka Exp $ */
/*
* Copyright (c) 2007-2010 Antti Kantee. All Rights Reserved.
@@ -27,7 +27,7 @@
#include <sys/cdefs.h>
#if !defined(lint)
-__RCSID("$NetBSD: rumpuser.c,v 1.5 2010/06/01 20:11:33 pooka Exp $");
+__RCSID("$NetBSD: rumpuser.c,v 1.6 2010/06/02 18:15:35 pooka Exp $");
#endif /* !lint */
/* thank the maker for this */
@@ -196,11 +196,20 @@
rumpuser_malloc(size_t howmuch, int alignment)
{
void *mem;
+ int rv;
if (alignment == 0)
alignment = sizeof(void *);
- posix_memalign(&mem, alignment, howmuch);
+ rv = posix_memalign(&mem, alignment, howmuch);
+ if (__predict_false(rv != 0)) {
+ if (rv == EINVAL) {
+ printf("rumpuser_malloc: invalid alignment %d\n",
+ alignment);
+ abort();
+ }
+ mem = NULL;
+ }
return mem;
}
Home |
Main Index |
Thread Index |
Old Index