[llvm-commits] [llvm] r85922 - /llvm/trunk/lib/Support/MemoryBuffer.cpp

Dan Gohman gohman at apple.com
Tue Nov 3 11:28:48 PST 2009


Hi Duncan,

On Nov 3, 2009, at 11:10 AM, Duncan Sands wrote:

> --- llvm/trunk/lib/Support/MemoryBuffer.cpp (original)
> +++ llvm/trunk/lib/Support/MemoryBuffer.cpp Tue Nov  3 13:10:22 2009
> @@ -226,7 +226,7 @@
>   size_t BytesLeft = FileSize;
>   while (BytesLeft) {
>     ssize_t NumRead = ::read(FD, BufPtr, BytesLeft);
> -    if (NumRead != -1) {
> +    if (NumRead > 0) {
>       BytesLeft -= NumRead;
>       BufPtr += NumRead;
>     } else if (errno == EINTR) {

Given this, the code should explicitly set errno to 0 so that it doesn't
infinite loop if it reaches the end of the file and errno happens to
have the value EINTR.

Dan




More information about the llvm-commits mailing list