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: 5c1dd6a4c65b ("Optimization in igmp_remove_group() pointed out by Axel Lin")
Signed-off-by: Axel Lin <axel.lin@ingics.com>
diff --git a/src/core/ipv4/igmp.c b/src/core/ipv4/igmp.c
index 58613d3..561448e 100644
--- a/src/core/ipv4/igmp.c
+++ b/src/core/ipv4/igmp.c
@@ -295,15 +295,10 @@
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;