Skip to content

Commit

Permalink
Fix cppcheck identicalInnerCondition warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Apr 17, 2023
1 parent 3c64bcc commit 8451357
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 22 deletions.
8 changes: 3 additions & 5 deletions src/core/geometry/qgsgeometryutils.cpp
Expand Up @@ -1634,13 +1634,11 @@ void QgsGeometryUtils::perpendicularCenterSegment( double pointx, double pointy,
{
QgsVector segmentVector = QgsVector( segmentPoint2x - segmentPoint1x, segmentPoint2y - segmentPoint1y );
QgsVector perpendicularVector = segmentVector.perpVector();
if ( desiredSegmentLength )
if ( desiredSegmentLength != 0 )
{
if ( desiredSegmentLength != 0 )
{
perpendicularVector = perpendicularVector.normalized() * ( desiredSegmentLength ) / 2;
}
perpendicularVector = perpendicularVector.normalized() * ( desiredSegmentLength ) / 2;
}

perpendicularSegmentPoint1x = pointx - perpendicularVector.x();
perpendicularSegmentPoint1y = pointy - perpendicularVector.y();
perpendicularSegmentPoint2x = pointx + perpendicularVector.x();
Expand Down
1 change: 1 addition & 0 deletions src/core/gps/qgsnmeaconnection.cpp
Expand Up @@ -492,6 +492,7 @@ void QgsNmeaConnection::processGsaSentence( const char *data, int len )
else if ( result.sat_prn[i] > 32 && result.sat_prn[i] <= 64 )
constellation = Qgis::GnssConstellation::Sbas;

// cppcheck-suppress identicalInnerCondition
if ( result.sat_prn[i] > 0 )
{
if ( mixedConstellation
Expand Down
27 changes: 10 additions & 17 deletions src/providers/grass/qgsgrass.cpp
Expand Up @@ -2518,23 +2518,16 @@ void QgsGrass::adjustCellHead( struct Cell_head *cellhd, int row_flag, int col_f

QMap<int, QString> QgsGrass::vectorTypeMap()
{
static QMap<int, QString> sVectorTypes;
static QMutex sMutex;
if ( sVectorTypes.isEmpty() )
{
sMutex.lock();
if ( sVectorTypes.isEmpty() )
{
sVectorTypes.insert( GV_POINT, QStringLiteral( "point" ) );
sVectorTypes.insert( GV_CENTROID, QStringLiteral( "centroid" ) );
sVectorTypes.insert( GV_LINE, QStringLiteral( "line" ) );
sVectorTypes.insert( GV_BOUNDARY, QStringLiteral( "boundary" ) );
sVectorTypes.insert( GV_AREA, QStringLiteral( "area" ) );
sVectorTypes.insert( GV_FACE, QStringLiteral( "face" ) );
sVectorTypes.insert( GV_KERNEL, QStringLiteral( "kernel" ) );
}
sMutex.unlock();
}
const thread_local QMap<int, QString> sVectorTypes
{
{ GV_POINT, QStringLiteral( "point" ) },
{ GV_CENTROID, QStringLiteral( "centroid" ) },
{ GV_LINE, QStringLiteral( "line" ) },
{ GV_BOUNDARY, QStringLiteral( "boundary" ) },
{ GV_AREA, QStringLiteral( "area" ) },
{ GV_FACE, QStringLiteral( "face" ) },
{ GV_KERNEL, QStringLiteral( "kernel" ) },
};
return sVectorTypes;
}

Expand Down
1 change: 1 addition & 0 deletions src/providers/spatialite/qgsspatialiteconnpool.cpp
Expand Up @@ -26,6 +26,7 @@ QgsSpatiaLiteConnPool *QgsSpatiaLiteConnPool::instance()
{
static QMutex sMutex;
QMutexLocker locker( &sMutex );
// cppcheck-suppress identicalInnerCondition
if ( ! sInstance )
{
sInstance = new QgsSpatiaLiteConnPool();
Expand Down

0 comments on commit 8451357

Please sign in to comment.