summaryrefslogtreecommitdiffstats
path: root/mapfile.c
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@linux.intel.com>2009-02-12 16:45:22 -0800
committerH. Peter Anvin <hpa@linux.intel.com>2009-02-12 16:45:22 -0800
commita3820f9cf44b9652b16e702176bfee2afe5f4563 (patch)
tree91db6807854d5c7ac6ee2d2129effc4e8ce50430 /mapfile.c
parent9d3b92cc70dd6d2a9eab61e5d2975ac26f023abd (diff)
downloadwraplinux-a3820f9cf44b9652b16e702176bfee2afe5f4563.tar.gz
wraplinux-a3820f9cf44b9652b16e702176bfee2afe5f4563.tar.xz
wraplinux-a3820f9cf44b9652b16e702176bfee2afe5f4563.zip
mapfile.c: minor stylistic cleanup
Minor stylistic cleanup in mapfile.c; emphasize that the actual system calls are the same in both branches of the "writable" conditional.
Diffstat (limited to 'mapfile.c')
-rw-r--r--mapfile.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/mapfile.c b/mapfile.c
index b4c22c8..32233eb 100644
--- a/mapfile.c
+++ b/mapfile.c
@@ -32,18 +32,22 @@ void *mapfile(int fd, size_t *len, int writable)
{
struct stat st;
void *ptr;
+ int prot, flags;
if (fstat(fd, &st))
return NULL;
*len = st.st_size;
- if (writable)
- ptr =
- mmap(NULL, st.st_size, PROT_READ | PROT_WRITE, MAP_PRIVATE,
- fd, 0);
- else
- ptr = mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0);
+ if (writable) {
+ prot = PROT_READ|PROT_WRITE;
+ flags = MAP_PRIVATE;
+ } else {
+ prot = PROT_READ;
+ flags = MAP_SHARED;
+ }
+
+ ptr = mmap(NULL, st.st_size, prot, flags, fd, 0);
return (ptr == MAP_FAILED) ? NULL : ptr;
}