summaryrefslogtreecommitdiffstats
path: root/sal/osl
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-04-06 10:47:24 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-04-12 10:11:34 +0200
commit992a33313046f4a4d322db9464c474e7429a019a (patch)
tree494143e3070af872027ecaca840516d3101a881c /sal/osl
parentconvert SwComparePosition to scoped enum (diff)
downloadcore-992a33313046f4a4d322db9464c474e7429a019a.tar.gz
core-992a33313046f4a4d322db9464c474e7429a019a.zip
clang-tidy: readability-else-after-return
run it against sal,cppu,cppuhelper I had to run this multiple times to catch all the cases in each module, and it requires some hand-tweaking of the resulting output - clang-tidy is not very good about cleaning up trailing spaces, and aligning things nicely. Change-Id: I00336345f5f036e12422b98d66526509380c497a Reviewed-on: https://gerrit.libreoffice.org/36194 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sal/osl')
-rw-r--r--sal/osl/unx/conditn.cxx2
-rw-r--r--sal/osl/unx/file.cxx166
-rw-r--r--sal/osl/unx/file_misc.cxx23
-rw-r--r--sal/osl/unx/file_url.cxx36
-rw-r--r--sal/osl/unx/memory.cxx12
-rw-r--r--sal/osl/unx/module.cxx41
-rw-r--r--sal/osl/unx/pipe.cxx62
-rw-r--r--sal/osl/unx/profile.cxx20
-rw-r--r--sal/osl/unx/random.cxx5
-rw-r--r--sal/osl/unx/security.cxx9
-rw-r--r--sal/osl/unx/socket.cxx53
11 files changed, 197 insertions, 232 deletions
diff --git a/sal/osl/unx/conditn.cxx b/sal/osl/unx/conditn.cxx
index ba86f937018f..56eadde87a17 100644
--- a/sal/osl/unx/conditn.cxx
+++ b/sal/osl/unx/conditn.cxx
@@ -209,7 +209,7 @@ oslConditionResult SAL_CALL osl_waitCondition(oslCondition Condition, const Time
return Result;
}
- else if ( ret != EINTR )
+ if ( ret != EINTR )
{
Result = osl_cond_result_error;
nRet = pthread_mutex_unlock(&pCond->m_Lock);
diff --git a/sal/osl/unx/file.cxx b/sal/osl/unx/file.cxx
index 416533a64de1..933780f87d8f 100644
--- a/sal/osl/unx/file.cxx
+++ b/sal/osl/unx/file.cxx
@@ -431,64 +431,62 @@ oslFileError FileHandle_Impl::readFileAt (
*pBytesRead = nBytes;
return osl_File_E_None;
}
- else if (m_kind == KIND_MEM || nullptr == m_buffer)
+ if (m_kind == KIND_MEM || nullptr == m_buffer)
{
// not buffered
return readAt (nOffset, pBuffer, nBytesRequested, pBytesRead);
}
- else
+
+ sal_uInt8 * buffer = static_cast<sal_uInt8*>(pBuffer);
+ for (*pBytesRead = 0; nBytesRequested > 0; )
{
- sal_uInt8 * buffer = static_cast<sal_uInt8*>(pBuffer);
- for (*pBytesRead = 0; nBytesRequested > 0; )
- {
- off_t const bufptr = (nOffset / m_bufsiz) * m_bufsiz;
- size_t const bufpos = (nOffset % m_bufsiz);
+ off_t const bufptr = (nOffset / m_bufsiz) * m_bufsiz;
+ size_t const bufpos = (nOffset % m_bufsiz);
- if (bufptr != m_bufptr)
+ if (bufptr != m_bufptr)
+ {
+ // flush current buffer
+ oslFileError result = syncFile();
+ if (result != osl_File_E_None)
+ return result;
+ m_bufptr = -1;
+ m_buflen = 0;
+
+ if (nBytesRequested >= m_bufsiz)
{
- // flush current buffer
- oslFileError result = syncFile();
- if (result != osl_File_E_None)
- return result;
- m_bufptr = -1;
- m_buflen = 0;
-
- if (nBytesRequested >= m_bufsiz)
- {
- // buffer too small, read through from file
- sal_uInt64 uDone = 0;
- result = readAt (nOffset, &(buffer[*pBytesRead]), nBytesRequested, &uDone);
- if (result != osl_File_E_None)
- return result;
-
- *pBytesRead += uDone;
- return osl_File_E_None;
- }
-
- // update buffer (pointer)
+ // buffer too small, read through from file
sal_uInt64 uDone = 0;
- result = readAt (bufptr, m_buffer, m_bufsiz, &uDone);
+ result = readAt (nOffset, &(buffer[*pBytesRead]), nBytesRequested, &uDone);
if (result != osl_File_E_None)
return result;
- m_bufptr = bufptr;
- m_buflen = uDone;
- }
- if (bufpos >= m_buflen)
- {
- // end of file
+
+ *pBytesRead += uDone;
return osl_File_E_None;
}
- size_t const bytes = std::min (m_buflen - bufpos, nBytesRequested);
- SAL_INFO("sal.file", "FileHandle_Impl::readFileAt(" << m_fd << ", " << nOffset << ", " << bytes << ")");
-
- memcpy (&(buffer[*pBytesRead]), &(m_buffer[bufpos]), bytes);
- nBytesRequested -= bytes;
- *pBytesRead += bytes;
- nOffset += bytes;
+ // update buffer (pointer)
+ sal_uInt64 uDone = 0;
+ result = readAt (bufptr, m_buffer, m_bufsiz, &uDone);
+ if (result != osl_File_E_None)
+ return result;
+ m_bufptr = bufptr;
+ m_buflen = uDone;
}
- return osl_File_E_None;
+ if (bufpos >= m_buflen)
+ {
+ // end of file
+ return osl_File_E_None;
+ }
+
+ size_t const bytes = std::min (m_buflen - bufpos, nBytesRequested);
+ SAL_INFO("sal.file", "FileHandle_Impl::readFileAt(" << m_fd << ", " << nOffset << ", " << bytes << ")");
+
+ memcpy (&(buffer[*pBytesRead]), &(m_buffer[bufpos]), bytes);
+ nBytesRequested -= bytes;
+ *pBytesRead += bytes;
+ nOffset += bytes;
}
+ return osl_File_E_None;
}
oslFileError FileHandle_Impl::writeFileAt (
@@ -506,63 +504,61 @@ oslFileError FileHandle_Impl::writeFileAt (
*pBytesWritten = nBytes;
return osl_File_E_None;
}
- else if (nullptr == m_buffer)
+ if (nullptr == m_buffer)
{
// not buffered
return writeAt (nOffset, pBuffer, nBytesToWrite, pBytesWritten);
}
- else
+
+ sal_uInt8 const * buffer = static_cast<sal_uInt8 const *>(pBuffer);
+ for (*pBytesWritten = 0; nBytesToWrite > 0; )
{
- sal_uInt8 const * buffer = static_cast<sal_uInt8 const *>(pBuffer);
- for (*pBytesWritten = 0; nBytesToWrite > 0; )
+ off_t const bufptr = (nOffset / m_bufsiz) * m_bufsiz;
+ size_t const bufpos = (nOffset % m_bufsiz);
+ if (bufptr != m_bufptr)
{
- off_t const bufptr = (nOffset / m_bufsiz) * m_bufsiz;
- size_t const bufpos = (nOffset % m_bufsiz);
- if (bufptr != m_bufptr)
+ // flush current buffer
+ oslFileError result = syncFile();
+ if (result != osl_File_E_None)
+ return result;
+ m_bufptr = -1;
+ m_buflen = 0;
+
+ if (nBytesToWrite >= m_bufsiz)
{
- // flush current buffer
- oslFileError result = syncFile();
- if (result != osl_File_E_None)
- return result;
- m_bufptr = -1;
- m_buflen = 0;
-
- if (nBytesToWrite >= m_bufsiz)
- {
- // buffer to small, write through to file
- sal_uInt64 uDone = 0;
- result = writeAt (nOffset, &(buffer[*pBytesWritten]), nBytesToWrite, &uDone);
- if (result != osl_File_E_None)
- return result;
- if (uDone != nBytesToWrite)
- return osl_File_E_IO;
-
- *pBytesWritten += uDone;
- return osl_File_E_None;
- }
-
- // update buffer (pointer)
+ // buffer to small, write through to file
sal_uInt64 uDone = 0;
- result = readAt (bufptr, m_buffer, m_bufsiz, &uDone);
+ result = writeAt (nOffset, &(buffer[*pBytesWritten]), nBytesToWrite, &uDone);
if (result != osl_File_E_None)
return result;
- m_bufptr = bufptr;
- m_buflen = uDone;
+ if (uDone != nBytesToWrite)
+ return osl_File_E_IO;
+
+ *pBytesWritten += uDone;
+ return osl_File_E_None;
}
- size_t const bytes = std::min (m_bufsiz - bufpos, nBytesToWrite);
- SAL_INFO("sal.file", "FileHandle_Impl::writeFileAt(" << m_fd << ", " << nOffset << ", " << bytes << ")");
+ // update buffer (pointer)
+ sal_uInt64 uDone = 0;
+ result = readAt (bufptr, m_buffer, m_bufsiz, &uDone);
+ if (result != osl_File_E_None)
+ return result;
+ m_bufptr = bufptr;
+ m_buflen = uDone;
+ }
- memcpy (&(m_buffer[bufpos]), &(buffer[*pBytesWritten]), bytes);
- nBytesToWrite -= bytes;
- *pBytesWritten += bytes;
- nOffset += bytes;
+ size_t const bytes = std::min (m_bufsiz - bufpos, nBytesToWrite);
+ SAL_INFO("sal.file", "FileHandle_Impl::writeFileAt(" << m_fd << ", " << nOffset << ", " << bytes << ")");
- m_buflen = std::max(m_buflen, bufpos + bytes);
- m_state |= STATE_MODIFIED;
- }
- return osl_File_E_None;
+ memcpy (&(m_buffer[bufpos]), &(buffer[*pBytesWritten]), bytes);
+ nBytesToWrite -= bytes;
+ *pBytesWritten += bytes;
+ nOffset += bytes;
+
+ m_buflen = std::max(m_buflen, bufpos + bytes);
+ m_state |= STATE_MODIFIED;
}
+ return osl_File_E_None;
}
oslFileError FileHandle_Impl::readLineAt (
diff --git a/sal/osl/unx/file_misc.cxx b/sal/osl/unx/file_misc.cxx
index ec599a3416b6..a651ed5cd342 100644
--- a/sal/osl/unx/file_misc.cxx
+++ b/sal/osl/unx/file_misc.cxx
@@ -207,11 +207,8 @@ oslFileError SAL_CALL osl_openDirectory(rtl_uString* ustrDirectoryURL, oslDirect
*pDirectory = static_cast<oslDirectory>(pDirImpl);
return osl_File_E_None;
}
- else
- {
- errno = ENOMEM;
- closedir( pdir );
- }
+ errno = ENOMEM;
+ closedir( pdir );
}
else
{
@@ -274,8 +271,7 @@ static struct dirent* osl_readdir_impl_(DIR* pdir, bool bFilterLocalAndParentDir
if (bFilterLocalAndParentDir &&
((strcmp(pdirent->d_name, ".") == 0) || (strcmp(pdirent->d_name, "..") == 0)))
continue;
- else
- break;
+ break;
}
return pdirent;
@@ -493,8 +489,7 @@ static int path_make_parent(sal_Unicode* path)
*(path + i) = 0;
return i;
}
- else
- return 0;
+ return 0;
}
static int create_dir_with_callback(
@@ -775,10 +770,8 @@ static oslFileError osl_psz_copyFile( const sal_Char* pszPath, const sal_Char* p
{
return osl_File_E_ISDIR;
}
- else
- {
- /* mfe: file does not exists or is no dir */
- }
+
+ /* mfe: file does not exists or is no dir */
tErr = oslDoCopy(pszPath,pszDestPath,nMode,nSourceSize,DestFileExists);
@@ -924,8 +917,8 @@ static int oslDoCopyLink(const sal_Char* pszSourceFileName, const sal_Char* pszD
nRet=errno;
return nRet;
}
- else
- pszLinkContent[ nRet ] = 0;
+
+ pszLinkContent[ nRet ] = 0;
nRet = symlink(pszLinkContent,pszDestFileName);
diff --git a/sal/osl/unx/file_url.cxx b/sal/osl/unx/file_url.cxx
index ddf2be4d8098..69ba4349b968 100644
--- a/sal/osl/unx/file_url.cxx
+++ b/sal/osl/unx/file_url.cxx
@@ -126,7 +126,7 @@ oslFileError getSystemPathFromFileUrl(
}
i = j + 1;
break;
- } else if (!rtl::isAsciiAlphanumeric(c) && c != '+' && c != '-'
+ } if (!rtl::isAsciiAlphanumeric(c) && c != '+' && c != '-'
&& c != '.')
{
break;
@@ -202,10 +202,9 @@ oslFileError getSystemPathFromFileUrl(
return osl_File_E_INVAL;
}
return getSystemPathFromFileUrl(home, path, false);
- } else {
- // FIXME: replace ~user with user's home directory
- return osl_File_E_INVAL;
}
+ // FIXME: replace ~user with user's home directory
+ return osl_File_E_INVAL;
}
return osl_File_E_None;
}
@@ -500,12 +499,12 @@ namespace
punresolved++;
continue;
}
- else if (*(punresolved + 1) == '/')
+ if (*(punresolved + 1) == '/')
{
punresolved += 2;
continue;
}
- else if ((*(punresolved + 1) == '.') && (*(punresolved + 2) == '\0' || (*(punresolved + 2) == '/')))
+ if ((*(punresolved + 1) == '.') && (*(punresolved + 2) == '\0' || (*(punresolved + 2) == '/')))
{
_rmlastpathtoken(path_resolved_so_far);
@@ -518,22 +517,21 @@ namespace
continue;
}
- else // a file or directory name may start with '.'
- {
- if ((presolvedsf = ustrtoend(path_resolved_so_far)) > sentinel)
- return oslTranslateFileError(OSL_FET_ERROR, ENAMETOOLONG);
+ // a file or directory name may start with '.'
- ustrchrcat(*punresolved++, path_resolved_so_far);
+ if ((presolvedsf = ustrtoend(path_resolved_so_far)) > sentinel)
+ return oslTranslateFileError(OSL_FET_ERROR, ENAMETOOLONG);
- if (*punresolved == '\0' && !realpath_failed)
- {
- ferr = _osl_resolvepath(
- path_resolved_so_far,
- &realpath_failed);
+ ustrchrcat(*punresolved++, path_resolved_so_far);
- if (ferr != osl_File_E_None)
- return ferr;
- }
+ if (*punresolved == '\0' && !realpath_failed)
+ {
+ ferr = _osl_resolvepath(
+ path_resolved_so_far,
+ &realpath_failed);
+
+ if (ferr != osl_File_E_None)
+ return ferr;
}
}
else if (*punresolved == '/')
diff --git a/sal/osl/unx/memory.cxx b/sal/osl/unx/memory.cxx
index db376ecaf722..745a7f14c3f2 100644
--- a/sal/osl/unx/memory.cxx
+++ b/sal/osl/unx/memory.cxx
@@ -20,16 +20,14 @@ void* osl_aligned_alloc( sal_Size align, sal_Size size )
{
return nullptr;
}
- else
- {
+
#if defined __ANDROID__
- return memalign(align, size);
+ return memalign(align, size);
#else
- void* ptr;
- int err = posix_memalign(&ptr, align, size);
- return err ? nullptr : ptr;
+ void* ptr;
+ int err = posix_memalign(&ptr, align, size);
+ return err ? nullptr : ptr;
#endif
- }
}
void osl_aligned_free( void* p )
diff --git a/sal/osl/unx/module.cxx b/sal/osl/unx/module.cxx
index d99abc32fd04..207b0379a924 100644
--- a/sal/osl/unx/module.cxx
+++ b/sal/osl/unx/module.cxx
@@ -172,28 +172,27 @@ oslModule osl_loadModuleRelativeAscii(
assert(relativePath && "illegal argument");
if (relativePath[0] == '/') {
return osl_loadModuleAscii(relativePath, mode);
- } else {
- rtl_String * path = nullptr;
- rtl_String * suffix = nullptr;
- oslModule module;
- if (!getModulePathFromAddress(
- reinterpret_cast< void * >(baseModule), &path))
- {
- return nullptr;
- }
- rtl_string_newFromStr_WithLength(
- &path, path->buffer,
- (rtl_str_lastIndexOfChar_WithLength(path->buffer, path->length, '/')
- + 1));
- /* cut off everything after the last slash; should the original path
- contain no slash, the resulting path is the empty string */
- rtl_string_newFromStr(&suffix, relativePath);
- rtl_string_newConcat(&path, path, suffix);
- rtl_string_release(suffix);
- module = osl_loadModuleAscii(path->buffer, mode);
- rtl_string_release(path);
- return module;
}
+ rtl_String * path = nullptr;
+ rtl_String * suffix = nullptr;
+ oslModule module;
+ if (!getModulePathFromAddress(
+ reinterpret_cast< void * >(baseModule), &path))
+ {
+ return nullptr;
+ }
+ rtl_string_newFromStr_WithLength(
+ &path, path->buffer,
+ (rtl_str_lastIndexOfChar_WithLength(path->buffer, path->length, '/')
+ + 1));
+ /* cut off everything after the last slash; should the original path
+ contain no slash, the resulting path is the empty string */
+ rtl_string_newFromStr(&suffix, relativePath);
+ rtl_string_newConcat(&path, path, suffix);
+ rtl_string_release(suffix);
+ module = osl_loadModuleAscii(path->buffer, mode);
+ rtl_string_release(path);
+ return module;
}
#endif // !DISABLE_DYNLOADING
diff --git a/sal/osl/unx/pipe.cxx b/sal/osl/unx/pipe.cxx
index c47d92b429c5..18a3dac02174 100644
--- a/sal/osl/unx/pipe.cxx
+++ b/sal/osl/unx/pipe.cxx
@@ -300,22 +300,20 @@ oslPipe SAL_CALL osl_psz_createPipe(const sal_Char *pszPipeName, oslPipeOptions
return pPipe;
}
- else
- { /* osl_pipe_OPEN */
- if ( access(name, F_OK) != -1 )
- {
- if ( connect( pPipe->m_Socket, reinterpret_cast<sockaddr *>(&addr), len) >= 0 )
- {
- return pPipe;
- }
- SAL_WARN("sal.osl.pipe", "connect() failed: " << strerror(errno));
+ /* osl_pipe_OPEN */
+ if ( access(name, F_OK) != -1 )
+ {
+ if ( connect( pPipe->m_Socket, reinterpret_cast<sockaddr *>(&addr), len) >= 0 )
+ {
+ return pPipe;
}
-
- close (pPipe->m_Socket);
- destroyPipeImpl(pPipe);
- return nullptr;
+ SAL_WARN("sal.osl.pipe", "connect() failed: " << strerror(errno));
}
+
+ close (pPipe->m_Socket);
+ destroyPipeImpl(pPipe);
+ return nullptr;
}
void SAL_CALL osl_acquirePipe( oslPipe pPipe )
@@ -444,32 +442,30 @@ oslPipe SAL_CALL osl_acceptPipe(oslPipe pPipe)
return nullptr;
}
#endif /* CLOSESOCKET_DOESNT_WAKE_UP_ACCEPT */
- else
- {
- /* alloc memory */
- pAcceptedPipe = createPipeImpl();
- OSL_ASSERT(pAcceptedPipe);
- if(pAcceptedPipe==nullptr)
- {
- close(s);
- return nullptr;
- }
+ /* alloc memory */
+ pAcceptedPipe = createPipeImpl();
+
+ OSL_ASSERT(pAcceptedPipe);
+ if(pAcceptedPipe==nullptr)
+ {
+ close(s);
+ return nullptr;
+ }
- /* set close-on-exec flag */
- int flags;
- if (!((flags = fcntl(s, F_GETFD, 0)) < 0))
+ /* set close-on-exec flag */
+ int flags;
+ if (!((flags = fcntl(s, F_GETFD, 0)) < 0))
+ {
+ flags |= FD_CLOEXEC;
+ if (fcntl(s, F_SETFD, flags) < 0)
{
- flags |= FD_CLOEXEC;
- if (fcntl(s, F_SETFD, flags) < 0)
- {
- SAL_WARN("sal.osl.pipe", "fcntl() failed: " << strerror(errno));
- }
+ SAL_WARN("sal.osl.pipe", "fcntl() failed: " << strerror(errno));
}
-
- pAcceptedPipe->m_Socket = s;
}
+ pAcceptedPipe->m_Socket = s;
+
return pAcceptedPipe;
}
diff --git a/sal/osl/unx/profile.cxx b/sal/osl/unx/profile.cxx
index 17bf399bde8e..a979c7b8e71b 100644
--- a/sal/osl/unx/profile.cxx
+++ b/sal/osl/unx/profile.cxx
@@ -1842,20 +1842,18 @@ static bool releaseProfile(osl_TProfileImpl* pProfile)
{
return osl_closeProfile(static_cast<oslProfile>(pProfile));
}
- else
+
+ if (! (pProfile->m_Flags & (osl_Profile_READLOCK | osl_Profile_WRITELOCK | osl_Profile_FLUSHWRITE )))
{
- if (! (pProfile->m_Flags & (osl_Profile_READLOCK | osl_Profile_WRITELOCK | osl_Profile_FLUSHWRITE )))
+ if (pProfile->m_Flags & FLG_MODIFIED)
{
- if (pProfile->m_Flags & FLG_MODIFIED)
- {
- bool bRet = storeProfile(pProfile, false);
- SAL_WARN_IF(!bRet, "sal.osl", "storeProfile(pProfile, false) ==> false");
- (void)bRet;
- }
-
- closeFileImpl(pProfile->m_pFile,pProfile->m_Flags);
- pProfile->m_pFile = nullptr;
+ bool bRet = storeProfile(pProfile, false);
+ SAL_WARN_IF(!bRet, "sal.osl", "storeProfile(pProfile, false) ==> false");
+ (void)bRet;
}
+
+ closeFileImpl(pProfile->m_pFile,pProfile->m_Flags);
+ pProfile->m_pFile = nullptr;
}
return true;
diff --git a/sal/osl/unx/random.cxx b/sal/osl/unx/random.cxx
index f9c97755b233..6f7d4a8adfb8 100644
--- a/sal/osl/unx/random.cxx
+++ b/sal/osl/unx/random.cxx
@@ -40,10 +40,7 @@ int osl_get_system_random_data(char* buffer, size_t desired_len)
close(fd);
return true;
}
- else
- {
- return false;
- }
+ return false;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sal/osl/unx/security.cxx b/sal/osl/unx/security.cxx
index 701f6e775499..f14107c1ba23 100644
--- a/sal/osl/unx/security.cxx
+++ b/sal/osl/unx/security.cxx
@@ -65,12 +65,11 @@ static bool sysconf_SC_GETPW_R_SIZE_MAX(std::size_t * value) {
FreeBSD versions support sysconf(_SC_GETPW_R_SIZE_MAX) in a broken
way and always set EINVAL, so be resilient here: */
return false;
- } else {
- SAL_WARN_IF( m < 0 || (unsigned long) m >= std::numeric_limits<std::size_t>::max(), "sal.osl",
- "m < 0 || (unsigned long) m >= std::numeric_limits<std::size_t>::max()");
- *value = (std::size_t) m;
- return true;
}
+ SAL_WARN_IF( m < 0 || (unsigned long) m >= std::numeric_limits<std::size_t>::max(), "sal.osl",
+ "m < 0 || (unsigned long) m >= std::numeric_limits<std::size_t>::max()");
+ *value = (std::size_t) m;
+ return true;
#else
/* some platforms like Mac OS X 1.3 do not define _SC_GETPW_R_SIZE_MAX: */
return false;
diff --git a/sal/osl/unx/socket.cxx b/sal/osl/unx/socket.cxx
index 0771ccfc3f0e..dd4055bab54d 100644
--- a/sal/osl/unx/socket.cxx
+++ b/sal/osl/unx/socket.cxx
@@ -959,8 +959,7 @@ oslHostAddr SAL_CALL osl_copyHostAddr (const oslHostAddr pAddr)
if (pAddr)
return osl_psz_createHostAddr (pAddr->pHostName, pAddr->pSockAddr);
- else
- return nullptr;
+ return nullptr;
}
void SAL_CALL osl_getHostnameOfHostAddr (
@@ -980,8 +979,7 @@ const sal_Char* SAL_CALL osl_psz_getHostnameOfHostAddr (const oslHostAddr pAddr)
{
if (pAddr)
return pAddr->pHostName;
- else
- return nullptr;
+ return nullptr;
}
oslSocketAddr SAL_CALL osl_getSocketAddrOfHostAddr (const oslHostAddr pAddr)
@@ -990,8 +988,7 @@ oslSocketAddr SAL_CALL osl_getSocketAddrOfHostAddr (const oslHostAddr pAddr)
if (pAddr)
return pAddr->pSockAddr;
- else
- return nullptr;
+ return nullptr;
}
void SAL_CALL osl_destroyHostAddr (oslHostAddr pAddr)
@@ -1182,8 +1179,7 @@ oslAddrFamily SAL_CALL osl_getFamilyOfSocketAddr(oslSocketAddr pAddr)
if (pAddr)
return FAMILY_FROM_NATIVE(pAddr->m_sockaddr.sa_family);
- else
- return osl_Socket_FamilyInvalid;
+ return osl_Socket_FamilyInvalid;
}
sal_Int32 SAL_CALL osl_getInetPortOfSocketAddr(oslSocketAddr pAddr)
@@ -1554,12 +1550,12 @@ oslSocketResult SAL_CALL osl_connectSocketTo(oslSocket pSocket,
&(pAddr->m_sockaddr),
sizeof(struct sockaddr)) != OSL_SOCKET_ERROR)
return osl_Socket_Ok;
- else
- if (errno == EWOULDBLOCK || errno == EINPROGRESS)
- {
- pSocket->m_nLastError=EINPROGRESS;
- return osl_Socket_InProgress;
- }
+
+ if (errno == EWOULDBLOCK || errno == EINPROGRESS)
+ {
+ pSocket->m_nLastError=EINPROGRESS;
+ return osl_Socket_InProgress;
+ }
pSocket->m_nLastError=errno;
int nErrno = errno;
@@ -1581,18 +1577,16 @@ oslSocketResult SAL_CALL osl_connectSocketTo(oslSocket pSocket,
return osl_Socket_Ok;
}
- else
+
+ /* really an error or just delayed? */
+ if (errno != EINPROGRESS)
{
- /* really an error or just delayed? */
- if (errno != EINPROGRESS)
- {
- pSocket->m_nLastError=errno;
- int nErrno = errno;
- SAL_WARN( "sal.osl", "connection failed: (" << nErrno << ") " << strerror(nErrno) );
+ pSocket->m_nLastError=errno;
+ int nErrno = errno;
+ SAL_WARN( "sal.osl", "connection failed: (" << nErrno << ") " << strerror(nErrno) );
- osl_enableNonBlockingMode(pSocket, false);
- return osl_Socket_Error;
- }
+ osl_enableNonBlockingMode(pSocket, false);
+ return osl_Socket_Error;
}
/* prepare select set for socket */
@@ -1645,11 +1639,8 @@ oslSocketResult SAL_CALL osl_connectSocketTo(oslSocket pSocket,
/* already destroyed */
return osl_Socket_Interrupted;
}
- else
- {
- pSocket->m_nLastError=errno;
- Result= osl_Socket_Error;
- }
+ pSocket->m_nLastError=errno;
+ Result= osl_Socket_Error;
}
else /* timeout */
{
@@ -2244,8 +2235,8 @@ sal_Bool SAL_CALL osl_isNonBlockingMode(oslSocket pSocket)
if (flags == -1 || !(flags & O_NONBLOCK))
return false;
- else
- return true;
+
+ return true;
}
oslSocketType SAL_CALL osl_getSocketType(oslSocket pSocket)