tdf#39440: fix several warnings reported by cppcheck

Change-Id: I560d28b7cc67740c6479494d0e5aa62d2ac6ffae
Reviewed-on: https://gerrit.libreoffice.org/19587
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Thorsten Behrens <Thorsten.Behrens@CIB.de>
diff --git a/bridges/source/cpp_uno/gcc3_linux_mips/cpp2uno.cxx b/bridges/source/cpp_uno/gcc3_linux_mips/cpp2uno.cxx
index 167b4ad..6e0a7dc 100644
--- a/bridges/source/cpp_uno/gcc3_linux_mips/cpp2uno.cxx
+++ b/bridges/source/cpp_uno/gcc3_linux_mips/cpp2uno.cxx
@@ -385,7 +385,7 @@ namespace

#ifdef BRDEBUG
    fprintf(stderr,"cpp_mediate1 gp=%p,fp=%p,ov=%p\n",gpreg,fpreg,ovrflw);
    fprintf(stderr,"gp=%x,%x,%x,%x\n",gpreg[0],gpreg[1],gpreg[2],gpreg[3]);
    fprintf(stderr,"gp=%p,%p,%p,%p\n",gpreg[0],gpreg[1],gpreg[2],gpreg[3]);
#endif

    // gpreg:  [ret *], this, [other gpr params]
diff --git a/bridges/source/cpp_uno/gcc3_linux_sparc/cpp2uno.cxx b/bridges/source/cpp_uno/gcc3_linux_sparc/cpp2uno.cxx
index 93b10de..f0fa890 100644
--- a/bridges/source/cpp_uno/gcc3_linux_sparc/cpp2uno.cxx
+++ b/bridges/source/cpp_uno/gcc3_linux_sparc/cpp2uno.cxx
@@ -377,7 +377,7 @@ void * pRegReturn = &nRegReturn;
//  fprintf(stderr,"cpp_mediate nFunctionIndex=%x\n",nFunctionIndex);
//  fflush(stderr);

    sal_Bool bComplex = nFunctionIndex & 0x80000000 ? sal_True : sal_False;
    const sal_Bool bComplex = (nFunctionIndex & 0x80000000) ? sal_True : sal_False;
    typelib_TypeClass aType =
        cpp_mediate( nFunctionIndex, vTableOffset, pCallStack+17, (sal_Int64*)&nRegReturn );

diff --git a/bridges/test/testoffice.cxx b/bridges/test/testoffice.cxx
index 5d17a00..9e34602 100644
--- a/bridges/test/testoffice.cxx
+++ b/bridges/test/testoffice.cxx
@@ -112,7 +112,7 @@ void testWriter(  const Reference < XComponent > & rCmp )
    printf( "pleast type any text\n" );
    while( true )
    {
        scanf( "%s" , pcText );
        scanf( "%1023s" , pcText );

        if( !strcmp( pcText , "end" ) )
        {
diff --git a/comphelper/source/misc/configuration.cxx b/comphelper/source/misc/configuration.cxx
index ea01cea..bb00475 100644
--- a/comphelper/source/misc/configuration.cxx
+++ b/comphelper/source/misc/configuration.cxx
@@ -220,8 +220,7 @@ void comphelper::ConfigurationListener::addListener(ConfigurationListenerPropert

void comphelper::ConfigurationListener::removeListener(ConfigurationListenerPropertyBase *pListener)
{
    auto it = maListeners.begin();
    it = std::find( maListeners.begin(), maListeners.end(), pListener );
    auto it = std::find( maListeners.begin(), maListeners.end(), pListener );
    if ( it != maListeners.end() )
    {
        maListeners.erase( it );
diff --git a/compilerplugins/clang/automem.cxx b/compilerplugins/clang/automem.cxx
index 7981c7a..dfa3525 100644
--- a/compilerplugins/clang/automem.cxx
+++ b/compilerplugins/clang/automem.cxx
@@ -26,7 +26,7 @@ class AutoMem:
    public RecursiveASTVisitor<AutoMem>, public loplugin::Plugin
{
public:
    explicit AutoMem(InstantiationData const & data): Plugin(data) {}
    explicit AutoMem(InstantiationData const & data): Plugin(data), mbInsideDestructor(false) {}

    virtual void run() override
    {
diff --git a/compilerplugins/clang/badvectorinit.cxx b/compilerplugins/clang/badvectorinit.cxx
index 709a65d..7f67ffc 100644
--- a/compilerplugins/clang/badvectorinit.cxx
+++ b/compilerplugins/clang/badvectorinit.cxx
@@ -89,7 +89,7 @@ class BadVectorInit:
    public RecursiveASTVisitor<BadVectorInit>, public loplugin::Plugin
{
public:
    explicit BadVectorInit(InstantiationData const & data): Plugin(data) {}
    explicit BadVectorInit(InstantiationData const & data): Plugin(data), mbInsideFunction(false) {}

    virtual void run() override
    {
diff --git a/compilerplugins/clang/staticmethods.cxx b/compilerplugins/clang/staticmethods.cxx
index 42c958d..1d9313f 100644
--- a/compilerplugins/clang/staticmethods.cxx
+++ b/compilerplugins/clang/staticmethods.cxx
@@ -21,7 +21,7 @@ class StaticMethods:
private:
    bool bVisitedThis;
public:
    explicit StaticMethods(InstantiationData const & data): Plugin(data) {}
    explicit StaticMethods(InstantiationData const & data): Plugin(data), bVisitedThis(false) {}

    void run() override
    { TraverseDecl(compiler.getASTContext().getTranslationUnitDecl()); }
diff --git a/cui/source/options/optlingu.cxx b/cui/source/options/optlingu.cxx
index af8ce63..0348f2b 100644
--- a/cui/source/options/optlingu.cxx
+++ b/cui/source/options/optlingu.cxx
@@ -616,17 +616,18 @@ Sequence< OUString > SvxLinguData_Impl::GetSortedImplNames( sal_Int16 nLang, sal

ServiceInfo_Impl * SvxLinguData_Impl::GetInfoByImplName( const OUString &rSvcImplName )
{
    ServiceInfo_Impl* pInfo = 0;
    for (sal_uLong i = 0;  i < nDisplayServices  &&  !pInfo;  ++i)
    for (sal_uLong i = 0;  i < nDisplayServices;  ++i)
    {
        ServiceInfo_Impl &rTmp = aDisplayServiceArr[ i ];
        if (rTmp.sSpellImplName == rSvcImplName ||
            rTmp.sHyphImplName  == rSvcImplName ||
            rTmp.sThesImplName  == rSvcImplName ||
            rTmp.sGrammarImplName == rSvcImplName)
            pInfo = &rTmp;
        {
            return &rTmp;
        }
    }
    return pInfo;
    return 0;
}


diff --git a/drawinglayer/source/processor2d/vclprocessor2d.cxx b/drawinglayer/source/processor2d/vclprocessor2d.cxx
index a63e7e9..b50c836a 100644
--- a/drawinglayer/source/processor2d/vclprocessor2d.cxx
+++ b/drawinglayer/source/processor2d/vclprocessor2d.cxx
@@ -599,7 +599,7 @@ namespace drawinglayer
                                        // offset in X, so iterate over Y first and draw lines
                                        for(sal_Int32 nYPos(nBTop); nYPos < nOTop + nOHeight; nYPos += nBHeight, nPosY++)
                                        {
                                            for(sal_Int32 nXPos(nPosY % 2 ? nBLeft - nBWidth + nOffsetX : nBLeft);
                                            for(sal_Int32 nXPos((nPosY % 2) ? nBLeft - nBWidth + nOffsetX : nBLeft);
                                                nXPos < nOLeft + nOWidth; nXPos += nBWidth)
                                            {
                                                const Rectangle aOutRectPixel(Point(nXPos, nYPos), aNeededBitmapSizePixel);
@@ -626,7 +626,7 @@ namespace drawinglayer
                                        // possible offset in Y, so iterate over X first and draw columns
                                        for(sal_Int32 nXPos(nBLeft); nXPos < nOLeft + nOWidth; nXPos += nBWidth, nPosX++)
                                        {
                                            for(sal_Int32 nYPos(nPosX % 2 ? nBTop - nBHeight + nOffsetY : nBTop);
                                            for(sal_Int32 nYPos((nPosX % 2) ? nBTop - nBHeight + nOffsetY : nBTop);
                                                nYPos < nOTop + nOHeight; nYPos += nBHeight)
                                            {
                                                const Rectangle aOutRectPixel(Point(nXPos, nYPos), aNeededBitmapSizePixel);
diff --git a/drawinglayer/source/texture/texture.cxx b/drawinglayer/source/texture/texture.cxx
index 4ede3c1..9df695c 100644
--- a/drawinglayer/source/texture/texture.cxx
+++ b/drawinglayer/source/texture/texture.cxx
@@ -780,7 +780,7 @@ namespace drawinglayer
                    {
                        for(double fPosX(fStartX); basegfx::fTools::less(fPosX, 1.0); fPosX += fWidth, nPosX++)
                        {
                            for(double fPosY(nPosX % 2 ? fStartY - fHeight + (mfOffsetY * fHeight) : fStartY);
                            for(double fPosY((nPosX % 2) ? fStartY - fHeight + (mfOffsetY * fHeight) : fStartY);
                                basegfx::fTools::less(fPosY, 1.0); fPosY += fHeight)
                            {
                                rMatrices.push_back(
@@ -796,7 +796,7 @@ namespace drawinglayer
                    {
                        for(double fPosY(fStartY); basegfx::fTools::less(fPosY, 1.0); fPosY += fHeight, nPosY++)
                        {
                            for(double fPosX(nPosY % 2 ? fStartX - fWidth + (mfOffsetX * fWidth) : fStartX);
                            for(double fPosX((nPosY % 2) ? fStartX - fWidth + (mfOffsetX * fWidth) : fStartX);
                                basegfx::fTools::less(fPosX, 1.0); fPosX += fWidth)
                            {
                                rMatrices.push_back(
diff --git a/dtrans/source/win32/workbench/test_wincb.cxx b/dtrans/source/win32/workbench/test_wincb.cxx
index 8eb355d..551b798 100644
--- a/dtrans/source/win32/workbench/test_wincb.cxx
+++ b/dtrans/source/win32/workbench/test_wincb.cxx
@@ -206,7 +206,7 @@ int SAL_CALL main( int nArgc, char* Argv[] )
    // threaded apartment we need a message loop to deliver
    // messages to our XTDataObject
    //HRESULT hr = CoInitializeEx( NULL, COINIT_MULTITHREADED );
    HRESULT hr = CoInitialize( NULL );
    (void)CoInitialize( NULL );

    char buff[6];

diff --git a/dtrans/source/win32/workbench/testmarshal.cxx b/dtrans/source/win32/workbench/testmarshal.cxx
index b3fd58f..4a5de8f 100644
--- a/dtrans/source/win32/workbench/testmarshal.cxx
+++ b/dtrans/source/win32/workbench/testmarshal.cxx
@@ -68,7 +68,7 @@ unsigned int _stdcall ThreadProc(LPVOID pParam)

    WaitForSingleObject( g_hEvtThreadWakeup, INFINITE );

    IDataObject* pIDo;
    IDataObject* pIDo = NULL;

#ifdef RAW_MARSHALING

diff --git a/dtrans/test/win32/dnd/atlwindow.cxx b/dtrans/test/win32/dnd/atlwindow.cxx
index 35e2cb5..e7039e2 100644
--- a/dtrans/test/win32/dnd/atlwindow.cxx
+++ b/dtrans/test/win32/dnd/atlwindow.cxx
@@ -139,7 +139,6 @@ LRESULT AWindow::OnMouseAction(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bH

LRESULT AWindow::OnTimer(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
    HRESULT hr;
    USES_CONVERSION;
    KillTimer( 1);
    if(m_xDragSource.is())
diff --git a/jvmfwk/source/fwkutil.cxx b/jvmfwk/source/fwkutil.cxx
index a48f25f..53e74b2 100644
--- a/jvmfwk/source/fwkutil.cxx
+++ b/jvmfwk/source/fwkutil.cxx
@@ -61,8 +61,8 @@ bool isAccessibilitySupportDesired()
        sValue == "1" )
        return false;

    bool retVal = false;
#ifdef WNT
    bool retVal = false;
    HKEY    hKey = 0;
    if (RegOpenKeyEx(HKEY_CURRENT_USER,
                     "Software\\LibreOffice\\Accessibility\\AtToolSupport",
@@ -104,7 +104,7 @@ bool isAccessibilitySupportDesired()

#elif defined UNX
    // Java is no longer required for a11y - we use atk directly.
    retVal = ::rtl::Bootstrap::get( "JFW_PLUGIN_FORCE_ACCESSIBILITY", sValue) && sValue == "1";
    bool retVal = ::rtl::Bootstrap::get( "JFW_PLUGIN_FORCE_ACCESSIBILITY", sValue) && sValue == "1";
#endif

    return retVal;
diff --git a/sal/osl/w32/profile.cxx b/sal/osl/w32/profile.cxx
index ff7a025..a3465ca 100644
--- a/sal/osl/w32/profile.cxx
+++ b/sal/osl/w32/profile.cxx
@@ -392,7 +392,7 @@ static sal_Bool writeProfileImpl(osl_TFile* pFile)

    bRet=WriteFile(pFile->m_Handle, pFile->m_pWriteBuf, pFile->m_nWriteBufLen - pFile->m_nWriteBufFree,&BytesWritten,NULL);

    if ( bRet == 0 || BytesWritten <= 0 )
    if ( bRet == 0 || BytesWritten == 0 )
    {
        OSL_ENSURE(bRet,"WriteFile failed!!!");
        OSL_TRACE("write failed '%s'",strerror(errno));