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 55bea302c3409bd35cb957f8f08354b86e85c828..40463e59f84b9916a0bda1b9b8db5d47de2f695b 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 254f3553e26104d801a774b2a9639cce00134234..fe1508799c4c9776e85a123c79da27094ec29cf2 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 a7ee65ecdd99f4d12e460c92d543c30c048d988b..dc19e5978b77391bb2aa6b0c8b47e5ff11fbacf0 100644 (file)
@@ -191,7 +191,9 @@ bool EglSyncObject::IsSynced()
 }
 
 EglSyncImplementation::EglSyncImplementation()
-: mEglImplementation( NULL )
+: mEglImplementation( NULL ),
+  mSyncInitialized( false ),
+  mSyncInitializeFailed( false )
 {
 }
 
index 0bb1203fae241fe757d258d26d0278d1a809eabe..0043b61890ea81ca47b5215312942e74e3147e3c 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 2e4246520357674aa819e49f8589bc3978d2d506..ecaec2b11141fb4854c0971ad33e7c842a46b726 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 57379b5385436973548105fd170df73fb8dde5d3..ddac990ddaee441b96feb596bd31ea809deb9d3d 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 d2d4f1441c8facd134f174b4f56ee2170511fb96..e561fb4d9748241defbff9ac1a5e540ddffe65e2 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 7af5a2738fe839ed2647a33c020c083136760c4c..f0618d97590215a9cfaf194058f7dd1e71b1267e 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 7165cc225acc3c5697827eb3a1a5a0464f68f70c..be3bf51bda9bc9ec1a0ba2fb5b7e445a977b5fe9 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 4baa4ff0bc5780bb9fd6e771e5ea22ba50dc73a3..80a9333581a7513242ebee86de5617de0b51c1f9 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 436986a1ff1fc002e180adfc58b1224b989cd2f7..caa8a191e740d79985b83526ff20716da869093b 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 2951398fabfcac0eb360053b19269a21084d479a..b1f5ef766a82fd6c7ef2b33ef8de81b4bb4d5626 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 47edf880ea0df77ba73292daeb729b45c06a18d2..7312f6cbd8d602cdd5491c22faa86ff60d03c53d 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 89fc4b5254d9f309969c9a90f595d53aa5ad58d7..2b1ffcd8c8d07363a2ec4967214caa22047303d5 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 5a176062bd792561a989ec539d3d23385aaaa3f8..45d97acf469d6a13db362dbe5a39f8691ac63021 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 602c82c61a0c988646eebfb846230346187d1fad..d00fd7d1a48db5a66741749223968f5e9b54d08f 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 )