summaryrefslogtreecommitdiff
path: root/cppu
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-04-06 10:47:24 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-04-12 10:11:34 +0200
commit992a33313046f4a4d322db9464c474e7429a019a (patch)
tree494143e3070af872027ecaca840516d3101a881c /cppu
parent77c1431ee88ab04a9ff48b849acedee6d455bafb (diff)
clang-tidy: readability-else-after-return
run it against sal,cppu,cppuhelper I had to run this multiple times to catch all the cases in each module, and it requires some hand-tweaking of the resulting output - clang-tidy is not very good about cleaning up trailing spaces, and aligning things nicely. Change-Id: I00336345f5f036e12422b98d66526509380c497a Reviewed-on: https://gerrit.libreoffice.org/36194 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'cppu')
-rw-r--r--cppu/qa/test_any.cxx30
-rw-r--r--cppu/qa/test_reference.cxx2
-rw-r--r--cppu/source/typelib/static_types.cxx5
-rw-r--r--cppu/source/typelib/typelib.cxx93
-rw-r--r--cppu/source/uno/lbmap.cxx5
-rw-r--r--cppu/source/uno/sequence.cxx14
6 files changed, 66 insertions, 83 deletions
diff --git a/cppu/qa/test_any.cxx b/cppu/qa/test_any.cxx
index d76ffc0c3424..38d35008513e 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 15a926f50a9a..3c6b7af1eb9e 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 33e5b296dc12..0a7c1ac1a9e8 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 52d1a2e09e68..f869e795c077 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:
+ 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_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 476198a0f69f..e8dcc574e58a 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 e7a6465b12e9..3fbe338cfc00 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;
}