minor: coding style

This commit is contained in:
sg 2015-10-06 21:57:40 +02:00
parent 22df34fc70
commit 2b971400fa
26 changed files with 167 additions and 176 deletions

View File

@ -883,7 +883,8 @@ netconn_gethostbyname(const char *name, ip_addr_t *addr)
#endif /* LWIP_DNS*/
#if LWIP_NETCONN_SEM_PER_THREAD
void netconn_thread_init(void)
void
netconn_thread_init(void)
{
sys_sem_t *sem = LWIP_NETCONN_THREAD_SEM_GET();
if ((sem == NULL) || !sys_sem_valid(sem)) {
@ -893,7 +894,8 @@ void netconn_thread_init(void)
}
}
void netconn_thread_cleanup(void)
void
netconn_thread_cleanup(void)
{
sys_sem_t *sem = LWIP_NETCONN_THREAD_SEM_GET();
if ((sem != NULL) && sys_sem_valid(sem)) {

View File

@ -575,7 +575,8 @@ ip4_input(struct pbuf *p, struct netif *inp)
#endif /* IP_ACCEPT_LINK_LAYER_ADDRESSING */
)
#endif /* LWIP_IGMP || IP_ACCEPT_LINK_LAYER_ADDRESSING */
{ if ((ip_addr_isbroadcast(ip_current_src_addr(), inp)) ||
{
if ((ip_addr_isbroadcast(ip_current_src_addr(), inp)) ||
(ip_addr_ismulticast(ip_current_src_addr()))) {
/* packet source is not valid */
LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_LEVEL_WARNING, ("ip_input: packet source is not valid.\n"));

View File

@ -497,8 +497,7 @@ ip6_input(struct pbuf *p, struct netif *inp)
else {
netif = NULL;
}
}
else {
} else {
/* start trying with inp. if that's not acceptable, start walking the
list of configured netifs.
'first' is used as a boolean to mark whether we started walking the list */

View File

@ -210,7 +210,9 @@ ip6addr_ntoa_r(const ip6_addr_t *addr, char *buf, int buflen)
if (current_block_index == 7) {
/* special case, we must render a ':' for the last block. */
buf[i++] = ':';
if (i >= buflen) return NULL;
if (i >= buflen) {
return NULL;
}
break;
}
if (empty_block_flag == 0) {
@ -224,41 +226,45 @@ ip6addr_ntoa_r(const ip6_addr_t *addr, char *buf, int buflen)
if (next_block_value == 0) {
empty_block_flag = 1;
buf[i++] = ':';
if (i >= buflen) return NULL;
if (i >= buflen) {
return NULL;
}
continue; /* move on to next block. */
}
}
else if (empty_block_flag == 1) {
} else if (empty_block_flag == 1) {
/* move on to next block. */
continue;
}
}
else if (empty_block_flag == 1) {
} else if (empty_block_flag == 1) {
/* Set this flag value so we don't produce multiple empty blocks. */
empty_block_flag = 2;
}
if (current_block_index > 0) {
buf[i++] = ':';
if (i >= buflen) return NULL;
if (i >= buflen) {
return NULL;
}
}
if ((current_block_value & 0xf000) == 0) {
zero_flag = 1;
}
else {
} else {
buf[i++] = xchar(((current_block_value & 0xf000) >> 12));
zero_flag = 0;
if (i >= buflen) return NULL;
if (i >= buflen) {
return NULL;
}
}
if (((current_block_value & 0xf00) == 0) && (zero_flag)) {
/* do nothing */
}
else {
} else {
buf[i++] = xchar(((current_block_value & 0xf00) >> 8));
zero_flag = 0;
if (i >= buflen) return NULL;
if (i >= buflen) {
return NULL;
}
}
if (((current_block_value & 0xf0) == 0) && (zero_flag)) {
@ -267,11 +273,15 @@ ip6addr_ntoa_r(const ip6_addr_t *addr, char *buf, int buflen)
else {
buf[i++] = xchar(((current_block_value & 0xf0) >> 4));
zero_flag = 0;
if (i >= buflen) return NULL;
if (i >= buflen) {
return NULL;
}
}
buf[i++] = xchar((current_block_value & 0xf));
if (i >= buflen) return NULL;
if (i >= buflen) {
return NULL;
}
}
buf[i] = 0;

View File

@ -183,9 +183,6 @@ nd6_input(struct pbuf *p, struct netif *inp)
mld6_leavegroup(netif_ip6_addr(inp, i), &multicast_address);
#endif /* LWIP_IPV6_MLD */
#if LWIP_IPV6_AUTOCONFIG
/* Check to see if this address was autoconfigured. */
if (!ip6_addr_islinklocal(ip6_current_dest_addr())) {
@ -211,8 +208,7 @@ nd6_input(struct pbuf *p, struct netif *inp)
MEMCPY(neighbor_cache[i].lladdr, lladdr_opt->addr, inp->hwaddr_len);
}
}
}
else {
} else {
/* This is a solicited NA.
* neighbor address resolution response?
* neighbor unreachability detection response? */
@ -287,8 +283,7 @@ nd6_input(struct pbuf *p, struct netif *inp)
if (p->len < (sizeof(struct ns_header) + (lladdr_opt->length << 3))) {
lladdr_opt = NULL;
}
}
else {
} else {
lladdr_opt = NULL;
}
@ -324,8 +319,7 @@ nd6_input(struct pbuf *p, struct netif *inp)
}
}
}
}
else {
} else {
/* Sender is trying to resolve our address. */
/* Verify that they included their own link-layer address. */
if (lladdr_opt == NULL) {
@ -347,9 +341,7 @@ nd6_input(struct pbuf *p, struct netif *inp)
neighbor_cache[i].state = ND6_DELAY;
neighbor_cache[i].counter.delay_time = LWIP_ND6_DELAY_FIRST_PROBE_TIME;
}
}
else
{
} else {
/* Add their IPv6 address and link-layer address to neighbor cache.
* We will need it at least to send a unicast NA message, but most
* likely we will also be communicating with this node soon. */
@ -509,13 +501,11 @@ nd6_input(struct pbuf *p, struct netif *inp)
break;
}
case ND6_OPTION_TYPE_ROUTE_INFO:
{
/* TODO implement preferred routes.
struct route_option * route_opt;
route_opt = (struct route_option *)buffer;*/
break;
}
default:
/* Unrecognized option, abort. */
ND6_STATS_INC(nd6.proterr);
@ -547,8 +537,7 @@ nd6_input(struct pbuf *p, struct netif *inp)
if (p->len < (sizeof(struct redirect_header) + (lladdr_opt->length << 3))) {
lladdr_opt = NULL;
}
}
else {
} else {
lladdr_opt = NULL;
}
@ -667,8 +656,7 @@ nd6_tmr(void)
if (neighbor_cache[i].counter.probes_sent >= LWIP_ND6_MAX_MULTICAST_SOLICIT) {
/* Retries exceeded. */
nd6_free_neighbor_cache_entry(i);
}
else {
} else {
/* Send a NS for this entry. */
neighbor_cache[i].counter.probes_sent++;
nd6_send_ns(neighbor_cache[i].netif, &(neighbor_cache[i].next_hop_address), ND6_SEND_FLAG_MULTICAST_DEST);
@ -683,8 +671,7 @@ nd6_tmr(void)
/* Change to stale state. */
neighbor_cache[i].state = ND6_STALE;
neighbor_cache[i].counter.stale_time = 0;
}
else {
} else {
neighbor_cache[i].counter.reachable_time -= ND6_TMR_INTERVAL;
}
break;
@ -696,8 +683,7 @@ nd6_tmr(void)
/* Change to PROBE state. */
neighbor_cache[i].state = ND6_PROBE;
neighbor_cache[i].counter.probes_sent = 0;
}
else {
} else {
neighbor_cache[i].counter.delay_time -= ND6_TMR_INTERVAL;
}
break;
@ -705,8 +691,7 @@ nd6_tmr(void)
if (neighbor_cache[i].counter.probes_sent >= LWIP_ND6_MAX_MULTICAST_SOLICIT) {
/* Retries exceeded. */
nd6_free_neighbor_cache_entry(i);
}
else {
} else {
/* Send a NS for this entry. */
neighbor_cache[i].counter.probes_sent++;
nd6_send_ns(neighbor_cache[i].netif, &(neighbor_cache[i].next_hop_address), 0);
@ -769,8 +754,7 @@ nd6_tmr(void)
prefix_list[i].netif = NULL;
prefix_list[i].flags = 0;
}
else {
} else {
prefix_list[i].invalidation_timer -= ND6_TMR_INTERVAL / 1000;
#if LWIP_IPV6_AUTOCONFIG
@ -813,8 +797,7 @@ nd6_tmr(void)
/* No NA received in response. Mark address as valid. */
netif->ip6_addr_state[i] = IP6_ADDR_PREFERRED;
/* TODO implement preferred and valid lifetimes. */
}
else if (netif->flags & NETIF_FLAG_UP) {
} else if (netif->flags & NETIF_FLAG_UP) {
#if LWIP_IPV6_MLD
if ((netif->ip6_addr_state[i] & 0x07) == 0) {
/* Join solicited node multicast group. */
@ -970,12 +953,10 @@ nd6_send_na(struct netif * netif, const ip6_addr_t * target_addr, u8_t flags)
if (flags & ND6_SEND_FLAG_MULTICAST_DEST) {
ip6_addr_set_solicitednode(&multicast_address, target_addr->addr[3]);
dest_addr = &multicast_address;
}
else if (flags & ND6_SEND_FLAG_ALLNODES_DEST) {
} else if (flags & ND6_SEND_FLAG_ALLNODES_DEST) {
ip6_addr_set_allnodes_linklocal(&multicast_address);
dest_addr = &multicast_address;
}
else {
} else {
dest_addr = ip6_current_src_addr();
}
@ -1012,8 +993,7 @@ nd6_send_rs(struct netif * netif)
/* Link-local source address, or unspecified address? */
if (ip6_addr_isvalid(netif_ip6_addr_state(netif, 0))) {
src_addr = netif_ip6_addr(netif, 0);
}
else {
} else {
src_addr = IP6_ADDR_ANY6;
}
@ -1527,8 +1507,7 @@ nd6_get_next_hop_entry(const ip6_addr_t * ip6addr, struct netif * netif)
if (i >= 0) {
/* found destination entry. make it our new cached index. */
nd6_cached_destination_index = i;
}
else {
} else {
/* Not found. Create a new destination entry. */
i = nd6_new_destination_cache_entry();
if (i >= 0) {
@ -1548,8 +1527,7 @@ nd6_get_next_hop_entry(const ip6_addr_t * ip6addr, struct netif * netif)
/* Destination in local link. */
destination_cache[nd6_cached_destination_index].pmtu = netif->mtu;
ip6_addr_copy(destination_cache[nd6_cached_destination_index].next_hop_addr, destination_cache[nd6_cached_destination_index].destination_addr);
}
else {
} else {
/* We need to select a router. */
i = nd6_select_router(ip6addr, netif);
if (i < 0) {
@ -1581,8 +1559,7 @@ nd6_get_next_hop_entry(const ip6_addr_t * ip6addr, struct netif * netif)
if (i >= 0) {
/* Found a matching record, make it new cached entry. */
nd6_cached_neighbor_index = i;
}
else {
} else {
/* Neighbor not in cache. Make a new entry. */
i = nd6_new_neighbor_cache_entry();
if (i >= 0) {
@ -1839,8 +1816,7 @@ nd6_reachability_hint(const ip6_addr_t * ip6addr)
if (ip6_addr_cmp(ip6addr, &(destination_cache[nd6_cached_destination_index].destination_addr))) {
i = nd6_cached_destination_index;
ND6_STATS_INC(nd6.cachehit);
}
else {
} else {
i = nd6_find_destination_cache_entry(ip6addr);
}
if (i < 0) {
@ -1851,8 +1827,7 @@ nd6_reachability_hint(const ip6_addr_t * ip6addr)
if (ip6_addr_cmp(&(destination_cache[i].next_hop_addr), &(neighbor_cache[nd6_cached_neighbor_index].next_hop_address))) {
i = nd6_cached_neighbor_index;
ND6_STATS_INC(nd6.cachehit);
}
else {
} else {
i = nd6_find_neighbor_cache_entry(&(destination_cache[i].next_hop_addr));
}
if (i < 0) {

View File

@ -525,7 +525,8 @@ netif_set_default(struct netif *netif)
* Bring an interface up, available for processing
* traffic.
*/
void netif_set_up(struct netif *netif)
void
netif_set_up(struct netif *netif)
{
if (!(netif->flags & NETIF_FLAG_UP)) {
netif->flags |= NETIF_FLAG_UP;
@ -581,7 +582,8 @@ netif_issue_reports(struct netif* netif, u8_t report_type)
/**
* Bring an interface down, disabling any traffic processing.
*/
void netif_set_down(struct netif *netif)
void
netif_set_down(struct netif *netif)
{
if (netif->flags & NETIF_FLAG_UP) {
netif->flags &= ~NETIF_FLAG_UP;
@ -600,7 +602,8 @@ void netif_set_down(struct netif *netif)
/**
* Set callback to be called when interface is brought up/down or address is changed while up
*/
void netif_set_status_callback(struct netif *netif, netif_status_callback_fn status_callback)
void
netif_set_status_callback(struct netif *netif, netif_status_callback_fn status_callback)
{
if (netif) {
netif->status_callback = status_callback;
@ -652,7 +655,8 @@ netif_set_link_up(struct netif *netif)
/**
* Called by a driver when its link goes down
*/
void netif_set_link_down(struct netif *netif )
void
netif_set_link_down(struct netif *netif )
{
if (netif->flags & NETIF_FLAG_LINK_UP) {
netif->flags &= ~NETIF_FLAG_LINK_UP;
@ -664,7 +668,8 @@ void netif_set_link_down(struct netif *netif )
/**
* Set callback to be called when link is brought up/down
*/
void netif_set_link_callback(struct netif *netif, netif_status_callback_fn link_callback)
void
netif_set_link_callback(struct netif *netif, netif_status_callback_fn link_callback)
{
if (netif) {
netif->link_callback = link_callback;

View File

@ -49,7 +49,8 @@
struct stats_ lwip_stats;
void stats_init(void)
void
stats_init(void)
{
#ifdef LWIP_DEBUG
#if MEMP_STATS

View File

@ -984,8 +984,7 @@ tcp_slowtmr_start:
++pcb_remove;
++pcb_reset;
}
else if((u32_t)(tcp_ticks - pcb->tmr) >
} else if ((u32_t)(tcp_ticks - pcb->tmr) >
(pcb->keep_idle + pcb->keep_cnt_sent * TCP_KEEP_INTVL(pcb))
/ TCP_SLOW_INTERVAL)
{

View File

@ -761,9 +761,9 @@ tcp_process(struct tcp_pcb *pcb)
/* If there's nothing left to acknowledge, stop the retransmit
timer, otherwise reset it to start again */
if(pcb->unacked == NULL)
if (pcb->unacked == NULL) {
pcb->rtime = -1;
else {
} else {
pcb->rtime = 0;
pcb->nrtx = 0;
}
@ -914,8 +914,7 @@ tcp_oos_insert_segment(struct tcp_seg *cseg, struct tcp_seg *next)
/* received segment overlaps all following segments */
tcp_segs_free(next);
next = NULL;
}
else {
} else {
/* delete some following segments
oos queue may have segments with FIN flag */
while (next &&
@ -1658,7 +1657,8 @@ tcp_receive(struct tcp_pcb *pcb)
}
}
static u8_t tcp_getoptbyte(void)
static u8_t
tcp_getoptbyte(void)
{
if ((tcphdr_opt2 == NULL) || (tcp_optidx < tcphdr_opt1len)) {
u8_t* opts = (u8_t *)tcphdr + TCP_HLEN;

View File

@ -447,8 +447,7 @@ sys_check_timeouts(void)
now = sys_now();
/* this cares for wraparounds */
diff = now - timeouts_last_time;
do
{
do {
#if PBUF_POOL_FREE_OOSEQ
PBUF_CHECK_FREE_OOSEQ();
#endif /* PBUF_POOL_FREE_OOSEQ */