From: Steve Kondik Date: Sat, 8 Jul 2017 08:57:16 +0000 (-0700) Subject: rdr: Fix incorrect error checking after fread() X-Git-Tag: v1.8.90~112^2~5 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=b315dfae97c7c24b8743794bee9433c70b85b051;p=tigervnc.git 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)) ~ ^ ~ --- 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; }