diff options
author | Doug Hogan <doug@cvs.openbsd.org> | 2014-09-27 06:28:46 +0000 |
---|---|---|
committer | Doug Hogan <doug@cvs.openbsd.org> | 2014-09-27 06:28:46 +0000 |
commit | c2c41019dccafa128c9c0b6cd0545526e58461be (patch) | |
tree | 3ca68d0f221226c7fdf3e8c47c1a219052e94c2e /regress | |
parent | 01fe706a518a954b84ed44e18ff408cb4e7525ee (diff) |
Fix mmap() calls that check for a result other than MAP_FAILED.
ok tedu@
Diffstat (limited to 'regress')
-rw-r--r-- | regress/lib/libc/mkstemp/mkstemp_test.c | 2 | ||||
-rw-r--r-- | regress/misc/X11/blt/blt.c | 6 | ||||
-rw-r--r-- | regress/misc/X11/bltone/bltone.c | 6 | ||||
-rw-r--r-- | regress/sys/kern/mmap3/mmaptest.c | 4 |
4 files changed, 9 insertions, 9 deletions
diff --git a/regress/lib/libc/mkstemp/mkstemp_test.c b/regress/lib/libc/mkstemp/mkstemp_test.c index ef973b061b6..c1c05eae39d 100644 --- a/regress/lib/libc/mkstemp/mkstemp_test.c +++ b/regress/lib/libc/mkstemp/mkstemp_test.c @@ -122,7 +122,7 @@ main(void) cwd[clen++] = '/'; cwd[clen] = '\0'; p = mmap(NULL, pg * 3, PROT_READ | PROT_WRITE, MAP_ANON, -1, 0); - if (p == NULL) + if (p == MAP_FAILED) err(1, "mmap"); if (mprotect(p, pg, PROT_NONE) || mprotect(p + pg * 2, pg, PROT_NONE)) err(1, "mprotect"); diff --git a/regress/misc/X11/blt/blt.c b/regress/misc/X11/blt/blt.c index 7d8df9edd25..18e6a360c5d 100644 --- a/regress/misc/X11/blt/blt.c +++ b/regress/misc/X11/blt/blt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: blt.c,v 1.2 2013/10/28 08:47:43 jsg Exp $ */ +/* $OpenBSD: blt.c,v 1.3 2014/09/27 06:28:45 doug Exp $ */ /* * Written by Mark Kettenis <kettenis@openbsd.org> 2004 Public Domain */ @@ -34,10 +34,10 @@ main (void) pagesize = getpagesize(); src = mmap(NULL, 2 * pagesize, PROT_READ|PROT_WRITE, MAP_ANON, -1, 0); - assert(src); + assert(src != MAP_FAILED); dst = mmap(NULL, 2 * pagesize, PROT_READ|PROT_WRITE, MAP_ANON, -1, 0); - assert(dst); + assert(dst != MAP_FAILED); mprotect((char *)src + pagesize, pagesize, PROT_NONE); src = (FbBits *)((char *)src + (pagesize - sizeof map)); diff --git a/regress/misc/X11/bltone/bltone.c b/regress/misc/X11/bltone/bltone.c index 36f67e6ba65..575e554f038 100644 --- a/regress/misc/X11/bltone/bltone.c +++ b/regress/misc/X11/bltone/bltone.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bltone.c,v 1.5 2013/10/28 08:47:43 jsg Exp $ */ +/* $OpenBSD: bltone.c,v 1.6 2014/09/27 06:28:45 doug Exp $ */ /* * Written by Mark Kettenis <kettenis@openbsd.org> 2004 Public Domain */ @@ -31,10 +31,10 @@ main (void) pagesize = getpagesize(); src = mmap(NULL, 2 * pagesize, PROT_READ|PROT_WRITE, MAP_ANON, -1, 0); - assert(src); + assert(src != MAP_FAILED); dst = mmap(NULL, 2 * pagesize, PROT_READ|PROT_WRITE, MAP_ANON, -1, 0); - assert(dst); + assert(dst != MAP_FAILED); mprotect((char *)src + pagesize, pagesize, PROT_NONE); src = (FbStip *)((char *)src + (pagesize - sizeof mask)); diff --git a/regress/sys/kern/mmap3/mmaptest.c b/regress/sys/kern/mmap3/mmaptest.c index 1318d46c41f..1e8ee706910 100644 --- a/regress/sys/kern/mmap3/mmaptest.c +++ b/regress/sys/kern/mmap3/mmaptest.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mmaptest.c,v 1.6 2006/02/20 17:03:27 mickey Exp $ */ +/* $OpenBSD: mmaptest.c,v 1.7 2014/09/27 06:28:45 doug Exp $ */ /* * Copyright (c) 2002 Marc Espie. * @@ -58,7 +58,7 @@ main(int argc, char *argv[]) if (fd == -1) err(1, "open(test.out) 2"); a2 = mmap(NULL, AREA, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0); - if (!a2) + if (a2 == MAP_FAILED) err(1, "mmap"); a2[10] = 3; msync(a2, AREA, MS_SYNC|MS_INVALIDATE); |