envcrc: check return value of fwrite()
PATCH 1/1 envcrc: check return value of fwrite()
Newer toolchains will often complain about unchecked fwrite():
envcrc.c:117: warning: ignoring return value of ?fwrite?, declared
with attribute warn_unused_result
So check the return value to silence the warnings.
Signed-off-by Mike Frysinger <[email protected]>
--- tools/envcrc.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
tools/envcrc.c +3 -1
@@ -21,6 +21,7 @@* MA 02111-1307 USA */ +#include <errno.h> #include <stdio.h> #include <stdint.h> #include <stdlib.h>
@@ -114,7 +115,8 @@ int main (int argc, char **argv) }for (i = start; i != end; i += step)printf ("%c" , (crc & (0xFF << (i *8 ))) >> (i *8 )); -fwrite (dataptr,1 , datasize, stdout); +if (fwrite (dataptr,1 , datasize, stdout) != datasize) +fprintf (stderr,"fwrite() failed: %s\n" ,strerror (errno)); }else { printf("CRC32 from offset %08X to %08X of environment = %08X\n", (unsigned int) (dataptr - envptr),
Signature · 1 line
1.6.5.1
Wolfgang Denk
AppliedPATCH 1/1 envcrc: check return value of fwrite()
Dear Mike Frysinger,
Quoted 11 lines · In message <[email protected]> you wrote:
Newer toolchains will often complain about unchecked
fwrite():
envcrc.c:117: warning: ignoring return value of `fwrite?, declared
with attributewarn_unused_resultSo check the return value to silence the warnings.
Signed-off-by Mike Frysinger <[email protected]>--- tools/envcrc.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk
Signature · 4 lines
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de "A witty saying proves nothing." - Voltaire