From 30e13c7c37f36960364d3170e0d9a0c690917912 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Tue, 31 May 2016 11:49:59 -0700 Subject: [PATCH] Clean up some unused result warnings. --- Common/Misc.cpp | 4 +++- ext/native/file/chunk_file.cpp | 25 +++++++++++++++---------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/Common/Misc.cpp b/Common/Misc.cpp index 5f80745b8..9c711cd90 100644 --- a/Common/Misc.cpp +++ b/Common/Misc.cpp @@ -60,7 +60,9 @@ const char *GetStringErrorMsg(int errCode) { static __thread char err_str[buff_size] = {}; // Thread safe (XSI-compliant) - strerror_r(errCode, err_str, buff_size); + if (strerror_r(errCode, err_str, buff_size) == 0) { + return "Unknown error"; + } #endif return err_str; diff --git a/ext/native/file/chunk_file.cpp b/ext/native/file/chunk_file.cpp index dd627b952..4026208c2 100644 --- a/ext/native/file/chunk_file.cpp +++ b/ext/native/file/chunk_file.cpp @@ -62,12 +62,12 @@ int ChunkFile::readInt() { return *(int *)(data + pos - 4); else { int i; - fread(&i, 1, 4, file); - return i; + if (fread(&i, 1, 4, file) == 4) { + return i; + } } - } else { - return 0; } + return 0; } void ChunkFile::writeInt(int i) { @@ -166,18 +166,23 @@ void ChunkFile::ascend() { //read a block void ChunkFile::readData(void *what, int count) { - if (fastMode) + if (fastMode) { memcpy(what, data + pos, count); - else - fread(what, 1, count, file); + } else { + if (fread(what, 1, count, file) != count) { + ELOG("Failed to read complete %d bytes", count); + } + } pos+=count; - char temp[4]; //discarded count &= 3; if (count) { count=4-count; - if (!fastMode) - fread(temp, 1, count, file); // could just as well seek + if (!fastMode) { + if (fseek(file, count, SEEK_CUR) != 0) { + ELOG("Missing padding"); + } + } pos+=count; } }