diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2016-12-14 09:49:39 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2016-12-15 06:45:14 +0000 |
commit | d15b4e204598fc7e4c1682c4f10228e217575937 (patch) | |
tree | 1173b2725abac5f06bfd2e28965a95256283e6a4 /svl | |
parent | 14a0d26d6ae0ee59a685c254ec235fea81636475 (diff) |
teach sallogareas plugin to catch inconsistencies
Change-Id: I8bcea5ffc74d48148bea78da8c17744e288c069a
Reviewed-on: https://gerrit.libreoffice.org/32004
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svl')
-rw-r--r-- | svl/source/items/cenumitm.cxx | 5 | ||||
-rw-r--r-- | svl/source/items/itempool.cxx | 1 | ||||
-rw-r--r-- | svl/source/items/itemset.cxx | 16 | ||||
-rw-r--r-- | svl/source/items/poolio.cxx | 15 | ||||
-rw-r--r-- | svl/source/items/style.cxx | 2 | ||||
-rw-r--r-- | svl/source/items/whassert.hxx | 31 |
6 files changed, 18 insertions, 52 deletions
diff --git a/svl/source/items/cenumitm.cxx b/svl/source/items/cenumitm.cxx index 187eb73991e9..033b6a6ae812 100644 --- a/svl/source/items/cenumitm.cxx +++ b/svl/source/items/cenumitm.cxx @@ -22,7 +22,6 @@ #include <tools/stream.hxx> #include <svl/cenumitm.hxx> #include <svl/eitem.hxx> -#include "whassert.hxx" #include <comphelper/extract.hxx> #include <libxml/xmlwriter.h> @@ -31,7 +30,7 @@ // virtual bool SfxEnumItemInterface::operator ==(const SfxPoolItem & rItem) const { - SFX_ASSERT(SfxPoolItem::operator ==(rItem), Which(), "unequal type"); + SAL_WARN_IF(!SfxPoolItem::operator ==(rItem), "svl.items", "unequal type, with ID/pos " << Which() ); return GetEnumValue() == static_cast< const SfxEnumItemInterface * >(&rItem)-> GetEnumValue(); @@ -71,7 +70,7 @@ bool SfxEnumItemInterface::PutValue(const css::uno::Any& rVal, OUString SfxEnumItemInterface::GetValueTextByPos(sal_uInt16) const { - SAL_INFO("svl", "SfxEnumItemInterface::GetValueTextByPos(): Pure virtual"); + SAL_INFO("svl.items", "SfxEnumItemInterface::GetValueTextByPos(): Pure virtual"); return OUString(); } diff --git a/svl/source/items/itempool.cxx b/svl/source/items/itempool.cxx index 27caf7c2e708..9f80d471cb88 100644 --- a/svl/source/items/itempool.cxx +++ b/svl/source/items/itempool.cxx @@ -24,7 +24,6 @@ #include <osl/diagnose.h> #include <sal/log.hxx> -#include "whassert.hxx" #include <svl/SfxBroadcaster.hxx> #include <svl/hint.hxx> #include "poolio.hxx" diff --git a/svl/source/items/itemset.cxx b/svl/source/items/itemset.cxx index 9996e9330476..9e44a8ba1889 100644 --- a/svl/source/items/itemset.cxx +++ b/svl/source/items/itemset.cxx @@ -29,7 +29,6 @@ #include <svl/itempool.hxx> #include <svl/itemiter.hxx> #include <svl/whiter.hxx> -#include "whassert.hxx" #include <tools/stream.hxx> #include <tools/solar.h> @@ -537,9 +536,10 @@ const SfxPoolItem* SfxItemSet::Put( const SfxPoolItem& rItem, sal_uInt16 nWhich } } } - SFX_ASSERT( !m_pPool->IsItemPoolable(nWhich) || - dynamic_cast<const SfxSetItem*>( &rItem ) != nullptr || **ppFnd == rItem, - nWhich, "putted Item unequal" ); + SAL_WARN_IF(m_pPool->IsItemPoolable(nWhich) && + dynamic_cast<const SfxSetItem*>( &rItem ) == nullptr && + **ppFnd != rItem, + "svl.items", "putted Item unequal, with ID/pos " << nWhich ); return *ppFnd; } ppFnd += *(pPtr+1) - *pPtr + 1; @@ -910,7 +910,7 @@ const SfxPoolItem& SfxItemSet::Get( sal_uInt16 nWhich, bool bSrchInParent) const { if( reinterpret_cast<SfxPoolItem*>(-1) == *ppFnd ) { //FIXME: The following code is duplicated further down - SFX_ASSERT(m_pPool, nWhich, "no Pool, but status is ambiguous"); + SAL_WARN_IF(!m_pPool, "svl.items", "no Pool, but status is ambiguous, with ID/pos " << nWhich); //!((SfxAllItemSet *)this)->aDefault.SetWhich(nWhich); //!return aDefault; return m_pPool->GetDefaultItem( nWhich ); @@ -934,7 +934,7 @@ const SfxPoolItem& SfxItemSet::Get( sal_uInt16 nWhich, bool bSrchInParent) const } while (bSrchInParent && nullptr != (pAktSet = pAktSet->m_pParent)); // Get the Default from the Pool and return - SFX_ASSERT(m_pPool, nWhich, "no Pool, but status is ambiguous"); + SAL_WARN_IF(!m_pPool, "svl.items", "no Pool, but status is ambiguous, with ID/pos " << nWhich); const SfxPoolItem *pItem = &m_pPool->GetDefaultItem( nWhich ); return *pItem; } @@ -1446,7 +1446,7 @@ void SfxItemSet::Load const size_t nMaxRecords = rStream.remainingSize() / nMinRecordSize; if (nCount > nMaxRecords) { - SAL_WARN("svl", "Parsing error: " << nMaxRecords << + SAL_WARN("svl.items", "Parsing error: " << nMaxRecords << " max possible entries, but " << nCount << " claimed, truncating"); nCount = nMaxRecords; } @@ -1471,7 +1471,7 @@ void SfxItemSet::Load { // Remember Item pointer in the set ppFnd += nWhich - *pPtr; - SFX_ASSERT( !*ppFnd, nWhich, "Item is present twice"); + SAL_WARN_IF( *ppFnd, "svl.items", "Item is present twice, with ID/pos " << nWhich); *ppFnd = pItem; ++m_nCount; break; diff --git a/svl/source/items/poolio.cxx b/svl/source/items/poolio.cxx index 4156ec945684..e008f74b032e 100644 --- a/svl/source/items/poolio.cxx +++ b/svl/source/items/poolio.cxx @@ -23,7 +23,6 @@ #include <sal/log.hxx> #include <tools/solar.h> #include <svl/itempool.hxx> -#include "whassert.hxx" #include <svl/SfxBroadcaster.hxx> #include <svl/filerec.hxx> #include "poolio.hxx" @@ -432,7 +431,7 @@ void SfxItemPool_Impl::readTheItems ( if ( nullptr != pOldArr ) for ( n = 0; bEmpty && n < pOldArr->size(); ++n ) bEmpty = pOldArr->operator[](n) == nullptr; - SAL_WARN_IF( !bEmpty, "svl", "loading non-empty pool" ); + SAL_WARN_IF( !bEmpty, "svl.items", "loading non-empty pool" ); if ( !bEmpty ) { // See if there's a new one for all old ones @@ -499,7 +498,7 @@ SvStream &SfxItemPool::Load(SvStream &rStream) for (auto const& rItemPtr : *rArrayPtr) if (rItemPtr) { - SAL_INFO( "svl", "loading non-empty ItemPool" ); + SAL_INFO( "svl.items", "loading non-empty ItemPool" ); AddRef(*rItemPtr); } } @@ -618,7 +617,7 @@ SvStream &SfxItemPool::Load(SvStream &rStream) const size_t nMaxRecords = rStream.remainingSize() / sizeof(sal_uInt16); if (nCount > nMaxRecords) { - SAL_WARN("svl", "Parsing error: " << nMaxRecords << + SAL_WARN("svl.items", "Parsing error: " << nMaxRecords << " max possible entries, but " << nCount << " claimed, truncating"); nCount = nMaxRecords; } @@ -864,7 +863,7 @@ const SfxPoolItem* SfxItemPool::LoadSurrogate } } - SFX_ASSERT( false, rWhich, "can't resolve Which-Id in LoadSurrogate" ); + SAL_WARN("svl.items", "can't resolve Which-Id in LoadSurrogate, with ID/pos " << rWhich ); } return nullptr; @@ -908,7 +907,7 @@ sal_uInt32 SfxItemPool::GetSurrogate(const SfxPoolItem *pItem) const { if ( pImpl->mpSecondary ) return pImpl->mpSecondary->GetSurrogate( pItem ); - SFX_ASSERT( false, pItem->Which(), "unknown Which-Id - don't ask me for surrogates" ); + SAL_WARN( "svl.items", "unknown Which-Id - don't ask me for surrogates, with ID/pos " << pItem->Which()); } // Pointer on static or pool-default attribute? @@ -924,7 +923,7 @@ sal_uInt32 SfxItemPool::GetSurrogate(const SfxPoolItem *pItem) const if ( p == pItem ) return i; } - SFX_ASSERT( false, pItem->Which(), "Item not in the pool"); + SAL_WARN( "svl.items", "Item not in the pool, with ID/pos " << pItem->Which()); return SFX_ITEMS_NULL; } @@ -1059,7 +1058,7 @@ sal_uInt16 SfxItemPool::GetNewWhich { if ( pImpl->mpSecondary ) return pImpl->mpSecondary->GetNewWhich( nFileWhich ); - SFX_ASSERT( false, nFileWhich, "unknown which in GetNewWhich()" ); + SAL_WARN( "svl.items", "unknown which in GetNewWhich(), with ID/pos " << nFileWhich); } // Newer/the same/older version? diff --git a/svl/source/items/style.cxx b/svl/source/items/style.cxx index a96cc5f22019..f979c1bdbe7a 100644 --- a/svl/source/items/style.cxx +++ b/svl/source/items/style.cxx @@ -258,7 +258,7 @@ bool SfxStyleSheetBase::SetFollow( const OUString& rName ) { if( !pPool->Find( rName, nFamily ) ) { - SAL_WARN( "svl", "StyleSheet-Follow not found" ); + SAL_WARN( "svl.items", "StyleSheet-Follow not found" ); return false; } aFollow = rName; diff --git a/svl/source/items/whassert.hxx b/svl/source/items/whassert.hxx deleted file mode 100644 index 253debbf0e87..000000000000 --- a/svl/source/items/whassert.hxx +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ -#ifndef INCLUDED_SVL_SOURCE_ITEMS_WHASSERT_HXX -#define INCLUDED_SVL_SOURCE_ITEMS_WHASSERT_HXX - -#include <sal/config.h> - -#include <sal/log.hxx> - -#define SFX_ASSERT( bCondition, nId, sMessage ) SAL_WARN_IF( \ - !(bCondition), "svl", sMessage ", with ID/pos " << (nId)); - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |