This is an automated email from the ASF dual-hosted git repository. vipulrahane pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mynewt-mcumgr.git
The following commit(s) were added to refs/heads/master by this push: new 7be5e26 Fix unitialized variable warning new 130ae98 Merge pull request #111 from utzig/fix-linked-list 7be5e26 is described below commit 7be5e2628331bdcc91b95e7ade1ee46d349e09bd Author: Fabio Utzig <ut...@apache.org> AuthorDate: Thu Feb 11 11:12:24 2021 -0300 Fix unitialized variable warning Fix usage of prev when curr==group, and add checking for invalid parameter. Signed-off-by: Fabio Utzig <fabio.ut...@nordicsemi.no> --- mgmt/src/mgmt.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mgmt/src/mgmt.c b/mgmt/src/mgmt.c index 77aa631..361211a 100644 --- a/mgmt/src/mgmt.c +++ b/mgmt/src/mgmt.c @@ -74,9 +74,13 @@ mgmt_streamer_free_buf(struct mgmt_streamer *streamer, void *buf) void mgmt_unregister_group(struct mgmt_group *group) { - struct mgmt_group *curr = mgmt_group_list, *prev; + struct mgmt_group *curr = mgmt_group_list, *prev = NULL; - if (curr && curr == group) { + if (!group) { + return; + } + + if (curr == group) { mgmt_group_list = curr->mg_next; return; } @@ -86,7 +90,7 @@ mgmt_unregister_group(struct mgmt_group *group) curr = curr->mg_next; } - if (!curr) { + if (!prev || !curr) { return; }