From c2ded8b6ba39c639a3d7ff2f4f21a6fa22ef96a9 Mon Sep 17 00:00:00 2001 From: Andre Noll Date: Sun, 14 Jan 2018 18:57:22 +0100 Subject: [PATCH] fd.c: Simplify para_mmap(). Both callers pass in a zero offset, so we can get rid of this parameter. --- fd.c | 8 +++----- fd.h | 3 +-- vss.c | 2 +- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/fd.c b/fd.c index 7079b51c..86a1f105 100644 --- 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. - * \param offset Mmap start. * \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; - *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: @@ -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; - 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); diff --git a/fd.h b/fd.h index 106f5a4c..25eea8a2 100644 --- 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); -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); diff --git a/vss.c b/vss.c index 00c632c7..f69225ea 100644 --- 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, - passed_fd, 0, &vsst->map); + passed_fd, &vsst->map); if (ret < 0) goto err; vsst->mapsize = statbuf.st_size; -- 2.39.2