Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
implement more cppcheck suggestions
  • Loading branch information
jef-n committed Jan 23, 2014
1 parent 68011dd commit 0d2c564
Show file tree
Hide file tree
Showing 28 changed files with 114 additions and 40 deletions.
4 changes: 2 additions & 2 deletions src/app/gps/qwtpolar-0.1/qwt_polar_grid.cpp
Expand Up @@ -1093,7 +1093,7 @@ int QwtPolarGrid::marginHint() const
*/
const QwtScaleDraw *QwtPolarGrid::scaleDraw( int axisId ) const
{
if ( axisId >= QwtPolar::AxisLeft || axisId <= QwtPolar::AxisBottom )
if ( axisId >= QwtPolar::AxisLeft && axisId <= QwtPolar::AxisBottom )
return ( QwtScaleDraw * )d_data->axisData[axisId].scaleDraw;

return NULL;
Expand All @@ -1108,7 +1108,7 @@ const QwtScaleDraw *QwtPolarGrid::scaleDraw( int axisId ) const
*/
QwtScaleDraw *QwtPolarGrid::scaleDraw( int axisId )
{
if ( axisId >= QwtPolar::AxisLeft || axisId <= QwtPolar::AxisBottom )
if ( axisId >= QwtPolar::AxisLeft && axisId <= QwtPolar::AxisBottom )
return ( QwtScaleDraw * )d_data->axisData[axisId].scaleDraw;

return NULL;
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsprojectproperties.cpp
Expand Up @@ -442,7 +442,7 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa

i = 0;
j = 0;
for ( QMap<QString, QgsMapLayer*>::const_iterator it = mapLayers.constBegin(); it != mapLayers.constEnd(); it++, i++ )
for ( QMap<QString, QgsMapLayer*>::const_iterator it = mapLayers.constBegin(); it != mapLayers.constEnd(); ++it, i++ )
{
currentLayer = it.value();
if ( currentLayer->type() == QgsMapLayer::RasterLayer )
Expand Down
16 changes: 15 additions & 1 deletion src/core/spatialite/spatialite.c
Expand Up @@ -10984,6 +10984,7 @@ gaiaExifTagGetHumanReadable (const gaiaExifTagPtr tag, char *str, int len,
break;
case 11:
human = "Shade";
break;
case 12:
human = "Daylight fluorescent (D 5700 � 7100K)";
break;
Expand All @@ -10992,6 +10993,7 @@ gaiaExifTagGetHumanReadable (const gaiaExifTagPtr tag, char *str, int len,
break;
case 14:
human = "Cool white fluorescent (W 3900 � 4500K)";
break;
case 15:
human = "White fluorescent (WW 3200 � 3700K)";
break;
Expand Down Expand Up @@ -11163,8 +11165,8 @@ gaiaExifTagGetHumanReadable (const gaiaExifTagPtr tag, char *str, int len,
strcpy (str, human);
else
{
memset (str, '\0', len);
memcpy (str, human, len - 1);
memset (str + len - 1, 0, 1);
}
*ok = 1;
return;
Expand Down Expand Up @@ -53508,8 +53510,10 @@ gaiaOutGml (gaiaOutBufferPtr out_buf, int version, int precision,
gaiaAppendToOutBuffer (out_buf, buf);
}
/* closing the Exterior Ring */
#if 0
if (is_multi)
{
#endif
if (version == 3)
{
strcpy (buf, "</gml:posList>");
Expand All @@ -53523,6 +53527,7 @@ gaiaOutGml (gaiaOutBufferPtr out_buf, int version, int precision,
strcat (buf, "</gml:outerBoundaryIs>");
}
}
#if 0
else
{
if (version == 3)
Expand All @@ -53538,13 +53543,16 @@ gaiaOutGml (gaiaOutBufferPtr out_buf, int version, int precision,
strcat (buf, "</gml:outerBoundaryIs>");
}
}
#endif
gaiaAppendToOutBuffer (out_buf, buf);
for (ib = 0; ib < polyg->NumInteriors; ib++)
{
/* interior rings */
ring = polyg->Interiors + ib;
#if 0
if (is_multi)
{
#endif
if (version == 3)
{
strcpy (buf, "<gml:interior>");
Expand All @@ -53559,6 +53567,7 @@ gaiaOutGml (gaiaOutBufferPtr out_buf, int version, int precision,
"<gml:coordinates decimal=\".\" cs=\",\" ts=\" \">");
}
}
#if 0
else
{
if (version == 3)
Expand All @@ -53575,6 +53584,7 @@ gaiaOutGml (gaiaOutBufferPtr out_buf, int version, int precision,
"<gml:coordinates decimal=\".\" cs=\",\" ts=\" \">");
}
}
#endif
gaiaAppendToOutBuffer (out_buf, buf);
for (iv = 0; iv < ring->Points; iv++)
{
Expand Down Expand Up @@ -53649,8 +53659,10 @@ gaiaOutGml (gaiaOutBufferPtr out_buf, int version, int precision,
gaiaAppendToOutBuffer (out_buf, buf);
}
/* closing the Interior Ring */
#if 0
if (is_multi)
{
#endif
if (version == 3)
{
strcpy (buf, "</gml:posList>");
Expand All @@ -53664,6 +53676,7 @@ gaiaOutGml (gaiaOutBufferPtr out_buf, int version, int precision,
strcat (buf, "</gml:innerBoundaryIs>");
}
}
#if 0
else
{
if (version == 3)
Expand All @@ -53679,6 +53692,7 @@ gaiaOutGml (gaiaOutBufferPtr out_buf, int version, int precision,
strcat (buf, "</gml:innerBoundaryIs>");
}
}
#endif
gaiaAppendToOutBuffer (out_buf, buf);
}
/* closing the Polygon */
Expand Down
9 changes: 6 additions & 3 deletions src/plugins/dxf2shp_converter/dxf2shpconverter.cpp
Expand Up @@ -51,9 +51,11 @@ static const QString sPluginIcon = ":/dxf2shp_converter.png";
* an interface object that provides access to exposed functions in QGIS.
* @param theQGisInterface - Pointer to the QGIS interface object
*/
dxf2shpConverter::dxf2shpConverter( QgisInterface *theQgisInterface ): QgisPlugin
( sName, sDescription, sCategory, sPluginVersion, sPluginType ), mQGisIface
( theQgisInterface ) {}
dxf2shpConverter::dxf2shpConverter( QgisInterface *theQgisInterface )
: QgisPlugin( sName, sDescription, sCategory, sPluginVersion, sPluginType )
, mQGisIface( theQgisInterface )
, mQActionPointer( 0 )
{}

dxf2shpConverter::~dxf2shpConverter()
{
Expand All @@ -67,6 +69,7 @@ dxf2shpConverter::~dxf2shpConverter()
void dxf2shpConverter::initGui()
{
// Create the action for tool
delete mQActionPointer;
mQActionPointer = new QAction( QIcon(), "Dxf2Shp Converter", this );

// Set the icon
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/dxf2shp_converter/dxflib/src/dl_attributes.h
Expand Up @@ -179,7 +179,7 @@ class DL_Attributes
/**
* Copies attributes (deep copies) from another attribute object.
*/
DL_Attributes operator = ( const DL_Attributes& attrib )
DL_Attributes &operator= ( const DL_Attributes& attrib )
{
setLayer( attrib.layer );
setColor( attrib.color );
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/dxf2shp_converter/dxflib/src/dl_extrusion.h
Expand Up @@ -139,7 +139,7 @@ class DL_Extrusion
/**
* Copies extrusion (deep copies) from another extrusion object.
*/
DL_Extrusion operator = ( const DL_Extrusion& extru )
DL_Extrusion &operator= ( const DL_Extrusion& extru )
{
setDirection( extru.direction[0], extru.direction[1], extru.direction[2] );
setElevation( extru.elevation );
Expand Down
11 changes: 9 additions & 2 deletions src/plugins/dxf2shp_converter/shapelib-1.2.10/dbfopen.c
Expand Up @@ -506,7 +506,7 @@ DBFClose( DBFHandle psDBF )
/************************************************************************/

DBFHandle SHPAPI_CALL
DBFCreate( const char * pszFilename )
DBFCreate( const char *pszFilename )

{
DBFHandle psDBF;
Expand Down Expand Up @@ -537,14 +537,20 @@ DBFCreate( const char * pszFilename )
/* -------------------------------------------------------------------- */
fp = fopen( pszFullname, "wb" );
if ( fp == NULL )
{
free( pszFullname );
return( NULL );
}

fputc( 0, fp );
fclose( fp );

fp = fopen( pszFullname, "rb+" );
if ( fp == NULL )
{
free( pszFullname );
return( NULL );
}

free( pszFullname );

Expand Down Expand Up @@ -1398,7 +1404,8 @@ DBFCloneEmpty( DBFHandle psDBF, const char * pszFilename )
DBFHandle newDBF;

newDBF = DBFCreate( pszFilename );
if ( newDBF == NULL ) return ( NULL );
if ( newDBF == NULL )
return ( NULL );

newDBF->pszHeader = ( char * ) malloc( 32 * psDBF->nFields );
memcpy( newDBF->pszHeader, psDBF->pszHeader, 32 * psDBF->nFields );
Expand Down
13 changes: 12 additions & 1 deletion src/plugins/dxf2shp_converter/shapelib-1.2.10/shpopen.c
Expand Up @@ -454,6 +454,7 @@ SHPOpen( const char * pszLayer, const char * pszAccess )
fclose( psSHP->fpSHP );
fclose( psSHP->fpSHX );
free( psSHP );
free( pabyBuf );

return( NULL );
}
Expand All @@ -471,6 +472,8 @@ SHPOpen( const char * pszLayer, const char * pszAccess )
fclose( psSHP->fpSHX );
free( psSHP );

free( pabyBuf );

return( NULL );
}

Expand Down Expand Up @@ -654,12 +657,20 @@ SHPCreate( const char * pszLayer, int nShapeType )
sprintf( pszFullname, "%s.shp", pszBasename );
fpSHP = fopen( pszFullname, "wb" );
if ( fpSHP == NULL )
return( NULL );
{
free( pszBasename );
free( pszFullname );
return NULL;
}

sprintf( pszFullname, "%s.shx", pszBasename );
fpSHX = fopen( pszFullname, "wb" );
if ( fpSHX == NULL )
{
free( pszBasename );
free( pszFullname );
return( NULL );
}

free( pszFullname );
free( pszBasename );
Expand Down
1 change: 0 additions & 1 deletion src/plugins/dxf2shp_converter/shapelib-1.2.10/shprewind.c
Expand Up @@ -90,7 +90,6 @@ int main( int argc, char ** argv )
/* -------------------------------------------------------------------- */
for ( i = 0; i < nEntities; i++ )
{
int j;
SHPObject *psShape;

psShape = SHPReadObject( hSHP, i );
Expand Down
7 changes: 7 additions & 0 deletions src/plugins/evis/evis.cpp
Expand Up @@ -91,6 +91,9 @@ static const QString sIcon = ":/evis/eVisEventBrowser.png";
eVis::eVis( QgisInterface * theQgisInterface )
: QgisPlugin( sName, sDescription, sCategory, sPluginVersion, sPluginType )
, mQGisIface( theQgisInterface )
, mDatabaseConnectionActionPointer( 0 )
, mEventIdToolActionPointer( 0 )
, mEventBrowserActionPointer( 0 )
{
mIdTool = 0;
}
Expand All @@ -101,6 +104,10 @@ eVis::~eVis()

void eVis::initGui()
{
delete mDatabaseConnectionActionPointer;
delete mEventIdToolActionPointer;
delete mEventBrowserActionPointer;

// Create the action for tool
mDatabaseConnectionActionPointer = new QAction( QIcon( ":/evis/eVisDatabaseConnection.png" ), tr( "eVis Database Connection" ), this );
mEventIdToolActionPointer = new QAction( QIcon( ":/evis/eVisEventIdTool.png" ), tr( "eVis Event Id Tool" ), this );
Expand Down
5 changes: 4 additions & 1 deletion src/plugins/georeferencer/qgsgeorefplugin.cpp
Expand Up @@ -81,7 +81,8 @@ static const QString sPluginIcon = ":/icons/default/mGeorefRun.png";
QgsGeorefPlugin::QgsGeorefPlugin( QgisInterface * theQgisInterface )
: QgisPlugin( sName, sDescription, sCategory, sPluginVersion, sPluginType )
, mQGisIface( theQgisInterface )
, mPluginGui( NULL )
, mActionRunGeoref( 0 )
, mPluginGui( 0 )
{
}

Expand All @@ -94,6 +95,8 @@ QgsGeorefPlugin::~QgsGeorefPlugin()
*/
void QgsGeorefPlugin::initGui()
{
delete mActionRunGeoref;

// Create the action for tool
mActionRunGeoref = new QAction( QIcon(), tr( "&Georeferencer" ), this );

Expand Down
1 change: 1 addition & 0 deletions src/plugins/georeferencer/qgsgeoreftransform.cpp
Expand Up @@ -62,6 +62,7 @@ class QgsLinearGeorefTransform : public QgsGeorefTransformInterface
class QgsHelmertGeorefTransform : public QgsGeorefTransformInterface
{
public:
QgsHelmertGeorefTransform() {}
struct HelmertParameters
{
QgsPoint origin;
Expand Down
12 changes: 8 additions & 4 deletions src/plugins/globe/globe_plugin.cpp
Expand Up @@ -86,16 +86,16 @@ static const QString sExperimental = QString( "true" );
GlobePlugin::GlobePlugin( QgisInterface* theQgisInterface )
: QgisPlugin( sName, sDescription, sCategory, sPluginVersion, sPluginType )
, mQGisIface( theQgisInterface )
, mQActionPointer( NULL )
, mQActionSettingsPointer( NULL )
, mQActionPointer( 0 )
, mQActionSettingsPointer( 0 )
, mOsgViewer( 0 )
, mViewerWidget( 0 )
, mMapNode( 0 )
, mBaseLayer( 0 )
, mQgisMapLayer( 0 )
, mTileSource( 0 )
, mElevationManager( NULL )
, mObjectPlacer( NULL )
, mElevationManager( 0 )
, mObjectPlacer( 0 )
{
mIsGlobeRunning = false;
//needed to be "seen" by other plugins by doing
Expand Down Expand Up @@ -213,6 +213,10 @@ struct SyncExtentControlHandler : public ControlEventHandler

void GlobePlugin::initGui()
{
delete mQActionPointer;
delete mQActionSettingsPointer;
delete mQActionUnload;

// Create the action for tool
mQActionPointer = new QAction( QIcon( ":/globe/globe.png" ), tr( "Launch Globe" ), this );
mQActionSettingsPointer = new QAction( QIcon( ":/globe/globe.png" ), tr( "Globe Settings" ), this );
Expand Down
9 changes: 5 additions & 4 deletions src/plugins/globe/osgEarthUtil/Controls.cpp
Expand Up @@ -431,7 +431,7 @@ Control::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa,
Q_UNUSED( aa );
bool handled = false;

if ( _eventHandlers.size() > 0 )
if ( !_eventHandlers.empty() )
{
handled = true;

Expand Down Expand Up @@ -1799,18 +1799,19 @@ ControlNodeBin::draw( const ControlContext& context, bool newContext, int bin )

if ( _sortingEnabled && _sortByDistance )
{
for( ControlNodeCollection::iterator i = _controlNodes.begin(); i != _controlNodes.end(); ++i )
for( ControlNodeCollection::iterator i = _controlNodes.begin(); i != _controlNodes.end(); )
{
ControlNode* node = i->second.get();
if ( node->getNumParents() == 0 )
{
_renderNodes.erase( node );
_controlNodes.erase( i );
i = _controlNodes.erase( i );
}
else
{
ControlNode::PerViewData& nodeData = node->getData( context._view );
byDepth.insert( ControlNodePair(nodeData._screenPos.z(), node) );
++i;
}
}

Expand Down Expand Up @@ -2154,7 +2155,7 @@ ControlCanvas::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter
_context._active.pop();
}

if ( _context._active.size() > 0 )
if ( !_context._active.empty() )
{
bool hit = _context._active.front()->intersects( ea.getX(), invY );
_context._active.front()->setActive( hit );
Expand Down

0 comments on commit 0d2c564

Please sign in to comment.