[Libreoffice-commits] core.git: include/tools

Caolán McNamara caolanm at redhat.com
Wed Apr 11 13:06:04 UTC 2018


 include/tools/diagnose_ex.h |   24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

New commits:
commit 42ca6e53291e975555cc9cd5ecff25bfea556d7e
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Apr 11 09:05:06 2018 +0100

    coverity#1401328 silence Uncaught exception
    
    and a bunch more
    
    Change-Id: Icdd195d1ddfc0259743892097a65c07277d53fd9
    Reviewed-on: https://gerrit.libreoffice.org/52711
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/include/tools/diagnose_ex.h b/include/tools/diagnose_ex.h
index 31c2b376baa2..9c18d5f51ad4 100644
--- a/include/tools/diagnose_ex.h
+++ b/include/tools/diagnose_ex.h
@@ -33,6 +33,24 @@ TOOLS_DLLPUBLIC void DbgUnhandledException(const css::uno::Any& caughtException,
         const char* currentFunction, const char* fileAndLineNo,
         const char* area = nullptr, const char* explanatory = nullptr);
 
+//getCaughtException throws exceptions in never-going-to-happen situations which
+//floods coverity with warnings
+inline css::uno::Any DbgGetCaughtException()
+{
+#if defined(__COVERITY__)
+    try
+    {
+        return ::cppu::getCaughtException();
+    }
+    catch (...)
+    {
+        std::abort();
+    }
+#else
+    return ::cppu::getCaughtException();
+#endif
+}
+
 /** reports a caught UNO exception via OSL diagnostics
 
     Note that whenever you use this, it might be an indicator that your error
@@ -40,11 +58,11 @@ TOOLS_DLLPUBLIC void DbgUnhandledException(const css::uno::Any& caughtException,
     This takes two optional parameters: area and explanatory
 */
 #define DBG_UNHANDLED_EXCEPTION_0_ARGS() \
-    DbgUnhandledException( ::cppu::getCaughtException(), OSL_THIS_FUNC, SAL_DETAIL_WHERE );
+    DbgUnhandledException( DbgGetCaughtException(), OSL_THIS_FUNC, SAL_DETAIL_WHERE );
 #define DBG_UNHANDLED_EXCEPTION_1_ARGS(area) \
-    DbgUnhandledException( ::cppu::getCaughtException(), OSL_THIS_FUNC, SAL_DETAIL_WHERE, area );
+    DbgUnhandledException( DbgGetCaughtException(), OSL_THIS_FUNC, SAL_DETAIL_WHERE, area );
 #define DBG_UNHANDLED_EXCEPTION_2_ARGS(area, explanatory) \
-    DbgUnhandledException( ::cppu::getCaughtException(), OSL_THIS_FUNC, SAL_DETAIL_WHERE, area, explanatory );
+    DbgUnhandledException( DbgGetCaughtException(), OSL_THIS_FUNC, SAL_DETAIL_WHERE, area, explanatory );
 
 #define DBG_UNHANDLED_FUNC_CHOOSER(_f1, _f2, _f3, ...) _f3
 #define DBG_UNHANDLED_FUNC_RECOMPOSER(argsWithParentheses) DBG_UNHANDLED_FUNC_CHOOSER argsWithParentheses


More information about the Libreoffice-commits mailing list