[Libreoffice-commits] .: 2 commits - sal/osl
Michael Meeks
michael at kemper.freedesktop.org
Tue May 3 02:22:59 PDT 2011
sal/osl/unx/readwrite_helper.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
New commits:
commit 82af2c10b5b093496bfb6d29f4a7068dd158f943
Author: Julien Chaffraix <julien.chaffraix at gmail.com>
Date: Sat Apr 30 16:37:49 2011 -0700
Properly advance the data / buffer pointer.
Spotted by Michael Meeks.
diff --git a/sal/osl/unx/readwrite_helper.c b/sal/osl/unx/readwrite_helper.c
index 51e1ec6..e259895 100644
--- a/sal/osl/unx/readwrite_helper.c
+++ b/sal/osl/unx/readwrite_helper.c
@@ -35,10 +35,12 @@
sal_Bool safeWrite(int fd, void* data, sal_uInt32 dataSize)
{
sal_Int32 nToWrite = dataSize;
+ unsigned char* dataToWrite = data;
+
// Check for overflow as we convert a signed to an unsigned.
OSL_ASSERT(dataSize == (sal_uInt32)nToWrite);
while ( nToWrite ) {
- sal_Int32 nWritten = write(fd, data, nToWrite);
+ sal_Int32 nWritten = write(fd, dataToWrite, nToWrite);
if ( nWritten < 0 ) {
if ( errno == EINTR )
continue;
@@ -49,6 +51,7 @@ sal_Bool safeWrite(int fd, void* data, sal_uInt32 dataSize)
OSL_ASSERT(nWritten > 0);
nToWrite -= nWritten;
+ dataToWrite += nWritten;
}
return sal_True;
@@ -57,10 +60,12 @@ sal_Bool safeWrite(int fd, void* data, sal_uInt32 dataSize)
sal_Bool safeRead( int fd, void* buffer, sal_uInt32 count )
{
sal_Int32 nToRead = count;
+ unsigned char* bufferForReading = buffer;
+
// Check for overflow as we convert a signed to an unsigned.
OSL_ASSERT(count == (sal_uInt32)nToRead);
while ( nToRead ) {
- sal_Int32 nRead = read(fd, buffer, nToRead);
+ sal_Int32 nRead = read(fd, bufferForReading, nToRead);
if ( nRead < 0 ) {
// We were interrupted before reading, retry.
if (errno == EINTR)
@@ -75,6 +80,7 @@ sal_Bool safeRead( int fd, void* buffer, sal_uInt32 count )
return sal_False;
nToRead -= nRead;
+ bufferForReading += nRead;
}
return sal_True;
commit 3f40d4b1862aab3a7d0bc54f005ff9816c6927d2
Author: Julien Chaffraix <julien.chaffraix at gmail.com>
Date: Sat Apr 30 16:13:22 2011 -0700
Handled EINTR in safeWrite.
This makes us match safeRead's behavior. Spotted by Michael Meeks.
diff --git a/sal/osl/unx/readwrite_helper.c b/sal/osl/unx/readwrite_helper.c
index 41aa41e..51e1ec6 100644
--- a/sal/osl/unx/readwrite_helper.c
+++ b/sal/osl/unx/readwrite_helper.c
@@ -39,9 +39,14 @@ sal_Bool safeWrite(int fd, void* data, sal_uInt32 dataSize)
OSL_ASSERT(dataSize == (sal_uInt32)nToWrite);
while ( nToWrite ) {
sal_Int32 nWritten = write(fd, data, nToWrite);
- if ( nWritten < 0 )
+ if ( nWritten < 0 ) {
+ if ( errno == EINTR )
+ continue;
+
return sal_False;
+ }
+
OSL_ASSERT(nWritten > 0);
nToWrite -= nWritten;
}
More information about the Libreoffice-commits
mailing list