From: Andrii Simiklit <[email protected]>

1. tools/i965_disasm.c:58:4: warning:
     ignoring return value of ‘fread’,
     declared with attribute warn_unused_result
     fread(assembly, *end, 1, fp);

v2: Fixed incorrect return value check.
       ( Eric Engestrom <[email protected]> )

v3: Zero size file check moved before fread with exit()
       ( Eric Engestrom <[email protected]> )

Signed-off-by: Andrii Simiklit <[email protected]>
---
 src/intel/tools/i965_disasm.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/intel/tools/i965_disasm.c b/src/intel/tools/i965_disasm.c
index 73a6760fc1..d820b10d97 100644
--- a/src/intel/tools/i965_disasm.c
+++ b/src/intel/tools/i965_disasm.c
@@ -50,12 +50,17 @@ i965_disasm_read_binary(FILE *fp, size_t *end)
    void *assembly;
 
    *end = i965_disasm_get_file_size(fp);
+   if (!*end) {
+      fprintf(stderr, "file is empty\n");
+      exit(0);
+   }
 
    assembly = malloc(*end + 1);
    if (assembly == NULL)
       return NULL;
 
-   fread(assembly, *end, 1, fp);
+   MAYBE_UNUSED size_t size = fread(assembly, *end, 1, fp);
+   assert(size && "error: unable to read all elements!");
    fclose(fp);
 
    return assembly;
-- 
2.17.1

_______________________________________________
mesa-dev mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to