Skip to content

Commit ef6c55e

Browse files
authored
Merge pull request openscad#5379 from openscad/clang-tidy-fixes
Various fixes for clang-tidy checks with few occurences
2 parents 335ed8e + afa6776 commit ef6c55e

26 files changed

+49
-46
lines changed

src/core/Expression.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,6 @@ Range::Range(Expression *begin, Expression *step, Expression *end, const Locatio
228228
* during normal operating, not runtime during error handling.
229229
*/
230230
static void NOINLINE print_range_depr(const Location& loc, const std::shared_ptr<const Context>& context){
231-
std::string locs = loc.toRelativeString(context->documentRoot());
232231
LOG(message_group::Deprecated, loc, context->documentRoot(), "Using ranges of the form [begin:end] with begin value greater than the end value is deprecated");
233232
}
234233

src/core/FreetypeRenderer.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -192,16 +192,16 @@ class FreetypeRenderer
192192
// when rendering from Freetype, and have not yet been scaled
193193
// back up to the desired font size.
194194
std::vector<GlyphData> glyph_array;
195-
double x_offset;
196-
double y_offset;
197-
double left;
198-
double right;
199-
double top;
200-
double bottom;
201-
double advance_x;
202-
double advance_y;
203-
double ascent;
204-
double descent;
195+
double x_offset{0.0};
196+
double y_offset{0.0};
197+
double left{0.0};
198+
double right{0.0};
199+
double top{0.0};
200+
double bottom{0.0};
201+
double advance_x{0.0};
202+
double advance_y{0.0};
203+
double ascent{0.0};
204+
double descent{0.0};
205205
ShapeResults(const FreetypeRenderer::Params& params);
206206
virtual ~ShapeResults();
207207
private:

src/geometry/ClipperUtils.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ std::unique_ptr<Polygon2d> apply(const std::vector<std::shared_ptr<const Polygon
177177
ClipperLib::ClipType clipType)
178178
{
179179
BoundingBox bounds;
180-
for (auto polygon : polygons) {
180+
for (const auto& polygon : polygons) {
181181
if (polygon) bounds.extend(polygon->getBoundingBox());
182182
}
183183
int pow2 = ClipperUtils::getScalePow2(bounds);

src/geometry/PolySetBuilder.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,7 @@ void PolySetBuilder::appendPolySet(const PolySet& ps)
171171
color_map[i] = it - colors_.begin();
172172
}
173173
}
174-
for (int i = 0, n = ps.color_indices.size(); i < n; i++) {
175-
const auto color_index = ps.color_indices[i];
174+
for (auto color_index : ps.color_indices) {
176175
color_indices_.push_back(color_index < 0 ? -1 : color_map[color_index]);
177176
}
178177
} else if (!color_indices_.empty()) {

src/geometry/manifold/manifoldutils.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const char* statusToString(Error status) {
4949
template <class TriangleMesh>
5050
std::shared_ptr<ManifoldGeometry> createManifoldFromSurfaceMesh(const TriangleMesh& tm)
5151
{
52-
typedef typename TriangleMesh::Vertex_index vertex_descriptor;
52+
using vertex_descriptor = typename TriangleMesh::Vertex_index;
5353

5454
manifold::MeshGL64 meshgl;
5555

src/glview/GLView.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ void GLView::paintGL()
183183
showObject(obj,eyedir);
184184
}
185185
glColor3f(0,1,0);
186-
for (const SelectedObject obj: this->shown_obj) {
186+
for (const SelectedObject &obj: this->shown_obj) {
187187
showObject(obj,eyedir);
188188
}
189189
glDisable(GL_LIGHTING);

src/glview/NULLGL.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ void GLView::setColorScheme(const std::string& cs) {assert(false && "not impleme
2222
#include "glview/system-gl.h"
2323

2424
double gl_version() { return -1; }
25-
std::string gl_dump() { return std::string("GL Renderer: NULLGL\n"); }
26-
std::string gl_extensions_dump() { return std::string("NULLGL Extensions"); }
25+
std::string gl_dump() { return {"GL Renderer: NULLGL\n"}; }
26+
std::string gl_extensions_dump() { return {"NULLGL Extensions"}; }
2727
bool report_glerror(const char *function) { return false; }
2828

2929
#include "glview/OpenGLContext.h"

src/glview/OffscreenContextEGL.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ std::shared_ptr<OffscreenContext> CreateOffscreenContextEGL(size_t width, size_t
115115
{
116116
auto ctx = std::make_shared<OffscreenContextEGL>(width, height);
117117

118-
int initialEglVersion = gladLoaderLoadEGL(NULL);
118+
int initialEglVersion = gladLoaderLoadEGL(nullptr);
119119
if (!initialEglVersion) {
120120
LOG("gladLoaderLoadEGL(NULL): Unable to load EGL");
121121
return nullptr;

src/glview/Renderer.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ void Renderer::setColorScheme(const ColorScheme& cs) {
206206
}
207207

208208

209-
std::vector<SelectedObject> Renderer::findModelObject(Vector3d near_pt, Vector3d far_pt, int mouse_x, int mouse_y, double tolerance) { return std::vector<SelectedObject>(); }
209+
std::vector<SelectedObject> Renderer::findModelObject(Vector3d near_pt, Vector3d far_pt, int mouse_x, int mouse_y, double tolerance) { return {}; }
210210
#else //NULLGL
211211

212212
Renderer::Renderer() : colorscheme(nullptr) {}
@@ -217,6 +217,6 @@ void Renderer::setColor(const float color[4], const shaderinfo_t *shaderinfo) co
217217
Color4f Renderer::setColor(ColorMode colormode, const float color[4], const shaderinfo_t *shaderinfo) const { return {}; }
218218
void Renderer::setColor(ColorMode colormode, const shaderinfo_t *shaderinfo) const {}
219219
void Renderer::setColorScheme(const ColorScheme& cs) {}
220-
std::vector<SelectedObject> Renderer::findModelObject(Vector3d near_pt, Vector3d far_pt, int mouse_x, int mouse_y, double tolerance) { return std::vector<SelectedObject>(); }
220+
std::vector<SelectedObject> Renderer::findModelObject(Vector3d near_pt, Vector3d far_pt, int mouse_x, int mouse_y, double tolerance) { return {}; }
221221

222222
#endif //NULLGL

src/glview/VertexState.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99

1010
#define GL_TRACE_ENABLE
1111
#ifdef GL_TRACE_ENABLE
12+
// NOLINTBEGIN(bugprone-macro-parentheses)
1213
#define GL_TRACE(fmt_, args) do { \
1314
if (OpenSCAD::debug != "") PRINTDB("%d : " fmt_, __LINE__ % args); \
1415
} while (0)
16+
// NOLINTEND(bugprone-macro-parentheses)
1517
#define GL_TRACE0(fmt_) do { \
1618
if (OpenSCAD::debug != "") PRINTDB("%d : " fmt_, __LINE__); \
1719
} while (0)

0 commit comments

Comments
 (0)