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

changes made to build without warnings #143

Merged
merged 29 commits into from
Apr 11, 2017
Merged

changes made to build without warnings #143

merged 29 commits into from
Apr 11, 2017

Conversation

aditya-vk
Copy link
Contributor

@aditya-vk aditya-vk commented Mar 24, 2017

typedef (unused) -> set to ignore this warning. Need a fix.

Major warnings:
different types compared -> type casted as appropriate
incorrectly ordered initialization -> reordered
unused variables -> specified to have been unused


This change is Reviewable

Copy link
Member

@mkoval mkoval left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for being diligent to fix these warnings. Since this is a rather pedantic pull request, I'll take this opportunity to be overly pedantic myself! 😉

  • Most of the casts to unsigned int probably should be casts to size_t instead.
  • Use static_cast instead of a C style casts.
  • Use AIKIDO_UPPER_CASE for macros to differentiate them from normal functions and variables.

Also, note that the hauser_parabolic_smoother subdirectory is imported from another project and doesn't use Aikido's coding standard. I recommend disabling all of the warnings in this subdirectory instead of trying to fix them - that just makes the diff with the tarball we imported unnecessarily larger.

@@ -62,7 +62,7 @@ bool RnBoxConstraintSampleGenerator::sample(
{
Eigen::VectorXd value(mDistributions.size());

for (size_t i = 0; i < value.size(); ++i)
for (int i = 0; i < value.size(); ++i) // i should be the same type as size()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this comment is necessary.

@@ -90,11 +90,11 @@ void Interpolated::evaluate(double _t, State *_state) const
void Interpolated::evaluateDerivative(double _t, int _derivative,
Eigen::VectorXd& _tangentVector ) const
{
if (_derivative == 0)
if (_derivative <= 0) // Invalid
Copy link
Contributor Author

@aditya-vk aditya-vk Mar 31, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't realize I pushed this edit as well. This has nothing to do with warnings. I am changing it back to the original for now.

@aditya-vk
Copy link
Contributor Author

aditya-vk commented Mar 31, 2017

  1. static_cast of variables and unsigned int to size_t - check
  2. ignore external project for warnings - check

CMakeLists.txt Outdated
@@ -137,7 +137,7 @@ include_directories(${DART_INCLUDE_DIRS})
# Libraries and unit tests.
#
# TODO: Add this to each target's DEFINITIONS property.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Werror -Wno-unused-local-typedefs")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is -Wno-unused-local-typedefs necessary? Could we remove the unused typedefs instead? 😉

: JointStateSpace(_joint)
, SE3()
: SE3()
, JointStateSpace(_joint) // Order of class members to be maintained
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is misleading. SE3 and JointSubSpace are super classes, not class members.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah. My bad. I'll fix it.

@jslee02
Copy link
Member

jslee02 commented Apr 3, 2017

Can we merge this after #114 is merged? I'd like to make -Werror optional (default is off) and turn it on for CI tests.

@jslee02 jslee02 added this to the Aikido 0.1.0 milestone Apr 4, 2017
@mkoval
Copy link
Member

mkoval commented Apr 4, 2017

I approved #114. Let's merge that first, make the last few changes here, and merge this as well.

@aditya-vk
Copy link
Contributor Author

aditya-vk commented Apr 4, 2017

I'll review this again first thing in the morning, address the suggestions by @mkoval. Should be ready for merge by morning.

@jslee02 jslee02 self-requested a review April 4, 2017 03:37
@aditya-vk
Copy link
Contributor Author

Should be ready for merge now. 😅

  • Removed unnecessary (and um erroneous) comments which weren't required
  • Removed the unused typedef and corresponding flag for compiling

@jslee02
Copy link
Member

jslee02 commented Apr 4, 2017

Let me resolve the conflicts with master branch.

jslee02 added 2 commits April 4, 2017 12:32
Conflicts:
	CMakeLists.txt
	src/external/hauser_parabolic_smoother/CMakeLists.txt
Copy link
Member

@jslee02 jslee02 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The conflicts with master branch are resolved, but I still see warnings from the unit tests. @aditya-vk Could you resolve them by building Aikido with tests target as make -j4 tests?

, SE2()
: SE2()
, JointStateSpace(_joint)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Remove unnecessary empty line

@aditya-vk
Copy link
Contributor Author

Builds without warnings even on unit tests.
ToDo: Run the same with -Wpedantic for a stricter check.

@aditya-vk
Copy link
Contributor Author

I am not sure what to do with the following warning:
error: anonymous variadic macros were introduced in C99 [-Werror=variadic-macros]

Rest of the warnings have all been fixed with -Wpedantic as well.

Copy link
Member

@mkoval mkoval left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe you can fix the variadic-macros warning by adding SYSTEM to this line:

include_directories("${gtest_SOURCE_DIR}/include")

The only variadic macro I see in the project is in gtest, which should be flagged as a SYSTEM header so it doesn't generate warnings.

@@ -11,4 +11,5 @@ set_target_properties("${PROJECT_NAME}_external_hauserparabolicsmoother"
)
target_compile_options("${PROJECT_NAME}_external_hauserparabolicsmoother"
PUBLIC ${AIKIDO_CXX_STANDARD_FLAGS}
PRIVATE -w
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this? 😱

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm correct, this is to ignore warnings from ${PROJECT_NAME}_external_hauserparabolicsmoother target. Since it's not an external target, we cannot use include_directories() with SYSTEM option.

@@ -90,11 +90,11 @@ void Interpolated::evaluate(double _t, State *_state) const
void Interpolated::evaluateDerivative(double _t, int _derivative,
Eigen::VectorXd& _tangentVector ) const
{
if (_derivative == 0)
if (_derivative == 0) // Invalid
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Remove comment.

@@ -26,7 +26,7 @@ class SO2UniformSamplerTests : public ::testing::Test
mRng = make_unique<RNGWrapper<std::default_random_engine>>(0);

mTargets.clear();
for (int i = 0; i < NUM_TARGETS; ++i)
for (auto i = 0u; i < NUM_TARGETS; ++i)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Could we just make this a size_t? I'm generally a fan of almost always auto, but it's a bit funny that we changed a bunch of other loop variables to size_ in this pull request. 😉

@aditya-vk
Copy link
Contributor Author

aditya-vk commented Apr 9, 2017

Woohoo! Done! I guess? :D

Added the SYSTEM flag in the CMakeLists.txt one level lower. I am not sure why including the flag in the tests/CMakeLists did not solve the issue..shouldn't it have?

Copy link
Member

@jslee02 jslee02 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure why including the flag in the tests/CMakeLists did not solve the issue..shouldn't it have?

I think it's because of the location of the SYSTEM option. It should appear before directory.

Sorry for this PR keeps bothering you but I still see errors. 😓

Some warnings are compiler version dependent. If you cannot reproduce the error (warning), I can help to fix them.

Also, as the warnings from gtest is resolved, we might don't want to change the gtest code. It would be good to undo the changes you've made in the previous commits.

@@ -1,5 +1,6 @@
# GTest setup.
add_subdirectory(gtest)

include_directories("${gtest_SOURCE_DIR}/include")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: This line is not added by this PR, but it seems redundant. "${gtest_SOURCE_DIR}/include" is included in the CMakeLists.txt under gtest subdirectory.

@@ -18,15 +18,15 @@ using dart::common::make_unique;
using DefaultRNG = RNGWrapper<std::default_random_engine>;


static Eigen::Vector6d getPose(Eigen::Isometry3d isometry)
static inline Eigen::Vector6d getPose(Eigen::Isometry3d isometry)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this really cause warnings? This function is defined in source code so we shouldn't worry about duplicated definitions. Am I missing something here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the documentation:
-Wunused-function
Warn whenever a static function is declared but not defined or a non-inline static function is unused. This warning is enabled by -Wall.
In our case a non-inline static function's not used.

Copy link
Member

@jslee02 jslee02 Apr 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems the real problem is that this function is unused. I think we could simply remove this function since it was defined only for the local tests but not used.

@@ -17,6 +17,8 @@ if(CMAKE_COMPILER_IS_GNUCXX)

set(AIKIDO_CXX_STANDARD_FLAGS -std=c++11)

add_compile_options(-Wall)
add_compile_options(-Wpedantic)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: We could put multiple options in one function like add_compile_options(-Wall -Wpedantic).

@@ -35,17 +35,11 @@ class NonCollidingTest : public ::testing::Test
auto boxNode = mBox->createJointAndBodyNodePair<FreeJoint>().second;
Eigen::Vector3d boxSize(0.5, 0.5, 0.5);
std::shared_ptr<BoxShape> boxShape(new BoxShape(boxSize));
auto shapeNode = boxNode->createShapeNodeWith
<VisualAspect, CollisionAspect, DynamicsAspect>(boxShape);
Copy link
Member

@jslee02 jslee02 Apr 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't remove the whole line, but just shapeNode variable. createShapeNodeWith<...>() creates ShapeNode within boxNode and returns the pointer. That means this function changes the internal state of bodyNode, which is necessary for this test.

// Create a shpae node for visualization and collision checking
auto shapeNode1 = bn1->createShapeNodeWith
<VisualAspect, CollisionAspect, DynamicsAspect>(box);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't remove the whole line but shapeNode1. (see above)

@coveralls
Copy link

Coverage Status

Coverage remained the same at 85.208% when pulling 21fe382 on werror_clean into a9b50ae on master.

@jslee02
Copy link
Member

jslee02 commented Apr 10, 2017

All the warnings of more tighter warning levels are gone! 🎉

@jslee02
Copy link
Member

jslee02 commented Apr 10, 2017

@mkoval Could you do take a look once more for sure?

@jslee02 jslee02 merged commit a59975f into master Apr 11, 2017
@jslee02 jslee02 deleted the werror_clean branch April 11, 2017 01:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants