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>
diff --git a/cppu/qa/test_any.cxx b/cppu/qa/test_any.cxx
index d76ffc0..38d3500 100644
--- a/cppu/qa/test_any.cxx
+++ b/cppu/qa/test_any.cxx
@@ -92,12 +92,12 @@ public:
            css::uno::Reference< css::uno::XInterface > ref(
                static_cast< css::uno::XInterface * >(this));
            return css::uno::Any(&ref, type);
        } else if (type == cppu::UnoType<Interface1>::get()) {
        }
        if (type == cppu::UnoType<Interface1>::get()) {
            css::uno::Reference< Interface1 > ref(this);
            return css::uno::Any(&ref, type);
        } else {
            return css::uno::Any();
        }
        return css::uno::Any();
    }

    virtual void SAL_CALL acquire() throw () override {
@@ -118,18 +118,20 @@ public:
                static_cast< css::uno::XInterface * >(
                    static_cast< Interface2a * >(this)));
            return css::uno::Any(&ref, type);
        } else if (type == cppu::UnoType<Interface2>::get()) {
        }
        if (type == cppu::UnoType<Interface2>::get()) {
            css::uno::Reference< Interface2 > ref(this);
            return css::uno::Any(&ref, type);
        } else if (type == cppu::UnoType<Interface2a>::get()) {
        }
        if (type == cppu::UnoType<Interface2a>::get()) {
            css::uno::Reference< Interface2a > ref(this);
            return css::uno::Any(&ref, type);
        } else if (type == cppu::UnoType<Interface3>::get()) {
        }
        if (type == cppu::UnoType<Interface3>::get()) {
            css::uno::Reference< Interface3 > ref(this);
            return css::uno::Any(&ref, type);
        } else {
            return css::uno::Any();
        }
        return css::uno::Any();
    }

    virtual void SAL_CALL acquire() throw () override {
@@ -150,18 +152,20 @@ public:
                static_cast< css::uno::XInterface * >(
                    static_cast< Interface2a * >(this)));
            return css::uno::Any(&ref, type);
        } else if (type == cppu::UnoType<Interface2>::get()) {
        }
        if (type == cppu::UnoType<Interface2>::get()) {
            css::uno::Reference< Interface2 > ref(this);
            return css::uno::Any(&ref, type);
        } else if (type == cppu::UnoType<Interface2a>::get()) {
        }
        if (type == cppu::UnoType<Interface2a>::get()) {
            css::uno::Reference< Interface2a > ref(this);
            return css::uno::Any(&ref, type);
        } else if (type == cppu::UnoType<Interface2b>::get()) {
        }
        if (type == cppu::UnoType<Interface2b>::get()) {
            css::uno::Reference< Interface2b > ref(this);
            return css::uno::Any(&ref, type);
        } else {
            return css::uno::Any();
        }
        return css::uno::Any();
    }

    virtual void SAL_CALL acquire() throw () override {
diff --git a/cppu/qa/test_reference.cxx b/cppu/qa/test_reference.cxx
index 15a926f..3c6b7af 100644
--- a/cppu/qa/test_reference.cxx
+++ b/cppu/qa/test_reference.cxx
@@ -56,7 +56,7 @@ public:
            return css::uno::makeAny<css::uno::Reference<css::uno::XInterface>>(
                this);
        }
        else if (_type == cppu::UnoType<Interface1>::get())
        if (_type == cppu::UnoType<Interface1>::get())
        {
            return css::uno::makeAny<css::uno::Reference<Interface1>>(this);
        }
diff --git a/cppu/source/typelib/static_types.cxx b/cppu/source/typelib/static_types.cxx
index 33e5b29..0a7c1ac 100644
--- a/cppu/source/typelib/static_types.cxx
+++ b/cppu/source/typelib/static_types.cxx
@@ -104,10 +104,7 @@ static inline typelib_TypeDescriptionReference * igetTypeByName( rtl_uString * p
    {
        return pRef;
    }
    else
    {
        return nullptr;
    }
    return nullptr;
}

extern "C"
diff --git a/cppu/source/typelib/typelib.cxx b/cppu/source/typelib/typelib.cxx
index 52d1a2e..f869e79 100644
--- a/cppu/source/typelib/typelib.cxx
+++ b/cppu/source/typelib/typelib.cxx
@@ -1489,11 +1489,8 @@ extern "C" void SAL_CALL typelib_typedescription_register(
                        ::typelib_typedescriptionreference_release( pTDR );
                        return;
                    }
                    else
                    {
                        // destruction of this type in progress (another thread!)
                        (void)osl_atomic_decrement( &pTDR->pType->nRefCount );
                    }
                    // destruction of this type in progress (another thread!)
                    (void)osl_atomic_decrement( &pTDR->pType->nRefCount );
                }
                // take new descr
                pTDR->pType = *ppNewDescription;
@@ -2205,13 +2202,10 @@ extern "C" void SAL_CALL typelib_typedescriptionreference_getDescription(
            *ppRet = pRef->pType;
            return;
        }
        else
        {
            (void)osl_atomic_decrement( &pRef->pType->nRefCount );
            // destruction of this type in progress (another thread!)
            // no access through this weak reference
            pRef->pType = nullptr;
        }
        (void)osl_atomic_decrement( &pRef->pType->nRefCount );
        // destruction of this type in progress (another thread!)
        // no access through this weak reference
        pRef->pType = nullptr;
    }
    }

@@ -2339,51 +2333,48 @@ extern "C" sal_Bool SAL_CALL typelib_typedescriptionreference_isAssignableFrom(
            {
                return true;
            }
            else
            switch (eAssignable)
            {
                switch (eAssignable)
            case typelib_TypeClass_STRUCT:
            case typelib_TypeClass_EXCEPTION:
            {
                typelib_TypeDescription * pFromDescr = nullptr;
                TYPELIB_DANGER_GET( &pFromDescr, pFrom );
                if (!reinterpret_cast<typelib_CompoundTypeDescription *>(pFromDescr)->pBaseTypeDescription)
                {
                case typelib_TypeClass_STRUCT:
                case typelib_TypeClass_EXCEPTION:
                {
                    typelib_TypeDescription * pFromDescr = nullptr;
                    TYPELIB_DANGER_GET( &pFromDescr, pFrom );
                    if (!reinterpret_cast<typelib_CompoundTypeDescription *>(pFromDescr)->pBaseTypeDescription)
                    {
                        TYPELIB_DANGER_RELEASE( pFromDescr );
                        return false;
                    }
                    bool bRet = typelib_typedescriptionreference_isAssignableFrom(
                        pAssignable,
                        reinterpret_cast<typelib_CompoundTypeDescription *>(pFromDescr)->pBaseTypeDescription->aBase.pWeakRef );
                    TYPELIB_DANGER_RELEASE( pFromDescr );
                    return bRet;
                }
                case typelib_TypeClass_INTERFACE:
                {
                    typelib_TypeDescription * pFromDescr = nullptr;
                    TYPELIB_DANGER_GET( &pFromDescr, pFrom );
                    typelib_InterfaceTypeDescription * pFromIfc
                        = reinterpret_cast<
                            typelib_InterfaceTypeDescription * >(pFromDescr);
                    bool bRet = false;
                    for (sal_Int32 i = 0; i < pFromIfc->nBaseTypes; ++i) {
                        if (typelib_typedescriptionreference_isAssignableFrom(
                                pAssignable,
                                pFromIfc->ppBaseTypes[i]->aBase.pWeakRef))
                        {
                            bRet = true;
                            break;
                        }
                    }
                    TYPELIB_DANGER_RELEASE( pFromDescr );
                    return bRet;
                }
                default:
                {
                    return false;
                }
                bool bRet = typelib_typedescriptionreference_isAssignableFrom(
                    pAssignable,
                    reinterpret_cast<typelib_CompoundTypeDescription *>(pFromDescr)->pBaseTypeDescription->aBase.pWeakRef );
                TYPELIB_DANGER_RELEASE( pFromDescr );
                return bRet;
            }
            case typelib_TypeClass_INTERFACE:
            {
                typelib_TypeDescription * pFromDescr = nullptr;
                TYPELIB_DANGER_GET( &pFromDescr, pFrom );
                typelib_InterfaceTypeDescription * pFromIfc
                    = reinterpret_cast<
                        typelib_InterfaceTypeDescription * >(pFromDescr);
                bool bRet = false;
                for (sal_Int32 i = 0; i < pFromIfc->nBaseTypes; ++i) {
                    if (typelib_typedescriptionreference_isAssignableFrom(
                            pAssignable,
                            pFromIfc->ppBaseTypes[i]->aBase.pWeakRef))
                    {
                        bRet = true;
                        break;
                    }
                }
                TYPELIB_DANGER_RELEASE( pFromDescr );
                return bRet;
            }
            default:
            {
                return false;
            }
            }
        }
        return (eAssignable >= typelib_TypeClass_CHAR && eAssignable <= typelib_TypeClass_DOUBLE &&
diff --git a/cppu/source/uno/lbmap.cxx b/cppu/source/uno/lbmap.cxx
index 476198a..e8dcc57 100644
--- a/cppu/source/uno/lbmap.cxx
+++ b/cppu/source/uno/lbmap.cxx
@@ -475,10 +475,7 @@ static Mapping getDirectMapping(
            aGuard.clear();
            return loadExternalMapping( rFrom, rTo, rAddPurpose );
        }
        else
        {
            return Mapping( (*iFind).second->pMapping );
        }
        return Mapping( (*iFind).second->pMapping );
    }
    return Mapping();
}
diff --git a/cppu/source/uno/sequence.cxx b/cppu/source/uno/sequence.cxx
index e7a6465..3fbe338 100644
--- a/cppu/source/uno/sequence.cxx
+++ b/cppu/source/uno/sequence.cxx
@@ -305,11 +305,8 @@ static inline bool idefaultConstructElements(
        OSL_ASSERT( nAlloc >= 0 ); // must have been an allocation failure
        return false;
    }
    else
    {
        *ppSeq = pSeq;
        return true;
    }
    *ppSeq = pSeq;
    return true;
}


@@ -568,11 +565,8 @@ static inline bool icopyConstructFromElements(
    {
        return false; // allocation failure
    }
    else
    {
        *ppSeq = pSeq;
        return true;
    }
    *ppSeq = pSeq;
    return true;
}


diff --git a/cppuhelper/source/component.cxx b/cppuhelper/source/component.cxx
index aa8e68c..fdff1a2 100644
--- a/cppuhelper/source/component.cxx
+++ b/cppuhelper/source/component.cxx
@@ -58,7 +58,7 @@ Any OComponentHelper::queryAggregation( Type const & rType )
        void * p = static_cast< lang::XComponent * >( this );
        return Any( &p, rType );
    }
    else if (rType == cppu::UnoType<lang::XTypeProvider>::get())
    if (rType == cppu::UnoType<lang::XTypeProvider>::get())
    {
        void * p = static_cast< lang::XTypeProvider * >( this );
        return Any( &p, rType );
diff --git a/cppuhelper/source/component_context.cxx b/cppuhelper/source/component_context.cxx
index 355445d..2df1b49 100644
--- a/cppuhelper/source/component_context.cxx
+++ b/cppuhelper/source/component_context.cxx
@@ -359,8 +359,7 @@ Any ComponentContext::lookupMap( OUString const & rName )
            pEntry->lateInit = false;
            return pEntry->value;
        }
        else
            ret = pEntry->value;
        ret = pEntry->value;
    }
    guard.clear();
    if (ret != xInstance) {
@@ -377,8 +376,7 @@ Any ComponentContext::getValueByName( OUString const & rName )
    {
        if (m_xDelegate.is())
            return m_xDelegate->getValueByName( rName );
        else
            return Any( Reference<XComponentContext>(this) );
        return Any( Reference<XComponentContext>(this) );
    }

    Any ret( lookupMap( rName ) );
diff --git a/cppuhelper/source/factory.cxx b/cppuhelper/source/factory.cxx
index 55b4f55..9ed9d0d 100644
--- a/cppuhelper/source/factory.cxx
+++ b/cppuhelper/source/factory.cxx
@@ -139,7 +139,7 @@ Reference<XInterface > OSingleFactoryHelper::createInstanceEveryTime(
    {
        return (*m_fptr)( xContext );
    }
    else if( pCreateFunction )
    if( pCreateFunction )
    {
        if (xContext.is())
        {
@@ -150,10 +150,7 @@ Reference<XInterface > OSingleFactoryHelper::createInstanceEveryTime(
        }
        return (*pCreateFunction)( xSMgr );
    }
    else
    {
        return Reference< XInterface >();
    }
    return Reference< XInterface >();
}

// XSingleServiceFactory
@@ -510,8 +507,7 @@ Any SAL_CALL ORegistryFactoryHelper::queryInterface(
    Any ret( OFactoryComponentHelper::queryInterface( type ) );
    if (ret.hasValue())
        return ret;
    else
        return OPropertySetHelper::queryInterface( type );
    return OPropertySetHelper::queryInterface( type );
}


@@ -624,7 +620,7 @@ Reference<XInterface > ORegistryFactoryHelper::createInstanceEveryTime(
    {
        return xModuleFactory->createInstanceWithContext( xContext );
    }
    else if( xModuleFactoryDepr.is() )
    if( xModuleFactoryDepr.is() )
    {
        return xModuleFactoryDepr->createInstance();
    }
@@ -652,7 +648,7 @@ Reference<XInterface > SAL_CALL ORegistryFactoryHelper::createInstanceWithArgume
    {
        return xModuleFactoryDepr->createInstanceWithArguments( Arguments );
    }
    else if( xModuleFactory.is() )
    if( xModuleFactory.is() )
    {
        SAL_INFO("cppuhelper", "no context ORegistryFactoryHelper::createInstanceWithArgumentsAndContext()!");
        return xModuleFactory->createInstanceWithArgumentsAndContext( Arguments, Reference< XComponentContext >() );
@@ -682,7 +678,7 @@ Reference< XInterface > ORegistryFactoryHelper::createInstanceWithArgumentsAndCo
    {
        return xModuleFactory->createInstanceWithArgumentsAndContext( rArguments, xContext );
    }
    else if( xModuleFactoryDepr.is() )
    if( xModuleFactoryDepr.is() )
    {
        SAL_INFO_IF(xContext.is(), "cppuhelper", "ignoring context calling ORegistryFactoryHelper::createInstaceWithArgumentsAndContext()!");
        return xModuleFactoryDepr->createInstanceWithArguments( rArguments );
diff --git a/cppuhelper/source/implbase_ex.cxx b/cppuhelper/source/implbase_ex.cxx
index 485e729..6025db0 100644
--- a/cppuhelper/source/implbase_ex.cxx
+++ b/cppuhelper/source/implbase_ex.cxx
@@ -247,10 +247,7 @@ Any SAL_CALL ImplHelper_queryNoXInterface(
    {
        return Any( &p, pTDR );
    }
    else
    {
        return Any();
    }
    return Any();
}

css::uno::Sequence<sal_Int8> ImplHelper_getImplementationId(
diff --git a/cppuhelper/source/interfacecontainer.cxx b/cppuhelper/source/interfacecontainer.cxx
index 6198986..2eb7197 100644
--- a/cppuhelper/source/interfacecontainer.cxx
+++ b/cppuhelper/source/interfacecontainer.cxx
@@ -115,7 +115,7 @@ XInterface * OInterfaceIteratorHelper::next()
        if( bIsList )
            // typecase to const,so the getArray method is faster
            return aData.pAsSequence->getConstArray()[nRemain].get();
        else if( aData.pAsInterface )
        if( aData.pAsInterface )
            return aData.pAsInterface;
    }
    // exception
@@ -159,7 +159,7 @@ sal_Int32 OInterfaceContainerHelper::getLength() const
    MutexGuard aGuard( rMutex );
    if( bIsList )
        return aData.pAsSequence->getLength();
    else if( aData.pAsInterface )
    if( aData.pAsInterface )
        return 1;
    return 0;
}
@@ -169,7 +169,7 @@ Sequence< Reference<XInterface> > OInterfaceContainerHelper::getElements() const
    MutexGuard aGuard( rMutex );
    if( bIsList )
        return *aData.pAsSequence;
    else if( aData.pAsInterface )
    if( aData.pAsInterface )
    {
        Reference<XInterface> x( aData.pAsInterface );
        return Sequence< Reference< XInterface > >( &x, 1 );
@@ -207,7 +207,7 @@ sal_Int32 OInterfaceContainerHelper::addInterface( const Reference<XInterface> &
        aData.pAsSequence->getArray()[ nLen ] = rListener;
        return nLen +1;
    }
    else if( aData.pAsInterface )
    if( aData.pAsInterface )
    {
        Sequence< Reference< XInterface > > * pSeq = new Sequence< Reference< XInterface > >( 2 );
        Reference<XInterface> * pArray = pSeq->getArray();
@@ -218,13 +218,10 @@ sal_Int32 OInterfaceContainerHelper::addInterface( const Reference<XInterface> &
        bIsList = true;
        return 2;
    }
    else
    {
        aData.pAsInterface = rListener.get();
        if( rListener.is() )
            rListener->acquire();
        return 1;
    }
    aData.pAsInterface = rListener.get();
    if( rListener.is() )
        rListener->acquire();
    return 1;
}

sal_Int32 OInterfaceContainerHelper::removeInterface( const Reference<XInterface> & rListener )
@@ -271,10 +268,9 @@ sal_Int32 OInterfaceContainerHelper::removeInterface( const Reference<XInterface
            bIsList = false;
            return 1;
        }
        else
            return aData.pAsSequence->getLength();
        return aData.pAsSequence->getLength();
    }
    else if( aData.pAsInterface && Reference<XInterface>( aData.pAsInterface ) == rListener )
    if( aData.pAsInterface && Reference<XInterface>( aData.pAsInterface ) == rListener )
    {
        aData.pAsInterface->release();
        aData.pAsInterface = nullptr;
@@ -423,8 +419,7 @@ sal_Int32 OMultiTypeInterfaceContainerHelper::addInterface(
        pMap->push_back(std::pair<Type, void*>(rKey, pLC));
        return pLC->addInterface( rListener );
    }
    else
        return static_cast<OInterfaceContainerHelper*>((*iter).second)->addInterface( rListener );
    return static_cast<OInterfaceContainerHelper*>((*iter).second)->addInterface( rListener );
}

sal_Int32 OMultiTypeInterfaceContainerHelper::removeInterface(
@@ -595,8 +590,7 @@ sal_Int32 OMultiTypeInterfaceContainerHelperInt32::addInterface(
        pMap->push_back(std::pair< sal_Int32, void* >(rKey, pLC));
        return pLC->addInterface( rListener );
    }
    else
        return static_cast<OInterfaceContainerHelper*>((*iter).second)->addInterface( rListener );
    return static_cast<OInterfaceContainerHelper*>((*iter).second)->addInterface( rListener );
}

sal_Int32 OMultiTypeInterfaceContainerHelperInt32::removeInterface(
diff --git a/cppuhelper/source/propertysetmixin.cxx b/cppuhelper/source/propertysetmixin.cxx
index 00769d5..741afb42 100644
--- a/cppuhelper/source/propertysetmixin.cxx
+++ b/cppuhelper/source/propertysetmixin.cxx
@@ -750,7 +750,8 @@ css::uno::Any PropertySetMixinImpl::Impl::wrapValue(
                object);
        }
        return strct;
    } else if (wrapDefaulted
    }
    if (wrapDefaulted
               && type->getName().startsWith("com.sun.star.beans.Defaulted<"))
    {
        css::uno::Any strct;
@@ -778,7 +779,8 @@ css::uno::Any PropertySetMixinImpl::Impl::wrapValue(
                object);
        }
        return strct;
    } else if (wrapOptional
    }
    if (wrapOptional
               && type->getName().startsWith("com.sun.star.beans.Optional<"))
    {
        css::uno::Any strct;
@@ -809,13 +811,12 @@ css::uno::Any PropertySetMixinImpl::Impl::wrapValue(
                object);
        }
        return strct;
    } else {
        if (wrapAmbiguous || wrapDefaulted || wrapOptional) {
            throw css::uno::RuntimeException(
                "unexpected type of attribute", object);
        }
        return value;
    }
    if (wrapAmbiguous || wrapDefaulted || wrapOptional) {
        throw css::uno::RuntimeException(
            "unexpected type of attribute", object);
    }
    return value;
}

PropertySetMixinImpl::PropertySetMixinImpl(
@@ -954,21 +955,22 @@ css::uno::Any PropertySetMixinImpl::queryInterface(css::uno::Type const & type)
        css::uno::Reference< css::uno::XInterface > ifc(
            static_cast< css::beans::XPropertySet * >(this));
        return css::uno::Any(&ifc, type);
    } else if ((m_impl->implements & IMPLEMENTS_FAST_PROPERTY_SET) != 0
    }
    if ((m_impl->implements & IMPLEMENTS_FAST_PROPERTY_SET) != 0
               && type == css::beans::XFastPropertySet::static_type())
    {
        css::uno::Reference< css::uno::XInterface > ifc(
            static_cast< css::beans::XFastPropertySet * >(this));
        return css::uno::Any(&ifc, type);
    } else if ((m_impl->implements & IMPLEMENTS_PROPERTY_ACCESS) != 0
    }
    if ((m_impl->implements & IMPLEMENTS_PROPERTY_ACCESS) != 0
               && type == css::beans::XPropertyAccess::static_type())
    {
        css::uno::Reference< css::uno::XInterface > ifc(
            static_cast< css::beans::XPropertyAccess * >(this));
        return css::uno::Any(&ifc, type);
    } else {
        return css::uno::Any();
    }
    return css::uno::Any();
}

css::uno::Reference< css::beans::XPropertySetInfo >
diff --git a/cppuhelper/source/propshlp.cxx b/cppuhelper/source/propshlp.cxx
index 5533e98..8cc395a 100644
--- a/cppuhelper/source/propshlp.cxx
+++ b/cppuhelper/source/propshlp.cxx
@@ -220,8 +220,7 @@ Any OPropertySetHelper2::queryInterface( const css::uno::Type & rType )
    Any cnd(cppu::queryInterface(rType, static_cast< XPropertySetOption * >(this)));
    if ( cnd.hasValue() )
        return cnd;
    else
        return OPropertySetHelper::queryInterface(rType);
    return OPropertySetHelper::queryInterface(rType);
}

/**
@@ -1054,19 +1053,16 @@ sal_Bool OPropertyArrayHelper::fillPropertyMembersByHandle
            *pAttributes = pProperties[ nHandle ].Attributes;
        return true;
    }
    else
    // normally the array is sorted
    for( sal_Int32 i = 0; i < nElements; i++ )
    {
        // normally the array is sorted
        for( sal_Int32 i = 0; i < nElements; i++ )
        if( pProperties[i].Handle == nHandle )
        {
            if( pProperties[i].Handle == nHandle )
            {
                if( pPropName )
                    *pPropName = pProperties[ i ].Name;
                if( pAttributes )
                    *pAttributes = pProperties[ i ].Attributes;
                return true;
            }
            if( pPropName )
                *pPropName = pProperties[ i ].Name;
            if( pAttributes )
                *pAttributes = pProperties[ i ].Attributes;
            return true;
        }
    }
    return false;
diff --git a/cppuhelper/source/shlib.cxx b/cppuhelper/source/shlib.cxx
index e3791ac..e78071b 100644
--- a/cppuhelper/source/shlib.cxx
+++ b/cppuhelper/source/shlib.cxx
@@ -127,37 +127,36 @@ css::uno::Reference<css::uno::XInterface> invokeComponentFactory(
            static_cast<css::uno::XInterface *>(
                (*function)(impl.getStr(), serviceManager.get(), nullptr)),
            SAL_NO_ACQUIRE);
    } else {
        css::uno::Mapping mapTo(source, target);
        css::uno::Mapping mapFrom(target, source);
        if (!(mapTo.is() && mapFrom.is())) {
            throw css::loader::CannotActivateFactoryException(
                "cannot get mappings",
                css::uno::Reference<css::uno::XInterface>());
        }
        void * smgr = mapTo.mapInterface(
            serviceManager.get(),
            cppu::UnoType<css::lang::XMultiServiceFactory>::get());
        void * factory = nullptr;
        target.invoke(getFactory, function, &impl, smgr, &factory);
        if (smgr != nullptr) {
            (*target.get()->pExtEnv->releaseInterface)(
                target.get()->pExtEnv, smgr);
        }
        if (factory == nullptr) {
            throw css::loader::CannotActivateFactoryException(
                ("calling factory function for \"" + implementation + "\" in <"
                 + uri + "> returned null"),
                css::uno::Reference<css::uno::XInterface>());
        }
        css::uno::Reference<css::uno::XInterface> res;
        mapFrom.mapInterface(
            reinterpret_cast<void **>(&res), factory,
            cppu::UnoType<css::uno::XInterface>::get());
        (*target.get()->pExtEnv->releaseInterface)(
            target.get()->pExtEnv, factory);
        return res;
    }
    css::uno::Mapping mapTo(source, target);
    css::uno::Mapping mapFrom(target, source);
    if (!(mapTo.is() && mapFrom.is())) {
        throw css::loader::CannotActivateFactoryException(
            "cannot get mappings",
            css::uno::Reference<css::uno::XInterface>());
    }
    void * smgr = mapTo.mapInterface(
        serviceManager.get(),
        cppu::UnoType<css::lang::XMultiServiceFactory>::get());
    void * factory = nullptr;
    target.invoke(getFactory, function, &impl, smgr, &factory);
    if (smgr != nullptr) {
        (*target.get()->pExtEnv->releaseInterface)(
            target.get()->pExtEnv, smgr);
    }
    if (factory == nullptr) {
        throw css::loader::CannotActivateFactoryException(
            ("calling factory function for \"" + implementation + "\" in <"
             + uri + "> returned null"),
            css::uno::Reference<css::uno::XInterface>());
    }
    css::uno::Reference<css::uno::XInterface> res;
    mapFrom.mapInterface(
        reinterpret_cast<void **>(&res), factory,
        cppu::UnoType<css::uno::XInterface>::get());
    (*target.get()->pExtEnv->releaseInterface)(
        target.get()->pExtEnv, factory);
    return res;
}

#if !defined DISABLE_DYNLOADING
@@ -186,44 +185,43 @@ cppuhelper::WrapperConstructorFn mapConstructorFn(
    }
    if (source.get() == target.get()) {
        return cppuhelper::WrapperConstructorFn(constructorFunction);
    } else {
        // note: it should be valid to capture these mappings because they are
        // ref-counted, and the returned closure will always be invoked in the
        // "source" environment
        css::uno::Mapping mapTo(source, target);
        css::uno::Mapping mapFrom(target, source);
        if (!(mapTo.is() && mapFrom.is())) {
            throw css::loader::CannotActivateFactoryException(
                "cannot get mappings",
                css::uno::Reference<css::uno::XInterface>());
        }
        return [mapFrom, mapTo, target, constructorFunction]
            (css::uno::XComponentContext *const context, css::uno::Sequence<css::uno::Any> const& args)
            {
                void *const ctxt = mapTo.mapInterface(
                    context,
                    cppu::UnoType<css::uno::XComponentContext>::get());
                if (args.getLength() > 0) {
                    std::abort(); // TODO map args
                }
                void * instance = nullptr;
                target.invoke(getInstance, constructorFunction, ctxt, &args, &instance);
                if (ctxt != nullptr) {
                    (*target.get()->pExtEnv->releaseInterface)(
                        target.get()->pExtEnv, ctxt);
                }
                css::uno::XInterface * res = nullptr;
                if (instance == nullptr) {
                    return res;
                }
                mapFrom.mapInterface(
                    reinterpret_cast<void **>(&res), instance,
                    cppu::UnoType<css::uno::XInterface>::get());
                (*target.get()->pExtEnv->releaseInterface)(
                    target.get()->pExtEnv, instance);
                return res;
            };
    }
    // note: it should be valid to capture these mappings because they are
    // ref-counted, and the returned closure will always be invoked in the
    // "source" environment
    css::uno::Mapping mapTo(source, target);
    css::uno::Mapping mapFrom(target, source);
    if (!(mapTo.is() && mapFrom.is())) {
        throw css::loader::CannotActivateFactoryException(
            "cannot get mappings",
            css::uno::Reference<css::uno::XInterface>());
    }
    return [mapFrom, mapTo, target, constructorFunction]
        (css::uno::XComponentContext *const context, css::uno::Sequence<css::uno::Any> const& args)
        {
            void *const ctxt = mapTo.mapInterface(
                context,
                cppu::UnoType<css::uno::XComponentContext>::get());
            if (args.getLength() > 0) {
                std::abort(); // TODO map args
            }
            void * instance = nullptr;
            target.invoke(getInstance, constructorFunction, ctxt, &args, &instance);
            if (ctxt != nullptr) {
                (*target.get()->pExtEnv->releaseInterface)(
                    target.get()->pExtEnv, ctxt);
            }
            css::uno::XInterface * res = nullptr;
            if (instance == nullptr) {
                return res;
            }
            mapFrom.mapInterface(
                reinterpret_cast<void **>(&res), instance,
                cppu::UnoType<css::uno::XInterface>::get());
            (*target.get()->pExtEnv->releaseInterface)(
                target.get()->pExtEnv, instance);
            return res;
        };
}

#endif
diff --git a/sal/osl/unx/conditn.cxx b/sal/osl/unx/conditn.cxx
index ba86f93..56eadde 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 416533a..933780f 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);

        if (bufptr != m_bufptr)
        {
            off_t  const bufptr = (nOffset / m_bufsiz) * m_bufsiz;
            size_t const bufpos = (nOffset % m_bufsiz);
            // flush current buffer
            oslFileError result = syncFile();
            if (result != osl_File_E_None)
                return result;
            m_bufptr = -1;
            m_buflen = 0;

            if (bufptr != m_bufptr)
            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 << ")");

            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;
            // 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;

        size_t const bytes = std::min (m_bufsiz - bufpos, nBytesToWrite);
        SAL_INFO("sal.file", "FileHandle_Impl::writeFileAt(" << m_fd << ", " << nOffset << ", " << bytes << ")");

        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 ec599a3..a651ed5 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 ddf2be4..69ba434 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 '.'
                // a file or directory name may start with '.'

                if ((presolvedsf = ustrtoend(path_resolved_so_far)) > sentinel)
                    return oslTranslateFileError(OSL_FET_ERROR, ENAMETOOLONG);

                ustrchrcat(*punresolved++, path_resolved_so_far);

                if (*punresolved == '\0' && !realpath_failed)
                {
                    if ((presolvedsf = ustrtoend(path_resolved_so_far)) > sentinel)
                        return oslTranslateFileError(OSL_FET_ERROR, ENAMETOOLONG);
                    ferr = _osl_resolvepath(
                        path_resolved_so_far,
                        &realpath_failed);

                    ustrchrcat(*punresolved++, path_resolved_so_far);

                    if (*punresolved == '\0' && !realpath_failed)
                    {
                        ferr = _osl_resolvepath(
                            path_resolved_so_far,
                            &realpath_failed);

                        if (ferr != osl_File_E_None)
                            return ferr;
                    }
                    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 db376ec..745a7f1 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 d99abc3..207b037 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 c47d92b..18a3dac 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 )

    /* osl_pipe_OPEN */
    if ( access(name, F_OK) != -1 )
    {
        if ( connect( pPipe->m_Socket, reinterpret_cast<sockaddr *>(&addr), len) >= 0 )
        {
            if ( connect( pPipe->m_Socket, reinterpret_cast<sockaddr *>(&addr), len) >= 0 )
            {
                return pPipe;
            }

            SAL_WARN("sal.osl.pipe", "connect() failed: " << strerror(errno));
            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)
    {
        /* 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))
        {
            flags |= FD_CLOEXEC;
            if (fcntl(s, F_SETFD, flags) < 0)
            {
                SAL_WARN("sal.osl.pipe", "fcntl() failed: " <<  strerror(errno));
            }
        }

        pAcceptedPipe->m_Socket = s;
        close(s);
        return nullptr;
    }

    /* 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)
        {
            SAL_WARN("sal.osl.pipe", "fcntl() failed: " <<  strerror(errno));
        }
    }

    pAcceptedPipe->m_Socket = s;

    return pAcceptedPipe;
}

diff --git a/sal/osl/unx/profile.cxx b/sal/osl/unx/profile.cxx
index 17bf399..a979c7b 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 & 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;
    if (! (pProfile->m_Flags & (osl_Profile_READLOCK | osl_Profile_WRITELOCK | osl_Profile_FLUSHWRITE )))
    {
        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;
    }

    return true;
diff --git a/sal/osl/unx/random.cxx b/sal/osl/unx/random.cxx
index f9c9775..6f7d4a8 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 701f6e7..f14107c 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 0771ccf..dd4055b 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)
        {
            pSocket->m_nLastError=errno;
            int nErrno = errno;
            SAL_WARN( "sal.osl", "connection failed: (" << nErrno << ") " << strerror(nErrno) );

            osl_enableNonBlockingMode(pSocket, false);
            return osl_Socket_Error;
        }
    /* 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) );

        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)
diff --git a/sal/rtl/bootstrap.cxx b/sal/rtl/bootstrap.cxx
index 6455c35..4a5fabf 100644
--- a/sal/rtl/bootstrap.cxx
+++ b/sal/rtl/bootstrap.cxx
@@ -76,10 +76,9 @@ bool resolvePathnameUrl(rtl::OUString * url) {
         osl::FileBase::E_None))
    {
        return true;
    } else {
        *url = rtl::OUString();
        return false;
    }
    *url = rtl::OUString();
    return false;
}

enum LookupMode {
@@ -537,9 +536,8 @@ bool Bootstrap_Impl::getDirectValue(
    if (find(_nameValueList, key, &v)) {
        expandValue(value, v, mode, this, key, requestStack);
        return true;
    } else {
        return false;
    }
    return false;
}

bool Bootstrap_Impl::getAmbienceValue(
@@ -557,9 +555,8 @@ bool Bootstrap_Impl::getAmbienceValue(
    {
        expandValue(value, v, mode, nullptr, key, requestStack);
        return true;
    } else {
        return false;
    }
    return false;
}

void Bootstrap_Impl::expandValue(
@@ -838,7 +835,8 @@ sal_Unicode read(rtl::OUString const & text, sal_Int32 * pos, bool * escaped) {
            *escaped = true;
            return static_cast< sal_Unicode >(
                (n1 << 12) | (n2 << 8) | (n3 << 4) | n4);
        } else if (*pos < text.getLength()) {
        }
        if (*pos < text.getLength()) {
            *escaped = true;
            return text[(*pos)++];
        }
diff --git a/sal/rtl/digest.cxx b/sal/rtl/digest.cxx
index 51cef81..068db56 100644
--- a/sal/rtl/digest.cxx
+++ b/sal/rtl/digest.cxx
@@ -135,8 +135,7 @@ rtlDigestAlgorithm SAL_CALL rtl_digest_queryAlgorithm (rtlDigest Digest)
    Digest_Impl *pImpl = static_cast<Digest_Impl *>(Digest);
    if (pImpl)
        return pImpl->m_algorithm;
    else
        return rtl_Digest_AlgorithmInvalid;
    return rtl_Digest_AlgorithmInvalid;
}

/*
@@ -148,8 +147,7 @@ sal_uInt32 SAL_CALL rtl_digest_queryLength (rtlDigest Digest)
    Digest_Impl *pImpl = static_cast<Digest_Impl *>(Digest);
    if (pImpl)
        return pImpl->m_length;
    else
        return 0;
    return 0;
}

/*
@@ -164,8 +162,7 @@ rtlDigestError SAL_CALL rtl_digest_init (
    {
        if (pImpl->m_init)
            return pImpl->m_init (Digest, pData, nDatLen);
        else
            return rtl_Digest_E_None;
        return rtl_Digest_E_None;
    }
    return rtl_Digest_E_Argument;
}
@@ -180,8 +177,7 @@ rtlDigestError SAL_CALL rtl_digest_update (
    Digest_Impl *pImpl = static_cast<Digest_Impl *>(Digest);
    if (pImpl && pImpl->m_update)
        return pImpl->m_update (Digest, pData, nDatLen);
    else
        return rtl_Digest_E_Argument;
    return rtl_Digest_E_Argument;
}

/*
@@ -194,8 +190,7 @@ rtlDigestError SAL_CALL rtl_digest_get (
    Digest_Impl *pImpl = static_cast<Digest_Impl *>(Digest);
    if (pImpl && pImpl->m_get)
        return pImpl->m_get (Digest, pBuffer, nBufLen);
    else
        return rtl_Digest_E_Argument;
    return rtl_Digest_E_Argument;
}

/*
diff --git a/sal/rtl/math.cxx b/sal/rtl/math.cxx
index 5dc94e0..7eeeb85 100644
--- a/sal/rtl/math.cxx
+++ b/sal/rtl/math.cxx
@@ -54,18 +54,16 @@ static double getN10Exp( int nExp )
        // because -nExp = nExp
        if ( -nExp <= n10Count && -nExp > 0 )
            return n10s[1][-nExp-1];
        else
            return pow( 10.0, static_cast<double>( nExp ) );
        return pow( 10.0, static_cast<double>( nExp ) );
    }
    else if ( nExp > 0 )
    if ( nExp > 0 )
    {
        if ( nExp <= n10Count )
            return n10s[0][nExp-1];
        else
            return pow( 10.0, static_cast<double>( nExp ) );
        return pow( 10.0, static_cast<double>( nExp ) );
    }
    else // ( nExp == 0 )
        return 1.0;
    // ( nExp == 0 )
    return 1.0;
}

namespace {
@@ -1144,21 +1142,19 @@ double SAL_CALL rtl_math_asinh( double fX ) SAL_THROW_EXTERN_C()
{
    if ( fX == 0.0 )
        return 0.0;
    else

    double fSign = 1.0;
    if ( fX < 0.0 )
    {
        double fSign = 1.0;
        if ( fX < 0.0 )
        {
            fX = - fX;
            fSign = -1.0;
        }
        if ( fX < 0.125 )
            return fSign * rtl_math_log1p( fX + fX*fX / (1.0 + sqrt( 1.0 + fX*fX)));
        else if ( fX < 1.25e7 )
            return fSign * log( fX + sqrt( 1.0 + fX*fX));
        else
            return fSign * log( 2.0*fX);
        fX = - fX;
        fSign = -1.0;
    }
    if ( fX < 0.125 )
        return fSign * rtl_math_log1p( fX + fX*fX / (1.0 + sqrt( 1.0 + fX*fX)));
    if ( fX < 1.25e7 )
        return fSign * log( fX + sqrt( 1.0 + fX*fX));

    return fSign * log( 2.0*fX);
}

/** improved accuracy of acosh for x large and for x near 1
@@ -1173,14 +1169,13 @@ double SAL_CALL rtl_math_acosh( double fX ) SAL_THROW_EXTERN_C()
        ::rtl::math::setNan( &fResult );
        return fResult;
    }
    else if ( fX == 1.0 )
    if ( fX == 1.0 )
        return 0.0;
    else if ( fX < 1.1 )
    if ( fX < 1.1 )
        return rtl_math_log1p( fZ + sqrt( fZ*fZ + 2.0*fZ));
    else if ( fX < 1.25e7 )
    if ( fX < 1.25e7 )
        return log( fX + sqrt( fX*fX - 1.0));
    else
        return log( 2.0*fX);
    return log( 2.0*fX);
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sal/rtl/uri.cxx b/sal/rtl/uri.cxx
index b00dfb9..91653f6 100644
--- a/sal/rtl/uri.cxx
+++ b/sal/rtl/uri.cxx
@@ -176,7 +176,7 @@ sal_uInt32 readUcs4(sal_Unicode const ** pBegin, sal_Unicode const * pEnd,
                    return nDstSize == 1
                        ? aDst[0] : rtl::combineSurrogates(aDst[0], aDst[1]);
                }
                else if (nInfo == RTL_TEXTTOUNICODE_INFO_SRCBUFFERTOSMALL
                if (nInfo == RTL_TEXTTOUNICODE_INFO_SRCBUFFERTOSMALL
                         && pEnd - p >= 3 && p[0] == cEscapePrefix
                         && (nWeight1 = getHexWeight(p[1])) >= 0
                         && (nWeight2 = getHexWeight(p[2])) >= 0)
@@ -202,13 +202,11 @@ sal_uInt32 readUcs4(sal_Unicode const ** pBegin, sal_Unicode const * pEnd,
        }
        return nChar;
    }
    else
    {
        *pType = EscapeNo;
        return rtl::isHighSurrogate(nChar) && *pBegin < pEnd
               && rtl::isLowSurrogate(**pBegin) ?
                   rtl::combineSurrogates(nChar, *(*pBegin)++) : nChar;
    }

    *pType = EscapeNo;
    return rtl::isHighSurrogate(nChar) && *pBegin < pEnd
           && rtl::isLowSurrogate(**pBegin) ?
               rtl::combineSurrogates(nChar, *(*pBegin)++) : nChar;
}

void writeUcs4(rtl_uString ** pBuffer, sal_Int32 * pCapacity, sal_uInt32 nUtf32)
@@ -305,9 +303,8 @@ bool writeEscapeChar(rtl_uString ** pBuffer, sal_Int32 * pCapacity,
        } else {
            if (bStrict) {
                return false;
            } else {
                writeUcs4(pBuffer, pCapacity, nUtf32);
            }
            writeUcs4(pBuffer, pCapacity, nUtf32);
        }
    }
    return true;
@@ -359,7 +356,7 @@ void parseUriRef(rtl_uString const * pUriRef, Components * pComponents)
                pPos = p;
                break;
            }
            else if (!rtl::isAsciiAlphanumeric(*p) && *p != '+' && *p != '-'
            if (!rtl::isAsciiAlphanumeric(*p) && *p != '+' && *p != '-'
                     && *p != '.')
            {
                break;
diff --git a/sal/rtl/ustring.cxx b/sal/rtl/ustring.cxx
index 3d15727..85ac84a 100644
--- a/sal/rtl/ustring.cxx
+++ b/sal/rtl/ustring.cxx
@@ -1017,7 +1017,7 @@ void SAL_CALL rtl_uString_internConvert( rtl_uString   ** newStr,
            rtl_ustring_intern_internal( newStr, pScratch, CANNOT_RETURN );
            return;
        }
        else if ( (ulen = rtl_canGuessUOutputLength(len, eTextEncoding)) != 0 )
        if ( (ulen = rtl_canGuessUOutputLength(len, eTextEncoding)) != 0 )
        {
            rtl_uString *pScratch;
            rtl_TextToUnicodeConverter hConverter;
diff --git a/sal/textenc/converter.cxx b/sal/textenc/converter.cxx
index bbf172d..109469f 100644
--- a/sal/textenc/converter.cxx
+++ b/sal/textenc/converter.cxx
@@ -150,8 +150,7 @@ sal::detail::textenc::handleBadInputUnicodeToTextConversion(
            *pPrefixWritten = true;
        return BAD_INPUT_CONTINUE;
    }
    else
        return BAD_INPUT_NO_OUTPUT;
    return BAD_INPUT_NO_OUTPUT;
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sal/textenc/convertgb18030.cxx b/sal/textenc/convertgb18030.cxx
index ee52a98..dec9d48 100644
--- a/sal/textenc/convertgb18030.cxx
+++ b/sal/textenc/convertgb18030.cxx
@@ -363,7 +363,7 @@ sal_Size ImplConvertUnicodeToGb18030(void const * pData,
                        goto no_output;
                    break;
                }
                else if (nChar <= pRange->m_nLastUnicode)
                if (nChar <= pRange->m_nLastUnicode)
                {
                    if (pDestBufEnd - pDestBufPtr >= 4)
                    {
diff --git a/sal/textenc/convertisciidevangari.cxx b/sal/textenc/convertisciidevangari.cxx
index 8a025ef..2e7f09e 100644
--- a/sal/textenc/convertisciidevangari.cxx
+++ b/sal/textenc/convertisciidevangari.cxx
@@ -194,7 +194,7 @@ sal_Size IsciiDevanagariToUnicode::convert(
                continue;
            if (eAction == BAD_INPUT_STOP)
                break;
            else if (eAction == BAD_INPUT_NO_OUTPUT)
            if (eAction == BAD_INPUT_NO_OUTPUT)
            {
                nInfo |= RTL_TEXTTOUNICODE_INFO_DESTBUFFERTOSMALL;
                break;
@@ -358,7 +358,7 @@ sal_Size UnicodeToIsciiDevanagari::convert(sal_Unicode const* pSrcBuf, sal_Size 
            {
                break;
            }
            else if (c <= sal::static_int_cast< sal_uInt32 >(
            if (c <= sal::static_int_cast< sal_uInt32 >(
                           ranges[i].unicode + ranges[i].range))
            {
                if (pDestBufEnd - pDestBufPtr < 1)
diff --git a/sal/textenc/convertsimple.cxx b/sal/textenc/convertsimple.cxx
index 6e08b5f..99689f6 100644
--- a/sal/textenc/convertsimple.cxx
+++ b/sal/textenc/convertsimple.cxx
@@ -497,11 +497,8 @@ int ImplConvertUnicodeCharToChar(
                    dest[0] = static_cast< char >(pCharExData->mnChar);
                    if ( pCharExData->mnChar2 == 0 )
                        return 1;
                    else
                    {
                        dest[1] = static_cast< char >(pCharExData->mnChar2);
                        return 2;
                    }
                    dest[1] = static_cast< char >(pCharExData->mnChar2);
                    return 2;
                }
            }
        }
@@ -546,13 +543,12 @@ sal_Size sal::detail::textenc::convertCharToUnicode(
                    *pInfo |= RTL_TEXTTOUNICODE_INFO_ERROR;
                    break;
                }
                else if ( (nFlags & RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_MASK) == RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_IGNORE )
                if ( (nFlags & RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_MASK) == RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_IGNORE )
                {
                    pSrcBuf++;
                    continue;
                }
                else
                    cConv = ImplGetUndefinedUnicodeChar(c, nFlags);
                cConv = ImplGetUndefinedUnicodeChar(c, nFlags);
            }
        }

@@ -642,8 +638,7 @@ sal_Size sal::detail::textenc::convertUnicodeToChar(
                                &pSrcBuf, pEndSrcBuf, &pDestBuf, pEndDestBuf,
                                nFlags, pInfo))
                            continue;
                        else
                            break;
                        break;
                    }
                }
            }
diff --git a/sal/textenc/convertsinglebytetobmpunicode.cxx b/sal/textenc/convertsinglebytetobmpunicode.cxx
index 2cfbb83..9bb994d2 100644
--- a/sal/textenc/convertsinglebytetobmpunicode.cxx
+++ b/sal/textenc/convertsinglebytetobmpunicode.cxx
@@ -126,7 +126,8 @@ sal_Size rtl_textenc_convertBmpUnicodeToSingleByte(
        for (std::size_t i = 0; i < entries; ++i) {
            if (c < ranges[i].unicode) {
                break;
            } else if (c <= sal::static_int_cast< sal_uInt32 >(
            }
            if (c <= sal::static_int_cast< sal_uInt32 >(
                           ranges[i].unicode + ranges[i].range))
            {
                if (destBufEnd - destBufPtr < 1) {
diff --git a/sal/textenc/handleundefinedunicodetotextchar.cxx b/sal/textenc/handleundefinedunicodetotextchar.cxx
index 164369f..2f6640b 100644
--- a/sal/textenc/handleundefinedunicodetotextchar.cxx
+++ b/sal/textenc/handleundefinedunicodetotextchar.cxx
@@ -125,12 +125,12 @@ bool sal::detail::textenc::handleUndefinedUnicodeToTextChar(
                *pInfo |= RTL_UNICODETOTEXT_INFO_ERROR;
                return false;
            }
            else if ( (nFlags & RTL_UNICODETOTEXT_FLAGS_INVALID_MASK) == RTL_UNICODETOTEXT_FLAGS_INVALID_IGNORE )
            if ( (nFlags & RTL_UNICODETOTEXT_FLAGS_INVALID_MASK) == RTL_UNICODETOTEXT_FLAGS_INVALID_IGNORE )
            {
                (*ppSrcBuf)++;
                return true;
            }
            else if (ImplGetInvalidAsciiMultiByte(nFlags,
            if (ImplGetInvalidAsciiMultiByte(nFlags,
                                                  *ppDestBuf,
                                                  pEndDestBuf - *ppDestBuf))
            {
@@ -138,12 +138,8 @@ bool sal::detail::textenc::handleUndefinedUnicodeToTextChar(
                ++*ppDestBuf;
                return true;
            }
            else
            {
                *pInfo |= RTL_UNICODETOTEXT_INFO_ERROR
                              | RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL;
                return false;
            }
            *pInfo |= RTL_UNICODETOTEXT_INFO_ERROR | RTL_UNICODETOTEXT_INFO_DESTBUFFERTOSMALL;
            return false;
        }
    }

@@ -153,7 +149,7 @@ bool sal::detail::textenc::handleUndefinedUnicodeToTextChar(
        *pInfo |= RTL_UNICODETOTEXT_INFO_ERROR;
        return false;
    }
    else if ( (nFlags & RTL_UNICODETOTEXT_FLAGS_UNDEFINED_MASK) == RTL_UNICODETOTEXT_FLAGS_UNDEFINED_IGNORE )
    if ( (nFlags & RTL_UNICODETOTEXT_FLAGS_UNDEFINED_MASK) == RTL_UNICODETOTEXT_FLAGS_UNDEFINED_IGNORE )
        (*ppSrcBuf)++;
    else if (ImplGetUndefinedAsciiMultiByte(nFlags,
                                            *ppDestBuf,
diff --git a/sal/textenc/tcvtmb.cxx b/sal/textenc/tcvtmb.cxx
index d36f5b8..a41611a 100644
--- a/sal/textenc/tcvtmb.cxx
+++ b/sal/textenc/tcvtmb.cxx
@@ -72,13 +72,12 @@ sal_Size ImplDBCSToUnicode( const void* pData, SAL_UNUSED_PARAMETER void*,
                    *pInfo |= RTL_TEXTTOUNICODE_INFO_ERROR;
                    break;
                }
                else if ( (nFlags & RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_MASK) == RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_IGNORE )
                if ( (nFlags & RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_MASK) == RTL_TEXTTOUNICODE_FLAGS_UNDEFINED_IGNORE )
                {
                    pSrcBuf++;
                    continue;
                }
                else
                    cConv = ImplGetUndefinedUnicodeChar(cLead, nFlags);
                cConv = ImplGetUndefinedUnicodeChar(cLead, nFlags);
            }
        }
        else
@@ -120,33 +119,27 @@ sal_Size ImplDBCSToUnicode( const void* pData, SAL_UNUSED_PARAMETER void*,
                                    (cTrail-pEUDCTab->mnTrail1Start);
                                break;
                            }
                            else
                            sal_uInt16 nTrailCount = pEUDCTab->mnTrail1End-pEUDCTab->mnTrail1Start+1;
                            if ( (pEUDCTab->mnTrailCount >= 2) &&
                                 (cTrail >= pEUDCTab->mnTrail2Start) &&
                                 (cTrail <= pEUDCTab->mnTrail2End) )
                            {
                                sal_uInt16 nTrailCount = pEUDCTab->mnTrail1End-pEUDCTab->mnTrail1Start+1;
                                if ( (pEUDCTab->mnTrailCount >= 2) &&
                                     (cTrail >= pEUDCTab->mnTrail2Start) &&
                                     (cTrail <= pEUDCTab->mnTrail2End) )
                                {
                                    cConv = pEUDCTab->mnUniStart+
                                        ((cLead-pEUDCTab->mnLeadStart)*pEUDCTab->mnTrailRangeCount)+
                                        nTrailCount+
                                        (cTrail-pEUDCTab->mnTrail2Start);
                                    break;
                                }
                                else
                                {
                                    nTrailCount = pEUDCTab->mnTrail2End-pEUDCTab->mnTrail2Start+1;
                                    if ( (pEUDCTab->mnTrailCount >= 3) &&
                                         (cTrail >= pEUDCTab->mnTrail3Start) &&
                                         (cTrail <= pEUDCTab->mnTrail3End) )
                                    {
                                        cConv = pEUDCTab->mnUniStart+
                                            ((cLead-pEUDCTab->mnLeadStart)*pEUDCTab->mnTrailRangeCount)+
                                            nTrailCount+
                                            (cTrail-pEUDCTab->mnTrail3Start);
                                        break;
                                    }
                                }
                                cConv = pEUDCTab->mnUniStart+
                                    ((cLead-pEUDCTab->mnLeadStart)*pEUDCTab->mnTrailRangeCount)+
                                    nTrailCount+
                                    (cTrail-pEUDCTab->mnTrail2Start);
                                break;
                            }
                            nTrailCount = pEUDCTab->mnTrail2End-pEUDCTab->mnTrail2Start+1;
                            if ( (pEUDCTab->mnTrailCount >= 3) &&
                                 (cTrail >= pEUDCTab->mnTrail3Start) &&
                                 (cTrail <= pEUDCTab->mnTrail3End) )
                            {
                                cConv = pEUDCTab->mnUniStart+
                                      ((cLead-pEUDCTab->mnLeadStart)*pEUDCTab->mnTrailRangeCount)+
                                      nTrailCount+
                                      (cTrail-pEUDCTab->mnTrail3Start);
                                break;
                            }
                        }

@@ -172,13 +165,12 @@ sal_Size ImplDBCSToUnicode( const void* pData, SAL_UNUSED_PARAMETER void*,
                                *pInfo |= RTL_TEXTTOUNICODE_INFO_ERROR;
                                break;
                            }
                            else if ( (nFlags & RTL_TEXTTOUNICODE_FLAGS_INVALID_MASK) == RTL_TEXTTOUNICODE_FLAGS_INVALID_IGNORE )
                            if ( (nFlags & RTL_TEXTTOUNICODE_FLAGS_INVALID_MASK) == RTL_TEXTTOUNICODE_FLAGS_INVALID_IGNORE )
                            {
                                pSrcBuf++;
                                continue;
                            }
                            else
                                cConv = RTL_TEXTENC_UNICODE_REPLACEMENT_CHARACTER;
                            cConv = RTL_TEXTENC_UNICODE_REPLACEMENT_CHARACTER;
                        }
                    }
                }
@@ -191,13 +183,12 @@ sal_Size ImplDBCSToUnicode( const void* pData, SAL_UNUSED_PARAMETER void*,
                    *pInfo |= RTL_TEXTTOUNICODE_INFO_ERROR;
                    break;
                }
                else if ( (nFlags & RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_MASK) == RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_IGNORE )
                if ( (nFlags & RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_MASK) == RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_IGNORE )
                {
                    pSrcBuf++;
                    continue;
                }
                else
                    cConv = RTL_TEXTENC_UNICODE_REPLACEMENT_CHARACTER;
                cConv = RTL_TEXTENC_UNICODE_REPLACEMENT_CHARACTER;
            }
        }

@@ -334,8 +325,7 @@ sal_Size ImplUnicodeToDBCS( const void* pData, SAL_UNUSED_PARAMETER void*,
                    &pSrcBuf, pEndSrcBuf, &pDestBuf, pEndDestBuf, nFlags,
                    pInfo))
                continue;
            else
                break;
            break;
        }

        /* SingleByte */
@@ -495,13 +485,12 @@ sal_Size ImplEUCJPToUnicode( const void* pData,
                        *pInfo |= RTL_TEXTTOUNICODE_INFO_ERROR;
                        break;
                    }
                    else if ( (nFlags & RTL_TEXTTOUNICODE_FLAGS_INVALID_MASK) == RTL_TEXTTOUNICODE_FLAGS_INVALID_IGNORE )
                    if ( (nFlags & RTL_TEXTTOUNICODE_FLAGS_INVALID_MASK) == RTL_TEXTTOUNICODE_FLAGS_INVALID_IGNORE )
                    {
                        pSrcBuf++;
                        continue;
                    }
                    else
                        cConv = RTL_TEXTENC_UNICODE_REPLACEMENT_CHARACTER;
                    cConv = RTL_TEXTENC_UNICODE_REPLACEMENT_CHARACTER;
                }
                else
                {
@@ -511,13 +500,12 @@ sal_Size ImplEUCJPToUnicode( const void* pData,
                        *pInfo |= RTL_TEXTTOUNICODE_INFO_ERROR;
                        break;
                    }
                    else if ( (nFlags & RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_MASK) == RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_IGNORE )
                    if ( (nFlags & RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_MASK) == RTL_TEXTTOUNICODE_FLAGS_MBUNDEFINED_IGNORE )
                    {
                        pSrcBuf++;
                        continue;
                    }
                    else
                        cConv = RTL_TEXTENC_UNICODE_REPLACEMENT_CHARACTER;
                    cConv = RTL_TEXTENC_UNICODE_REPLACEMENT_CHARACTER;
                }
            }
        }
@@ -616,8 +604,7 @@ sal_Size ImplUnicodeToEUCJP( const void* pData,
                            &pSrcBuf, pEndSrcBuf, &pDestBuf, pEndDestBuf,
                            nFlags, pInfo))
                        continue;
                    else
                        break;
                    break;
                }
            }
        }
diff --git a/sal/textenc/tcvtutf7.cxx b/sal/textenc/tcvtutf7.cxx
index 3670074..f9cae77 100644
--- a/sal/textenc/tcvtutf7.cxx
+++ b/sal/textenc/tcvtutf7.cxx
@@ -306,7 +306,7 @@ sal_Size ImplUTF7ToUnicode( SAL_UNUSED_PARAMETER const void*, void* pContext,
                            *pInfo |= RTL_TEXTTOUNICODE_INFO_ERROR;
                            break;
                        }
                        else if ( (nFlags & RTL_TEXTTOUNICODE_FLAGS_INVALID_MASK) != RTL_TEXTTOUNICODE_FLAGS_INVALID_IGNORE )
                        if ( (nFlags & RTL_TEXTTOUNICODE_FLAGS_INVALID_MASK) != RTL_TEXTTOUNICODE_FLAGS_INVALID_IGNORE )
                        {
                            if ( pDestBuf >= pEndDestBuf )
                            {
@@ -347,7 +347,7 @@ sal_Size ImplUTF7ToUnicode( SAL_UNUSED_PARAMETER const void*, void* pContext,
                            *pInfo |= RTL_TEXTTOUNICODE_INFO_ERROR;
                            break;
                        }
                        else if ( (nFlags & RTL_TEXTTOUNICODE_FLAGS_INVALID_MASK) != RTL_TEXTTOUNICODE_FLAGS_INVALID_IGNORE )
                        if ( (nFlags & RTL_TEXTTOUNICODE_FLAGS_INVALID_MASK) != RTL_TEXTTOUNICODE_FLAGS_INVALID_IGNORE )
                        {
                            if ( pDestBuf >= pEndDestBuf )
                            {
diff --git a/sal/textenc/tencinfo.cxx b/sal/textenc/tencinfo.cxx
index b0312bb..a220d71 100644
--- a/sal/textenc/tencinfo.cxx
+++ b/sal/textenc/tencinfo.cxx
@@ -783,8 +783,7 @@ sal_uInt8 SAL_CALL rtl_getBestWindowsCharsetFromTextEncoding( rtl_TextEncoding e
    const ImplTextEncodingData* pData = Impl_getTextEncodingData( eTextEncoding );
    if ( pData )
        return pData->mnBestWindowsCharset;
    else
        return 1;
    return 1;
}

/* ----------------------------------------------------------------------- */
@@ -794,10 +793,9 @@ const char* SAL_CALL rtl_getBestUnixCharsetFromTextEncoding( rtl_TextEncoding eT
    const ImplTextEncodingData* pData = Impl_getTextEncodingData( eTextEncoding );
    if ( pData )
        return pData->mpBestUnixCharset;
    else if( eTextEncoding == RTL_TEXTENCODING_UNICODE )
    if( eTextEncoding == RTL_TEXTENCODING_UNICODE )
        return "iso10646-1";
    else
        return nullptr;
    return nullptr;
}

/* ----------------------------------------------------------------------- */
@@ -815,8 +813,7 @@ const char* SAL_CALL rtl_getBestMimeCharsetFromTextEncoding( rtl_TextEncoding eT
    const ImplTextEncodingData* pData = Impl_getTextEncodingData( eTextEncoding );
    if ( pData )
        return pData->mpBestMimeCharset;
    else
        return nullptr;
    return nullptr;
}

/* The following two functions are based on <http://www.sharmahd.com/tm/
diff --git a/sal/textenc/textcvt.cxx b/sal/textenc/textcvt.cxx
index 63f2612..3bd377d 100644
--- a/sal/textenc/textcvt.cxx
+++ b/sal/textenc/textcvt.cxx
@@ -107,8 +107,7 @@ rtl_TextToUnicodeConverter SAL_CALL rtl_createTextToUnicodeConverter( rtl_TextEn
    const ImplTextEncodingData* pData = Impl_getTextEncodingData( eTextEncoding );
    if ( pData )
        return static_cast<rtl_TextToUnicodeConverter>(const_cast<ImplTextConverter *>(&pData->maConverter));
    else
        return nullptr;
    return nullptr;
}

/* ----------------------------------------------------------------------- */
@@ -124,10 +123,9 @@ rtl_TextToUnicodeContext SAL_CALL rtl_createTextToUnicodeContext( rtl_TextToUnic
    const ImplTextConverter* pConverter = static_cast<const ImplTextConverter*>(hConverter);
    if ( !pConverter )
        return nullptr;
    else if ( pConverter->mpCreateTextToUnicodeContext )
    if ( pConverter->mpCreateTextToUnicodeContext )
        return pConverter->mpCreateTextToUnicodeContext();
    else
        return reinterpret_cast<rtl_TextToUnicodeContext>(1);
    return reinterpret_cast<rtl_TextToUnicodeContext>(1);
}

/* ----------------------------------------------------------------------- */
@@ -185,8 +183,7 @@ rtl_UnicodeToTextConverter SAL_CALL rtl_createUnicodeToTextConverter( rtl_TextEn
    const ImplTextEncodingData* pData = Impl_getTextEncodingData( eTextEncoding );
    if ( pData )
        return static_cast<rtl_TextToUnicodeConverter>(const_cast<ImplTextConverter *>(&pData->maConverter));
    else
        return nullptr;
    return nullptr;
}

/* ----------------------------------------------------------------------- */
@@ -202,10 +199,9 @@ rtl_UnicodeToTextContext SAL_CALL rtl_createUnicodeToTextContext( rtl_UnicodeToT
    const ImplTextConverter* pConverter = static_cast<const ImplTextConverter*>(hConverter);
    if ( !pConverter )
        return nullptr;
    else if ( pConverter->mpCreateUnicodeToTextContext )
    if ( pConverter->mpCreateUnicodeToTextContext )
        return pConverter->mpCreateUnicodeToTextContext();
    else
        return reinterpret_cast<rtl_UnicodeToTextContext>(1);
    return reinterpret_cast<rtl_UnicodeToTextContext>(1);
}

/* ----------------------------------------------------------------------- */