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

Chris Sherlock chris.sherlock79 at gmail.com
Fri Jul 7 19:18:30 UTC 2017


 sal/osl/unx/file_misc.cxx |   47 +++++++++++++++++++++++-----------------------
 1 file changed, 24 insertions(+), 23 deletions(-)

New commits:
commit 00def4025b5fd95b0fc8d88fbbb9477526e8b12e
Author: Chris Sherlock <chris.sherlock79 at gmail.com>
Date:   Wed Jul 5 12:19:01 2017 +1000

    osl: unx osl_getNextDirectoryItem() cleanup
    
    I could not easily tell on first reading this function if Directory was
    a pointer or not (it is), so changed name to pDirectory). The signature
    was too long, so fixed this, whitespacing was inconsistent so small
    change there. Also converted to more contentional testing of nullptr.
    
    Change-Id: Ia8b1d33a4a4fbe3e050d63116997ef57a28d73b3
    Reviewed-on: https://gerrit.libreoffice.org/39537
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Michael Stahl <mstahl at redhat.com>

diff --git a/sal/osl/unx/file_misc.cxx b/sal/osl/unx/file_misc.cxx
index 5ff4d62bb4d2..4b6c9e12b8fd 100644
--- a/sal/osl/unx/file_misc.cxx
+++ b/sal/osl/unx/file_misc.cxx
@@ -277,21 +277,22 @@ static struct dirent* osl_readdir_impl_(DIR* pdir, bool bFilterLocalAndParentDir
     return pdirent;
 }
 
-oslFileError SAL_CALL osl_getNextDirectoryItem(oslDirectory Directory, oslDirectoryItem* pItem, SAL_UNUSED_PARAMETER sal_uInt32 /*uHint*/)
+oslFileError SAL_CALL osl_getNextDirectoryItem(oslDirectory pDirectory,
+        oslDirectoryItem* pItem, SAL_UNUSED_PARAMETER sal_uInt32 /*uHint*/)
 {
-    oslDirectoryImpl* pDirImpl     = static_cast<oslDirectoryImpl*>(Directory);
-    rtl_uString*      ustrFileName = nullptr;
-    rtl_uString*      ustrFilePath = nullptr;
-    struct dirent*    pEntry;
+    oslDirectoryImpl* pDirImpl = static_cast<oslDirectoryImpl*>(pDirectory);
+    rtl_uString* ustrFileName = nullptr;
+    rtl_uString* ustrFilePath = nullptr;
+    struct dirent* pEntry;
 
-    OSL_ASSERT(Directory);
+    OSL_ASSERT(pDirectory);
     OSL_ASSERT(pItem);
 
-    if ((Directory == nullptr) || (pItem == nullptr))
+    if ((pDirectory == nullptr) || (pItem == nullptr))
         return osl_File_E_INVAL;
 
 #ifdef ANDROID
-    if( pDirImpl->eKind == oslDirectoryImpl::KIND_ASSETS )
+    if(pDirImpl->eKind == oslDirectoryImpl::KIND_ASSETS)
     {
         pEntry = lo_apk_readdir(pDirImpl->pApkDirStruct);
     }
@@ -301,34 +302,34 @@ oslFileError SAL_CALL osl_getNextDirectoryItem(oslDirectory Directory, oslDirect
         pEntry = osl_readdir_impl_(pDirImpl->pDirStruct, true);
     }
 
-    if (pEntry == nullptr)
+    if (!pEntry)
         return osl_File_E_NOENT;
 
 #if defined(MACOSX)
 
     // convert decomposed filename to precomposed unicode
     char composed_name[BUFSIZ];
-    CFMutableStringRef strRef = CFStringCreateMutable (nullptr, 0 );
-    CFStringAppendCString( strRef, pEntry->d_name, kCFStringEncodingUTF8 );  //UTF8 is default on Mac OSX
-    CFStringNormalize( strRef, kCFStringNormalizationFormC );
-    CFStringGetCString( strRef, composed_name, BUFSIZ, kCFStringEncodingUTF8 );
-    CFRelease( strRef );
-    rtl_string2UString( &ustrFileName, composed_name, strlen( composed_name),
-    osl_getThreadTextEncoding(), OSTRING_TO_OUSTRING_CVTFLAGS );
+    CFMutableStringRef strRef = CFStringCreateMutable(nullptr, 0 );
+    CFStringAppendCString(strRef, pEntry->d_name, kCFStringEncodingUTF8);  // UTF8 is default on Mac OSX
+    CFStringNormalize(strRef, kCFStringNormalizationFormC);
+    CFStringGetCString(strRef, composed_name, BUFSIZ, kCFStringEncodingUTF8);
+    CFRelease(strRef);
+    rtl_string2UString(&ustrFileName, composed_name, strlen(composed_name),
+                       osl_getThreadTextEncoding(), OSTRING_TO_OUSTRING_CVTFLAGS);
 
 #else  // not MACOSX
     /* convert file name to unicode */
-    rtl_string2UString( &ustrFileName, pEntry->d_name, strlen( pEntry->d_name ),
-        osl_getThreadTextEncoding(), OSTRING_TO_OUSTRING_CVTFLAGS );
-    OSL_ASSERT(ustrFileName != nullptr);
+    rtl_string2UString(&ustrFileName, pEntry->d_name, strlen(pEntry->d_name),
+                       osl_getThreadTextEncoding(), OSTRING_TO_OUSTRING_CVTFLAGS);
+    OSL_ASSERT(ustrFileName);
 
 #endif
 
     osl_systemPathMakeAbsolutePath(pDirImpl->ustrPath, ustrFileName, &ustrFilePath);
-    rtl_uString_release( ustrFileName );
+    rtl_uString_release(ustrFileName);
 
-    DirectoryItem_Impl * pImpl = static_cast< DirectoryItem_Impl* >(*pItem);
-    if (pImpl != nullptr)
+    DirectoryItem_Impl* pImpl = static_cast< DirectoryItem_Impl* >(*pItem);
+    if (pImpl)
     {
         pImpl->release();
         pImpl = nullptr;
@@ -339,7 +340,7 @@ oslFileError SAL_CALL osl_getNextDirectoryItem(oslDirectory Directory, oslDirect
     pImpl = new DirectoryItem_Impl(ustrFilePath);
 #endif /* _DIRENT_HAVE_D_TYPE */
     *pItem = pImpl;
-    rtl_uString_release( ustrFilePath );
+    rtl_uString_release(ustrFilePath);
 
     return osl_File_E_None;
 }


More information about the Libreoffice-commits mailing list