Skip to content

Commit

Permalink
Merge remote-tracking branch 'raul/scanbuild'
Browse files Browse the repository at this point in the history
  • Loading branch information
dbaston committed Dec 2, 2019
2 parents 7ed0c82 + a12ffb1 commit dc3522b
Show file tree
Hide file tree
Showing 15 changed files with 65 additions and 40 deletions.
12 changes: 12 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,18 @@ matrix:
env:
- E="TOOL=cmake && BUILD_TYPE=Release && CXX=clang++ && ARCH=-m64 && CC=clang"

- os: linux
cache:
apt: true
directories:
- $HOME/.ccache
addons:
apt:
sources: *sources
packages: ['clang','ccache','doxygen']
env:
- E="TOOL=autotools_scanbuild && BUILD_TYPE=Release && ARCH=-m64

before_install:
- eval "${E}"
- export CXXFLAGS=${ARCH}
Expand Down
8 changes: 6 additions & 2 deletions capi/geos_ts_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2958,7 +2958,9 @@ extern "C" {
{

double length;
GEOSLength_r(extHandle, g, &length);
if(GEOSLength_r(extHandle, g, &length) != 1) {
return -1.0;
};
return GEOSProject_r(extHandle, g, p) / length;
}

Expand All @@ -2968,7 +2970,9 @@ extern "C" {
double d)
{
double length;
GEOSLength_r(extHandle, g, &length);
if (GEOSLength_r(extHandle, g, &length) != 1) {
return 0;
}
return GEOSInterpolate_r(extHandle, g, d * length);
}

Expand Down
6 changes: 3 additions & 3 deletions include/geos/algorithm/ttmath/ttmathbig.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ class Big

public:

Int<exp> exponent;
UInt<man> mantissa;
unsigned char info;
Int<exp> exponent{0};
UInt<man> mantissa{0};
unsigned char info{0};


/*!
Expand Down
3 changes: 0 additions & 3 deletions include/geos/operation/distance/DistanceOp.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,6 @@ class GEOS_DLL DistanceOp {
const std::vector<const geom::Polygon*>& polys,
std::array<std::unique_ptr<GeometryLocation>, 2> & locPtPoly);

void computeInside(std::unique_ptr<GeometryLocation> & ptLoc,
const geom::Polygon* poly,
std::array<std::unique_ptr<GeometryLocation>, 2> & locPtPoly);

/**
* Computes distance between facets (lines and points)
Expand Down
1 change: 0 additions & 1 deletion src/algorithm/LineIntersector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ nearestEndpoint(const Coordinate& p1, const Coordinate& p2,
}
dist = Distance::pointToSegment(q2, p1, p2);
if(dist < minDist) {
minDist = dist;
nearestPt = &q2;
}
return *nearestPt;
Expand Down
2 changes: 1 addition & 1 deletion src/algorithm/MinimumBoundingCircle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ Coordinate
MinimumBoundingCircle::pointWithMinAngleWithSegment(std::vector<Coordinate>& pts, Coordinate& P, Coordinate& Q)
{
double minAng = std::numeric_limits<double>::max();
const Coordinate* minAngPt = nullptr;
const Coordinate* minAngPt = &pts[0];

for(const auto& p : pts) {
if(p == P) {
Expand Down
2 changes: 2 additions & 0 deletions src/algorithm/Orientation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*
**********************************************************************/

#include <cassert>
#include <cmath>
#include <vector>

Expand Down Expand Up @@ -48,6 +49,7 @@ Orientation::isCCW(const geom::CoordinateSequence* ring)

// # of points without closing endpoint
const std::size_t nPts = ring->getSize() - 1;
assert(nPts >= 3); // This is here for scan-build

// find highest point
const geom::Coordinate* hiPt = &ring->getAt(0);
Expand Down
1 change: 0 additions & 1 deletion src/geom/LineSegment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@ LineSegment::closestPoints(const LineSegment& line)
line.closestPoint(p1, close11);
dist = close11.distance(p1);
if(dist < minDistance) {
minDistance = dist;
closestPt[0] = p1;
closestPt[1] = close11;
}
Expand Down
4 changes: 4 additions & 0 deletions src/geom/util/CoordinateOperation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ std::unique_ptr<Geometry>
CoordinateOperation::edit(const Geometry* geometry,
const GeometryFactory* factory)
{
if (geometry == nullptr) {
return nullptr;
}

if(const LinearRing* ring = dynamic_cast<const LinearRing*>(geometry)) {
const CoordinateSequence* coords = ring->getCoordinatesRO();
auto newCoords = edit(coords, geometry);
Expand Down
4 changes: 4 additions & 0 deletions src/geom/util/ShortCircuitedGeometryVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ ShortCircuitedGeometryVisitor::applyTo(const Geometry& geom)
{
for(std::size_t i = 0, n = geom.getNumGeometries(); i < n; ++i) {
const Geometry* element = geom.getGeometryN(i);
if (element == nullptr) {
continue;
}

if(dynamic_cast<const GeometryCollection*>(element)) {
applyTo(*element);
}
Expand Down
8 changes: 4 additions & 4 deletions src/io/WKTReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,17 @@ WKTReader::getCoordinates(StringTokenizer* tokenizer)
Coordinate coord;
getPreciseCoordinate(tokenizer, coord, dim);

auto coordinates = detail::make_unique<CoordinateArraySequence>(0, dim);
coordinates->add(coord);
std::vector<Coordinate> v;
v.push_back(coord);

nextToken = getNextCloserOrComma(tokenizer);
while(nextToken == ",") {
getPreciseCoordinate(tokenizer, coord, dim);
coordinates->add(coord);
v.push_back(coord);
nextToken = getNextCloserOrComma(tokenizer);
}

return std::move(coordinates);
return geometryFactory->getCoordinateSequenceFactory()->create(std::move(v), dim);
}


Expand Down
29 changes: 8 additions & 21 deletions src/operation/distance/DistanceOp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,31 +260,18 @@ DistanceOp::computeInside(vector<unique_ptr<GeometryLocation>> & locs,
{
for(auto& loc : locs) {
for(const auto& poly : polys) {
computeInside(loc, poly, locPtPoly);
if(minDistance <= terminateDistance) {
return;
}
const Coordinate& pt = loc->getCoordinate();

if (Location::EXTERIOR != ptLocator.locate(pt, static_cast<const Geometry*>(poly))) {
minDistance = 0.0;
locPtPoly[0] = std::move(loc);
locPtPoly[1].reset(new GeometryLocation(poly, pt));
return;
}
}
}
}

/*private*/
void
DistanceOp::computeInside(std::unique_ptr<GeometryLocation> & ptLoc,
const Polygon* poly,
array<std::unique_ptr<GeometryLocation>, 2> & locPtPoly)
{
const Coordinate& pt = ptLoc->getCoordinate();

// if pt is not in exterior, distance to geom is 0
if(Location::EXTERIOR != ptLocator.locate(pt, static_cast<const Geometry*>(poly))) {
minDistance = 0.0;
locPtPoly[0] = std::move(ptLoc);
locPtPoly[1].reset(new GeometryLocation(poly, pt));
return;
}
}

/*private*/
void
DistanceOp::computeFacetDistance()
Expand Down
5 changes: 1 addition & 4 deletions src/operation/union/UnaryUnionOp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,13 @@ UnaryUnionOp::Union()
*/

GeomPtr unionLA = unionWithNull(std::move(unionLines), std::move(unionPolygons));
assert(!unionLines.get());
assert(!unionPolygons.get());


if(! unionPoints.get()) {
ret = std::move(unionLA);
assert(!unionLA.get());
}
else if(! unionLA.get()) {
ret = std::move(unionPoints);
assert(!unionPoints.get());
}
else {
ret = PointGeometryUnion::Union(*unionPoints, *unionLA);
Expand Down
2 changes: 2 additions & 0 deletions tests/xmltester/SimpleWKTTester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ main(int /*argc*/, char** /*argv*/)
out.flush();
out.close();
cout << "End of Testing" << endl;
delete r;
delete w;

}
catch(const GEOSException& ge) {
Expand Down
18 changes: 18 additions & 0 deletions tools/ci/script_autotools_scanbuild.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash -e
#
# Travis CI script for GEOS build with GNU Autotools
#
# Copyright (C) 2013 Mateusz Loskot <[email protected]>
#
# This is free software; you can redistribute and/or modify it under
# the terms of the GNU Lesser General Public Licence as published
# by the Free Software Foundation.
# See the COPYING file for more information.
#
source ${TRAVIS_BUILD_DIR}/tools/ci/common.sh

cd ${TRAVIS_BUILD_DIR}
./autogen.sh
cd -
${TRAVIS_BUILD_DIR}/configure CC=clang CXX=clang++ CXXFLAGS="-std=c++11"
scan-build --status-bugs make -j2

0 comments on commit dc3522b

Please sign in to comment.