From 0be61adb0771a9bc0386b6e8d90e4bffd8dfa0e7 Mon Sep 17 00:00:00 2001 From: Julien Nabet Date: Sun, 24 Nov 2019 10:43:47 +0100 Subject: cppcheck: performing init in init list (dbaccess/desktop/dtrans/e.) Change-Id: I7909df04a550a4fa843a70d20b5192231c3f175e Reviewed-on: https://gerrit.libreoffice.org/83600 Reviewed-by: Julien Nabet Tested-by: Julien Nabet --- .../source/ui/misc/dbsubcomponentcontroller.cxx | 2 +- dbaccess/source/ui/querydesign/TableFieldInfo.cxx | 3 +- desktop/source/migration/migration_impl.hxx | 6 ++-- desktop/source/offacc/acceptor.cxx | 2 +- dtrans/source/win32/clipb/MtaOleClipb.cxx | 26 +++++++-------- editeng/source/editeng/impedit.cxx | 37 +++++++++++----------- editeng/source/editeng/impedit.hxx | 12 +++---- editeng/source/editeng/impedit2.cxx | 37 ++++++++-------------- editeng/source/outliner/outlundo.cxx | 14 ++------ embedserv/source/embed/servprov.cxx | 3 +- 10 files changed, 58 insertions(+), 84 deletions(-) diff --git a/dbaccess/source/ui/misc/dbsubcomponentcontroller.cxx b/dbaccess/source/ui/misc/dbsubcomponentcontroller.cxx index eb3331d6fe88..7f7163a32ba1 100644 --- a/dbaccess/source/ui/misc/dbsubcomponentcontroller.cxx +++ b/dbaccess/source/ui/misc/dbsubcomponentcontroller.cxx @@ -91,8 +91,8 @@ namespace dbaui } explicit DataSourceHolder(const Reference< XDataSource >& _rxDataSource) + : m_xDataSource(_rxDataSource) { - m_xDataSource = _rxDataSource; Reference< XDocumentDataSource > xDocDS( m_xDataSource, UNO_QUERY ); if ( xDocDS.is() ) m_xDocument = xDocDS->getDatabaseDocument(); diff --git a/dbaccess/source/ui/querydesign/TableFieldInfo.cxx b/dbaccess/source/ui/querydesign/TableFieldInfo.cxx index 7aae617ef7b9..bf3121c9b63c 100644 --- a/dbaccess/source/ui/querydesign/TableFieldInfo.cxx +++ b/dbaccess/source/ui/querydesign/TableFieldInfo.cxx @@ -23,9 +23,8 @@ using namespace dbaui; // class OTableFieldInfo OTableFieldInfo::OTableFieldInfo() : - m_eDataType(1000) + m_eFieldType(TAB_NORMAL_FIELD), m_eDataType(1000) { - m_eFieldType = TAB_NORMAL_FIELD; } OTableFieldInfo::~OTableFieldInfo() diff --git a/desktop/source/migration/migration_impl.hxx b/desktop/source/migration/migration_impl.hxx index c4eb5ed8f07d..399066bdafe6 100644 --- a/desktop/source/migration/migration_impl.hxx +++ b/desktop/source/migration/migration_impl.hxx @@ -98,11 +98,9 @@ struct MigrationItem const OUString& sPrevSibling, const OUString& sCommandURL, const css::uno::Reference< css::container::XIndexContainer > & xPopupMenu) + : m_sParentNodeName(sParentNodeName), m_sPrevSibling(sPrevSibling), + m_sCommandURL(sCommandURL), m_xPopupMenu(xPopupMenu) { - m_sParentNodeName = sParentNodeName; - m_sPrevSibling = sPrevSibling; - m_sCommandURL = sCommandURL; - m_xPopupMenu = xPopupMenu; } bool operator==(const MigrationItem& aMigrationItem) diff --git a/desktop/source/offacc/acceptor.cxx b/desktop/source/offacc/acceptor.cxx index f687edfc758b..a417d6a5d502 100644 --- a/desktop/source/offacc/acceptor.cxx +++ b/desktop/source/offacc/acceptor.cxx @@ -218,8 +218,8 @@ Reference< XInterface > Acceptor::impl_getInstance( const Reference< XMultiServi // InstanceProvider AccInstanceProvider::AccInstanceProvider(const Reference& rxContext) + : m_rContext(rxContext) { - m_rContext = rxContext; } AccInstanceProvider::~AccInstanceProvider() diff --git a/dtrans/source/win32/clipb/MtaOleClipb.cxx b/dtrans/source/win32/clipb/MtaOleClipb.cxx index b58f8ea89d24..5ab8e1adb9a9 100644 --- a/dtrans/source/win32/clipb/MtaOleClipb.cxx +++ b/dtrans/source/win32/clipb/MtaOleClipb.cxx @@ -176,18 +176,16 @@ static HRESULT UnmarshalIDataObjectAndReleaseStream( LPSTREAM lpStream, IDataObj class CAutoComInit { public: - CAutoComInit( ) + /* + to be safe we call CoInitialize + although it is not necessary if + the calling thread was created + using osl_CreateThread because + this function calls CoInitialize + for every thread it creates + */ + CAutoComInit( ) : m_hResult( CoInitialize( nullptr ) ) { - /* - to be safe we call CoInitialize - although it is not necessary if - the calling thread was created - using osl_CreateThread because - this function calls CoInitialize - for every thread it creates - */ - m_hResult = CoInitialize( nullptr ); - if ( S_OK == m_hResult ) OSL_FAIL( "com was not yet initialized, the thread was not created using osl_createThread" ); @@ -221,7 +219,8 @@ private: CMtaOleClipboard::CMtaOleClipboard( ) : m_hOleThread( nullptr ), m_uOleThreadId( 0 ), - m_hEvtThrdReady( nullptr ), + // signals that the thread was successfully setup + m_hEvtThrdReady(CreateEventW( nullptr, MANUAL_RESET, INIT_NONSIGNALED, nullptr )), m_hwndMtaOleReqWnd( nullptr ), // signals that the window is destroyed - to stop waiting any winproc result m_hEvtWndDisposed(CreateEventW(nullptr, MANUAL_RESET, INIT_NONSIGNALED, nullptr)), @@ -232,9 +231,6 @@ CMtaOleClipboard::CMtaOleClipboard( ) : m_hTerminateClipboardChangedNotifierEvent( m_hClipboardChangedNotifierEvents[1] ), m_ClipboardChangedEventCount( 0 ) { - // signals that the thread was successfully setup - m_hEvtThrdReady = CreateEventW( nullptr, MANUAL_RESET, INIT_NONSIGNALED, nullptr ); - OSL_ASSERT( nullptr != m_hEvtThrdReady ); SAL_WARN_IF(!m_hEvtWndDisposed, "dtrans", "CreateEventW failed: m_hEvtWndDisposed is nullptr"); diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx index 98cc989ef6b9..348d74bf41ff 100644 --- a/editeng/source/editeng/impedit.cxx +++ b/editeng/source/editeng/impedit.cxx @@ -66,26 +66,25 @@ static void lcl_AllignToPixel( Point& rPoint, OutputDevice const * pOutDev, shor // class ImpEditView ImpEditView::ImpEditView( EditView* pView, EditEngine* pEng, vcl::Window* pWindow ) : - aOutArea( Point(), pEng->GetPaperSize() ) + pEditView(pView), + mpViewShell(nullptr), + mpOtherShell(nullptr), + pEditEngine(pEng), + pOutWin(pWindow), + nInvMore(1), + nControl(EVControlBits::AUTOSCROLL | EVControlBits::ENABLEPASTE), + nTravelXPos(TRAVEL_X_DONTKNOW), + nExtraCursorFlags(GetCursorFlags::NONE), + nCursorBidiLevel(CURSOR_BIDILEVEL_DONTKNOW), + nScrollDiffX(0), + bReadOnly(false), + bClickedInSelection(false), + bActiveDragAndDropListener(false), + aOutArea( Point(), pEng->GetPaperSize() ), + eSelectionMode(EESelectionMode::Std), + eAnchorMode(EEAnchorMode::TopLeft), + mpEditViewCallbacks(nullptr) { - pEditView = pView; - pEditEngine = pEng; - pOutWin = pWindow; - mpViewShell = nullptr; - mpOtherShell = nullptr; - nScrollDiffX = 0; - nExtraCursorFlags = GetCursorFlags::NONE; - nCursorBidiLevel = CURSOR_BIDILEVEL_DONTKNOW; - bReadOnly = false; - bClickedInSelection = false; - eSelectionMode = EESelectionMode::Std; - eAnchorMode = EEAnchorMode::TopLeft; - mpEditViewCallbacks = nullptr; - nInvMore = 1; - nTravelXPos = TRAVEL_X_DONTKNOW; - nControl = EVControlBits::AUTOSCROLL | EVControlBits::ENABLEPASTE; - bActiveDragAndDropListener = false; - aEditSelection.Min() = pEng->GetEditDoc().GetStartPaM(); aEditSelection.Max() = pEng->GetEditDoc().GetEndPaM(); diff --git a/editeng/source/editeng/impedit.hxx b/editeng/source/editeng/impedit.hxx index 26c9d25961fa..6980e39d0824 100644 --- a/editeng/source/editeng/impedit.hxx +++ b/editeng/source/editeng/impedit.hxx @@ -134,10 +134,10 @@ struct DragAndDropInfo bool bDragAccepted : 1; DragAndDropInfo() + : nSensibleRange(0), nCursorWidth(0), nOutlinerDropDest(0), pBackground(nullptr), + pField(nullptr), bVisCursor(false), bDroppedInMe(false), bStarterOfDD(false), + bHasValidData(false), bUndoAction(false), bOutlinerMode(false), bDragAccepted(false) { - pBackground = nullptr; bVisCursor = false; bDroppedInMe = false; bStarterOfDD = false; - bHasValidData = false; bUndoAction = false; bOutlinerMode = false; - nSensibleRange = 0; nCursorWidth = 0; pField = nullptr; nOutlinerDropDest = 0; bDragAccepted = false; } ~DragAndDropInfo() { @@ -174,8 +174,8 @@ struct SpellInfo bool bMultipleDoc; svx::SpellPortions aLastSpellPortions; SpellContentSelections aLastSpellContentSelections; - SpellInfo() - { bSpellToEnd = true; eState = EESpellState::Ok; bMultipleDoc = false; } + SpellInfo() : eState(EESpellState::Ok), bSpellToEnd(true), bMultipleDoc(false) + { } }; // used for text conversion @@ -195,7 +195,7 @@ struct FormatterFontMetric sal_uInt16 nMaxAscent; sal_uInt16 nMaxDescent; - FormatterFontMetric() { nMaxAscent = 0; nMaxDescent = 0; /* nMinLeading = 0xFFFF; */ } + FormatterFontMetric() : nMaxAscent(0), nMaxDescent(0) { /* nMinLeading = 0xFFFF; */ } sal_uInt16 GetHeight() const { return nMaxAscent+nMaxDescent; } }; diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx index c65dc164ea4a..3d040c00435d 100644 --- a/editeng/source/editeng/impedit2.cxx +++ b/editeng/source/editeng/impedit2.cxx @@ -95,7 +95,21 @@ ImpEditEngine::ImpEditEngine( EditEngine* pEE, SfxItemPool* pItemPool ) : aMinAutoPaperSize( 0x0, 0x0 ), aMaxAutoPaperSize( 0x7FFFFFFF, 0x7FFFFFFF ), aEditDoc( pItemPool ), + pEditEngine(pEE), + pActiveView(nullptr), + pStylePool(nullptr), + pTextObjectPool(nullptr), + pUndoManager(nullptr), aWordDelimiters(" .,;:-`'?!_=\"{}()[]"), + maBackgroundColor(COL_AUTO), + nStretchX(100), + nStretchY(100), + nAsianCompressionMode(CharCompressType::NONE), + eDefaultHorizontalTextDirection(EEHorizontalTextDirection::Default), + nBigTextObjectStart(20), + eDefLanguage(LANGUAGE_DONTKNOW), + nCurTextHeight(0), + nCurTextHeightNTP(0), bKernAsianPunctuation(false), bAddExtLeading(false), bIsFormatting(false), @@ -113,29 +127,6 @@ ImpEditEngine::ImpEditEngine( EditEngine* pEE, SfxItemPool* pItemPool ) : mbReplaceLeadingSingleQuotationMark(true), mbNbspRunNext(false) { - pEditEngine = pEE; - pActiveView = nullptr; - pConvInfo = nullptr; - pTextObjectPool = nullptr; - pStylePool = nullptr; - pUndoManager = nullptr; - pUndoMarkSelection = nullptr; - - nCurTextHeight = 0; - nCurTextHeightNTP = 0; - nBigTextObjectStart = 20; - - nStretchX = 100; - nStretchY = 100; - - eDefLanguage = LANGUAGE_DONTKNOW; - maBackgroundColor = COL_AUTO; - - nAsianCompressionMode = CharCompressType::NONE; - - eDefaultHorizontalTextDirection = EEHorizontalTextDirection::Default; - - aStatus.GetControlWord() = EEControlBits::USECHARATTRIBS | EEControlBits::DOIDLEFORMAT | EEControlBits::PASTESPECIAL | EEControlBits::UNDOATTRIBS | EEControlBits::ALLOWBIGOBJS | EEControlBits::RTFSTYLESHEETS | diff --git a/editeng/source/outliner/outlundo.cxx b/editeng/source/outliner/outlundo.cxx index 32f8302f8dd5..65f390f62487 100644 --- a/editeng/source/outliner/outlundo.cxx +++ b/editeng/source/outliner/outlundo.cxx @@ -37,11 +37,8 @@ OutlinerUndoBase::OutlinerUndoBase( sal_uInt16 _nId, Outliner* pOutliner ) } OutlinerUndoChangeParaFlags::OutlinerUndoChangeParaFlags( Outliner* pOutliner, sal_Int32 nPara, ParaFlag nOldFlags, ParaFlag nNewFlags ) -: OutlinerUndoBase( OLUNDO_DEPTH, pOutliner ) +: OutlinerUndoBase( OLUNDO_DEPTH, pOutliner ), mnPara(nPara), mnOldFlags(nOldFlags), mnNewFlags(nNewFlags) { - mnPara = nPara; - mnOldFlags = nOldFlags; - mnNewFlags = nNewFlags; } void OutlinerUndoChangeParaFlags::Undo() @@ -99,11 +96,8 @@ void OutlinerUndoChangeParaNumberingRestart::ImplApplyData( const ParaRestartDat } OutlinerUndoChangeDepth::OutlinerUndoChangeDepth( Outliner* pOutliner, sal_Int32 nPara, sal_Int16 nOldDepth, sal_Int16 nNewDepth ) - : OutlinerUndoBase( OLUNDO_DEPTH, pOutliner ) + : OutlinerUndoBase( OLUNDO_DEPTH, pOutliner ), mnPara(nPara), mnOldDepth(nOldDepth), mnNewDepth(nNewDepth) { - mnPara = nPara; - mnOldDepth = nOldDepth; - mnNewDepth = nNewDepth; } void OutlinerUndoChangeDepth::Undo() @@ -137,11 +131,9 @@ void OutlinerUndoCheckPara::Redo() } OLUndoExpand::OLUndoExpand(Outliner* pOut, sal_uInt16 _nId ) - : EditUndo( _nId, nullptr ) + : EditUndo( _nId, nullptr ), pOutliner(pOut), nCount(0) { DBG_ASSERT(pOut,"Undo:No Outliner"); - pOutliner = pOut; - nCount = 0; } diff --git a/embedserv/source/embed/servprov.cxx b/embedserv/source/embed/servprov.cxx index 09ef6211724e..3557fa33257c 100644 --- a/embedserv/source/embed/servprov.cxx +++ b/embedserv/source/embed/servprov.cxx @@ -56,9 +56,8 @@ class CurThreadData oslThreadKey m_hKey; }; -CurThreadData::CurThreadData() +CurThreadData::CurThreadData() : m_hKey(osl_createThreadKey( nullptr )) { - m_hKey = osl_createThreadKey( nullptr ); } CurThreadData::~CurThreadData() -- cgit