From: Arnaud Giersch Date: Wed, 24 Apr 2019 20:50:48 +0000 (+0200) Subject: Check result of lseek. X-Git-Tag: v3.22.2~44 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/230f7574373e48a724bcb7247e7c4cb6bd96f62d?hp=76bab631c9b3781401200871b2cbf76c7273757b Check result of lseek. --- diff --git a/src/xbt/mmalloc/mmorecore.c b/src/xbt/mmalloc/mmorecore.c index 853e611355..e28edb75dc 100644 --- a/src/xbt/mmalloc/mmorecore.c +++ b/src/xbt/mmalloc/mmorecore.c @@ -63,7 +63,6 @@ */ void *mmorecore(struct mdesc *mdp, ssize_t size) { - ssize_t test = 0; void* result; // please keep it uninitialized to track issues off_t foffset; /* File offset at which new mapping will start */ size_t mapbytes; /* Number of bytes to map */ @@ -103,10 +102,11 @@ void *mmorecore(struct mdesc *mdp, ssize_t size) foffset = (char*)mdp->top - (char*)mdp->base; if (mdp->fd > 0) { - /* FIXME: Test results of lseek() */ - lseek(mdp->fd, foffset + mapbytes - 1, SEEK_SET); - test = write(mdp->fd, &buf, 1); - if (test == -1) { + if (lseek(mdp->fd, foffset + mapbytes - 1, SEEK_SET) == -1) { + fprintf(stderr, "Internal error: lseek into mmap'ed fd failed! error: %s", strerror(errno)); + abort(); + } + if (write(mdp->fd, &buf, 1) == -1) { fprintf(stderr,"Internal error: write to mmap'ed fd failed! error: %s", strerror(errno)); abort(); }