Skip to content
Permalink
Browse files

implement more cppcheck suggestions

  • Loading branch information
jef-n committed Jan 23, 2014
1 parent 68011dd commit 0d2c564cf27f1c0c84f49465405b8df800f62297
Showing with 114 additions and 40 deletions.
  1. +2 −2 src/app/gps/qwtpolar-0.1/qwt_polar_grid.cpp
  2. +1 −1 src/app/qgsprojectproperties.cpp
  3. +15 −1 src/core/spatialite/spatialite.c
  4. +6 −3 src/plugins/dxf2shp_converter/dxf2shpconverter.cpp
  5. +1 −1 src/plugins/dxf2shp_converter/dxflib/src/dl_attributes.h
  6. +1 −1 src/plugins/dxf2shp_converter/dxflib/src/dl_extrusion.h
  7. +9 −2 src/plugins/dxf2shp_converter/shapelib-1.2.10/dbfopen.c
  8. +12 −1 src/plugins/dxf2shp_converter/shapelib-1.2.10/shpopen.c
  9. +0 −1 src/plugins/dxf2shp_converter/shapelib-1.2.10/shprewind.c
  10. +7 −0 src/plugins/evis/evis.cpp
  11. +4 −1 src/plugins/georeferencer/qgsgeorefplugin.cpp
  12. +1 −0 src/plugins/georeferencer/qgsgeoreftransform.cpp
  13. +8 −4 src/plugins/globe/globe_plugin.cpp
  14. +5 −4 src/plugins/globe/osgEarthUtil/Controls.cpp
  15. +8 −3 src/plugins/gps_importer/qgsgpsplugin.cpp
  16. +2 −1 src/plugins/grass/qtermwidget/CharacterColor.h
  17. +2 −1 src/plugins/grass/qtermwidget/Filter.cpp
  18. +0 −1 src/plugins/grass/qtermwidget/KeyboardTranslator.cpp
  19. +1 −2 src/plugins/grass/qtermwidget/TerminalDisplay.cpp
  20. +3 −0 src/plugins/heatmap/heatmap.cpp
  21. +6 −4 src/plugins/offline_editing/offline_editing_plugin.cpp
  22. +2 −0 src/plugins/spatialquery/qgsspatialqueryplugin.cpp
  23. +3 −0 src/plugins/spit/qgsspitplugin.cpp
  24. +1 −1 src/plugins/sqlanywhere/sasourceselect.h
  25. +3 −0 src/plugins/sqlanywhere/sqlanywhere.cpp
  26. +3 −0 src/plugins/topology/topol.cpp
  27. +5 −1 src/plugins/zonal_statistics/qgszonalstatisticsplugin.cpp
  28. +3 −4 src/providers/oracle/ocispatial/qsql_ocispatial.cpp
@@ -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;
@@ -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;
@@ -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 )
break;
case 11:
human = "Shade";
break;
case 12:
human = "Daylight fluorescent (D 5700 � 7100K)";
break;
break;
case 14:
human = "Cool white fluorescent (W 3900 � 4500K)";
break;
case 15:
human = "White fluorescent (WW 3200 � 3700K)";
break;
strcpy (str, human);
else
{
memset (str, '\0', len);
memcpy (str, human, len - 1);
memset (str + len - 1, 0, 1);
}
*ok = 1;
return;
gaiaAppendToOutBuffer (out_buf, buf);
}
/* closing the Exterior Ring */
#if 0
if (is_multi)
{
#endif
if (version == 3)
{
strcpy (buf, "</gml:posList>");
strcat (buf, "</gml:outerBoundaryIs>");
}
}
#if 0
else
{
if (version == 3)
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>");
"<gml:coordinates decimal=\".\" cs=\",\" ts=\" \">");
}
}
#if 0
else
{
if (version == 3)
"<gml:coordinates decimal=\".\" cs=\",\" ts=\" \">");
}
}
#endif
gaiaAppendToOutBuffer (out_buf, buf);
for (iv = 0; iv < ring->Points; iv++)
{
gaiaAppendToOutBuffer (out_buf, buf);
}
/* closing the Interior Ring */
#if 0
if (is_multi)
{
#endif
if (version == 3)
{
strcpy (buf, "</gml:posList>");
strcat (buf, "</gml:innerBoundaryIs>");
}
}
#if 0
else
{
if (version == 3)
strcat (buf, "</gml:innerBoundaryIs>");
}
}
#endif
gaiaAppendToOutBuffer (out_buf, buf);
}
/* closing the Polygon */
@@ -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()
{
@@ -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
@@ -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 );
@@ -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 );
@@ -506,7 +506,7 @@ DBFClose( DBFHandle psDBF )
/************************************************************************/

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

{
DBFHandle psDBF;
@@ -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 );

@@ -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 );
@@ -454,6 +454,7 @@ SHPOpen( const char * pszLayer, const char * pszAccess )
fclose( psSHP->fpSHP );
fclose( psSHP->fpSHX );
free( psSHP );
free( pabyBuf );

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

free( pabyBuf );

return( NULL );
}

@@ -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 );
@@ -90,7 +90,6 @@ int main( int argc, char ** argv )
/* -------------------------------------------------------------------- */
for ( i = 0; i < nEntities; i++ )
{
int j;
SHPObject *psShape;

psShape = SHPReadObject( hSHP, i );
@@ -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;
}
@@ -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 );
@@ -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 )
{
}

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

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

@@ -62,6 +62,7 @@ class QgsLinearGeorefTransform : public QgsGeorefTransformInterface
class QgsHelmertGeorefTransform : public QgsGeorefTransformInterface
{
public:
QgsHelmertGeorefTransform() {}
struct HelmertParameters
{
QgsPoint origin;
@@ -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
@@ -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 );
@@ -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;

@@ -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;
}
}

@@ -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 );

0 comments on commit 0d2c564

Please sign in to comment.
You can’t perform that action at this time.