Kaydet (Commit) 98e60805 authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:flatten in stoc..store

Change-Id: Ib8c86179a3d13852cbb02b389b6103aca5456dba
Reviewed-on: https://gerrit.libreoffice.org/67013
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 4cff0606
......@@ -295,23 +295,24 @@ void IdlAttributeFieldImpl::set( const Any & rObj, const Any & rValue )
void IdlAttributeFieldImpl::checkException(
uno_Any * exception, Reference< XInterface > const & context) const
{
if (exception != nullptr) {
Any e;
uno_any_destruct(&e, reinterpret_cast< uno_ReleaseFunc >(cpp_release));
uno_type_any_constructAndConvert(
&e, exception->pData, exception->pType,
getReflection()->getUno2Cpp().get());
uno_any_destruct(exception, nullptr);
if (!e.isExtractableTo(
cppu::UnoType<RuntimeException>::get()))
{
throw WrappedTargetRuntimeException(
"non-RuntimeException occurred when accessing an"
" interface type attribute",
context, e);
}
cppu::throwException(e);
if (exception == nullptr)
return;
Any e;
uno_any_destruct(&e, reinterpret_cast< uno_ReleaseFunc >(cpp_release));
uno_type_any_constructAndConvert(
&e, exception->pData, exception->pType,
getReflection()->getUno2Cpp().get());
uno_any_destruct(exception, nullptr);
if (!e.isExtractableTo(
cppu::UnoType<RuntimeException>::get()))
{
throw WrappedTargetRuntimeException(
"non-RuntimeException occurred when accessing an"
" interface type attribute",
context, e);
}
cppu::throwException(e);
}
......
......@@ -188,19 +188,19 @@ NestedKeyImpl::NestedKeyImpl( const OUString& rKeyName,
void NestedKeyImpl::computeChanges()
{
Guard< Mutex > aGuard( m_xRegistry->m_mutex );
if ( m_state != m_xRegistry->m_state )
{
Reference<XRegistryKey> rootKey(m_xRegistry->m_localReg->getRootKey());
if ( m_state == m_xRegistry->m_state )
return;
Reference<XRegistryKey> tmpKey = rootKey->openKey(m_name);
Reference<XRegistryKey> rootKey(m_xRegistry->m_localReg->getRootKey());
if ( tmpKey.is() )
{
m_localKey = rootKey->openKey(m_name);
}
Reference<XRegistryKey> tmpKey = rootKey->openKey(m_name);
m_state = m_xRegistry->m_state;
if ( tmpKey.is() )
{
m_localKey = rootKey->openKey(m_name);
}
m_state = m_xRegistry->m_state;
}
......
......@@ -947,22 +947,22 @@ void Invocation_Impl::fillInfoForMethod
rInfo.aType = aReturnType;
Sequence<ParamInfo> aParamInfos = xMethod->getParameterInfos();
sal_Int32 nParamCount = aParamInfos.getLength();
if( nParamCount > 0 )
{
const ParamInfo* pInfo = aParamInfos.getConstArray();
if( nParamCount <= 0 )
return;
rInfo.aParamTypes.realloc( nParamCount );
Type* pParamTypes = rInfo.aParamTypes.getArray();
rInfo.aParamModes.realloc( nParamCount );
ParamMode* pParamModes = rInfo.aParamModes.getArray();
const ParamInfo* pInfo = aParamInfos.getConstArray();
for( sal_Int32 i = 0 ; i < nParamCount ; i++ )
{
Reference< XIdlClass > xParamClass = pInfo[i].aType;
Type aParamType( xParamClass->getTypeClass(), xParamClass->getName() );
pParamTypes[ i ] = aParamType;
pParamModes[ i ] = pInfo[i].aMode;
}
rInfo.aParamTypes.realloc( nParamCount );
Type* pParamTypes = rInfo.aParamTypes.getArray();
rInfo.aParamModes.realloc( nParamCount );
ParamMode* pParamModes = rInfo.aParamModes.getArray();
for( sal_Int32 i = 0 ; i < nParamCount ; i++ )
{
Reference< XIdlClass > xParamClass = pInfo[i].aType;
Type aParamType( xParamClass->getTypeClass(), xParamClass->getName() );
pParamTypes[ i ] = aParamType;
pParamModes[ i ] = pInfo[i].aMode;
}
}
......
This diff is collapsed.
......@@ -192,19 +192,19 @@ static void binuno_proxy_free(
static void binuno_proxy_acquire( uno_Interface * pUnoI )
{
binuno_Proxy * that = static_cast< binuno_Proxy * >( pUnoI );
if (osl_atomic_increment( &that->m_nRefCount ) == 1)
{
// rebirth of zombie
uno_ExtEnvironment * uno_env =
that->m_root->m_factory->m_uno_env.get()->pExtEnv;
OSL_ASSERT( uno_env != nullptr );
(*uno_env->registerProxyInterface)(
uno_env, reinterpret_cast< void ** >( &pUnoI ), binuno_proxy_free,
that->m_oid.pData,
reinterpret_cast< typelib_InterfaceTypeDescription * >(
that->m_typeDescr.get() ) );
OSL_ASSERT( that == static_cast< binuno_Proxy * >( pUnoI ) );
}
if (osl_atomic_increment( &that->m_nRefCount ) != 1)
return;
// rebirth of zombie
uno_ExtEnvironment * uno_env =
that->m_root->m_factory->m_uno_env.get()->pExtEnv;
OSL_ASSERT( uno_env != nullptr );
(*uno_env->registerProxyInterface)(
uno_env, reinterpret_cast< void ** >( &pUnoI ), binuno_proxy_free,
that->m_oid.pData,
reinterpret_cast< typelib_InterfaceTypeDescription * >(
that->m_typeDescr.get() ) );
OSL_ASSERT( that == static_cast< binuno_Proxy * >( pUnoI ) );
}
......
......@@ -386,19 +386,19 @@ AccessController::AccessController( Reference< XComponentContext > const & xComp
}
// switch on caching for DYNAMIC_ONLY and ON (shareable multi-user process)
if (ON == m_mode || DYNAMIC_ONLY == m_mode)
if (!(ON == m_mode || DYNAMIC_ONLY == m_mode))
return;
sal_Int32 cacheSize = 0; // multi-user cache size
if (! (m_xComponentContext->getValueByName(
"/services/" SERVICE_NAME "/user-cache-size" ) >>= cacheSize))
{
sal_Int32 cacheSize = 0; // multi-user cache size
if (! (m_xComponentContext->getValueByName(
"/services/" SERVICE_NAME "/user-cache-size" ) >>= cacheSize))
{
cacheSize = 128; // reasonable default?
}
cacheSize = 128; // reasonable default?
}
#ifdef __CACHE_DIAGNOSE
cacheSize = 2;
cacheSize = 2;
#endif
m_user2permissions.setSize( cacheSize );
}
m_user2permissions.setSize( cacheSize );
}
void AccessController::disposing()
......@@ -495,53 +495,53 @@ void AccessController::checkAndClearPostPoned()
std::unique_ptr< t_rec_vec > rec( static_cast< t_rec_vec * >( m_rec.getData() ) );
m_rec.setData( nullptr ); // takeover ownership
OSL_ASSERT(rec);
if (rec)
if (!rec)
return;
t_rec_vec const& vec = *rec;
switch (m_mode)
{
t_rec_vec const& vec = *rec;
switch (m_mode)
case SINGLE_USER:
{
OSL_ASSERT( m_singleUser_init );
for (const auto & p : vec)
{
case SINGLE_USER:
OSL_ASSERT( m_singleUserId == p.first );
m_singleUserPermissions.checkPermission( p.second );
}
break;
}
case SINGLE_DEFAULT_USER:
{
OSL_ASSERT( m_defaultPerm_init );
for (const auto & p : vec)
{
OSL_ASSERT( m_singleUser_init );
for (const auto & p : vec)
{
OSL_ASSERT( m_singleUserId == p.first );
m_singleUserPermissions.checkPermission( p.second );
}
break;
OSL_ASSERT( p.first.isEmpty() ); // default-user
m_defaultPermissions.checkPermission( p.second );
}
case SINGLE_DEFAULT_USER:
break;
}
case ON:
{
for (const auto & p : vec)
{
OSL_ASSERT( m_defaultPerm_init );
for (const auto & p : vec)
PermissionCollection const * pPermissions;
// lookup policy for user
{
OSL_ASSERT( p.first.isEmpty() ); // default-user
m_defaultPermissions.checkPermission( p.second );
MutexGuard guard( m_mutex );
pPermissions = m_user2permissions.lookup( p.first );
}
break;
}
case ON:
{
for (const auto & p : vec)
OSL_ASSERT( pPermissions );
if (pPermissions)
{
PermissionCollection const * pPermissions;
// lookup policy for user
{
MutexGuard guard( m_mutex );
pPermissions = m_user2permissions.lookup( p.first );
}
OSL_ASSERT( pPermissions );
if (pPermissions)
{
pPermissions->checkPermission( p.second );
}
pPermissions->checkPermission( p.second );
}
break;
}
default:
OSL_FAIL( "### this should never be called in this ac mode!" );
break;
}
break;
}
default:
OSL_FAIL( "### this should never be called in this ac mode!" );
break;
}
}
......
......@@ -140,28 +140,28 @@ SocketPermission::SocketPermission(
// separate host from portrange
sal_Int32 colon = m_host.indexOf( ':' );
if (colon >= 0) // port [range] given
if (colon < 0) // port [range] not given
return;
sal_Int32 minus = m_host.indexOf( '-', colon +1 );
if (minus < 0)
{
sal_Int32 minus = m_host.indexOf( '-', colon +1 );
if (minus < 0)
{
m_lowerPort = m_upperPort = m_host.copy( colon +1 ).toInt32();
}
else if (minus == (colon +1)) // -N
{
m_upperPort = m_host.copy( minus +1 ).toInt32();
}
else if (minus == (m_host.getLength() -1)) // N-
{
m_lowerPort = m_host.copy( colon +1, m_host.getLength() -1 -colon -1 ).toInt32();
}
else // A-B
{
m_lowerPort = m_host.copy( colon +1, minus - colon -1 ).toInt32();
m_upperPort = m_host.copy( minus +1 ).toInt32();
}
m_host = m_host.copy( 0, colon );
m_lowerPort = m_upperPort = m_host.copy( colon +1 ).toInt32();
}
else if (minus == (colon +1)) // -N
{
m_upperPort = m_host.copy( minus +1 ).toInt32();
}
else if (minus == (m_host.getLength() -1)) // N-
{
m_lowerPort = m_host.copy( colon +1, m_host.getLength() -1 -colon -1 ).toInt32();
}
else // A-B
{
m_lowerPort = m_host.copy( colon +1, minus - colon -1 ).toInt32();
m_upperPort = m_host.copy( minus +1 ).toInt32();
}
m_host = m_host.copy( 0, colon );
}
inline bool SocketPermission::resolveHost() const
......@@ -301,40 +301,40 @@ FilePermission::FilePermission(
, m_url( perm.URL )
, m_allFiles( perm.URL == "<<ALL FILES>>" )
{
if (! m_allFiles)
if ( m_allFiles)
return;
if ( m_url == "*" )
{
if ( m_url == "*" )
{
OUStringBuffer buf( 64 );
buf.append( getWorkingDir() );
buf.append( "/*" );
m_url = buf.makeStringAndClear();
}
else if ( m_url == "-" )
{
OUStringBuffer buf( 64 );
buf.append( getWorkingDir() );
buf.append( "/-" );
m_url = buf.makeStringAndClear();
}
else if (!m_url.startsWith("file:///"))
{
// relative path
OUString out;
oslFileError rc = ::osl_getAbsoluteFileURL(
getWorkingDir().pData, perm.URL.pData, &out.pData );
m_url = (osl_File_E_None == rc ? out : perm.URL); // fallback
}
OUStringBuffer buf( 64 );
buf.append( getWorkingDir() );
buf.append( "/*" );
m_url = buf.makeStringAndClear();
}
else if ( m_url == "-" )
{
OUStringBuffer buf( 64 );
buf.append( getWorkingDir() );
buf.append( "/-" );
m_url = buf.makeStringAndClear();
}
else if (!m_url.startsWith("file:///"))
{
// relative path
OUString out;
oslFileError rc = ::osl_getAbsoluteFileURL(
getWorkingDir().pData, perm.URL.pData, &out.pData );
m_url = (osl_File_E_None == rc ? out : perm.URL); // fallback
}
#ifdef _WIN32
// correct win drive letters
if (9 < m_url.getLength() && '|' == m_url[ 9 ]) // file:///X|
{
static OUString s_colon = ":";
// common case in API is a ':' (sal), so convert '|' to ':'
m_url = m_url.replaceAt( 9, 1, s_colon );
}
#endif
// correct win drive letters
if (9 < m_url.getLength() && '|' == m_url[ 9 ]) // file:///X|
{
static OUString s_colon = ":";
// common case in API is a ':' (sal), so convert '|' to ':'
m_url = m_url.replaceAt( 9, 1, s_colon );
}
#endif
}
bool FilePermission::implies( Permission const & perm ) const
......
......@@ -316,20 +316,20 @@ public:
void OServiceManager_Listener::disposing(const EventObject & rEvt )
{
Reference<XSet > x( xSMgr );
if( x.is() )
if( !x.is() )
return;
try
{
try
{
x->remove( Any( &rEvt.Source, cppu::UnoType<XInterface>::get()) );
}
catch( const IllegalArgumentException & )
{
OSL_FAIL( "IllegalArgumentException caught" );
}
catch( const NoSuchElementException & )
{
OSL_FAIL( "NoSuchElementException caught" );
}
x->remove( Any( &rEvt.Source, cppu::UnoType<XInterface>::get()) );
}
catch( const IllegalArgumentException & )
{
OSL_FAIL( "IllegalArgumentException caught" );
}
catch( const NoSuchElementException & )
{
OSL_FAIL( "NoSuchElementException caught" );
}
}
......@@ -1161,24 +1161,24 @@ void OServiceManager::remove( const Any & Element )
//remove from the service map
Reference<XServiceInfo > xSF( Reference<XServiceInfo >::query( xEle ) );
if( xSF.is() )
if( !xSF.is() )
return;
Sequence< OUString > aServiceNames = xSF->getSupportedServiceNames();
const OUString * pArray = aServiceNames.getConstArray();
for( sal_Int32 i = 0; i < aServiceNames.getLength(); i++ )
{
Sequence< OUString > aServiceNames = xSF->getSupportedServiceNames();
const OUString * pArray = aServiceNames.getConstArray();
for( sal_Int32 i = 0; i < aServiceNames.getLength(); i++ )
{
pair<HashMultimap_OWString_Interface::iterator, HashMultimap_OWString_Interface::iterator> p =
m_ServiceMap.equal_range( pArray[i] );
pair<HashMultimap_OWString_Interface::iterator, HashMultimap_OWString_Interface::iterator> p =
m_ServiceMap.equal_range( pArray[i] );
while( p.first != p.second )
while( p.first != p.second )
{
if( xEle == (*p.first).second )
{
if( xEle == (*p.first).second )
{
m_ServiceMap.erase( p.first );
break;
}
++p.first;
m_ServiceMap.erase( p.first );
break;
}
++p.first;
}
}
}
......
......@@ -220,42 +220,42 @@ void PageCache::rescale_Impl (std::size_t new_size)
std::size_t new_bytes = new_size * sizeof(Entry*);
Entry ** new_table = static_cast<Entry**>(std::malloc(new_bytes));
if (new_table != nullptr)
{
Entry ** old_table = m_hash_table;
std::size_t old_size = m_hash_size;
if (new_table == nullptr)
return;
SAL_INFO(
"store",
"ave chain length: " << (m_hash_entries >> m_hash_shift)
<< ", total entries: " << m_hash_entries << " [old_size: "
<< old_size << " new_size: " << new_size << "]");
Entry ** old_table = m_hash_table;
std::size_t old_size = m_hash_size;
memset (new_table, 0, new_bytes);
SAL_INFO(
"store",
"ave chain length: " << (m_hash_entries >> m_hash_shift)
<< ", total entries: " << m_hash_entries << " [old_size: "
<< old_size << " new_size: " << new_size << "]");
m_hash_table = new_table;
m_hash_size = new_size;
m_hash_shift = highbit(m_hash_size) - 1;
memset (new_table, 0, new_bytes);
std::size_t i;
for (i = 0; i < old_size; i++)
m_hash_table = new_table;
m_hash_size = new_size;
m_hash_shift = highbit(m_hash_size) - 1;
std::size_t i;
for (i = 0; i < old_size; i++)
{
Entry * curr = old_table[i];
while (curr != nullptr)
{
Entry * curr = old_table[i];
while (curr != nullptr)
{
Entry * next = curr->m_pNext;
int index = hash_index_Impl(curr->m_nOffset);
curr->m_pNext = m_hash_table[index];
m_hash_table[index] = curr;
curr = next;
}
old_table[i] = nullptr;
Entry * next = curr->m_pNext;
int index = hash_index_Impl(curr->m_nOffset);
curr->m_pNext = m_hash_table[index];
m_hash_table[index] = curr;
curr = next;
}
if (old_table != m_hash_table_0)
{
old_table[i] = nullptr;
}
if (old_table != m_hash_table_0)
{
std::free (old_table);
}
std::free (old_table);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment