Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up Clang compiler warnings #589

Merged
merged 5 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 31 additions & 32 deletions graphics/src/MeshManager_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include "gz/common/Mesh.hh"
#include "gz/common/SubMesh.hh"
#include "gz/common/MeshManager.hh"
#include "gz/common/config.hh"

#include "gz/common/testing/AutoLogFixture.hh"
#include "gz/common/testing/TestPaths.hh"
Expand All @@ -38,18 +37,18 @@ TEST_F(MeshManager, CreateExtrudedPolyline)
// The smaller square should be treated as a hole inside the bigger square.
std::vector<std::vector<gz::math::Vector2d> > path;
std::vector<gz::math::Vector2d> subpath01;
subpath01.push_back(gz::math::Vector2d(0, 0));
subpath01.push_back(gz::math::Vector2d(1, 0));
subpath01.push_back(gz::math::Vector2d(1, 1));
subpath01.push_back(gz::math::Vector2d(0, 1));
subpath01.push_back(gz::math::Vector2d(0, 0));
subpath01.emplace_back(0, 0);
subpath01.emplace_back(1, 0);
subpath01.emplace_back(1, 1);
subpath01.emplace_back(0, 1);
subpath01.emplace_back(0, 0);

std::vector<gz::math::Vector2d> subpath02;
subpath02.push_back(gz::math::Vector2d(0.25, 0.25));
subpath02.push_back(gz::math::Vector2d(0.25, 0.75));
subpath02.push_back(gz::math::Vector2d(0.75, 0.75));
subpath02.push_back(gz::math::Vector2d(0.75, 0.25));
subpath02.push_back(gz::math::Vector2d(0.25, 0.25));
subpath02.emplace_back(0.25, 0.25);
subpath02.emplace_back(0.25, 0.75);
subpath02.emplace_back(0.75, 0.75);
subpath02.emplace_back(0.75, 0.25);
subpath02.emplace_back(0.25, 0.25);

path.push_back(subpath01);
path.push_back(subpath02);
Expand Down Expand Up @@ -141,19 +140,19 @@ TEST_F(MeshManager, CreateExtrudedPolylineClosedPath)
// The following two subpaths form the letter 'A'.
std::vector<std::vector<gz::math::Vector2d> > path2;
std::vector<gz::math::Vector2d> subpath03;
subpath03.push_back(gz::math::Vector2d(2.27467, 1.0967));
subpath03.push_back(gz::math::Vector2d(1.81094, 2.35418));
subpath03.push_back(gz::math::Vector2d(2.74009, 2.35418));
subpath03.emplace_back(2.27467, 1.0967);
subpath03.emplace_back(1.81094, 2.35418);
subpath03.emplace_back(2.74009, 2.35418);

std::vector<gz::math::Vector2d> subpath04;
subpath04.push_back(gz::math::Vector2d(2.08173, 0.7599));
subpath04.push_back(gz::math::Vector2d(2.4693, 0.7599));
subpath04.push_back(gz::math::Vector2d(3.4323, 3.28672));
subpath04.push_back(gz::math::Vector2d(3.07689, 3.28672));
subpath04.push_back(gz::math::Vector2d(2.84672, 2.63851));
subpath04.push_back(gz::math::Vector2d(1.7077, 2.63851));
subpath04.push_back(gz::math::Vector2d(1.47753, 3.28672));
subpath04.push_back(gz::math::Vector2d(1.11704, 3.28672));
subpath04.emplace_back(2.08173, 0.7599);
subpath04.emplace_back(2.4693, 0.7599);
subpath04.emplace_back(3.4323, 3.28672);
subpath04.emplace_back(3.07689, 3.28672);
subpath04.emplace_back(2.84672, 2.63851);
subpath04.emplace_back(1.7077, 2.63851);
subpath04.emplace_back(1.47753, 3.28672);
subpath04.emplace_back(1.11704, 3.28672);

path2.push_back(subpath03);
path2.push_back(subpath04);
Expand Down Expand Up @@ -254,9 +253,9 @@ TEST_F(MeshManager, CreateExtrudedPolylineInvalid)
// test extruding invalid polyline
std::vector<std::vector<gz::math::Vector2d> > path;
std::vector<gz::math::Vector2d> subpath01;
subpath01.push_back(gz::math::Vector2d(0, 0));
subpath01.push_back(gz::math::Vector2d(0, 1));
subpath01.push_back(gz::math::Vector2d(0, 2));
subpath01.emplace_back(0, 0);
subpath01.emplace_back(0, 1);
subpath01.emplace_back(0, 2);

path.push_back(subpath01);

Expand All @@ -272,7 +271,7 @@ TEST_F(MeshManager, CreateExtrudedPolylineInvalid)
/////////////////////////////////////////////////
TEST_F(MeshManager, Remove)
{
auto mgr = common::MeshManager::Instance();
auto *mgr = common::MeshManager::Instance();

EXPECT_FALSE(mgr->HasMesh("box"));
mgr->CreateBox("box",
Expand All @@ -294,7 +293,7 @@ TEST_F(MeshManager, Remove)
/////////////////////////////////////////////////
TEST_F(MeshManager, ConvexDecomposition)
{
auto mgr = common::MeshManager::Instance();
auto *mgr = common::MeshManager::Instance();
const common::Mesh *boxMesh = mgr->Load(
common::testing::TestFile("data", "box.dae"));

Expand All @@ -304,8 +303,8 @@ TEST_F(MeshManager, ConvexDecomposition)
std::size_t maxConvexHulls = 4;
std::size_t resolution = 1000;
auto submesh = boxMesh->SubMeshByIndex(0u).lock();
auto decomposed = std::move(common::MeshManager::ConvexDecomposition(
*(submesh.get()), maxConvexHulls, resolution));
auto decomposed = common::MeshManager::ConvexDecomposition(
*submesh, maxConvexHulls, resolution);

// Decomposing a box should just produce a box
EXPECT_EQ(1u, decomposed.size());
Expand All @@ -321,8 +320,8 @@ TEST_F(MeshManager, ConvexDecomposition)
ASSERT_NE(nullptr, drillMesh);
EXPECT_EQ(1u, drillMesh->SubMeshCount());
submesh = drillMesh->SubMeshByIndex(0u).lock();
decomposed = std::move(common::MeshManager::ConvexDecomposition(
*(submesh.get()), maxConvexHulls, resolution));
decomposed = common::MeshManager::ConvexDecomposition(
*submesh, maxConvexHulls, resolution);

// A drill should be decomposed into multiple submeshes
EXPECT_LT(1u, decomposed.size());
Expand All @@ -340,7 +339,7 @@ TEST_F(MeshManager, ConvexDecomposition)
/////////////////////////////////////////////////
TEST_F(MeshManager, MergeSubMeshes)
{
auto mgr = common::MeshManager::Instance();
auto *mgr = common::MeshManager::Instance();
const common::Mesh *mesh = mgr->Load(
common::testing::TestFile("data",
"multiple_texture_coordinates_triangle.dae"));
Expand Down
13 changes: 12 additions & 1 deletion io/src/CSVStreams.cc
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,21 @@
{
}

/// \brief Copy assignment.
public: Implementation& operator=(Implementation other)

Check warning on line 178 in io/src/CSVStreams.cc

View check run for this annotation

Codecov / codecov/patch

io/src/CSVStreams.cc#L178

Added line #L178 was not covered by tests
{
if (this != &other)

Check warning on line 180 in io/src/CSVStreams.cc

View check run for this annotation

Codecov / codecov/patch

io/src/CSVStreams.cc#L180

Added line #L180 was not covered by tests
{
std::swap(this->stream, other.stream);
std::swap(this->dialect, other.dialect);
std::swap(this->row, other.row);

Check warning on line 184 in io/src/CSVStreams.cc

View check run for this annotation

Codecov / codecov/patch

io/src/CSVStreams.cc#L182-L184

Added lines #L182 - L184 were not covered by tests
}
return *this;

Check warning on line 186 in io/src/CSVStreams.cc

View check run for this annotation

Codecov / codecov/patch

io/src/CSVStreams.cc#L186

Added line #L186 was not covered by tests
}
/// \brief Advance iterator to next row if possible.
public: void Next()
{
if (this->stream)
if (this->stream != nullptr)
{
try
{
Expand Down
21 changes: 21 additions & 0 deletions io/src/CSVStreams_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,27 @@ TEST(CSVStreams, CanIterateValidCSV)
CSVIStreamIterator(ss), CSVIStreamIterator());
EXPECT_EQ(expectedRows, rows);
}

{
std::stringstream ss;
ss << "foo,bar" << std::endl
<< "bar," << std::endl
<< ",foo" << std::endl
<< "," << std::endl
<< "baz,baz";
auto it = CSVIStreamIterator(ss);
// Copy constructor for coverage
auto it_copy = it;

auto row0 = *it_copy;
EXPECT_EQ(row0[0], "foo");
EXPECT_EQ(row0[1], "bar");
it_copy++;

auto row1 = *it_copy;
EXPECT_EQ(row1[0], "bar");
EXPECT_EQ(row1[1], "");
}
}

/////////////////////////////////////////////////
Expand Down
4 changes: 4 additions & 0 deletions profiler/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ if(GZ_PROFILER_REMOTERY)
./Remotery/lib/Remotery.h
)

# A few warnings to suppress, rather than modifying vendored code
set_source_files_properties(./Remotery/lib/Remotery.c PROPERTIES
COMPILE_FLAGS
"$<$<COMPILE_LANG_AND_ID:CXX,ARMClang,AppleClang,Clang,GNU,LCC>:-Wno-strict-prototypes -Wno-unused-but-set-variable>")

if(APPLE)
set(
Expand Down
Loading