-
Notifications
You must be signed in to change notification settings - Fork 3k
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 Coverity uninitialized pointer field Thread.h #11273
Conversation
@Tharazi97, thank you for your changes. |
rtos/Thread.h
Outdated
@@ -540,7 +540,7 @@ class Thread : private mbed::NonCopyable<Thread> { | |||
bool _dynamic_stack; | |||
Semaphore _join_sem; | |||
mutable Mutex _mutex; | |||
mbed_rtos_storage_thread_t _obj_mem; | |||
mbed_rtos_storage_thread_t _obj_mem = {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current init is in start() method - it sets this to 0:
mbed-os/rtos/source/Thread.cpp
Line 109 in b1ced1b
memset(&_obj_mem, 0, sizeof(_obj_mem)); |
Assuming based on how it is initialized (POD type), this could be handled in the constructor as the rest of members - to be consistent however this is valid now as it is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a fan of the existing constructor
method and its in-body init - now we're C++11 you could use proper constructor delegation, and the final most-flexible constructor could do everything via its member-initializer list.
I'd also prefer if everything was consistent - all defaults in body of constructor
, all defaults in member-initializer-list, or all defaults as default-member initializers.
So make it a memset
in constructor
, or do a more wide-ranging refactor/tidy including real constructor delegation.
I guess this is warning about I think this is probably fine, but you should net off the size increase a bit by removing the |
Yes I think it is warning caused by |
You could certainly set |
Changed _obj_mem to be initialized with constructor of new thread.
b1ced1b
to
6467f56
Compare
@kjbracey-arm you were right. I've moved |
started CI |
restarted |
Test run: FAILEDSummary: 1 of 11 test jobs failed Failed test jobs:
|
CI fail seems not related. |
Test restarted |
Description
Changed _obj_mem to be initialized with creating new thread.
Pull request type
Reviewers
@jamesbeyond @maciejbocianski
Release Notes