summaryrefslogtreecommitdiff
path: root/user/mmaptest.c
diff options
context:
space:
mode:
authorSanjit Bhat <[email protected]>2023-11-27 21:10:38 -0500
committerSanjit Bhat <[email protected]>2023-11-27 21:10:38 -0500
commit1c9102da1f5eb9dca30d08a7ed54a6540fe8c3cc (patch)
treea989d79b79d8deb5050c75e24eb0cc231e734141 /user/mmaptest.c
parentfc66c882be2fec6f607e28f2af8ccd5cf1a21dde (diff)
downloadxv6-labs-1c9102da1f5eb9dca30d08a7ed54a6540fe8c3cc.tar.gz
xv6-labs-1c9102da1f5eb9dca30d08a7ed54a6540fe8c3cc.tar.bz2
xv6-labs-1c9102da1f5eb9dca30d08a7ed54a6540fe8c3cc.zip
mmap: add err checking to all munmap calls
Diffstat (limited to 'user/mmaptest.c')
-rw-r--r--user/mmaptest.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/user/mmaptest.c b/user/mmaptest.c
index 0819622..8716a2a 100644
--- a/user/mmaptest.c
+++ b/user/mmaptest.c
@@ -232,10 +232,12 @@ mmap_test(void)
if(memcmp(p2, "67890", 5) != 0)
err("mmap2 mismatch");
- munmap(p1, PGSIZE);
+ if (munmap(p1, PGSIZE) == -1)
+ err("munmap (5)");
if(memcmp(p2, "67890", 5) != 0)
err("mmap2 mismatch (2)");
- munmap(p2, PGSIZE);
+ if (munmap(p2, PGSIZE) == -1)
+ err("munmap (6)");
printf("test mmap two files: OK\n");
@@ -276,7 +278,8 @@ fork_test(void)
err("fork");
if (pid == 0) {
_v1(p1);
- munmap(p1, PGSIZE); // just the first page
+ if (munmap(p1, PGSIZE) == -1) // just the first page
+ err("munmap (7)");
exit(0); // tell the parent that the mapping looks OK.
}