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 Coverity warnings in String API #18281

Merged
merged 1 commit into from
Apr 19, 2018

Conversation

akien-mga
Copy link
Member

  • StringName::StringName(const StringName &p_name)
    Non-static class member _data is not initialized in this constructor nor in any functions that it calls.

  • StringName::_Data()
    Non-static class member idx is not initialized in this constructor nor in any functions that it calls.

  • String::num_uint64(...)
    This less-than-zero comparison of an unsigned value is never true. n % base < 0UL.

  • String::hex_to_int(...) and String::hex_to_int64(...)
    Execution cannot reach this statement (deadcode)

- StringName::StringName(const StringName &p_name)
  Non-static class member _data is not initialized in this constructor nor in any functions that it calls.

- StringName::_Data()
  Non-static class member idx is not initialized in this constructor nor in any functions that it calls.

- String::num_uint64(...)
  This less-than-zero comparison of an unsigned value is never true. n % base < 0UL.

- String::hex_to_int(...) and String::hex_to_int64(...)
  Execution cannot reach this statement (deadcode)
@@ -67,6 +67,7 @@ class StringName {
_Data() {
cname = NULL;
next = prev = NULL;
idx = 0;
Copy link
Member Author

Choose a reason for hiding this comment

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

Coverity also reports:

Non-static class member field refcount.count is not initialized in this constructor nor in any functions that it calls.

But I'm not sure how/if it should be fixed. The code that actually uses _data always seems to do _data->refcount.init();, I guess it could be made here too?

Copy link
Member Author

Choose a reason for hiding this comment

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

Or should we make SafeRefCount initialize its count to 0?

@akien-mga akien-mga merged commit 394e6d5 into godotengine:master Apr 19, 2018
@akien-mga akien-mga deleted the coverity-string branch April 19, 2018 09:26
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.

1 participant