summaryrefslogtreecommitdiffstats
path: root/xlators/features/changelog
diff options
context:
space:
mode:
authorNiels de Vos <ndevos@redhat.com>2014-11-15 23:07:04 +0100
committerVenky Shankar <vshankar@redhat.com>2014-11-17 18:56:17 -0800
commitcc57d9bee98270e6e961765716d421bf2f0950d3 (patch)
tree9dad4365bce307ac8bbb5bdce4a71cea4a4eea13 /xlators/features/changelog
parenta7ec009499f2c8f0c96aa03110ff4755eef8f1b8 (diff)
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 <santosh.pradhan@gmail.com> Signed-off-by: Niels de Vos <ndevos@redhat.com> Reviewed-on: http://review.gluster.org/9130 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Venky Shankar <vshankar@redhat.com> Tested-by: Venky Shankar <vshankar@redhat.com>
Diffstat (limited to 'xlators/features/changelog')
-rw-r--r--xlators/features/changelog/lib/src/gf-changelog-process.c14
1 files changed, 6 insertions, 8 deletions
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;