summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-07-26 12:22:16 +0100
committerCaolán McNamara <caolanm@redhat.com>2018-07-27 09:32:19 +0200
commitba1e1727c238210b022741a710486964f28bb065 (patch)
tree8b8a5afbc4a16eef7dc95b144937fa57cf6c9abd
parent877dd9e9d1c1774817fa96f62adda98d5bce0ce8 (diff)
Related: rhbz#1602589 add comments to coverity annotations
Change-Id: I88c941832a0d682ea4b6028c28edd48cf5df38f7 Reviewed-on: https://gerrit.libreoffice.org/58093 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--bridges/source/cpp_uno/shared/bridge.cxx2
-rw-r--r--bridges/source/jni_uno/jni_bridge.cxx4
-rw-r--r--bridges/source/jni_uno/jni_info.cxx6
-rw-r--r--comphelper/source/misc/threadpool.cxx2
-rw-r--r--cppu/source/typelib/static_types.cxx2
-rw-r--r--cppu/source/typelib/typelib.cxx2
-rw-r--r--framework/source/accelerators/acceleratorconfiguration.cxx4
-rw-r--r--idlc/source/parser.y2
-rw-r--r--include/LibreOfficeKit/LibreOfficeKitInit.h6
-rw-r--r--registry/source/regimpl.cxx6
-rw-r--r--sal/osl/unx/file.cxx4
-rw-r--r--sal/osl/unx/pipe.cxx9
-rw-r--r--sal/osl/w32/file.cxx4
-rw-r--r--sal/rtl/alloc_arena.cxx2
-rw-r--r--sal/rtl/alloc_cache.cxx6
-rw-r--r--sfx2/source/control/itemdel.cxx2
-rw-r--r--svtools/source/svhtml/htmlout.cxx2
-rw-r--r--unoidl/source/legacyprovider.cxx32
-rw-r--r--unotest/source/cpp/officeconnection.cxx2
19 files changed, 51 insertions, 48 deletions
diff --git a/bridges/source/cpp_uno/shared/bridge.cxx b/bridges/source/cpp_uno/shared/bridge.cxx
index 556350022e48..186d89aa1956 100644
--- a/bridges/source/cpp_uno/shared/bridge.cxx
+++ b/bridges/source/cpp_uno/shared/bridge.cxx
@@ -144,7 +144,7 @@ uno_Mapping * Bridge::createMapping(
bool bExportCpp2Uno)
{
Bridge * bridge = new Bridge(pCppEnv, pUnoEnv, bExportCpp2Uno);
- //coverity[leaked_storage]
+ // coverity[leaked_storage] - on purpose
return bExportCpp2Uno ? &bridge->aCpp2Uno : &bridge->aUno2Cpp;
}
diff --git a/bridges/source/jni_uno/jni_bridge.cxx b/bridges/source/jni_uno/jni_bridge.cxx
index 4a0d4b30af53..7f38d3221420 100644
--- a/bridges/source/jni_uno/jni_bridge.cxx
+++ b/bridges/source/jni_uno/jni_bridge.cxx
@@ -552,7 +552,7 @@ SAL_DLLPUBLIC_EXPORT void uno_ext_getMapping(
uno_registerMapping(
&mapping, Bridge_free,
pFrom, &pTo->pExtEnv->aBase, nullptr );
- // coverity[leaked_storage]
+ // coverity[leaked_storage] - on purpose
}
else if ( from_env_typename == UNO_LB_UNO && to_env_typename == UNO_LB_JAVA )
{
@@ -562,7 +562,7 @@ SAL_DLLPUBLIC_EXPORT void uno_ext_getMapping(
uno_registerMapping(
&mapping, Bridge_free,
&pFrom->pExtEnv->aBase, pTo, nullptr );
- // coverity[leaked_storage]
+ // coverity[leaked_storage] - on purpose
}
}
catch (const BridgeRuntimeError & err)
diff --git a/bridges/source/jni_uno/jni_info.cxx b/bridges/source/jni_uno/jni_info.cxx
index 9b43356856af..045ac44ee6be 100644
--- a/bridges/source/jni_uno/jni_info.cxx
+++ b/bridges/source/jni_uno/jni_info.cxx
@@ -103,7 +103,7 @@ JNI_interface_type_info::JNI_interface_type_info(
typelib_InterfaceTypeDescription * td =
reinterpret_cast< typelib_InterfaceTypeDescription * >(
m_td.get() );
- // coverity [ctor_dtor_leak]
+ // coverity[ctor_dtor_leak] - on purpose
m_methods.reset(new jmethodID[ td->nMapFunctionIndexToMemberIndex ]);
sal_Int32 nMethodIndex = 0;
typelib_TypeDescriptionReference ** ppMembers = td->ppMembers;
@@ -288,7 +288,7 @@ JNI_compound_type_info::JNI_compound_type_info(
td->aBase.pWeakRef,
jni_info->m_RuntimeException_type.getTypeLibType() ))
{
- // coverity [ctor_dtor_leak]
+ // coverity[ctor_dtor_leak] - on purpose
m_fields.reset(new jfieldID[ 2 ]);
m_fields[ 0 ] = nullptr; // special Throwable.getMessage()
// field Context
@@ -860,7 +860,7 @@ JNI_info::JNI_info(
{
css::uno::TypeDescription XInterface_td(
cppu::UnoType<css::uno::XInterface>::get());
- // coverity [ctor_dtor_leak]
+ // coverity[ctor_dtor_leak] - on purpose
m_XInterface_type_info =
new JNI_interface_type_info( jni, XInterface_td.get() );
}
diff --git a/comphelper/source/misc/threadpool.cxx b/comphelper/source/misc/threadpool.cxx
index 650541406a6a..fc9b2b3e5404 100644
--- a/comphelper/source/misc/threadpool.cxx
+++ b/comphelper/source/misc/threadpool.cxx
@@ -154,7 +154,7 @@ void ThreadPool::shutdownLocked(std::unique_lock<std::mutex>& aGuard)
}
assert( maTasks.empty() );
- // coverity[missing_lock]
+ // coverity[missing_lock] - on purpose
mbTerminate = true;
maTasksChanged.notify_all();
diff --git a/cppu/source/typelib/static_types.cxx b/cppu/source/typelib/static_types.cxx
index eabd3950450f..2a3a5432b07f 100644
--- a/cppu/source/typelib/static_types.cxx
+++ b/cppu/source/typelib/static_types.cxx
@@ -439,7 +439,7 @@ void SAL_CALL typelib_static_interface_type_init(
typelib_TypeDescriptionReference * pBaseType )
SAL_THROW_EXTERN_C()
{
- // coverity[callee_ptr_arith]
+ // coverity[callee_ptr_arith] - not a bug
typelib_static_mi_interface_type_init(
ppRef, pTypeName, pBaseType == nullptr ? 0 : 1, &pBaseType);
}
diff --git a/cppu/source/typelib/typelib.cxx b/cppu/source/typelib/typelib.cxx
index 46238d5481b0..ec51f2128143 100644
--- a/cppu/source/typelib/typelib.cxx
+++ b/cppu/source/typelib/typelib.cxx
@@ -890,7 +890,7 @@ extern "C" void SAL_CALL typelib_typedescription_newInterface(
typelib_TypeDescriptionReference ** ppMembers )
SAL_THROW_EXTERN_C()
{
- // coverity[callee_ptr_arith]
+ // coverity[callee_ptr_arith] - not a bug
typelib_typedescription_newMIInterface(
ppRet, pTypeName, 0, 0, 0, 0, 0, pBaseInterface == nullptr ? 0 : 1,
&pBaseInterface, nMembers, ppMembers);
diff --git a/framework/source/accelerators/acceleratorconfiguration.cxx b/framework/source/accelerators/acceleratorconfiguration.cxx
index f8995ea47561..398b2ed5978f 100644
--- a/framework/source/accelerators/acceleratorconfiguration.cxx
+++ b/framework/source/accelerators/acceleratorconfiguration.cxx
@@ -1123,7 +1123,7 @@ void XCUBasedAcceleratorConfiguration::impl_ts_save(bool bPreferred)
// take over all changes into the original container
SolarMutexGuard g;
- // coverity[check_after_deref]
+ // coverity[check_after_deref] - confusing but correct
if (m_pPrimaryWriteCache)
{
m_aPrimaryReadCache.takeOver(*m_pPrimaryWriteCache);
@@ -1161,7 +1161,7 @@ void XCUBasedAcceleratorConfiguration::impl_ts_save(bool bPreferred)
// take over all changes into the original container
SolarMutexGuard g;
- // coverity[check_after_deref]
+ // coverity[check_after_deref] - confusing but correct
if (m_pSecondaryWriteCache)
{
m_aSecondaryReadCache.takeOver(*m_pSecondaryWriteCache);
diff --git a/idlc/source/parser.y b/idlc/source/parser.y
index 9cc9e8d5ab5d..cb5f3ec470e3 100644
--- a/idlc/source/parser.y
+++ b/idlc/source/parser.y
@@ -2115,7 +2115,7 @@ at_least_one_scoped_name :
} else
{
std::list< OString >* pScopedNames = new std::list< OString >;
- // coverity [copy_paste_error]
+ // coverity[copy_paste_error] - this is not a cut and paste
pScopedNames->push_back(*$1);
$$ = pScopedNames;
}
diff --git a/include/LibreOfficeKit/LibreOfficeKitInit.h b/include/LibreOfficeKit/LibreOfficeKitInit.h
index 687090a58b9f..a4befd405cb1 100644
--- a/include/LibreOfficeKit/LibreOfficeKitInit.h
+++ b/include/LibreOfficeKit/LibreOfficeKitInit.h
@@ -287,13 +287,13 @@ static LibreOfficeKit *lok_init_2( const char *install_path, const char *user_p
}
free( imp_lib );
// dlhandle is "leaked"
- // coverity[leaked_storage]
+ // coverity[leaked_storage] - on purpose
return pSym( install_path );
}
free( imp_lib );
// dlhandle is "leaked"
- // coverity[leaked_storage]
+ // coverity[leaked_storage] - on purpose
return pSym2( install_path, user_profile_url );
#else
return libreofficekit_hook_2( install_path, user_profile_url );
@@ -330,7 +330,7 @@ int lok_preinit( const char *install_path, const char *user_profile_url )
free( imp_lib );
// dlhandle is "leaked"
- // coverity[leaked_storage]
+ // coverity[leaked_storage] - on purpose
return pSym( install_path, user_profile_url );
}
#endif
diff --git a/registry/source/regimpl.cxx b/registry/source/regimpl.cxx
index 79279b1f3f90..1e24220f0ee9 100644
--- a/registry/source/regimpl.cxx
+++ b/registry/source/regimpl.cxx
@@ -324,8 +324,7 @@ void dumpType(typereg::Reader const & reader, OString const & indent) {
printf(
"%s parameter count: %u\n", indent.getStr(),
static_cast< unsigned int >(reader.getMethodParameterCount(i)));
- // coverity[tainted_data] cid#1215304 unhelpfully warns about an
- // untrusted loop bound here:
+ // coverity[tainted_data] - cid#1215304 unhelpfully warns about untrusted loop bound
for (sal_uInt16 j = 0; j < reader.getMethodParameterCount(i); ++j)
{
printf(
@@ -366,8 +365,7 @@ void dumpType(typereg::Reader const & reader, OString const & indent) {
printf(
"%s exception count: %u\n", indent.getStr(),
static_cast< unsigned int >(reader.getMethodExceptionCount(i)));
- // coverity[tainted_data] cid#1215304 unhelpfully warns about an
- // untrusted loop bound here:
+ // coverity[tainted_data] - cid#1215304 unhelpfully warns about untrusted loop bound
for (sal_uInt16 j = 0; j < reader.getMethodExceptionCount(i); ++j)
{
printf(
diff --git a/sal/osl/unx/file.cxx b/sal/osl/unx/file.cxx
index 0101bf6f8e36..94aa6e42fc8a 100644
--- a/sal/osl/unx/file.cxx
+++ b/sal/osl/unx/file.cxx
@@ -1134,10 +1134,10 @@ const off_t MAX_OFF_T = std::numeric_limits< off_t >::max();
namespace {
-//coverity[result_independent_of_operands]
+// coverity[result_independent_of_operands] - crossplatform requirement
template<typename T> bool exceedsMaxOffT(T n) { return n > MAX_OFF_T; }
-//coverity[result_independent_of_operands]
+// coverity[result_independent_of_operands] - crossplatform requirement
template<typename T> bool exceedsMinOffT(T n)
{ return n < std::numeric_limits<off_t>::min(); }
diff --git a/sal/osl/unx/pipe.cxx b/sal/osl/unx/pipe.cxx
index 0c68255dbb1d..eb03ff2280c5 100644
--- a/sal/osl/unx/pipe.cxx
+++ b/sal/osl/unx/pipe.cxx
@@ -287,10 +287,11 @@ oslPipe osl_psz_createPipe(const sal_Char *pszPipeName, oslPipeOptions Options,
if (listen(pPipe->m_Socket, 5) < 0)
{
SAL_WARN("sal.osl.pipe", "listen() failed: " << strerror(errno));
- // coverity[toctou] cid#1255391 warns about unlink(name) after
- // stat(name, &status) above, but the intervening call to bind makes
- // those two clearly unrelated, as it would fail if name existed at
- // that point in time:
+ // cid#1255391 warns about unlink(name) after stat(name, &status)
+ // above, but the intervening call to bind makes those two clearly
+ // unrelated, as it would fail if name existed at that point in
+ // time:
+ // coverity[toctou] - this is bogus
unlink(name); /* remove filesystem entry */
close(pPipe->m_Socket);
destroyPipeImpl(pPipe);
diff --git a/sal/osl/w32/file.cxx b/sal/osl/w32/file.cxx
index aed1b315bb9e..a63b58a1bdca 100644
--- a/sal/osl/w32/file.cxx
+++ b/sal/osl/w32/file.cxx
@@ -776,7 +776,7 @@ oslFileError SAL_CALL osl_closeFile(oslFileHandle Handle)
namespace {
-//coverity[result_independent_of_operands]
+// coverity[result_independent_of_operands] - crossplatform requirement
template<typename T> bool exceedsMaxSIZE_T(T n)
{ return n > std::numeric_limits< SIZE_T >::max(); }
@@ -930,7 +930,7 @@ LONGLONG const g_limit_longlong = std::numeric_limits< LONGLONG >::max();
namespace {
-//coverity[result_independent_of_operands]
+// coverity[result_independent_of_operands] - crossplatform requirement
template<typename T> bool exceedsMaxLONGLONG(T n)
{ return n > g_limit_longlong; }
diff --git a/sal/rtl/alloc_arena.cxx b/sal/rtl/alloc_arena.cxx
index 1cd06615d1a3..39e694e017d8 100644
--- a/sal/rtl/alloc_arena.cxx
+++ b/sal/rtl/alloc_arena.cxx
@@ -258,7 +258,7 @@ void rtl_arena_hash_rescale(
rtl_arena_segment_type * next = curr->m_fnext;
rtl_arena_segment_type ** head;
- // coverity[negative_shift]
+ // coverity[negative_shift] - bogus
head = &(arena->m_hash_table[RTL_ARENA_HASH_INDEX(arena, curr->m_addr)]);
curr->m_fnext = (*head);
(*head) = curr;
diff --git a/sal/rtl/alloc_cache.cxx b/sal/rtl/alloc_cache.cxx
index 38449ccfb795..41886c7ac235 100644
--- a/sal/rtl/alloc_cache.cxx
+++ b/sal/rtl/alloc_cache.cxx
@@ -817,7 +817,7 @@ void rtl_cache_deactivate(rtl_cache_type * cache)
/* cleanup cpu layer */
if ((mag = cache->m_cpu_curr))
{
- // coverity[missing_lock]
+ // coverity[missing_lock] - locking is fine
cache->m_cpu_curr = nullptr;
rtl_cache_magazine_clear (cache, mag);
rtl_cache_free (mag_cache, mag);
@@ -825,7 +825,7 @@ void rtl_cache_deactivate(rtl_cache_type * cache)
if ((mag = cache->m_cpu_prev))
{
- // coverity[missing_lock]
+ // coverity[missing_lock] - locking is fine
cache->m_cpu_prev = nullptr;
rtl_cache_magazine_clear (cache, mag);
rtl_cache_free (mag_cache, mag);
@@ -1267,7 +1267,7 @@ static void rtl_cache_depot_wsupdate(
RTL_MEMORY_LOCK_ACQUIRE(&(cache->m_depot_lock));
}
}
- // coverity[missing_unlock]
+ // coverity[missing_unlock] - locking is fine
}
/**
diff --git a/sfx2/source/control/itemdel.cxx b/sfx2/source/control/itemdel.cxx
index c6d53ef45936..d0555950dd39 100644
--- a/sfx2/source/control/itemdel.cxx
+++ b/sfx2/source/control/itemdel.cxx
@@ -77,7 +77,7 @@ void DeleteItemOnIdle(SfxPoolItem* pItem)
DBG_ASSERT( 0 == pItem->GetRefCount(), "deleting item in use" );
SfxItemDisruptor_Impl *pDesruptor = new SfxItemDisruptor_Impl(pItem);
pDesruptor->LaunchDeleteOnIdle();
- // coverity[leaked_storage] pDesruptor takes care of its own destruction at idle time
+ // coverity[leaked_storage] - pDesruptor takes care of its own destruction at idle time
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/svtools/source/svhtml/htmlout.cxx b/svtools/source/svhtml/htmlout.cxx
index fb0a5b941a17..ae382dbb437c 100644
--- a/svtools/source/svhtml/htmlout.cxx
+++ b/svtools/source/svhtml/htmlout.cxx
@@ -465,7 +465,7 @@ static OString lcl_ConvertCharToHTML( sal_uInt32 c,
// If the character could not be converted to the destination
// character set, the UNICODE character is exported as character
// entity.
- // coverity[callee_ptr_arith]
+ // coverity[callee_ptr_arith] - its ok
nLen = lcl_FlushContext(rContext, cBuffer, nFlags);
sal_Char *pBuffer = cBuffer;
while( nLen-- )
diff --git a/unoidl/source/legacyprovider.cxx b/unoidl/source/legacyprovider.cxx
index a7eb47fc7a88..eb9462c733f2 100644
--- a/unoidl/source/legacyprovider.cxx
+++ b/unoidl/source/legacyprovider.cxx
@@ -259,9 +259,9 @@ rtl::Reference< Entity > readEntity(
{
sal_uInt16 m
= reader.getMethodExceptionCount(k);
- // coverity[tainted_data] cid#1213376
- // unhelpfully warns about an untrusted loop
- // bound here:
+ // cid#1213376 unhelpfully warns about an
+ // untrusted loop bound here:
+ // coverity[tainted_data] - trusted data source
for (sal_uInt16 l = 0; l != m; ++l) {
getExcs.push_back(
reader.getMethodExceptionTypeName(k, l).
@@ -273,9 +273,9 @@ rtl::Reference< Entity > readEntity(
{
sal_uInt16 m
= reader.getMethodExceptionCount(k);
- // coverity[tainted_data] cid#1213376
- // unhelpfully warns about an untrusted loop
- // bound here:
+ // cid#1213376 unhelpfully warns about an
+ // untrusted loop bound here:
+ // coverity[tainted_data] - trusted data source
for (sal_uInt16 l = 0; l != m; ++l) {
setExcs.push_back(
reader.getMethodExceptionTypeName(k, l).
@@ -309,8 +309,9 @@ rtl::Reference< Entity > readEntity(
std::vector< InterfaceTypeEntity::Method::Parameter >
params;
sal_uInt16 m = reader.getMethodParameterCount(j);
- // coverity[tainted_data] cid#1213376 unhelpfully warns
- // about an untrusted loop bound here:
+ // cid#1213376 unhelpfully warns about an untrusted loop
+ // bound here:
+ // coverity[tainted_data] - trusted data source
for (sal_uInt16 k = 0; k != m; ++k) {
RTParamMode mode = reader.getMethodParameterFlags(j, k);
InterfaceTypeEntity::Method::Parameter::Direction dir;
@@ -342,8 +343,9 @@ rtl::Reference< Entity > readEntity(
}
std::vector< OUString > excs;
m = reader.getMethodExceptionCount(j);
- // coverity[tainted_data] cid#1213376 unhelpfully warns
- // about an untrusted loop bound here:
+ // cid#1213376 unhelpfully warns about an untrusted loop
+ // bound here:
+ // coverity[tainted_data] - trusted data source
for (sal_uInt16 k = 0; k != m; ++k) {
excs.push_back(
reader.getMethodExceptionTypeName(j, k).replace(
@@ -607,8 +609,9 @@ rtl::Reference< Entity > readEntity(
SingleInterfaceBasedServiceEntity::Constructor::
Parameter > params;
sal_uInt16 m = reader.getMethodParameterCount(j);
- // coverity[tainted_data] cid#1213376 unhelpfully warns
- // about an untrusted loop bound here:
+ // cid#1213376 unhelpfully warns about an untrusted
+ // loop bound here:
+ // coverity[tainted_data] - trusted data source
for (sal_uInt16 k = 0; k != m; ++k) {
RTParamMode mode
= reader.getMethodParameterFlags(j, k);
@@ -647,8 +650,9 @@ rtl::Reference< Entity > readEntity(
}
std::vector< OUString > excs;
m = reader.getMethodExceptionCount(j);
- // coverity[tainted_data] cid#1213376 unhelpfully warns
- // about an untrusted loop bound here:
+ // cid#1213376 unhelpfully warns about an untrusted
+ // loop bound here:
+ // coverity[tainted_data] - trusted data source
for (sal_uInt16 k = 0; k != m; ++k) {
excs.push_back(
reader.getMethodExceptionTypeName(j, k).replace(
diff --git a/unotest/source/cpp/officeconnection.cxx b/unotest/source/cpp/officeconnection.cxx
index a82471e3b921..c85ad7b72e5f 100644
--- a/unotest/source/cpp/officeconnection.cxx
+++ b/unotest/source/cpp/officeconnection.cxx
@@ -78,7 +78,7 @@ void OfficeConnection::setUp() {
{
envs = &argEnv.pData;
}
- // coverity[callee_ptr_arith]
+ // coverity[callee_ptr_arith] - arith is fine
CPPUNIT_ASSERT_EQUAL(
osl_Process_E_None,
osl_executeProcess(