summaryrefslogtreecommitdiffstats
path: root/lib/libc
diff options
context:
space:
mode:
authoralex <alex@FreeBSD.org>1997-01-16 21:58:40 +0000
committeralex <alex@FreeBSD.org>1997-01-16 21:58:40 +0000
commita3118e8c6826349b3fc54da3850d6dea994a3a35 (patch)
treed61898dd79824c10ca33127214d8569c804559c2 /lib/libc
parent752ba4d26f2e94cc31940f50407a6b18b86ee0e8 (diff)
downloadFreeBSD-src-a3118e8c6826349b3fc54da3850d6dea994a3a35.zip
FreeBSD-src-a3118e8c6826349b3fc54da3850d6dea994a3a35.tar.gz
Sweep through the tree fixing mmap() usage:
- Use MAP_FAILED instead of the constant -1 to indicate failure (required by POSIX). - Removed flag arguments of '0' (required by POSIX). - Fixed code which expected an error return of 0. - Fixed code which thought any address with the high bit set was an error. - Check for failure where no checks were present. Discussed with: bde
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/db/recno/rec_open.c2
-rw-r--r--lib/libc/gen/nlist.c4
2 files changed, 3 insertions, 3 deletions
diff --git a/lib/libc/db/recno/rec_open.c b/lib/libc/db/recno/rec_open.c
index 51d8a3c..8f8eff2 100644
--- a/lib/libc/db/recno/rec_open.c
+++ b/lib/libc/db/recno/rec_open.c
@@ -169,7 +169,7 @@ slow: if ((t->bt_rfp = fdopen(rfd, "r")) == NULL)
t->bt_msize = sb.st_size;
if ((t->bt_smap = mmap(NULL, t->bt_msize,
PROT_READ, MAP_PRIVATE, rfd,
- (off_t)0)) == (caddr_t)-1)
+ (off_t)0)) == MAP_FAILED)
goto slow;
t->bt_cmap = t->bt_smap;
t->bt_emap = t->bt_smap + sb.st_size;
diff --git a/lib/libc/gen/nlist.c b/lib/libc/gen/nlist.c
index 7292452..7415cbe 100644
--- a/lib/libc/gen/nlist.c
+++ b/lib/libc/gen/nlist.c
@@ -99,8 +99,8 @@ __fdnlist(fd, list)
* without making the memory allocation permanent as with
* malloc/free (i.e., munmap will return it to the system).
*/
- a_out_mmap = mmap(NULL, (size_t)st.st_size, PROT_READ, 0, fd, (off_t)0);
- if (a_out_mmap == (char *)-1)
+ a_out_mmap = mmap(NULL, (size_t)st.st_size, PROT_READ, MAP_PRIVATE, fd, (off_t)0);
+ if (a_out_mmap == MAP_FAILED)
return (-1);
exec = (struct exec *)a_out_mmap;
OpenPOWER on IntegriCloud