From cc57d9bee98270e6e961765716d421bf2f0950d3 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Sat, 15 Nov 2014 23:07:04 +0100 Subject: changelog: correct mmap() error checking Upon failure, mmap() returns MAP_FAILED, which is not equal to NULL. This small correction makes sure that the potential error gets caught and handled. BUG: 1138621 Change-Id: I0a88b5187afa7187dcaa8f7d2cb0f9bb775c929d Reported-by: Santosh Pradhan Signed-off-by: Niels de Vos Reviewed-on: http://review.gluster.org/9130 Tested-by: Gluster Build System Reviewed-by: Venky Shankar Tested-by: Venky Shankar --- xlators/features/changelog/lib/src/gf-changelog-process.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'xlators/features') diff --git a/xlators/features/changelog/lib/src/gf-changelog-process.c b/xlators/features/changelog/lib/src/gf-changelog-process.c index 83f8928de6d..1a275e676fb 100644 --- a/xlators/features/changelog/lib/src/gf-changelog-process.c +++ b/xlators/features/changelog/lib/src/gf-changelog-process.c @@ -126,7 +126,7 @@ gf_changelog_parse_binary (xlator_t *this, char *bname_start = NULL; char *bname_end = NULL; char *mover = NULL; - char *start = NULL; + void *start = NULL; char current_mover = ' '; size_t blen = 0; int parse_err = 0; @@ -134,9 +134,8 @@ gf_changelog_parse_binary (xlator_t *this, nleft = stbuf->st_size; - start = (char *) mmap (NULL, nleft, - PROT_READ, MAP_PRIVATE, from_fd, 0); - if (!start) { + start = mmap (NULL, nleft, PROT_READ, MAP_PRIVATE, from_fd, 0); + if (start == MAP_FAILED) { gf_log (this->name, GF_LOG_ERROR, "mmap() error (reason: %s)", strerror (errno)); goto out; @@ -230,7 +229,7 @@ gf_changelog_parse_ascii (xlator_t *this, off_t nleft = 0; char *ptr = NULL; char *eptr = NULL; - char *start = NULL; + void *start = NULL; char *mover = NULL; int parse_err = 0; char current_mover = ' '; @@ -239,9 +238,8 @@ gf_changelog_parse_ascii (xlator_t *this, nleft = stbuf->st_size; - start = (char *) mmap (NULL, nleft, - PROT_READ, MAP_PRIVATE, from_fd, 0); - if (!start) { + start = mmap (NULL, nleft, PROT_READ, MAP_PRIVATE, from_fd, 0); + if (start == MAP_FAILED) { gf_log (this->name, GF_LOG_ERROR, "mmap() error (reason: %s)", strerror (errno)); goto out; -- cgit