From b315dfae97c7c24b8743794bee9433c70b85b051 Mon Sep 17 00:00:00 2001 From: Steve Kondik Date: Sat, 8 Jul 2017 01:57:16 -0700 Subject: [PATCH] rdr: Fix incorrect error checking after fread() fread() returns size_t, which is unsigned. Don't check for negative values to avoid warnings from Clang. /home/shade/dev/tigervnc/common/rdr/FileInStream.cxx:74:13: error: comparison of unsigned expression < 0 is always false [-Werror,-Wtautological-compare] if (n < 0 || ferror(file)) ~ ^ ~ --- common/rdr/FileInStream.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common/rdr/FileInStream.cxx b/common/rdr/FileInStream.cxx index 8d5c22e0..3acdfd45 100644 --- a/common/rdr/FileInStream.cxx +++ b/common/rdr/FileInStream.cxx @@ -70,12 +70,12 @@ int FileInStream::overrun(int itemSize, int nItems, bool wait) while (end < b + itemSize) { size_t n = fread((U8 *)end, b + sizeof(b) - end, 1, file); - if (n < 1) { - if (n < 0 || ferror(file)) + if (n == 0) { + if (ferror(file)) throw SystemException("fread", errno); if (feof(file)) throw EndOfStream(); - if (n == 0) { return 0; } + return 0; } end += b + sizeof(b) - end; } -- 2.39.5