Date: prev next · Thread: first prev next last
2017 Archives by date, by thread · List index


On 01/24/2017 10:10 AM, Caolán McNamara wrote:
commit 06202a90d6857a66512e10fef771b36196fc2d03
Author: Caolán McNamara <caolanm@redhat.com>
Date:   Tue Jan 24 09:07:35 2017 +0000

    coverity#1399266 Uncaught exception

    Change-Id: I1066fda2258e6acbbbad23256f815975564e5e61

diff --git a/o3tl/qa/cow_wrapper_clients.hxx b/o3tl/qa/cow_wrapper_clients.hxx
index 138f496..7750b71 100644
--- a/o3tl/qa/cow_wrapper_clients.hxx
+++ b/o3tl/qa/cow_wrapper_clients.hxx
@@ -22,6 +22,7 @@

 #include "o3tl/cow_wrapper.hxx"
 #include "cppunit/extensions/HelperMacros.h"
+#include <assert.h>

 /* Definition of Cow_Wrapper_Clients classes */

@@ -153,15 +154,12 @@ struct BogusRefCountPolicy
     static sal_uInt32 s_nEndOfScope;
     typedef sal_uInt32 ref_count_t;
     static void incrementCount( ref_count_t& rCount ) {
-        if(s_bShouldIncrement)
-        {
-            ++rCount;
-            s_bShouldIncrement = false;
-        }
-        else
-            CPPUNIT_FAIL("Ref-counting policy incremented when it should not have.");
+        assert(s_bShouldIncrement && "Ref-counting policy incremented when it should not have.");
+        ++rCount;
+        s_bShouldIncrement = false;
     }
     static bool decrementCount( ref_count_t& rCount ) {
+        assert((s_nEndOfScope || s_bShouldDecrement) && "Ref-counting policy decremented when it should 
not have.");

should we take this as motivation to build CppunitTest_* code always as if --enable-assert-always-abort?

         if(s_nEndOfScope)
         {
             --rCount;
@@ -172,8 +170,6 @@ struct BogusRefCountPolicy
             --rCount;
             s_bShouldDecrement = false;
         }
-        else
-            CPPUNIT_FAIL("Ref-counting policy decremented when it should not have.");
         return rCount != 0;
     }
 };


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.