[Mesa-dev] [PATCH v3 5/5] intel/tools: avoid 'ignoring return value'
asimiklit.work at gmail.com
asimiklit.work at gmail.com
Wed Nov 14 13:49:24 UTC 2018
From: Andrii Simiklit <andrii.simiklit at globallogic.com>
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 <eric.engestrom at intel.com> )
v3: Zero size file check moved before fread with exit()
( Eric Engestrom <eric.engestrom at intel.com> )
Signed-off-by: Andrii Simiklit <andrii.simiklit at globallogic.com>
---
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
More information about the mesa-dev
mailing list