-
Notifications
You must be signed in to change notification settings - Fork 75
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
mgmt: Add support for un-registering a group along with the same support in img_mgmt #108
Conversation
vrahane
commented
Feb 10, 2021
- Add support for un-registering a group at runtime
- Add support for un-registering an image management group at runtime
- Re-entrancy to be handled by caller since the API modifies a list
- Add support for unregistering command group at runtime - Add support for unregistering img_mgmt_group at runtime
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.
LGTM
https://travis-ci.org/github/apache/mynewt-nimble/jobs/758517372 this breaks build... |
About time CI is added to this repo... |
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.
@vrahane Please fix the issues in a new PR.
{ | ||
struct mgmt_group *curr = mgmt_group_list, *prev; | ||
|
||
if (curr && curr == group) { |
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.
There is no need to test curr
here because if it is NULL it won't be equal to group
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 only reason I keep checking current everywhere is just to be safe since there was no NULL check for group.
void | ||
mgmt_unregister_group(struct mgmt_group *group) | ||
{ | ||
struct mgmt_group *curr = mgmt_group_list, *prev; |
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.
Please check that group
is not NULL
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.
mgmt_register_group() does not do it either.
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 think I know the reason why the NULL check is not there, it’s because memory for the groups is not allocated here, it is a structure defined in the static memory that does not change. Nonetheless, does not hurt to add the check here.
} | ||
|
||
while (curr && curr != group) { | ||
prev = curr; |
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.
If curr
is valid and equal to group
, prev
will remain uninitialized.
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.
curr will never be equal to group initially here because we take care of that condition above.
Thank you @sjanc, somehow, I did not see any build issues on the zephyr build locally. @utzig ’s PR will fix it. |