From e1ec88cfbc239285b9b83a84e4df6be470c82668 Mon Sep 17 00:00:00 2001 From: Xiangyin Ma Date: Wed, 5 Nov 2014 19:25:21 +0000 Subject: [PATCH] Adaptor: Fix Klocwork issues [Problem] Klocwork issues [Cause] 1. Data member not initialized in the constructor or non-used data member 2. Floating point expression is test for equality 3. Constant condition in conditional expression 4. Memory leak 5. syntax shortcuts: variable used twice in one expression where one usage is subject to side-effects 6. Unreachable code [Solution] Change-Id: I815b8d9ae73c6bc08b807d898e197db90c6c08a4 --- adaptors/base/render-thread.h | 1 - adaptors/common/events/tap-gesture-detector.cpp | 1 + adaptors/common/gl/egl-sync-implementation.cpp | 4 +++- adaptors/common/indicator-buffer.h | 4 ---- adaptors/common/indicator-impl.cpp | 6 +++--- adaptors/common/orientation-impl.cpp | 3 ++- adaptors/tizen/accessibility-manager-impl-tizen.cpp | 3 ++- adaptors/x11/ecore-x-render-surface.h | 1 - adaptors/x11/window-impl-x.cpp | 4 +++- .../slp/font-platform/font-controller-impl.cpp | 7 +++++++ platform-abstractions/slp/image-loaders/loader-bmp.cpp | 2 +- .../slp/image-loaders/loader-jpeg-turbo.cpp | 15 +-------------- .../slp/resource-loader/resource-loader.cpp | 2 +- .../slp/resource-loader/resource-model-requester.cpp | 3 +-- .../slp/resource-loader/resource-shader-requester.cpp | 3 +-- .../slp/resource-loader/resource-text-requester.cpp | 3 +-- 16 files changed, 27 insertions(+), 35 deletions(-) diff --git a/adaptors/base/render-thread.h b/adaptors/base/render-thread.h index 55bea30..40463e5 100644 --- a/adaptors/base/render-thread.h +++ b/adaptors/base/render-thread.h @@ -210,7 +210,6 @@ private: // Data EglFactoryInterface* mEglFactory; ///< Factory class to create EGL implementation EglInterface* mEGL; ///< Interface to EGL implementation boost::thread* mThread; ///< render thread - bool mUsingPixmap; ///< whether we're using a pixmap or a window RenderSurface* mSurface; ///< Current surface const EnvironmentOptions& mEnvironmentOptions; ///< Environment options bool mSurfaceReplaced; ///< True when new surface has been initialzed. diff --git a/adaptors/common/events/tap-gesture-detector.cpp b/adaptors/common/events/tap-gesture-detector.cpp index 254f355..fe15087 100644 --- a/adaptors/common/events/tap-gesture-detector.cpp +++ b/adaptors/common/events/tap-gesture-detector.cpp @@ -54,6 +54,7 @@ TapGestureDetector::TapGestureDetector(CoreEventInterface& coreEventInterface, V mMinimumTapsRequired(request.minTaps), mMaximumTapsRequired(request.maxTaps), mTapsRegistered(0), + mTouchTime(0), mTimerSlot( this ) { mTimer = Dali::Timer::New(MAXIMUM_TIME_ALLOWED); diff --git a/adaptors/common/gl/egl-sync-implementation.cpp b/adaptors/common/gl/egl-sync-implementation.cpp index a7ee65e..dc19e59 100644 --- a/adaptors/common/gl/egl-sync-implementation.cpp +++ b/adaptors/common/gl/egl-sync-implementation.cpp @@ -191,7 +191,9 @@ bool EglSyncObject::IsSynced() } EglSyncImplementation::EglSyncImplementation() -: mEglImplementation( NULL ) +: mEglImplementation( NULL ), + mSyncInitialized( false ), + mSyncInitializeFailed( false ) { } diff --git a/adaptors/common/indicator-buffer.h b/adaptors/common/indicator-buffer.h index 0bb1203..0043b61 100644 --- a/adaptors/common/indicator-buffer.h +++ b/adaptors/common/indicator-buffer.h @@ -82,10 +82,6 @@ private: int mImageWidth; int mImageHeight; Pixel::Format mPixelFormat; - - // Only used with fallback bitmap buffer implementation - bool mUpdatingBitmap:1; ///< Whether BitmapImage is being uploaded to graphics memory - bool mUpdateBitmapAgain:1; ///< Whether to update BitmapImage again after upload complete }; } // Adaptor diff --git a/adaptors/common/indicator-impl.cpp b/adaptors/common/indicator-impl.cpp index 2e42465..ecaec2b 100644 --- a/adaptors/common/indicator-impl.cpp +++ b/adaptors/common/indicator-impl.cpp @@ -1221,18 +1221,18 @@ void Indicator::ShowIndicator(float duration) mIndicatorAnimation.FinishedSignal().Connect(this, &Indicator::OnAnimationFinished); } - if(mIsShowing && duration != 0) + if(mIsShowing && !EqualsZero(duration)) { // If need to show during showing, do nothing. // In 2nd phase (below) will update timer } - else if(!mIsShowing && mIsAnimationPlaying && duration == 0) + else if(!mIsShowing && mIsAnimationPlaying && EqualsZero(duration)) { // If need to hide during hiding or hidden already, do nothing } else { - if(duration == 0) + if( EqualsZero(duration) ) { mIndicatorAnimation.MoveTo(mIndicatorImageActor, Vector3(0, -mImageHeight, 0), Dali::AlphaFunctions::EaseOut); diff --git a/adaptors/common/orientation-impl.cpp b/adaptors/common/orientation-impl.cpp index 57379b5..ddac990 100644 --- a/adaptors/common/orientation-impl.cpp +++ b/adaptors/common/orientation-impl.cpp @@ -56,7 +56,8 @@ Orientation::~Orientation() void Orientation::SetAdaptor(Dali::Adaptor& adaptor) { - Adaptor::GetImplementation(adaptor).SetRotationObserver(this); + Adaptor& adaptorImpl = Adaptor::GetImplementation(adaptor); + adaptorImpl.SetRotationObserver(this); } int Orientation::GetDegrees() const diff --git a/adaptors/tizen/accessibility-manager-impl-tizen.cpp b/adaptors/tizen/accessibility-manager-impl-tizen.cpp index d2d4f14..e561fb4 100644 --- a/adaptors/tizen/accessibility-manager-impl-tizen.cpp +++ b/adaptors/tizen/accessibility-manager-impl-tizen.cpp @@ -275,7 +275,8 @@ void AccessibilityManager::DisableAccessibility() if ( Adaptor::IsAvailable() ) { Dali::Adaptor& adaptor = Dali::Adaptor::Get(); - Adaptor::GetImplementation( adaptor ).DestroyTtsPlayer( Dali::TtsPlayer::SCREEN_READER ); + Adaptor& adaptorIpml = Adaptor::GetImplementation( adaptor ); + adaptorIpml.DestroyTtsPlayer( Dali::TtsPlayer::SCREEN_READER ); } } } diff --git a/adaptors/x11/ecore-x-render-surface.h b/adaptors/x11/ecore-x-render-surface.h index 7af5a27..f0618d9 100644 --- a/adaptors/x11/ecore-x-render-surface.h +++ b/adaptors/x11/ecore-x-render-surface.h @@ -213,7 +213,6 @@ protected: protected: // Data XDisplay* mMainDisplay; ///< X-connection for rendering - Ecore_X_Window mRootWindow; ///< X-Root window SurfaceType mType; ///< type of renderable PositionSize mPosition; ///< Position std::string mTitle; ///< Title of window which shows from "xinfo -topvwins" command diff --git a/adaptors/x11/window-impl-x.cpp b/adaptors/x11/window-impl-x.cpp index 7165cc2..be3bf51 100644 --- a/adaptors/x11/window-impl-x.cpp +++ b/adaptors/x11/window-impl-x.cpp @@ -327,7 +327,9 @@ Window::Window() mNextIndicatorOrientation(Dali::Window::PORTRAIT), mIndicatorOpacityMode(Dali::Window::OPAQUE), mOverlay(NULL), - mAdaptor(NULL) + mAdaptor(NULL), + mEventHandler(NULL), + mPreferredOrientation(Dali::Window::PORTRAIT) { } diff --git a/platform-abstractions/slp/font-platform/font-controller-impl.cpp b/platform-abstractions/slp/font-platform/font-controller-impl.cpp index 4baa4ff..80a9333 100755 --- a/platform-abstractions/slp/font-platform/font-controller-impl.cpp +++ b/platform-abstractions/slp/font-platform/font-controller-impl.cpp @@ -753,15 +753,22 @@ void FontController::CreatePreferedFontList( ) GetFontFamily( pattern, styledFont->first ); GetFontStyle( pattern, styledFont->second ); + bool releaseMemory = true; if( *styledFont != previousFont ) { mPreferredFonts.PushBack( styledFont ); + releaseMemory = false; } if( i == 0u ) { mDefaultStyledFont = *styledFont; } previousFont = *styledFont; + + if( releaseMemory ) + { + delete styledFont; + } } // Set all fonts to non validated. diff --git a/platform-abstractions/slp/image-loaders/loader-bmp.cpp b/platform-abstractions/slp/image-loaders/loader-bmp.cpp index 436986a..caa8a19 100644 --- a/platform-abstractions/slp/image-loaders/loader-bmp.cpp +++ b/platform-abstractions/slp/image-loaders/loader-bmp.cpp @@ -279,7 +279,7 @@ bool DecodeBF32(FILE *fp, for (unsigned int yPos = 0; yPos < height; yPos++) { - PixelBuffer *pixelsPtr = pixels; + PixelBuffer *pixelsPtr; if (topDown) { // the data in the file is top down, and we store the data top down diff --git a/platform-abstractions/slp/image-loaders/loader-jpeg-turbo.cpp b/platform-abstractions/slp/image-loaders/loader-jpeg-turbo.cpp index 2951398..b1f5ef7 100755 --- a/platform-abstractions/slp/image-loaders/loader-jpeg-turbo.cpp +++ b/platform-abstractions/slp/image-loaders/loader-jpeg-turbo.cpp @@ -45,15 +45,6 @@ namespace const unsigned DECODED_PIXEL_SIZE = 3; const TJPF DECODED_PIXEL_LIBJPEG_TYPE = TJPF_RGB; - // Configuration options for JPEG decoder: - - const bool FORCEMMX = false; ///< On Intel, use MMX-optimised codepaths. - const bool FORCESSE = false; ///< On Intel, use SSE1-optimised codepaths. - const bool FORCESSE2 = false; ///< On Intel, use SSE2-optimised codepaths. - const bool FORCESSE3 = false; ///< On Intel, use SSE3-optimised codepaths. - /** Use the fastest chrominance upsampling algorithm available in the underlying codec. */ - const bool FASTUPSAMPLE = false; - /** Transformations that can be applied to decoded pixels to respect exif orientation * codes in image headers */ enum JPGFORM_CODE @@ -240,11 +231,7 @@ bool LoadJpegHeader( FILE *fp, unsigned int &width, unsigned int &height ) bool LoadBitmapFromJpeg( FILE *fp, Bitmap& bitmap, ImageAttributes& attributes, const ResourceLoadingClient& client ) { - int flags=(FORCEMMX ? TJ_FORCEMMX : 0) | - (FORCESSE ? TJ_FORCESSE : 0) | - (FORCESSE2 ? TJ_FORCESSE2 : 0) | - (FORCESSE3 ? TJ_FORCESSE3 : 0) | - (FASTUPSAMPLE ? TJ_FASTUPSAMPLE : 0); + const int flags= 0; if( fseek(fp,0,SEEK_END) ) { diff --git a/platform-abstractions/slp/resource-loader/resource-loader.cpp b/platform-abstractions/slp/resource-loader/resource-loader.cpp index 47edf88..7312f6c 100755 --- a/platform-abstractions/slp/resource-loader/resource-loader.cpp +++ b/platform-abstractions/slp/resource-loader/resource-loader.cpp @@ -677,7 +677,6 @@ GlyphSet* ResourceLoader::GetCachedGlyphData(const TextResourceType& textRequest // create a new bitmap, and copy in the data BitmapPtr bitmapData ( Integration::Bitmap::New(Bitmap::BITMAP_2D_PACKED_PIXELS, ResourcePolicy::DISCARD) ); - DALI_ASSERT_ALWAYS( data.length == DISTANCE_FIELD_SIZE * DISTANCE_FIELD_SIZE ); // assign the data bitmapData->GetPackedPixelsProfile()->AssignBuffer( Pixel::A8, data.data, DISTANCE_FIELD_SIZE * DISTANCE_FIELD_SIZE, DISTANCE_FIELD_SIZE, DISTANCE_FIELD_SIZE ); @@ -859,6 +858,7 @@ Integration::BitmapPtr ResourceLoader::GetGlyphImage( FT_Library freeType, const if( NULL != slpFace ) { image = GetGlyphBitmap( slpFace->face, character ); + delete slpFace; } return image; diff --git a/platform-abstractions/slp/resource-loader/resource-model-requester.cpp b/platform-abstractions/slp/resource-loader/resource-model-requester.cpp index 89fc4b5..2b1ffcd 100644 --- a/platform-abstractions/slp/resource-loader/resource-model-requester.cpp +++ b/platform-abstractions/slp/resource-loader/resource-model-requester.cpp @@ -63,8 +63,7 @@ void ResourceModelRequester::LoadResource( Integration::ResourceRequest& request ResourcePointer ResourceModelRequester::LoadResourceSynchronously( const Integration::ResourceType& type, const std::string& path ) { - DALI_ASSERT_ALWAYS( 0 && "Cannot load models synchronously" ); - return NULL; + DALI_ASSERT_ALWAYS( false && "Cannot load models synchronously" ); } LoadStatus ResourceModelRequester::LoadFurtherResources( ResourceRequest& request, LoadedResource partialResource ) diff --git a/platform-abstractions/slp/resource-loader/resource-shader-requester.cpp b/platform-abstractions/slp/resource-loader/resource-shader-requester.cpp index 5a17606..45d97ac 100644 --- a/platform-abstractions/slp/resource-loader/resource-shader-requester.cpp +++ b/platform-abstractions/slp/resource-loader/resource-shader-requester.cpp @@ -52,8 +52,7 @@ void ResourceShaderRequester::LoadResource( Integration::ResourceRequest& reques ResourcePointer ResourceShaderRequester::LoadResourceSynchronously( const Integration::ResourceType& type, const std::string& path ) { - DALI_ASSERT_ALWAYS( 0 && "Cannot load shaders synchronously" ); - return NULL; + DALI_ASSERT_ALWAYS( false && "Cannot load shaders synchronously" ); } Integration::LoadStatus ResourceShaderRequester::LoadFurtherResources( Integration::ResourceRequest& request, LoadedResource partialResource ) diff --git a/platform-abstractions/slp/resource-loader/resource-text-requester.cpp b/platform-abstractions/slp/resource-loader/resource-text-requester.cpp index 602c82c..d00fd7d 100644 --- a/platform-abstractions/slp/resource-loader/resource-text-requester.cpp +++ b/platform-abstractions/slp/resource-loader/resource-text-requester.cpp @@ -105,8 +105,7 @@ void ResourceTextRequester::LoadResource( Integration::ResourceRequest& request ResourcePointer ResourceTextRequester::LoadResourceSynchronously( const Integration::ResourceType& type, const std::string& path ) { - DALI_ASSERT_ALWAYS( 0 && "Cannot load text synchronously" ); - return NULL; + DALI_ASSERT_ALWAYS( false && "Cannot load text synchronously" ); } LoadStatus ResourceTextRequester::LoadFurtherResources( ResourceRequest& request, LoadedResource partialResource ) -- 2.7.4