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

Fix some issues found by cppcheck. #59911

Merged
merged 1 commit into from
Apr 6, 2022

Conversation

bruvzg
Copy link
Member

@bruvzg bruvzg commented Apr 5, 2022

@bruvzg bruvzg added this to the 4.0 milestone Apr 5, 2022
@bruvzg bruvzg changed the title [WIPFix some issues found by cppcheck. [WIP] Fix some issues found by cppcheck. Apr 5, 2022
@@ -51,7 +51,7 @@ ScriptIterator::ScriptIterator(const String &p_string, int p_start, int p_length
}

int paren_size = PAREN_STACK_DEPTH;
ParenStackEntry *paren_stack = (ParenStackEntry *)memalloc(paren_size * sizeof(ParenStackEntry));
ParenStackEntry *paren_stack = static_cast<ParenStackEntry *>(memalloc(paren_size * sizeof(ParenStackEntry)));
Copy link
Member

Choose a reason for hiding this comment

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

For the record, what are the kind of issues with using a C-style cast instead of static_cast or dynamic_cast in this context that cppcheck would report?

Copy link
Member Author

Choose a reason for hiding this comment

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

cppcheck reports all C-casts, I guess the only purpose of these reports is to make intention of the cast more clear, so it's just a style change.

Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

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

Changes look good so far.

@bruvzg bruvzg force-pushed the cppcheck_fixes branch 4 times, most recently from dc98130 to 3620e92 Compare April 6, 2022 11:32
@bruvzg
Copy link
Member Author

bruvzg commented Apr 6, 2022

Looked at the rest of report, and added more fixes (but it's definitely not everything):

  • I have not checked any of noExplicitConstructor, useInitializationList and virtualCallInConstructor.
  • As well as most of unused variables / functions warnings (many of these seems to be false positive, due to use different defines).
  • Skipped all alloca usage warnings (not sure what's wrong with allocating on stack, and if we want to change any of these).
  • cppcheck do not like x.operator String() syntax, but it should be OK to use, so I left it as is.
  • Some of duplicateCondition look suspicion and need to be checked.

@bruvzg bruvzg changed the title [WIP] Fix some issues found by cppcheck. Fix some issues found by cppcheck. Apr 6, 2022
@bruvzg bruvzg marked this pull request as ready for review April 6, 2022 12:45
@bruvzg bruvzg requested review from a team as code owners April 6, 2022 12:45
@bruvzg bruvzg requested review from a team as code owners April 6, 2022 12:45
@akien-mga akien-mga merged commit ac591d9 into godotengine:master Apr 6, 2022
@akien-mga
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants