Minor coding style changes, added assertion

This commit is contained in:
goldsimon 2010-01-10 13:32:36 +00:00
parent e4d19dc4a0
commit 86f2942c2a

View File

@ -97,6 +97,8 @@ netif_add(struct netif *netif, struct ip_addr *ipaddr, struct ip_addr *netmask,
{
static u8_t netifnum = 0;
LWIP_ASSERT("No init function given", init != NULL);
/* reset new interface configuration state */
netif->ip_addr.addr = 0;
netif->netmask.addr = 0;
@ -188,9 +190,12 @@ netif_set_addr(struct netif *netif, struct ip_addr *ipaddr, struct ip_addr *netm
*
* @param netif the network interface to remove
*/
void netif_remove(struct netif * netif)
void
netif_remove(struct netif *netif)
{
if ( netif == NULL ) return;
if (netif == NULL) {
return;
}
#if LWIP_IGMP
/* stop IGMP processing */
@ -204,25 +209,24 @@ void netif_remove(struct netif * netif)
/* is it the first netif? */
if (netif_list == netif) {
netif_list = netif->next;
snmp_dec_iflist();
}
else {
} else {
/* look for netif further down the list */
struct netif * tmpNetif;
for (tmpNetif = netif_list; tmpNetif != NULL; tmpNetif = tmpNetif->next) {
if (tmpNetif->next == netif) {
tmpNetif->next = netif->next;
snmp_dec_iflist();
break;
}
}
if (tmpNetif == NULL)
return; /* we didn't find any netif today */
}
snmp_dec_iflist();
/* this netif is default? */
if (netif_default == netif)
if (netif_default == netif) {
/* reset default netif */
netif_set_default(NULL);
}
LWIP_DEBUGF( NETIF_DEBUG, ("netif_remove: removed netif\n") );
}
@ -275,8 +279,7 @@ netif_set_ipaddr(struct netif *netif, struct ip_addr *ipaddr)
struct tcp_pcb_listen *lpcb;
/* address is actually being changed? */
if ((ip_addr_cmp(ipaddr, &(netif->ip_addr))) == 0)
{
if ((ip_addr_cmp(ipaddr, &(netif->ip_addr))) == 0) {
/* extern struct tcp_pcb *tcp_active_pcbs; defined by tcp.h */
LWIP_DEBUGF(NETIF_DEBUG | LWIP_DBG_STATE, ("netif_set_ipaddr: netif address being changed\n"));
pcb = tcp_active_pcbs;
@ -371,13 +374,10 @@ netif_set_netmask(struct netif *netif, struct ip_addr *netmask)
void
netif_set_default(struct netif *netif)
{
if (netif == NULL)
{
if (netif == NULL) {
/* remove default route */
snmp_delete_iprteidx_tree(1, netif);
}
else
{
} else {
/* install default route */
snmp_insert_iprteidx_tree(1, netif);
}
@ -433,8 +433,7 @@ void netif_set_up(struct netif *netif)
*/
void netif_set_down(struct netif *netif)
{
if ( netif->flags & NETIF_FLAG_UP )
{
if (netif->flags & NETIF_FLAG_UP) {
netif->flags &= ~NETIF_FLAG_UP;
#if LWIP_SNMP
snmp_get_sysuptime(&netif->ts);
@ -451,9 +450,10 @@ void netif_set_down(struct netif *netif)
*/
void netif_set_status_callback(struct netif *netif, void (* status_callback)(struct netif *netif ))
{
if ( netif )
if (netif) {
netif->status_callback = status_callback;
}
}
#endif /* LWIP_NETIF_STATUS_CALLBACK */
#if LWIP_NETIF_LINK_CALLBACK