Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey@blender.org>2021-01-27 16:06:47 +0300
committerSergey Sharybin <sergey@blender.org>2021-01-28 13:05:38 +0300
commit573bda1fae5fbdaf676110ad4ab8be2fed9d766b (patch)
tree6d2e982fa549ffc9df3def1d6dcccfab48d92975 /source/blender/blenlib/intern/BLI_mmap.c
parent92567c072a97cbacf2edf0d84a8000d139fb8dbe (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/blender/blenlib/intern/BLI_mmap.c')
-rw-r--r--source/blender/blenlib/intern/BLI_mmap.c6
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;
}