[Libreoffice-commits] core.git: sal/osl

Tor Lillqvist (via logerrit) logerrit at kemper.freedesktop.org
Sat Apr 4 08:52:18 UTC 2020


 sal/osl/unx/file.cxx |   44 +++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 39 insertions(+), 5 deletions(-)

New commits:
commit 0050759cb9cf8ac337c0ecec48c009501de9fb0f
Author:     Tor Lillqvist <tml at collabora.com>
AuthorDate: Fri Apr 3 17:47:03 2020 +0300
Commit:     Tor Lillqvist <tml at collabora.com>
CommitDate: Sat Apr 4 10:51:37 2020 +0200

    Add SAL_INFO with "sal.file" also for the pread, read, pwrite, and write calls
    
    Change-Id: Ib8fe62614a87d7350bec195ff22ae5701558d967
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91678
    Tested-by: Jenkins
    Reviewed-by: Tor Lillqvist <tml at collabora.com>

diff --git a/sal/osl/unx/file.cxx b/sal/osl/unx/file.cxx
index d8396f6279b6..b79fd415b214 100644
--- a/sal/osl/unx/file.cxx
+++ b/sal/osl/unx/file.cxx
@@ -347,17 +347,27 @@ oslFileError FileHandle_Impl::readAt(
     }
 
     ssize_t nBytes = ::pread(m_fd, pBuffer, nBytesRequested, nOffset);
-    if ((nBytes == -1) && (errno == EOVERFLOW))
+    int saved_errno = errno;
+    if ((nBytes == -1) && (saved_errno == EOVERFLOW))
     {
         /* Some 'pread()'s fail with EOVERFLOW when reading at (or past)
          * end-of-file, different from 'lseek() + read()' behaviour.
          * Returning '0 bytes read' and 'osl_File_E_None' instead.
          */
+        SAL_INFO("sal.file", "pread(" << m_fd << "," << pBuffer << "," << nBytesRequested << "," << nOffset << "): " << UnixErrnoString(saved_errno));
         nBytes = 0;
     }
+    else if (nBytes == -1)
+    {
+        SAL_INFO("sal.file", "pread(" << m_fd << "," << pBuffer << "," << nBytesRequested << "," << nOffset << "): " << UnixErrnoString(saved_errno));
+    }
+    else
+    {
+        SAL_INFO("sal.file", "pread(" << m_fd << "," << pBuffer << "," << nBytesRequested << "," << nOffset << ") => " << nBytes);
+    }
 
     if (nBytes == -1)
-        return oslTranslateFileError(errno);
+        return oslTranslateFileError(saved_errno);
 
     *pBytesRead = nBytes;
 
@@ -379,8 +389,16 @@ oslFileError FileHandle_Impl::writeAt(
         return osl_File_E_BADF;
 
     ssize_t nBytes = ::pwrite(m_fd, pBuffer, nBytesToWrite, nOffset);
+    int saved_errno = errno;
     if (nBytes == -1)
-        return oslTranslateFileError(errno);
+    {
+        SAL_INFO("sal.file", "pwrite(" << m_fd << "," << pBuffer << "," << nBytesToWrite << "," << nOffset << "): " << UnixErrnoString(saved_errno));
+        return oslTranslateFileError(saved_errno);
+    }
+    else
+    {
+        SAL_INFO("sal.file", "pwrite(" << m_fd << "," << pBuffer << "," << nBytesToWrite << "," << nOffset << ") => " << nBytes);
+    }
 
     m_size = std::max(m_size, sal::static_int_cast< sal_uInt64 >(nOffset + nBytes));
 
@@ -399,8 +417,16 @@ oslFileError FileHandle_Impl::readFileAt(
     {
         // not seekable (pipe)
         ssize_t nBytes = ::read(m_fd, pBuffer, nBytesRequested);
+        int saved_errno = errno;
         if (nBytes == -1)
-            return oslTranslateFileError(errno);
+        {
+            SAL_INFO("sal.file", "read(" << m_fd << "," << pBuffer << "," << nBytesRequested << "): " << UnixErrnoString(saved_errno));
+            return oslTranslateFileError(saved_errno);
+        }
+        else
+        {
+            SAL_INFO("sal.file", "read(" << m_fd << "," << pBuffer << "," << nBytesRequested << ") => " << nBytes);
+        }
 
         *pBytesRead = nBytes;
 
@@ -480,8 +506,16 @@ oslFileError FileHandle_Impl::writeFileAt(
     {
         // not seekable (pipe)
         ssize_t nBytes = ::write(m_fd, pBuffer, nBytesToWrite);
+        int saved_errno = errno;
         if (nBytes == -1)
-            return oslTranslateFileError(errno);
+        {
+            SAL_INFO("sal.file", "write(" << m_fd << "," << pBuffer << "," << nBytesToWrite << "): " << UnixErrnoString(saved_errno));
+            return oslTranslateFileError(saved_errno);
+        }
+        else
+        {
+            SAL_INFO("sal.file", "write(" << m_fd << "," << pBuffer << "," << nBytesToWrite << ") => " <<nBytes);
+        }
 
         *pBytesWritten = nBytes;
 


More information about the Libreoffice-commits mailing list