From: Wim Taymans Date: Sat, 15 Jun 2002 16:12:20 +0000 (+0000) Subject: Better error handling when mmap'ing X-Git-Tag: BRANCH-RELEASE-0_4_0-ROOT~51 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=32f702aa20c4e9ca3013056154b525eeb962549e;p=platform%2Fupstream%2Fgstreamer.git Better error handling when mmap'ing Original commit message from CVS: Better error handling when mmap'ing --- diff --git a/gst/cothreads.c b/gst/cothreads.c index 88be004..6028b7f 100644 --- a/gst/cothreads.c +++ b/gst/cothreads.c @@ -146,7 +146,7 @@ cothread_state* cothread_create (cothread_context *ctx) { cothread_state *thread; - void *sp; + void *sp, *mmaped = 0; guchar *stack_end; gint slot = 0; @@ -178,11 +178,16 @@ cothread_create (cothread_context *ctx) thread = (cothread_state *) (stack_end + ((slot - 1) * COTHREAD_STACKSIZE)); GST_DEBUG (0, "new stack at %p", thread); - if (mmap ((void *) thread, COTHREAD_STACKSIZE, - PROT_READ | PROT_WRITE | PROT_EXEC, MAP_FIXED | MAP_PRIVATE | MAP_ANON, -1, 0) == MAP_FAILED) { + mmaped = mmap ((void *) thread, COTHREAD_STACKSIZE, + PROT_READ | PROT_WRITE | PROT_EXEC, MAP_FIXED | MAP_PRIVATE | MAP_ANON, -1, 0); + if (mmaped == MAP_FAILED) { perror ("mmap'ing cothread stack space"); return NULL; } + if (mmaped != thread) { + g_warning ("could not mmap requested memory"); + return NULL; + } thread->ctx = ctx; thread->threadnum = slot;