ref: 2d117f68c983271c73089271e631cc2485786479
parent: 8954858bf79a9ad48eacb063d42b47882ede1175
author: Antonio Niño Díaz <[email protected]>
date: Thu Aug 17 19:03:42 EDT 2017
Fix compiler warnings about unused return values 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 <[email protected]>
--- a/src/link/object.c
+++ b/src/link/object.c
@@ -228,8 +228,11 @@
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 @@
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 @@
{
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;