From 573bda1fae5fbdaf676110ad4ab8be2fed9d766b Mon Sep 17 00:00:00 2001 From: Sergey Sharybin Date: Wed, 27 Jan 2021 14:06:47 +0100 Subject: 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 --- source/blender/blenlib/intern/BLI_mmap.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'source/blender/blenlib/intern/BLI_mmap.c') 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; } -- cgit v1.2.3