net/mld: Fix a typo in conditional compilation. Clean up return values from mld_ngroups().

This commit is contained in:
Gregory Nutt 2018-11-11 16:23:18 -06:00
parent 9b1025ca1b
commit d94bd49b78
2 changed files with 6 additions and 6 deletions

View File

@ -91,7 +91,7 @@ static int mld_ngroups(FAR struct net_driver_s *dev)
* needed.
*/
return ngroups - 1;
return ngroups > 0 ? ngroups - 1 : 0;
}
/****************************************************************************
@ -147,12 +147,12 @@ FAR struct mld_group_s *mld_grpalloc(FAR struct net_driver_s *dev,
group->ifindex = dev->d_ifindex;
#ifndef CONFIG_CONFIG_NET_MLD_ROUTER
#ifndef CONFIG_NET_MLD_ROUTER
/* Start the query timer if we are the Querier and this is the first
* group member of the group.
*/
if (mld_ngroups(dev) < 1)
if (mld_ngroups(dev) == 0)
{
mld_start_gentimer(dev, MSEC2TICK(MLD_QUERY_MSEC));
}
@ -271,12 +271,12 @@ void mld_grpfree(FAR struct net_driver_s *dev, FAR struct mld_group_s *group)
mldinfo("Call sched_kfree()\n");
kmm_free(group);
#ifndef CONFIG_CONFIG_NET_MLD_ROUTER
#ifndef CONFIG_NET_MLD_ROUTER
/* If there are no longer any groups, then stop the general query and v1
* compatibility timers.
*/
if (mld_ngroups(dev) < 1)
if (mld_ngroups(dev) == 0)
{
wd_cancel(dev->d_mld.gendog);
wd_cancel(dev->d_mld.v1dog);

View File

@ -105,7 +105,7 @@ void mld_devinit(struct net_driver_s *dev)
mld_addmcastmac(dev, g_ipv6_allrouters);
mld_addmcastmac(dev, g_ipv6_allmldv2routers);
#ifdef CONFIG_CONFIG_NET_MLD_ROUTER
#ifdef CONFIG_NET_MLD_ROUTER
/* Start the general query timer. */
mld_start_gentimer(dev, MSEC2TICK(MLD_QUERY_MSEC));