From 29ad1acdfe90f16a17f228ac2ee4e5e71d83b388 Mon Sep 17 00:00:00 2001 From: whitequark Date: Sun, 14 Feb 2016 00:36:54 +0000 Subject: [PATCH] Enable and mollify -Wunused-variable. In my (whitequark's) experience this warning tends to expose copy-paste errors with a high SNR, so making a few fragments slightly less symmetric is worth it. Also mollify -Wlogical-op-parentheses while we're at it. --- CMakeLists.txt | 7 +++++++ src/constrainteq.cpp | 1 - src/draw.cpp | 1 - src/drawconstraint.cpp | 1 - src/drawentity.cpp | 2 -- src/glhelper.cpp | 1 - src/group.cpp | 3 +-- src/mesh.cpp | 2 -- src/srf/boolean.cpp | 5 +---- src/srf/surfinter.cpp | 3 +-- src/system.cpp | 2 +- src/textscreens.cpp | 1 - src/unix/gloffscreen.cpp | 2 -- src/util.cpp | 3 --- 14 files changed, 11 insertions(+), 23 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f67998e..3b90f84 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,6 +42,13 @@ if(WIN32) -D_UNICODE) endif() +if(CMAKE_CXX_COMPILER_ID STREQUAL GNU OR CMAKE_CXX_COMPILER_ID STREQUAL Clang) + set(WARNING_FLAGS + -Wunused-variable) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_FLAGS}") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING_FLAGS}") +endif() + if(MINGW) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static-libgcc") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++") diff --git a/src/constrainteq.cpp b/src/constrainteq.cpp index 15369cd..8acde19 100644 --- a/src/constrainteq.cpp +++ b/src/constrainteq.cpp @@ -604,7 +604,6 @@ void ConstraintBase::GenerateReal(IdList *l) { } ExprVector au = a->NormalExprsU(), - av = a->NormalExprsV(), an = a->NormalExprsN(); ExprVector bu = b->NormalExprsU(), bv = b->NormalExprsV(), diff --git a/src/draw.cpp b/src/draw.cpp index fa056c1..e1deec9 100644 --- a/src/draw.cpp +++ b/src/draw.cpp @@ -130,7 +130,6 @@ void GraphicsWindow::MakeUnselected(Selection *stog, bool coincidentPointTrick){ Selection *s; // If an item was selected, then we just un-select it. - bool wasSelected = false; selection.ClearTags(); for(s = selection.First(); s; s = selection.NextAfter(s)) { if(s->Equals(stog)) { diff --git a/src/drawconstraint.cpp b/src/drawconstraint.cpp index ef97bfd..af22ccb 100644 --- a/src/drawconstraint.cpp +++ b/src/drawconstraint.cpp @@ -244,7 +244,6 @@ int Constraint::DoLineTrimmedAgainstBox(Vector ref, Vector a, Vector b) { void Constraint::DoLineWithArrows(Vector ref, Vector a, Vector b, bool onlyOneExt) { - Vector gn = (SS.GW.projRight.Cross(SS.GW.projUp)).WithMagnitude(1); double pixels = 1.0 / SS.GW.scale; Vector ab = a.Minus(b); diff --git a/src/drawentity.cpp b/src/drawentity.cpp index 6d1233a..75eb3f6 100644 --- a/src/drawentity.cpp +++ b/src/drawentity.cpp @@ -465,8 +465,6 @@ void Entity::GenerateBezierCurves(SBezierList *sbl) { void Entity::DrawOrGetDistance(void) { if(!IsVisible()) return; - Group *g = SK.GetGroup(group); - switch(type) { case POINT_N_COPY: case POINT_N_TRANS: diff --git a/src/glhelper.cpp b/src/glhelper.cpp index 81e7de6..e9ed14c 100644 --- a/src/glhelper.cpp +++ b/src/glhelper.cpp @@ -46,7 +46,6 @@ double ssglStrWidth(const std::string &str, double h) iter = ReadUTF8(iter, &chr); const VectorGlyph &glyph = GetVectorGlyph(chr); - int glyphWidth = glyph.width; if(glyph.baseCharacter != 0) { const VectorGlyph &baseGlyph = GetVectorGlyph(glyph.baseCharacter); width += max(glyph.width, baseGlyph.width); diff --git a/src/group.cpp b/src/group.cpp index 3cf091d..1e25a31 100644 --- a/src/group.cpp +++ b/src/group.cpp @@ -514,7 +514,7 @@ void Group::Generate(IdList *entity, bool Group::IsSolvedOkay() { return this->solved.how == System::SOLVED_OKAY || - this->allowRedundant && this->solved.how == System::REDUNDANT_OKAY; + (this->allowRedundant && this->solved.how == System::REDUNDANT_OKAY); } void Group::AddEq(IdList *l, Expr *expr, int index) { @@ -525,7 +525,6 @@ void Group::AddEq(IdList *l, Expr *expr, int index) { } void Group::GenerateEquations(IdList *l) { - Equation eq = {}; if(type == IMPORTED) { // Normalize the quaternion ExprQuaternion q = { diff --git a/src/mesh.cpp b/src/mesh.cpp index 2e4e3ab..7880814 100644 --- a/src/mesh.cpp +++ b/src/mesh.cpp @@ -403,7 +403,6 @@ SKdNode *SKdNode::From(STriangleLl *tll) { int tcnt = 0; STriangleLl *ll; for(ll = tll; ll; ll = ll->next) { - STriangle *tr = ll->tri; split[i] += (ll->tri->a).Element(i); split[i] += (ll->tri->b).Element(i); split[i] += (ll->tri->c).Element(i); @@ -672,7 +671,6 @@ void SKdNode::SplitLinesAgainstTriangle(SEdgeList *sel, STriangle *tr) { for(se = sel->l.First(); se; se = sel->l.NextAfter(se)) { Vector pt = ((se->a).Plus(se->b)).ScaledBy(0.5); - double dt = pt.Dot(tn) - td; if(pt.Dot(tn) - td > -LENGTH_EPS) { // Edge is in front of or on our plane (remember, tn.z > 0) // so it is exempt from further splitting diff --git a/src/srf/boolean.cpp b/src/srf/boolean.cpp index ec2dcee..d87dec0 100644 --- a/src/srf/boolean.cpp +++ b/src/srf/boolean.cpp @@ -6,7 +6,7 @@ //----------------------------------------------------------------------------- #include "solvespace.h" -static int I, N, FLAG; +static int I; void SShell::MakeFromUnionOf(SShell *a, SShell *b) { MakeFromBoolean(a, b, AS_UNION); @@ -109,7 +109,6 @@ SCurve SCurve::MakeCopySplitAgainst(SShell *agnstA, SShell *agnstB, // And now uses the intersections to generate our split pwl edge(s) Vector prev = Vector::From(VERY_POSITIVE, 0, 0); for(pi = il.First(); pi; pi = il.NextAfter(pi)) { - double t = (pi->p.Minus(LineStart)).DivPivoting(LineDirection); // On-edge intersection will generate same split point for // both surfaces, so don't create zero-length edge. if(!prev.Equals(pi->p)) { @@ -360,8 +359,6 @@ void SSurface::EdgeNormalsWithinSurface(Point2d auv, Point2d buv, { // the midpoint of the edge Point2d muv = (auv.Plus(buv)).ScaledBy(0.5); - // a vector parallel to the edge - Point2d abuv = buv.Minus(auv).WithMagnitude(0.01); *pt = PointAt(muv); diff --git a/src/srf/surfinter.cpp b/src/srf/surfinter.cpp index 2959393..79d71cd 100644 --- a/src/srf/surfinter.cpp +++ b/src/srf/surfinter.cpp @@ -312,8 +312,7 @@ void SSurface::IntersectAgainst(SSurface *b, SShell *agnstA, SShell *agnstB, SPointList spl = {}; int a; for(a = 0; a < 2; a++) { - SShell *shA = (a == 0) ? agnstA : agnstB, - *shB = (a == 0) ? agnstB : agnstA; + SShell *shA = (a == 0) ? agnstA : agnstB; SSurface *srfA = (a == 0) ? this : b, *srfB = (a == 0) ? b : this; diff --git a/src/system.cpp b/src/system.cpp index 4fe704d..5ff118e 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -401,7 +401,7 @@ int System::Solve(Group *g, int *dof, List *bad, { WriteEquationsExceptFor(Constraint::NO_CONSTRAINT, g); - int i, j = 0; + int i; bool rankOk; /* diff --git a/src/textscreens.cpp b/src/textscreens.cpp index 0caf6c1..a16b386 100644 --- a/src/textscreens.cpp +++ b/src/textscreens.cpp @@ -374,7 +374,6 @@ void TextWindow::ShowGroupInfo(void) { g->color.alphaF(), &TextWindow::ScreenOpacity); } else if(g->type == Group::IMPORTED) { - bool sup = g->suppress; Printf(false, " %Fd%f%LP%s suppress this group's solid model", &TextWindow::ScreenChangeGroupOption, g->suppress ? CHECK_TRUE : CHECK_FALSE); diff --git a/src/unix/gloffscreen.cpp b/src/unix/gloffscreen.cpp index 00c141a..107721f 100644 --- a/src/unix/gloffscreen.cpp +++ b/src/unix/gloffscreen.cpp @@ -64,8 +64,6 @@ bool GLOffscreen::begin(int width, int height) { } uint8_t *GLOffscreen::end(bool flip) { - uint32_t *pixels_tgt = flip ? _pixels_inv : _pixels; - #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ glReadPixels(0, 0, _width, _height, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, _pixels_inv); diff --git a/src/util.cpp b/src/util.cpp index 4cf1eca..0ab6f48 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -810,9 +810,6 @@ void Vector::ClosestPointBetweenLines(Vector a0, Vector da, Vector b0, Vector db, double *ta, double *tb) { - Vector a1 = a0.Plus(da), - b1 = a1.Plus(db); - // Make a semi-orthogonal coordinate system from those directions; // note that dna and dnb need not be perpendicular. Vector dn = da.Cross(db); // normal to both