diff --git a/cola/libcola/cc_nonoverlapconstraints.cpp b/cola/libcola/cc_nonoverlapconstraints.cpp index 69502d09..8ff40bc4 100644 --- a/cola/libcola/cc_nonoverlapconstraints.cpp +++ b/cola/libcola/cc_nonoverlapconstraints.cpp @@ -199,9 +199,9 @@ void NonOverlapConstraints::computeOverlapForShapePairInfo(ShapePairInfo& info, { COLA_ASSERT(shape1.halfDim[0] == 0); COLA_ASSERT(shape1.halfDim[1] == 0); - COLA_ASSERT(info.varIndex1 + 1 < vs[0].size()); + COLA_ASSERT(info.varIndex1 + 1U < vs[0].size()); right1 = vs[0][info.varIndex1 + 1]->finalPosition; - COLA_ASSERT(info.varIndex1 + 1 < vs[1].size()); + COLA_ASSERT(info.varIndex1 + 1U < vs[1].size()); top1 = vs[1][info.varIndex1 + 1]->finalPosition; left1 -= shape1.rectPadding.min(XDIM); bottom1 -= shape1.rectPadding.min(YDIM); @@ -218,9 +218,9 @@ void NonOverlapConstraints::computeOverlapForShapePairInfo(ShapePairInfo& info, { COLA_ASSERT(shape2.halfDim[0] == 0); COLA_ASSERT(shape2.halfDim[1] == 0); - COLA_ASSERT(info.varIndex2 + 1 < vs[0].size()); + COLA_ASSERT(info.varIndex2 + 1U < vs[0].size()); right2 = vs[0][info.varIndex2 + 1]->finalPosition; - COLA_ASSERT(info.varIndex2 + 1 < vs[1].size()); + COLA_ASSERT(info.varIndex2 + 1U < vs[1].size()); top2 = vs[1][info.varIndex2 + 1]->finalPosition; left2 -= shape2.rectPadding.min(XDIM); bottom2 -= shape2.rectPadding.min(YDIM); diff --git a/cola/libdialect/chains.cpp b/cola/libdialect/chains.cpp index 2aa26b7a..87f5d874 100644 --- a/cola/libdialect/chains.cpp +++ b/cola/libdialect/chains.cpp @@ -429,7 +429,7 @@ BendSequences Chain::computePossibleBendSequences(void) const { try { CardinalDir dIn = m_graph->getSepMatrix().getCardinalDir(A->id(), b->id()); inDirs.push_back(dIn); - } catch (std::runtime_error) { + } catch (std::runtime_error const&) { // In this case the left anchor edge is not yet aligned, so we get to consider // both possible non-aggressive alignments of it. inDirs = possibleCardinalDirections(A, b); @@ -438,7 +438,7 @@ BendSequences Chain::computePossibleBendSequences(void) const { try { CardinalDir dOut = m_graph->getSepMatrix().getCardinalDir(y->id(), Z->id()); outDirs.push_back(dOut); - } catch (std::runtime_error) { + } catch (std::runtime_error const&) { outDirs = possibleCardinalDirections(y, Z); } // Now we can look up the possible bend sequences. diff --git a/cola/libdialect/constraints.cpp b/cola/libdialect/constraints.cpp index 439ce75a..942a73a2 100644 --- a/cola/libdialect/constraints.cpp +++ b/cola/libdialect/constraints.cpp @@ -72,6 +72,8 @@ SepDir dialect::negateSepDir(SepDir sd) { return SepDir::RIGHT; case SepDir::UP: return SepDir::DOWN; + default : + COLA_ASSERT(false); } } @@ -112,6 +114,8 @@ SepDir dialect::cardinalDirToSepDir(CardinalDir dir) { return SepDir::WEST; case CardinalDir::NORTH: return SepDir::NORTH; + default: + COLA_ASSERT(false); } } @@ -317,8 +321,8 @@ string SepPair::writeTglf(std::map id2ext, const SepMatrix &m ygtStr = ygt == GapType::BDRY ? "B" : "C"; // Prepare indices. unsigned src, tgt; - try { src = id2ext.at(this->src); } catch (std::out_of_range) { src = this->src; } - try { tgt = id2ext.at(this->tgt); } catch (std::out_of_range) { tgt = this->tgt; } + try { src = id2ext.at(this->src); } catch (std::out_of_range const&) { src = this->src; } + try { tgt = id2ext.at(this->tgt); } catch (std::out_of_range const&) { tgt = this->tgt; } std::ostringstream ss; // Vertically aligned if (xgt == GapType::CENTRE && xst == SepType::EQ && xgap == 0) { diff --git a/cola/libdialect/graphs.cpp b/cola/libdialect/graphs.cpp index 17236960..ad575034 100644 --- a/cola/libdialect/graphs.cpp +++ b/cola/libdialect/graphs.cpp @@ -110,6 +110,9 @@ LineSegment_SP BoundingBox::buildSideSegment(CardinalDir side) const { return std::make_shared(Point(x, Y), Point(X, Y)); case CardinalDir::NORTH: return std::make_shared(Point(x, y), Point(X, y)); + default: + COLA_ASSERT(false); + } } @@ -826,7 +829,7 @@ bool Graph::hasSameLayoutAs(const Graph &other, double tol, id_map *idMap) const ++it; ++jt; } } - } catch (std::out_of_range) { + } catch (std::out_of_range const&) { // We invoke the .at() method of various maps, above. // If any of these fails, the two Graphs do not have the same layout. return false; @@ -1055,7 +1058,7 @@ bool Graph::applyProjSeq(const ColaOptions &opts, ProjSeq &ps, int accept) { double iel = opts.idealEdgeLength; if (iel == 0) iel = getIEL(); // Do stress computations iff iel >= 0. - double lastStress; + double lastStress = 0.0; if (iel >= 0) lastStress = computeStress(); // We will check whether all projections work. bool allOK = true; diff --git a/cola/libdialect/io.cpp b/cola/libdialect/io.cpp index d8084d50..84f99694 100644 --- a/cola/libdialect/io.cpp +++ b/cola/libdialect/io.cpp @@ -108,13 +108,14 @@ Graph_SP dialect::buildGraphFromTglf(istream &in) { COLA_ASSERT(iss >> i1 >> i2 >> gtc >> dir >> rel1 >> rel2 >> gap); id_type j1 = nodesByExternalId[i1]->id(), j2 = nodesByExternalId[i2]->id(); - GapType gt; - SepDir sd; - SepType st; + GapType gt{}; + SepDir sd{}; + SepType st{}; switch(gtc) { case 'B': gt=GapType::BDRY; break; case 'C': gt=GapType::CENTRE; break; - COLA_ASSERT(false); + default: + COLA_ASSERT(false); } switch(dir) { case 'E': sd=SepDir::EAST; break; @@ -127,12 +128,14 @@ Graph_SP dialect::buildGraphFromTglf(istream &in) { case 'U': sd=SepDir::UP; break; case 'X': sd=SepDir::RIGHT; break; case 'Y': sd=SepDir::DOWN; break; - COLA_ASSERT(false); + default: + COLA_ASSERT(false); } switch(rel1) { case '=': st=SepType::EQ; break; case '>': st=SepType::INEQ; break; - COLA_ASSERT(false); + default: + COLA_ASSERT(false); } graph->getSepMatrix().addSep(j1, j2, gt, sd, st, gap); break; diff --git a/cola/libdialect/ortho.cpp b/cola/libdialect/ortho.cpp index af71f28d..e3f9ac7b 100644 --- a/cola/libdialect/ortho.cpp +++ b/cola/libdialect/ortho.cpp @@ -151,6 +151,8 @@ Point Compass::vectorSigns(CompassDir d) { case CompassDir::NW: return Point(-1, -1); case CompassDir::NORTH: return Point( 0, -1); case CompassDir::NE: return Point( 1, -1); + default: + COLA_ASSERT(false); } } @@ -249,6 +251,8 @@ std::string Compass::dirToString(CompassDir d) { case CompassDir::SW: return "SW"; case CompassDir::NW: return "NW"; case CompassDir::NE: return "NE"; + default : + COLA_ASSERT(false); } } @@ -258,6 +262,8 @@ std::string Compass::cardToString(CardinalDir d) { case CardinalDir::SOUTH: return "SOUTH"; case CardinalDir::WEST: return "WEST"; case CardinalDir::NORTH: return "NORTH"; + default: + COLA_ASSERT(false); } } diff --git a/cola/libdialect/quadaction.cpp b/cola/libdialect/quadaction.cpp index 034280bf..035bd404 100644 --- a/cola/libdialect/quadaction.cpp +++ b/cola/libdialect/quadaction.cpp @@ -107,9 +107,9 @@ string Assignment::toString() const { return s; } -Quad::Quad(unsigned num) : num(num) { +Quad::Quad(unsigned int num) : num(num) { // The only valid num's for quadrants are 0, 1, 2, 3. - COLA_ASSERT(0 <= num && num <= 3); + COLA_ASSERT(num <= 3); } void Quad::sortAndComputeCosts() { diff --git a/cola/libdialect/quadaction.h b/cola/libdialect/quadaction.h index 38f29340..5e6edb07 100644 --- a/cola/libdialect/quadaction.h +++ b/cola/libdialect/quadaction.h @@ -141,7 +141,7 @@ struct Quad { //! @brief Standard constructor. //! //! @param[in] num The number of this quadrant in {0, 1, 2, 3} - Quad(unsigned num); + Quad(unsigned int num); //! @brief Add a neighbour. void addNbr(const Nbr_SP &nbr) { nbrs.push_back(nbr); } diff --git a/cola/libdialect/routing.cpp b/cola/libdialect/routing.cpp index 9709bfed..dad79e37 100644 --- a/cola/libdialect/routing.cpp +++ b/cola/libdialect/routing.cpp @@ -145,9 +145,11 @@ void RoutingAdapter::recordRoutes(bool refine) { // in the window are within epsilon of one another (in both dimensions), // we will skip both. vector refined_pts; - size_t N = pts.size() - 2; // the number of interior points + size_t M = pts.size(); // We expect that there are at least two route points. - COLA_ASSERT(N >= 0); + COLA_ASSERT( M >= 2); + // the number of interior points: + size_t N = M - 2; size_t i = 0; // We always keep the first route point. refined_pts.push_back(pts[0]); diff --git a/cola/libdialect/util.h b/cola/libdialect/util.h index 2af2bf03..a064ac5c 100644 --- a/cola/libdialect/util.h +++ b/cola/libdialect/util.h @@ -94,7 +94,7 @@ struct Matrix2d { std::string toString() const { std::string s = ""; s += "\n "; - char buffer [10]; + char buffer [21]; for (int j=0; j