[haiku-commits] r35944 - haiku/trunk/src/kits/support

  • From: superstippi@xxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 24 Mar 2010 17:48:33 +0100 (CET)

Author: stippi
Date: 2010-03-24 17:48:33 +0100 (Wed, 24 Mar 2010)
New Revision: 35944
Changeset: http://dev.haiku-os.org/changeset/35944/haiku

Modified:
   haiku/trunk/src/kits/support/BufferIO.cpp
Log:
 * Don't store a possibly negative return value in an unsigned size_t, which
   is later used as parameter to memcpy(). Should fix r5623 (untested).
 * Fixed coding style for some comments.


Modified: haiku/trunk/src/kits/support/BufferIO.cpp
===================================================================
--- haiku/trunk/src/kits/support/BufferIO.cpp   2010-03-24 16:30:04 UTC (rev 
35943)
+++ haiku/trunk/src/kits/support/BufferIO.cpp   2010-03-24 16:48:33 UTC (rev 
35944)
@@ -73,14 +73,21 @@
                || pos < fBufferStart
                || pos > fBufferStart + fBufferUsed
                || pos + size > fBufferStart + fBufferUsed) {
-               if (fBufferIsDirty)
-                       Flush(); // If there are pending writes, do them.
+               if (fBufferIsDirty) {
+                       // If there are pending writes, do them.
+                       Flush();
+               }
 
                // ...cache as much as we can from the stream
-               fBufferUsed = fStream->ReadAt(pos, fBuffer, fBufferSize);
+               ssize_t sizeRead = fStream->ReadAt(pos, fBuffer, fBufferSize);
+               if (sizeRead < 0)
+                       return sizeRead;
 
-               if (fBufferUsed > 0)
-                       fBufferStart = pos; // The data is buffered starting 
from this offset
+               fBufferUsed = sizeRead;
+               if (fBufferUsed > 0) {
+                       // The data is buffered starting from this offset
+                       fBufferStart = pos;
+               }
        }
 
        size = min_c(size, fBufferUsed);
@@ -117,7 +124,8 @@
                ssize_t read;
                off_t where = pos;
 
-               if (pos + size <= fBufferSize) // Can we just cache from the 
beginning ?
+               // Can we just cache from the beginning?
+               if (pos + size <= fBufferSize)
                        where = 0;
 
                // ...cache more.


Other related posts:

  • » [haiku-commits] r35944 - haiku/trunk/src/kits/support - superstippi