diff options
author | Eric Engestrom <eric@engestrom.ch> | 2016-09-25 16:49:52 +0100 |
---|---|---|
committer | Jason Ekstrand <jason.ekstrand@intel.com> | 2016-10-01 15:27:46 -0700 |
commit | c86793804498a33e36302b670d3a8b095f9bdc93 (patch) | |
tree | 7e196583230c7e3bc611e83717c764cec778cee8 /src/compiler | |
parent | 65c8cbe89df3c0e23e83f32111cce6609f86c85d (diff) | |
download | external_mesa3d-c86793804498a33e36302b670d3a8b095f9bdc93.zip external_mesa3d-c86793804498a33e36302b670d3a8b095f9bdc93.tar.gz external_mesa3d-c86793804498a33e36302b670d3a8b095f9bdc93.tar.bz2 |
nir/spirv: improve mmap() error handling
Signed-off-by: Eric Engestrom <eric@engestrom.ch>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/spirv/spirv2nir.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/compiler/spirv/spirv2nir.c b/src/compiler/spirv/spirv2nir.c index a024028..3dc0735 100644 --- a/src/compiler/spirv/spirv2nir.c +++ b/src/compiler/spirv/spirv2nir.c @@ -38,6 +38,8 @@ #include <fcntl.h> #include <unistd.h> #include <stdio.h> +#include <errno.h> +#include <string.h> #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); |