mapfile.c: minor stylistic cleanup
authorH. Peter Anvin <hpa@linux.intel.com>
Fri, 13 Feb 2009 00:45:22 +0000 (16:45 -0800)
committerH. Peter Anvin <hpa@linux.intel.com>
Fri, 13 Feb 2009 00:45:22 +0000 (16:45 -0800)
Minor stylistic cleanup in mapfile.c; emphasize that the actual system
calls are the same in both branches of the "writable" conditional.

mapfile.c

index b4c22c8..32233eb 100644 (file)
--- 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;
 }