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

COMP: Fix ununsed code ( if(false) ) #4674

Merged

Conversation

andrei-sandor
Copy link
Contributor

@andrei-sandor andrei-sandor commented May 16, 2024

This is a comment to fix the -Wunreachable-code warning generated by clang.

This fix simply removes if (false) clauses. An investigation was done to see why these clause exist. This change was done 10 years ago. The clauses at that time were if(0).

@github-actions github-actions bot added type:Compiler Compiler support or related warnings type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct area:Registration Issues affecting the Registration module labels May 16, 2024
Copy link
Member

@dzenanz dzenanz left a comment

Choose a reason for hiding this comment

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

This pattern is used to be able to quickly change the code to test a feature.

The proper fix here would be to expose a new command-line parameter and use it in the if clause. Bonus points if that new command line parameter is exercised in corresponding test specification, e.g. https://github.com/InsightSoftwareConsortium/ITK/blob/v5.4rc03/Modules/Registration/Metricsv4/test/CMakeLists.txt#L113-L123.

@andrei-sandor
Copy link
Contributor Author

For the last commit, we would like to know what better name would it be to replace foo. Here, foo represents the variable false.

@@ -164,6 +164,10 @@ itkJointHistogramMutualInformationImageToImageRegistrationTest(int argc, char *
{
numberOfDisplacementIterations = std::stoi(argv[5]);
}
if (argc >= 7)
Copy link
Member

Choose a reason for hiding this comment

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

You need to declare the variables, e.g.

bool useScalesEstimator = true;
if (argc >= 7)
...

This is a comment to fix the -Wunreachable-code warning generated by clang.

This fix simply removes if (false) clauses. An investigation was done to see why these clause exist. This change was done 10 years ago. The clause at that time was if(0).
Copy link
Member

@thewtex thewtex left a comment

Choose a reason for hiding this comment

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

@andrei-sandor thank you!

@thewtex thewtex merged commit 970908c into InsightSoftwareConsortium:master May 31, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:Registration Issues affecting the Registration module type:Compiler Compiler support or related warnings type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants