Fix unused result from mmap() call

The unused result was reported by Clang-Tidy 11.

It does make sense to check for the failed mmap() calls rather than
quietly suppress errors.

In this change failures are reported, but application execution is
not aborted. This is a bit disputable, but it feels to be a safer
thing to do now.

It is unclear how to test the code though, as we don't have any
tools in-place to simulate read errors.

Differential Revision: https://developer.blender.org/D10223
This commit is contained in:
Sergey Sharybin 2021-01-27 14:06:47 +01:00
parent 92567c072a
commit 573bda1fae
1 changed files with 5 additions and 1 deletions

View File

@ -88,7 +88,11 @@ static void sigbus_handler(int sig, siginfo_t *siginfo, void *ptr)
file->io_error = true;
/* Replace the mapped memory with zeroes. */
mmap(file->memory, file->length, PROT_READ, MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0);
const void *mapped_memory = mmap(
file->memory, file->length, PROT_READ, MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0);
if (mapped_memory == MAP_FAILED) {
fprintf(stderr, "SIGBUS handler: Error replacing mapped file with zeros\n");
}
return;
}