From: Mike Frysinger Date: Sat, 13 Feb 2021 07:42:50 +0000 (-0500) Subject: sim: rx: mitigate fread warning X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=9ee455572d97fd8ce458a6df523c447e85dc3edf;p=binutils-gdb.git sim: rx: mitigate fread warning Current toolchains warn about unused result from fread, so mitigate the edge case if fread returns short data. It's not great, but it gets things building again. --- diff --git a/sim/rx/ChangeLog b/sim/rx/ChangeLog index d548becfcd0..e78fe61dab5 100644 --- a/sim/rx/ChangeLog +++ b/sim/rx/ChangeLog @@ -1,3 +1,8 @@ +2021-02-13 Mike Frysinger + + * trace.c (load_file_and_line): Use fread return value to index + the data. + 2021-02-13 Mike Frysinger * configure.ac: Replace sinclude with AC_CONFIG_MACRO_DIRS. diff --git a/sim/rx/trace.c b/sim/rx/trace.c index e5db49b5ca9..caa51b794df 100644 --- a/sim/rx/trace.c +++ b/sim/rx/trace.c @@ -143,6 +143,7 @@ load_file_and_line (const char *filename, int lineno) FILE *file; int i; struct stat s; + size_t ret; const char *found_filename, *slash; found_filename = filename; @@ -162,8 +163,8 @@ load_file_and_line (const char *filename, int lineno) f->filename = strdup (filename); f->data = (char *) malloc (s.st_size + 2); file = fopen (found_filename, "rb"); - fread (f->data, 1, s.st_size, file); - f->data[s.st_size] = 0; + ret = fread (f->data, 1, s.st_size, file); + f->data[ret] = 0; fclose (file); f->nlines = 1;