diff options
author | Eric Engestrom <[email protected]> | 2016-09-25 16:49:50 +0100 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2016-10-01 15:27:31 -0700 |
commit | 23519a9de259c5f8c837421330c9a05912b4e8e6 (patch) | |
tree | 8f066ed2f5e05e6f63711b5a34bea8af1be71c1a /src/compiler/spirv | |
parent | 913e0296f2168c13a2a8ac649e17bb12683681e1 (diff) |
nir/spirv: add some error checking to open()
CovID: 1373369
Signed-off-by: Eric Engestrom <[email protected]>
Reviewed-by: Jason Ekstrand <[email protected]>
Diffstat (limited to 'src/compiler/spirv')
-rw-r--r-- | src/compiler/spirv/spirv2nir.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/compiler/spirv/spirv2nir.c b/src/compiler/spirv/spirv2nir.c index c837186bdfc..d151c2cc828 100644 --- a/src/compiler/spirv/spirv2nir.c +++ b/src/compiler/spirv/spirv2nir.c @@ -37,10 +37,17 @@ #include <sys/types.h> #include <fcntl.h> #include <unistd.h> +#include <stdio.h> int main(int argc, char **argv) { int fd = open(argv[1], O_RDONLY); + if (fd < 0) + { + fprintf(stderr, "Failed to open %s\n", argv[1]); + return 1; + } + off_t len = lseek(fd, 0, SEEK_END); assert(len % 4 == 0); @@ -52,4 +59,6 @@ int main(int argc, char **argv) nir_function *func = spirv_to_nir(map, word_count, NULL, 0, MESA_SHADER_FRAGMENT, "main", NULL); nir_print_shader(func->shader, stderr); + + return 0; } |