From c86793804498a33e36302b670d3a8b095f9bdc93 Mon Sep 17 00:00:00 2001 From: Eric Engestrom Date: Sun, 25 Sep 2016 16:49:52 +0100 Subject: [PATCH] nir/spirv: improve mmap() error handling Signed-off-by: Eric Engestrom Reviewed-by: Jason Ekstrand --- src/compiler/spirv/spirv2nir.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/compiler/spirv/spirv2nir.c b/src/compiler/spirv/spirv2nir.c index a02402874fc..3dc07351322 100644 --- a/src/compiler/spirv/spirv2nir.c +++ b/src/compiler/spirv/spirv2nir.c @@ -38,6 +38,8 @@ #include #include #include +#include +#include #define WORD_SIZE 4 @@ -62,7 +64,13 @@ int main(int argc, char **argv) size_t word_count = len / WORD_SIZE; const void *map = mmap(NULL, len, PROT_READ, MAP_PRIVATE, fd, 0); - assert(map != NULL); + if (map == MAP_FAILED) + { + fprintf(stderr, "Failed to mmap the file: errno=%d, %s\n", + errno, strerror(errno)); + close(fd); + return 1; + } nir_function *func = spirv_to_nir(map, word_count, NULL, 0, MESA_SHADER_FRAGMENT, "main", NULL); -- 2.30.2