fd.c: Simplify para_mmap().
authorAndre Noll <maan@tuebingen.mpg.de>
Sun, 14 Jan 2018 17:57:22 +0000 (18:57 +0100)
committerAndre Noll <maan@tuebingen.mpg.de>
Mon, 12 Mar 2018 19:59:00 +0000 (20:59 +0100)
Both callers pass in a zero offset, so we can get rid of this
parameter.

fd.c
fd.h
vss.c

diff --git a/fd.c b/fd.c
index 7079b51cc95c683af1187f0b4af1412b07e40950..86a1f10541f8ca64ffb659d2fc637ea61865e7ff 100644 (file)
--- a/fd.c
+++ b/fd.c
@@ -455,22 +455,20 @@ again:
  * PROT_EXEC PROT_READ PROT_WRITE.
  * \param flags Exactly one of MAP_SHARED and MAP_PRIVATE.
  * \param fd The file to mmap from.
  * PROT_EXEC PROT_READ PROT_WRITE.
  * \param flags Exactly one of MAP_SHARED and MAP_PRIVATE.
  * \param fd The file to mmap from.
- * \param offset Mmap start.
  * \param map Result pointer.
  *
  * \return Standard.
  *
  * \sa mmap(2).
  */
  * \param map Result pointer.
  *
  * \return Standard.
  *
  * \sa mmap(2).
  */
-int para_mmap(size_t length, int prot, int flags, int fd, off_t offset,
-               void *map)
+int para_mmap(size_t length, int prot, int flags, int fd, void *map)
 {
        void **m = map;
 
        errno = EINVAL;
        if (!length)
                goto err;
 {
        void **m = map;
 
        errno = EINVAL;
        if (!length)
                goto err;
-       *m = mmap(NULL, length, prot, flags, fd, offset);
+       *m = mmap(NULL, length, prot, flags, fd, (off_t)0);
        if (*m != MAP_FAILED)
                return 1;
 err:
        if (*m != MAP_FAILED)
                return 1;
 err:
@@ -639,7 +637,7 @@ int mmap_full_file(const char *path, int open_mode, void **map,
        if (S_ISDIR(file_status.st_mode))
                goto out;
 
        if (S_ISDIR(file_status.st_mode))
                goto out;
 
-       ret = para_mmap(*size, mmap_prot, mmap_flags, fd, 0, map);
+       ret = para_mmap(*size, mmap_prot, mmap_flags, fd, map);
 out:
        if (ret < 0 || !fd_ptr)
                close(fd);
 out:
        if (ret < 0 || !fd_ptr)
                close(fd);
diff --git a/fd.h b/fd.h
index 106f5a4ceaaae81209385a23a73092a22a0035c0..25eea8a27ceaaec24ac24a8e3ab210d5ff798b05 100644 (file)
--- a/fd.h
+++ b/fd.h
@@ -12,8 +12,7 @@ __must_check int mark_fd_nonblocking(int fd);
 __must_check int mark_fd_blocking(int fd);
 void para_fd_set(int fd, fd_set *fds, int *max_fileno);
 __must_check int para_fgets(char *line, int size, FILE *f);
 __must_check int mark_fd_blocking(int fd);
 void para_fd_set(int fd, fd_set *fds, int *max_fileno);
 __must_check int para_fgets(char *line, int size, FILE *f);
-int para_mmap(size_t length, int prot, int flags, int fd, off_t offset,
-               void *map);
+int para_mmap(size_t length, int prot, int flags, int fd, void *map);
 int para_open(const char *path, int flags, mode_t mode);
 int para_mkdir(const char *path, mode_t mode);
 int para_chdir(const char *path);
 int para_open(const char *path, int flags, mode_t mode);
 int para_mkdir(const char *path, mode_t mode);
 int para_chdir(const char *path);
diff --git a/vss.c b/vss.c
index 00c632c70674a034044f6c73c7f2c6b87bf63bd1..f69225ea1ee5927d5d327f418db4cbf7e31cc8bc 100644 (file)
--- a/vss.c
+++ b/vss.c
@@ -997,7 +997,7 @@ static void recv_afs_result(struct vss_task *vsst, fd_set *rfds)
                goto err;
        }
        ret = para_mmap(statbuf.st_size, PROT_READ, MAP_PRIVATE | MAP_POPULATE,
                goto err;
        }
        ret = para_mmap(statbuf.st_size, PROT_READ, MAP_PRIVATE | MAP_POPULATE,
-               passed_fd, 0, &vsst->map);
+               passed_fd, &vsst->map);
        if (ret < 0)
                goto err;
        vsst->mapsize = statbuf.st_size;
        if (ret < 0)
                goto err;
        vsst->mapsize = statbuf.st_size;