Skip to content

Commit 0d2c564

Browse files
committed
implement more cppcheck suggestions
1 parent 68011dd commit 0d2c564

28 files changed

+114
-40
lines changed

src/app/gps/qwtpolar-0.1/qwt_polar_grid.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,7 @@ int QwtPolarGrid::marginHint() const
10931093
*/
10941094
const QwtScaleDraw *QwtPolarGrid::scaleDraw( int axisId ) const
10951095
{
1096-
if ( axisId >= QwtPolar::AxisLeft || axisId <= QwtPolar::AxisBottom )
1096+
if ( axisId >= QwtPolar::AxisLeft && axisId <= QwtPolar::AxisBottom )
10971097
return ( QwtScaleDraw * )d_data->axisData[axisId].scaleDraw;
10981098

10991099
return NULL;
@@ -1108,7 +1108,7 @@ const QwtScaleDraw *QwtPolarGrid::scaleDraw( int axisId ) const
11081108
*/
11091109
QwtScaleDraw *QwtPolarGrid::scaleDraw( int axisId )
11101110
{
1111-
if ( axisId >= QwtPolar::AxisLeft || axisId <= QwtPolar::AxisBottom )
1111+
if ( axisId >= QwtPolar::AxisLeft && axisId <= QwtPolar::AxisBottom )
11121112
return ( QwtScaleDraw * )d_data->axisData[axisId].scaleDraw;
11131113

11141114
return NULL;

src/app/qgsprojectproperties.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ QgsProjectProperties::QgsProjectProperties( QgsMapCanvas* mapCanvas, QWidget *pa
442442

443443
i = 0;
444444
j = 0;
445-
for ( QMap<QString, QgsMapLayer*>::const_iterator it = mapLayers.constBegin(); it != mapLayers.constEnd(); it++, i++ )
445+
for ( QMap<QString, QgsMapLayer*>::const_iterator it = mapLayers.constBegin(); it != mapLayers.constEnd(); ++it, i++ )
446446
{
447447
currentLayer = it.value();
448448
if ( currentLayer->type() == QgsMapLayer::RasterLayer )

src/core/spatialite/spatialite.c

+15-1
Original file line numberDiff line numberDiff line change
@@ -10984,6 +10984,7 @@ gaiaExifTagGetHumanReadable (const gaiaExifTagPtr tag, char *str, int len,
1098410984
break;
1098510985
case 11:
1098610986
human = "Shade";
10987+
break;
1098710988
case 12:
1098810989
human = "Daylight fluorescent (D 5700 � 7100K)";
1098910990
break;
@@ -10992,6 +10993,7 @@ gaiaExifTagGetHumanReadable (const gaiaExifTagPtr tag, char *str, int len,
1099210993
break;
1099310994
case 14:
1099410995
human = "Cool white fluorescent (W 3900 � 4500K)";
10996+
break;
1099510997
case 15:
1099610998
human = "White fluorescent (WW 3200 � 3700K)";
1099710999
break;
@@ -11163,8 +11165,8 @@ gaiaExifTagGetHumanReadable (const gaiaExifTagPtr tag, char *str, int len,
1116311165
strcpy (str, human);
1116411166
else
1116511167
{
11166-
memset (str, '\0', len);
1116711168
memcpy (str, human, len - 1);
11169+
memset (str + len - 1, 0, 1);
1116811170
}
1116911171
*ok = 1;
1117011172
return;
@@ -53508,8 +53510,10 @@ gaiaOutGml (gaiaOutBufferPtr out_buf, int version, int precision,
5350853510
gaiaAppendToOutBuffer (out_buf, buf);
5350953511
}
5351053512
/* closing the Exterior Ring */
53513+
#if 0
5351153514
if (is_multi)
5351253515
{
53516+
#endif
5351353517
if (version == 3)
5351453518
{
5351553519
strcpy (buf, "</gml:posList>");
@@ -53523,6 +53527,7 @@ gaiaOutGml (gaiaOutBufferPtr out_buf, int version, int precision,
5352353527
strcat (buf, "</gml:outerBoundaryIs>");
5352453528
}
5352553529
}
53530+
#if 0
5352653531
else
5352753532
{
5352853533
if (version == 3)
@@ -53538,13 +53543,16 @@ gaiaOutGml (gaiaOutBufferPtr out_buf, int version, int precision,
5353853543
strcat (buf, "</gml:outerBoundaryIs>");
5353953544
}
5354053545
}
53546+
#endif
5354153547
gaiaAppendToOutBuffer (out_buf, buf);
5354253548
for (ib = 0; ib < polyg->NumInteriors; ib++)
5354353549
{
5354453550
/* interior rings */
5354553551
ring = polyg->Interiors + ib;
53552+
#if 0
5354653553
if (is_multi)
5354753554
{
53555+
#endif
5354853556
if (version == 3)
5354953557
{
5355053558
strcpy (buf, "<gml:interior>");
@@ -53559,6 +53567,7 @@ gaiaOutGml (gaiaOutBufferPtr out_buf, int version, int precision,
5355953567
"<gml:coordinates decimal=\".\" cs=\",\" ts=\" \">");
5356053568
}
5356153569
}
53570+
#if 0
5356253571
else
5356353572
{
5356453573
if (version == 3)
@@ -53575,6 +53584,7 @@ gaiaOutGml (gaiaOutBufferPtr out_buf, int version, int precision,
5357553584
"<gml:coordinates decimal=\".\" cs=\",\" ts=\" \">");
5357653585
}
5357753586
}
53587+
#endif
5357853588
gaiaAppendToOutBuffer (out_buf, buf);
5357953589
for (iv = 0; iv < ring->Points; iv++)
5358053590
{
@@ -53649,8 +53659,10 @@ gaiaOutGml (gaiaOutBufferPtr out_buf, int version, int precision,
5364953659
gaiaAppendToOutBuffer (out_buf, buf);
5365053660
}
5365153661
/* closing the Interior Ring */
53662+
#if 0
5365253663
if (is_multi)
5365353664
{
53665+
#endif
5365453666
if (version == 3)
5365553667
{
5365653668
strcpy (buf, "</gml:posList>");
@@ -53664,6 +53676,7 @@ gaiaOutGml (gaiaOutBufferPtr out_buf, int version, int precision,
5366453676
strcat (buf, "</gml:innerBoundaryIs>");
5366553677
}
5366653678
}
53679+
#if 0
5366753680
else
5366853681
{
5366953682
if (version == 3)
@@ -53679,6 +53692,7 @@ gaiaOutGml (gaiaOutBufferPtr out_buf, int version, int precision,
5367953692
strcat (buf, "</gml:innerBoundaryIs>");
5368053693
}
5368153694
}
53695+
#endif
5368253696
gaiaAppendToOutBuffer (out_buf, buf);
5368353697
}
5368453698
/* closing the Polygon */

src/plugins/dxf2shp_converter/dxf2shpconverter.cpp

+6-3
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,11 @@ static const QString sPluginIcon = ":/dxf2shp_converter.png";
5151
* an interface object that provides access to exposed functions in QGIS.
5252
* @param theQGisInterface - Pointer to the QGIS interface object
5353
*/
54-
dxf2shpConverter::dxf2shpConverter( QgisInterface *theQgisInterface ): QgisPlugin
55-
( sName, sDescription, sCategory, sPluginVersion, sPluginType ), mQGisIface
56-
( theQgisInterface ) {}
54+
dxf2shpConverter::dxf2shpConverter( QgisInterface *theQgisInterface )
55+
: QgisPlugin( sName, sDescription, sCategory, sPluginVersion, sPluginType )
56+
, mQGisIface( theQgisInterface )
57+
, mQActionPointer( 0 )
58+
{}
5759

5860
dxf2shpConverter::~dxf2shpConverter()
5961
{
@@ -67,6 +69,7 @@ dxf2shpConverter::~dxf2shpConverter()
6769
void dxf2shpConverter::initGui()
6870
{
6971
// Create the action for tool
72+
delete mQActionPointer;
7073
mQActionPointer = new QAction( QIcon(), "Dxf2Shp Converter", this );
7174

7275
// Set the icon

src/plugins/dxf2shp_converter/dxflib/src/dl_attributes.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ class DL_Attributes
179179
/**
180180
* Copies attributes (deep copies) from another attribute object.
181181
*/
182-
DL_Attributes operator = ( const DL_Attributes& attrib )
182+
DL_Attributes &operator= ( const DL_Attributes& attrib )
183183
{
184184
setLayer( attrib.layer );
185185
setColor( attrib.color );

src/plugins/dxf2shp_converter/dxflib/src/dl_extrusion.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ class DL_Extrusion
139139
/**
140140
* Copies extrusion (deep copies) from another extrusion object.
141141
*/
142-
DL_Extrusion operator = ( const DL_Extrusion& extru )
142+
DL_Extrusion &operator= ( const DL_Extrusion& extru )
143143
{
144144
setDirection( extru.direction[0], extru.direction[1], extru.direction[2] );
145145
setElevation( extru.elevation );

src/plugins/dxf2shp_converter/shapelib-1.2.10/dbfopen.c

+9-2
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ DBFClose( DBFHandle psDBF )
506506
/************************************************************************/
507507

508508
DBFHandle SHPAPI_CALL
509-
DBFCreate( const char * pszFilename )
509+
DBFCreate( const char *pszFilename )
510510

511511
{
512512
DBFHandle psDBF;
@@ -537,14 +537,20 @@ DBFCreate( const char * pszFilename )
537537
/* -------------------------------------------------------------------- */
538538
fp = fopen( pszFullname, "wb" );
539539
if ( fp == NULL )
540+
{
541+
free( pszFullname );
540542
return( NULL );
543+
}
541544

542545
fputc( 0, fp );
543546
fclose( fp );
544547

545548
fp = fopen( pszFullname, "rb+" );
546549
if ( fp == NULL )
550+
{
551+
free( pszFullname );
547552
return( NULL );
553+
}
548554

549555
free( pszFullname );
550556

@@ -1398,7 +1404,8 @@ DBFCloneEmpty( DBFHandle psDBF, const char * pszFilename )
13981404
DBFHandle newDBF;
13991405

14001406
newDBF = DBFCreate( pszFilename );
1401-
if ( newDBF == NULL ) return ( NULL );
1407+
if ( newDBF == NULL )
1408+
return ( NULL );
14021409

14031410
newDBF->pszHeader = ( char * ) malloc( 32 * psDBF->nFields );
14041411
memcpy( newDBF->pszHeader, psDBF->pszHeader, 32 * psDBF->nFields );

src/plugins/dxf2shp_converter/shapelib-1.2.10/shpopen.c

+12-1
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,7 @@ SHPOpen( const char * pszLayer, const char * pszAccess )
454454
fclose( psSHP->fpSHP );
455455
fclose( psSHP->fpSHX );
456456
free( psSHP );
457+
free( pabyBuf );
457458

458459
return( NULL );
459460
}
@@ -471,6 +472,8 @@ SHPOpen( const char * pszLayer, const char * pszAccess )
471472
fclose( psSHP->fpSHX );
472473
free( psSHP );
473474

475+
free( pabyBuf );
476+
474477
return( NULL );
475478
}
476479

@@ -654,12 +657,20 @@ SHPCreate( const char * pszLayer, int nShapeType )
654657
sprintf( pszFullname, "%s.shp", pszBasename );
655658
fpSHP = fopen( pszFullname, "wb" );
656659
if ( fpSHP == NULL )
657-
return( NULL );
660+
{
661+
free( pszBasename );
662+
free( pszFullname );
663+
return NULL;
664+
}
658665

659666
sprintf( pszFullname, "%s.shx", pszBasename );
660667
fpSHX = fopen( pszFullname, "wb" );
661668
if ( fpSHX == NULL )
669+
{
670+
free( pszBasename );
671+
free( pszFullname );
662672
return( NULL );
673+
}
663674

664675
free( pszFullname );
665676
free( pszBasename );

src/plugins/dxf2shp_converter/shapelib-1.2.10/shprewind.c

-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ int main( int argc, char ** argv )
9090
/* -------------------------------------------------------------------- */
9191
for ( i = 0; i < nEntities; i++ )
9292
{
93-
int j;
9493
SHPObject *psShape;
9594

9695
psShape = SHPReadObject( hSHP, i );

src/plugins/evis/evis.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ static const QString sIcon = ":/evis/eVisEventBrowser.png";
9191
eVis::eVis( QgisInterface * theQgisInterface )
9292
: QgisPlugin( sName, sDescription, sCategory, sPluginVersion, sPluginType )
9393
, mQGisIface( theQgisInterface )
94+
, mDatabaseConnectionActionPointer( 0 )
95+
, mEventIdToolActionPointer( 0 )
96+
, mEventBrowserActionPointer( 0 )
9497
{
9598
mIdTool = 0;
9699
}
@@ -101,6 +104,10 @@ eVis::~eVis()
101104

102105
void eVis::initGui()
103106
{
107+
delete mDatabaseConnectionActionPointer;
108+
delete mEventIdToolActionPointer;
109+
delete mEventBrowserActionPointer;
110+
104111
// Create the action for tool
105112
mDatabaseConnectionActionPointer = new QAction( QIcon( ":/evis/eVisDatabaseConnection.png" ), tr( "eVis Database Connection" ), this );
106113
mEventIdToolActionPointer = new QAction( QIcon( ":/evis/eVisEventIdTool.png" ), tr( "eVis Event Id Tool" ), this );

src/plugins/georeferencer/qgsgeorefplugin.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ static const QString sPluginIcon = ":/icons/default/mGeorefRun.png";
8181
QgsGeorefPlugin::QgsGeorefPlugin( QgisInterface * theQgisInterface )
8282
: QgisPlugin( sName, sDescription, sCategory, sPluginVersion, sPluginType )
8383
, mQGisIface( theQgisInterface )
84-
, mPluginGui( NULL )
84+
, mActionRunGeoref( 0 )
85+
, mPluginGui( 0 )
8586
{
8687
}
8788

@@ -94,6 +95,8 @@ QgsGeorefPlugin::~QgsGeorefPlugin()
9495
*/
9596
void QgsGeorefPlugin::initGui()
9697
{
98+
delete mActionRunGeoref;
99+
97100
// Create the action for tool
98101
mActionRunGeoref = new QAction( QIcon(), tr( "&Georeferencer" ), this );
99102

src/plugins/georeferencer/qgsgeoreftransform.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ class QgsLinearGeorefTransform : public QgsGeorefTransformInterface
6262
class QgsHelmertGeorefTransform : public QgsGeorefTransformInterface
6363
{
6464
public:
65+
QgsHelmertGeorefTransform() {}
6566
struct HelmertParameters
6667
{
6768
QgsPoint origin;

src/plugins/globe/globe_plugin.cpp

+8-4
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,16 @@ static const QString sExperimental = QString( "true" );
8686
GlobePlugin::GlobePlugin( QgisInterface* theQgisInterface )
8787
: QgisPlugin( sName, sDescription, sCategory, sPluginVersion, sPluginType )
8888
, mQGisIface( theQgisInterface )
89-
, mQActionPointer( NULL )
90-
, mQActionSettingsPointer( NULL )
89+
, mQActionPointer( 0 )
90+
, mQActionSettingsPointer( 0 )
9191
, mOsgViewer( 0 )
9292
, mViewerWidget( 0 )
9393
, mMapNode( 0 )
9494
, mBaseLayer( 0 )
9595
, mQgisMapLayer( 0 )
9696
, mTileSource( 0 )
97-
, mElevationManager( NULL )
98-
, mObjectPlacer( NULL )
97+
, mElevationManager( 0 )
98+
, mObjectPlacer( 0 )
9999
{
100100
mIsGlobeRunning = false;
101101
//needed to be "seen" by other plugins by doing
@@ -213,6 +213,10 @@ struct SyncExtentControlHandler : public ControlEventHandler
213213

214214
void GlobePlugin::initGui()
215215
{
216+
delete mQActionPointer;
217+
delete mQActionSettingsPointer;
218+
delete mQActionUnload;
219+
216220
// Create the action for tool
217221
mQActionPointer = new QAction( QIcon( ":/globe/globe.png" ), tr( "Launch Globe" ), this );
218222
mQActionSettingsPointer = new QAction( QIcon( ":/globe/globe.png" ), tr( "Globe Settings" ), this );

src/plugins/globe/osgEarthUtil/Controls.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ Control::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa,
431431
Q_UNUSED( aa );
432432
bool handled = false;
433433

434-
if ( _eventHandlers.size() > 0 )
434+
if ( !_eventHandlers.empty() )
435435
{
436436
handled = true;
437437

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

18001800
if ( _sortingEnabled && _sortByDistance )
18011801
{
1802-
for( ControlNodeCollection::iterator i = _controlNodes.begin(); i != _controlNodes.end(); ++i )
1802+
for( ControlNodeCollection::iterator i = _controlNodes.begin(); i != _controlNodes.end(); )
18031803
{
18041804
ControlNode* node = i->second.get();
18051805
if ( node->getNumParents() == 0 )
18061806
{
18071807
_renderNodes.erase( node );
1808-
_controlNodes.erase( i );
1808+
i = _controlNodes.erase( i );
18091809
}
18101810
else
18111811
{
18121812
ControlNode::PerViewData& nodeData = node->getData( context._view );
18131813
byDepth.insert( ControlNodePair(nodeData._screenPos.z(), node) );
1814+
++i;
18141815
}
18151816
}
18161817

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

2157-
if ( _context._active.size() > 0 )
2158+
if ( !_context._active.empty() )
21582159
{
21592160
bool hit = _context._active.front()->intersects( ea.getX(), invY );
21602161
_context._active.front()->setActive( hit );

0 commit comments

Comments
 (0)