igmp: Fix optimized code for igmp_remove_group

The code in the for loop checks tmp_group->next == group, so current code
actually checks from the 3rd entry in the linked groups list. Fix it.

Fixes: 5c1dd6a4c6 ("Optimization in igmp_remove_group() pointed out by Axel Lin")
Signed-off-by: Axel Lin <axel.lin@ingics.com>
This commit is contained in:
Axel Lin 2016-12-17 22:41:11 +08:00 committed by Dirk Ziegelmeier
parent 5c1dd6a4c6
commit f488c5b7bc

View File

@ -295,15 +295,10 @@ static err_t
igmp_remove_group(struct netif* netif, struct igmp_group *group)
{
err_t err = ERR_OK;
struct igmp_group *tmp_group = netif_igmp_data(netif);
struct igmp_group *tmp_group;
/* Skip the first group in the list, it is always the allsystems group added in igmp_start() */
if(tmp_group != NULL) {
tmp_group = tmp_group->next;
}
/* look for group further down the list */
for (; tmp_group != NULL; tmp_group = tmp_group->next) {
for (tmp_group = netif_igmp_data(netif); tmp_group != NULL; tmp_group = tmp_group->next) {
if (tmp_group->next == group) {
tmp_group->next = group->next;
break;