Adaptor: Fix Klocwork issues 37/29937/3
authorXiangyin Ma <x1.ma@samsung.com>
Wed, 5 Nov 2014 19:25:21 +0000 (19:25 +0000)
committerXiangyin Ma <x1.ma@samsung.com>
Thu, 6 Nov 2014 13:57:04 +0000 (13:57 +0000)
[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

16 files changed:
adaptors/base/render-thread.h
adaptors/common/events/tap-gesture-detector.cpp
adaptors/common/gl/egl-sync-implementation.cpp
adaptors/common/indicator-buffer.h
adaptors/common/indicator-impl.cpp
adaptors/common/orientation-impl.cpp
adaptors/tizen/accessibility-manager-impl-tizen.cpp
adaptors/x11/ecore-x-render-surface.h
adaptors/x11/window-impl-x.cpp
platform-abstractions/slp/font-platform/font-controller-impl.cpp
platform-abstractions/slp/image-loaders/loader-bmp.cpp
platform-abstractions/slp/image-loaders/loader-jpeg-turbo.cpp
platform-abstractions/slp/resource-loader/resource-loader.cpp
platform-abstractions/slp/resource-loader/resource-model-requester.cpp
platform-abstractions/slp/resource-loader/resource-shader-requester.cpp
platform-abstractions/slp/resource-loader/resource-text-requester.cpp

index 55bea30..40463e5 100644 (file)
@@ -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.
index 254f355..fe15087 100644 (file)
@@ -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);
index a7ee65e..dc19e59 100644 (file)
@@ -191,7 +191,9 @@ bool EglSyncObject::IsSynced()
 }
 
 EglSyncImplementation::EglSyncImplementation()
-: mEglImplementation( NULL )
+: mEglImplementation( NULL ),
+  mSyncInitialized( false ),
+  mSyncInitializeFailed( false )
 {
 }
 
index 0bb1203..0043b61 100644 (file)
@@ -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
index 2e42465..ecaec2b 100644 (file)
@@ -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);
 
index 57379b5..ddac990 100644 (file)
@@ -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
index d2d4f14..e561fb4 100644 (file)
@@ -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 );
     }
   }
 }
index 7af5a27..f0618d9 100644 (file)
@@ -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
index 7165cc2..be3bf51 100644 (file)
@@ -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)
 {
 }
 
index 4baa4ff..80a9333 100755 (executable)
@@ -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.
index 436986a..caa8a19 100644 (file)
@@ -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
index 2951398..b1f5ef7 100755 (executable)
@@ -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) )
   {
index 47edf88..7312f6c 100755 (executable)
@@ -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;
index 89fc4b5..2b1ffcd 100644 (file)
@@ -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 )
index 5a17606..45d97ac 100644 (file)
@@ -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 )
index 602c82c..d00fd7d 100644 (file)
@@ -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 )