intel/tools: Remove redundant definitions of INTEL_DEBUG
[mesa.git] / src / intel / tools / i965_disasm.c
index 73a6760fc131d36117704f9091454698a87238b2..5fe4afa35ff287723c1905715f4d5b868d86daf9 100644 (file)
@@ -29,8 +29,6 @@
 #include "compiler/brw_eu.h"
 #include "dev/gen_device_info.h"
 
-uint64_t INTEL_DEBUG;
-
 /* Return size of file in bytes pointed by fp */
 static size_t
 i965_disasm_get_file_size(FILE *fp)
@@ -47,17 +45,23 @@ i965_disasm_get_file_size(FILE *fp)
 static void *
 i965_disasm_read_binary(FILE *fp, size_t *end)
 {
+   size_t size;
    void *assembly;
 
    *end = i965_disasm_get_file_size(fp);
+   if (!*end)
+      return NULL;
 
    assembly = malloc(*end + 1);
    if (assembly == NULL)
       return NULL;
 
-   fread(assembly, *end, 1, fp);
+   size = fread(assembly, *end, 1, fp);
    fclose(fp);
-
+   if (!size) {
+      free(assembly);
+      return NULL;
+   }
    return assembly;
 }
 
@@ -167,7 +171,11 @@ int main(int argc, char *argv[])
 
    assembly = i965_disasm_read_binary(fp, &end);
    if (!assembly) {
-      fprintf(stderr, "Unable to allocate buffer to read binary file\n");
+      if (end)
+        fprintf(stderr, "Unable to allocate buffer to read binary file\n");
+      else
+        fprintf(stderr, "Input file is empty\n");
+
       exit(EXIT_FAILURE);
    }