From a3bf01f57b4cd64f3d48557f9537a63439a4b936 Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Sun, 27 Aug 2023 12:21:19 +0100 Subject: [PATCH] LoggedFread: Do not log EOF as an error Usually we call fread in a loop until reaching EOF. Reaching EOF is not an error, so we should not log it as such. The error message was previously seen when loading demo files. --- Source/utils/endian_stream.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/utils/endian_stream.hpp b/Source/utils/endian_stream.hpp index 76c9e1694..0e40d320c 100644 --- a/Source/utils/endian_stream.hpp +++ b/Source/utils/endian_stream.hpp @@ -13,7 +13,7 @@ namespace devilution { inline void LoggedFread(void *buffer, size_t size, FILE *stream) { - if (std::fread(buffer, size, 1, stream) != 1) { + if (std::fread(buffer, size, 1, stream) != 1 && !std::feof(stream)) { LogError("fread failed: {}", std::strerror(errno)); } }