From 2d117f68c983271c73089271e631cc2485786479 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ni=C3=B1o=20D=C3=ADaz?= Date: Thu, 17 Aug 2017 23:03:42 +0100 Subject: [PATCH] Fix compiler warnings about unused return values MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In some implementations of libc the function fread has the attribute `warn_unused_result`, that is treated as an error by the compiler as specified in the flags passed to it. Signed-off-by: Antonio Niño Díaz --- src/link/object.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/link/object.c b/src/link/object.c index 5b2fd8cf..f338fd24 100644 --- a/src/link/object.c +++ b/src/link/object.c @@ -228,8 +228,11 @@ obj_ReadRGBSection(FILE * f) SLONG nNumberOfPatches; struct sPatch **ppPatch, *pPatch; - fread(pSection->pData, sizeof(UBYTE), - pSection->nByteSize, f); + if (fread(pSection->pData, sizeof(UBYTE), + pSection->nByteSize, f) != pSection->nByteSize) { + err(1, "Read error."); + } + nNumberOfPatches = readlong(f); ppPatch = &pSection->pPatches; @@ -254,8 +257,10 @@ obj_ReadRGBSection(FILE * f) err(1, NULL); } - fread(pPatch->pRPN, sizeof(UBYTE), - pPatch->nRPNSize, f); + if (fread(pPatch->pRPN, sizeof(UBYTE), + pPatch->nRPNSize, f) != pPatch->nRPNSize) { + errx(1, "Read error."); + } } else pPatch->pRPN = NULL; @@ -336,8 +341,10 @@ obj_ReadOpenFile(FILE * pObjfile, char *tzObjectfile) { char tzHeader[strlen(RGBDS_OBJECT_VERSION_STRING) + 1]; - fread(tzHeader, sizeof(char), strlen(RGBDS_OBJECT_VERSION_STRING), - pObjfile); + if (fread(tzHeader, sizeof(char), strlen(RGBDS_OBJECT_VERSION_STRING), + pObjfile) != strlen(RGBDS_OBJECT_VERSION_STRING)) { + errx(1, "%s: Read error.", tzObjectfile); + } tzHeader[strlen(RGBDS_OBJECT_VERSION_STRING)] = 0;