From 440c466f75a69e81204c0d62701fe24292646c49 Mon Sep 17 00:00:00 2001 From: Xiangyin Ma Date: Fri, 14 Nov 2014 18:05:41 +0000 Subject: [PATCH] (demo) fix klocwork issues Change-Id: I9db6f14c19c657aee1e149187ed9f14dbf8a28b6 --- demo/dali-table-view.cpp | 8 +++- examples/builder/dali-builder.cpp | 2 +- examples/cluster/cluster-example.cpp | 16 +++++++ .../image-scaling-irregular-grid/grid-flags.h | 51 ++++++++-------------- .../image-scaling-irregular-grid-example.cpp | 12 +++-- examples/radial-menu/radial-sweep-view-impl.cpp | 2 + 6 files changed, 47 insertions(+), 44 deletions(-) diff --git a/demo/dali-table-view.cpp b/demo/dali-table-view.cpp index fae3df1..4f7176b 100644 --- a/demo/dali-table-view.cpp +++ b/demo/dali-table-view.cpp @@ -874,8 +874,12 @@ void DaliTableView::CreateShapeImage( ShapeType shapeType, const Size& size, Bit break; } - GenerateDistanceFieldMap( &imageDataA8[ 0 ], size, distanceFieldOut.GetBuffer(), size, 8.0f, size ); - distanceFieldOut.Update(); + PixelBuffer* buffer = distanceFieldOut.GetBuffer(); + if( buffer ) + { + GenerateDistanceFieldMap( &imageDataA8[ 0 ], size, buffer, size, 8.0f, size ); + distanceFieldOut.Update(); + } } void DaliTableView::GenerateSquare( const Size& size, std::vector< unsigned char >& distanceFieldOut ) diff --git a/examples/builder/dali-builder.cpp b/examples/builder/dali-builder.cpp index 2fad6f1..9c97fec 100644 --- a/examples/builder/dali-builder.cpp +++ b/examples/builder/dali-builder.cpp @@ -87,7 +87,7 @@ class FileWatcher public: FileWatcher(void); ~FileWatcher(void); - explicit FileWatcher(const std::string &fn) { SetFilename(fn) ; }; + explicit FileWatcher(const std::string &fn): mLastTime(0) { SetFilename(fn) ; }; void SetFilename(const std::string &fn); std::string GetFilename(); diff --git a/examples/cluster/cluster-example.cpp b/examples/cluster/cluster-example.cpp index f582038..6af3c8d 100644 --- a/examples/cluster/cluster-example.cpp +++ b/examples/cluster/cluster-example.cpp @@ -407,6 +407,22 @@ struct ClusterInfo } + /** + * Assignment operator + */ + ClusterInfo& operator=( const ClusterInfo& rhs ) + { + if( this != &rhs ) + { + mCluster = rhs.mCluster; + mIndex = rhs.mIndex; + mPosition = rhs.mPosition; + mSize = rhs.mSize; + } + return *this; + } + + Cluster mCluster; ///< Cluster instance int mIndex; ///< Cluster index Vector3 mPosition; ///< Cluster original position diff --git a/examples/image/image-scaling-irregular-grid/grid-flags.h b/examples/image/image-scaling-irregular-grid/grid-flags.h index 4802817..68453b2 100644 --- a/examples/image/image-scaling-irregular-grid/grid-flags.h +++ b/examples/image/image-scaling-irregular-grid/grid-flags.h @@ -16,28 +16,16 @@ * limitations under the License. * */ +#include #include +/** Controls the output of application logging. */ +//#define DEBUG_PRINT_GRID_DIAGNOSTICS + namespace Dali { namespace Demo { -namespace -{ -const bool DEBUG_PRINT_GRID_DIAGNOSTICS = false; - -inline unsigned min( unsigned a, unsigned b ) -{ - return a < b ? a : b; -} - -inline unsigned max( unsigned a, unsigned b ) -{ - return a > b ? a : b; -} - -} - /** * @brief A 2D grid of booleans, settable and gettable via integer (x,y) coordinates. * */ @@ -49,17 +37,16 @@ public: */ GridFlags( unsigned width, unsigned height ) : mCells( width * height ), mWidth( width ), mHeight( height ), mHighestUsedRow( 0 ) { - if( DEBUG_PRINT_GRID_DIAGNOSTICS ) - { +#ifdef DEBUG_PRINT_GRID_DIAGNOSTICS fprintf(stderr, "Grid created with dimensions: (%u, %u).\n", mWidth, mHeight ); - } +#endif } void Set( const unsigned x, const unsigned y ) { const unsigned index = CellIndex( x, y ); mCells[index] += 1u; ///< += To allow a debug check of the number of times a cell is set. - mHighestUsedRow = max( mHighestUsedRow, y ); + mHighestUsedRow = std::max( mHighestUsedRow, y ); } bool Get( unsigned x, unsigned y ) const @@ -86,10 +73,9 @@ public: { const unsigned regionWidth = (region.x + 0.5f); const unsigned regionHeight = (region.y + 0.5f); - if( DEBUG_PRINT_GRID_DIAGNOSTICS ) - { +#ifdef DEBUG_PRINT_GRID_DIAGNOSTICS fprintf( stderr, "Allocation requested for region (%u, %u). Result: ", regionWidth, regionHeight ); - } +#endif unsigned bestRegionWidth = 0; unsigned bestRegionHeight = 0; unsigned bestCellX = 0; @@ -104,8 +90,8 @@ public: { // Look for clear grid cells under the desired region: - const unsigned clampedRegionHeight = min( regionHeight, mHeight - y); - const unsigned clampedRegionWidth = min( regionWidth, mWidth - x); + const unsigned clampedRegionHeight = std::min( regionHeight, mHeight - y); + const unsigned clampedRegionWidth = std::min( regionWidth, mWidth - x); const unsigned regionLimitY = y + clampedRegionHeight; const unsigned regionLimitX = x + clampedRegionWidth; @@ -156,18 +142,16 @@ whole_region_not_found: if( bestRegionWidth == 0 || bestRegionHeight == 0 ) { - if( DEBUG_PRINT_GRID_DIAGNOSTICS ) - { +#ifdef DEBUG_PRINT_GRID_DIAGNOSTICS fputs( "false.\n", stderr ); - } +#endif return false; } // Allocate the found region: - if( DEBUG_PRINT_GRID_DIAGNOSTICS ) - { +#ifdef DEBUG_PRINT_GRID_DIAGNOSTICS fprintf( stderr, " - bestCellX = %u, bestCellY = %u, bestRegionWidth = %u, bestRegionHeight = %u - ", bestCellX, bestCellY, bestRegionWidth, bestRegionHeight ); - } +#endif for( unsigned y = bestCellY; y < bestCellY + bestRegionHeight; ++y ) { for( unsigned x = bestCellX; x < bestCellX + bestRegionWidth; ++x ) @@ -179,10 +163,9 @@ whole_region_not_found: outCellX = bestCellX; outCellY = bestCellY; outRegion = Vector2( bestRegionWidth, bestRegionHeight ); - if( DEBUG_PRINT_GRID_DIAGNOSTICS ) - { +#ifdef DEBUG_PRINT_GRID_DIAGNOSTICS fputs( "true.\n", stderr ); - } +#endif return true; } diff --git a/examples/image/image-scaling-irregular-grid/image-scaling-irregular-grid-example.cpp b/examples/image/image-scaling-irregular-grid/image-scaling-irregular-grid-example.cpp index 7cf2cb3..1cb8aa6 100644 --- a/examples/image/image-scaling-irregular-grid/image-scaling-irregular-grid-example.cpp +++ b/examples/image/image-scaling-irregular-grid/image-scaling-irregular-grid-example.cpp @@ -58,7 +58,7 @@ namespace { /** Controls the output of application logging. */ -const bool DEBUG_PRINT_DIAGNOSTICS = false; +//#define DEBUG_PRINT_DIAGNOSTICS; const char* BACKGROUND_IMAGE( DALI_IMAGE_DIR "background-4.jpg" ); const char* TOOLBAR_IMAGE( DALI_IMAGE_DIR "top-bar.png" ); @@ -175,10 +175,9 @@ const unsigned NUM_IMAGE_PATHS = sizeof(IMAGE_PATHS) / sizeof(IMAGE_PATHS[0]) - */ Image CreateImage(const std::string& filename, unsigned int width, unsigned int height, ImageAttributes::ScalingMode scalingMode ) { - if( DEBUG_PRINT_DIAGNOSTICS ) - { +#ifdef DEBUG_PRINT_DIAGNOSTICS fprintf( stderr, "CreateImage(%s, %u, %u, scalingMode=%u)\n", filename.c_str(), width, height, unsigned( scalingMode ) ); - } +#endif ImageAttributes attributes; attributes.SetSize( width, height ); @@ -402,10 +401,9 @@ public: bool allocated = grid.AllocateRegion( config->dimensions, cellX, cellY, imageGridDims ); if( !allocated ) { - if( DEBUG_PRINT_DIAGNOSTICS ) - { +#ifdef DEBUG_PRINT_DIAGNOSTICS fprintf( stderr, "Failed to allocate image in grid with dims (%f, %f) and path: %s.\n", config->dimensions.x, config->dimensions.y, config->path ); - } +#endif continue; } diff --git a/examples/radial-menu/radial-sweep-view-impl.cpp b/examples/radial-menu/radial-sweep-view-impl.cpp index af94125..ac01fce 100644 --- a/examples/radial-menu/radial-sweep-view-impl.cpp +++ b/examples/radial-menu/radial-sweep-view-impl.cpp @@ -141,6 +141,8 @@ RadialSweepViewImpl::RadialSweepViewImpl( float duration, float diameter, Degree mInitialActorAngle(0), mFinalActorAngle(0), mEasingFunction(HoldZeroFastEaseInOutHoldOne), + mStartAngleIndex(Property::INVALID_INDEX), + mRotationAngleIndex(Property::INVALID_INDEX), mRotateActorsWithStencil(false), mRotateActors(false) { -- 2.7.4