diff options
author | Sergey Sharybin <sergey@blender.org> | 2021-01-27 16:06:47 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey@blender.org> | 2021-01-28 13:05:38 +0300 |
commit | 573bda1fae5fbdaf676110ad4ab8be2fed9d766b (patch) | |
tree | 6d2e982fa549ffc9df3def1d6dcccfab48d92975 /source | |
parent | 92567c072a97cbacf2edf0d84a8000d139fb8dbe (diff) |
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
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenlib/intern/BLI_mmap.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/source/blender/blenlib/intern/BLI_mmap.c b/source/blender/blenlib/intern/BLI_mmap.c index 210312456d9..2fd162de22c 100644 --- a/source/blender/blenlib/intern/BLI_mmap.c +++ b/source/blender/blenlib/intern/BLI_mmap.c @@ -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; } |