intel/compiler: Return early if read() failed
authorEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>
Wed, 20 Nov 2019 15:21:42 +0000 (16:21 +0100)
committerMarge Bot <eric+marge@anholt.net>
Wed, 22 Jan 2020 20:52:47 +0000 (20:52 +0000)
This was the only warning I could see while compiling Iris.

Reviewed-by: Matt Turner <mattst88@gmail.com>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/2821>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/2821>

src/intel/compiler/brw_eu.cpp

index 4ce36fc25973a38a19518bdb34ae04b8a122550c..16600bdc537ba8ef52cc1b2c0e784ffeaf882baa 100644 (file)
@@ -394,8 +394,11 @@ bool brw_try_override_assembly(struct brw_codegen *p, int start_offset,
    p->store = (brw_inst *)reralloc_size(p->mem_ctx, p->store, p->next_insn_offset);
    assert(p->store);
 
-   read(fd, p->store + start_offset, sb.st_size);
+   ssize_t ret = read(fd, p->store + start_offset, sb.st_size);
    close(fd);
+   if (ret != sb.st_size) {
+      return false;
+   }
 
    ASSERTED bool valid =
       brw_validate_instructions(p->devinfo, p->store,