Make functions static where applicable, add default cases to switches where applicable, prevent old-style function prototypes (without arguments)

This commit is contained in:
goldsimon 2010-03-26 14:07:05 +00:00
parent 8bbe3d2fe0
commit 46b7bd6ec3
5 changed files with 56 additions and 14 deletions

View File

@ -653,7 +653,7 @@ netconn_free(struct netconn *conn)
* @bytes_drained bytes drained from recvmbox * @bytes_drained bytes drained from recvmbox
* @accepts_drained pending connections drained from acceptmbox * @accepts_drained pending connections drained from acceptmbox
*/ */
void static void
netconn_drain(struct netconn *conn) netconn_drain(struct netconn *conn)
{ {
void *mem; void *mem;
@ -1343,6 +1343,9 @@ do_getaddr(struct api_msg_msg *msg)
*(msg->msg.ad.port) = (msg->msg.ad.local?msg->conn->pcb.tcp->local_port:msg->conn->pcb.tcp->remote_port); *(msg->msg.ad.port) = (msg->msg.ad.local?msg->conn->pcb.tcp->local_port:msg->conn->pcb.tcp->remote_port);
break; break;
#endif /* LWIP_TCP */ #endif /* LWIP_TCP */
default:
LWIP_ASSERT("invalid netconn_type", 0);
break;
} }
} else { } else {
msg->err = ERR_CONN; msg->err = ERR_CONN;

View File

@ -1643,6 +1643,9 @@ lwip_getsockopt_internal(void *arg)
*(int*)optval = (udp_flags(sock->conn->pcb.udp) & UDP_FLAGS_NOCHKSUM) ? 1 : 0; *(int*)optval = (udp_flags(sock->conn->pcb.udp) & UDP_FLAGS_NOCHKSUM) ? 1 : 0;
break; break;
#endif /* LWIP_UDP*/ #endif /* LWIP_UDP*/
default:
LWIP_ASSERT("unhandled optname", 0);
break;
} /* switch (optname) */ } /* switch (optname) */
break; break;
@ -1671,6 +1674,9 @@ lwip_getsockopt_internal(void *arg)
s, *(u32_t *)optval)); s, *(u32_t *)optval));
break; break;
#endif /* LWIP_IGMP */ #endif /* LWIP_IGMP */
default:
LWIP_ASSERT("unhandled optname", 0);
break;
} /* switch (optname) */ } /* switch (optname) */
break; break;
@ -1706,7 +1712,9 @@ lwip_getsockopt_internal(void *arg)
s, *(int *)optval)); s, *(int *)optval));
break; break;
#endif /* LWIP_TCP_KEEPALIVE */ #endif /* LWIP_TCP_KEEPALIVE */
default:
LWIP_ASSERT("unhandled optname", 0);
break;
} /* switch (optname) */ } /* switch (optname) */
break; break;
#endif /* LWIP_TCP */ #endif /* LWIP_TCP */
@ -1724,9 +1732,15 @@ lwip_getsockopt_internal(void *arg)
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_UDPLITE, UDPLITE_RECV_CSCOV) = %d\n", LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_getsockopt(%d, IPPROTO_UDPLITE, UDPLITE_RECV_CSCOV) = %d\n",
s, (*(int*)optval)) ); s, (*(int*)optval)) );
break; break;
default:
LWIP_ASSERT("unhandled optname", 0);
break;
} /* switch (optname) */ } /* switch (optname) */
break; break;
#endif /* LWIP_UDP */ #endif /* LWIP_UDP */
default:
LWIP_ASSERT("unhandled level", 0);
break;
} /* switch (level) */ } /* switch (level) */
sys_sem_signal(&sock->conn->op_completed); sys_sem_signal(&sock->conn->op_completed);
} }
@ -1993,6 +2007,9 @@ lwip_setsockopt_internal(void *arg)
} }
break; break;
#endif /* LWIP_UDP */ #endif /* LWIP_UDP */
default:
LWIP_ASSERT("unhandled optname", 0);
break;
} /* switch (optname) */ } /* switch (optname) */
break; break;
@ -2036,6 +2053,9 @@ lwip_setsockopt_internal(void *arg)
} }
break; break;
#endif /* LWIP_IGMP */ #endif /* LWIP_IGMP */
default:
LWIP_ASSERT("unhandled optname", 0);
break;
} /* switch (optname) */ } /* switch (optname) */
break; break;
@ -2075,7 +2095,9 @@ lwip_setsockopt_internal(void *arg)
s, sock->conn->pcb.tcp->keep_cnt)); s, sock->conn->pcb.tcp->keep_cnt));
break; break;
#endif /* LWIP_TCP_KEEPALIVE */ #endif /* LWIP_TCP_KEEPALIVE */
default:
LWIP_ASSERT("unhandled optname", 0);
break;
} /* switch (optname) */ } /* switch (optname) */
break; break;
#endif /* LWIP_TCP*/ #endif /* LWIP_TCP*/
@ -2103,9 +2125,15 @@ lwip_setsockopt_internal(void *arg)
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_UDPLITE, UDPLITE_RECV_CSCOV) -> %d\n", LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_setsockopt(%d, IPPROTO_UDPLITE, UDPLITE_RECV_CSCOV) -> %d\n",
s, (*(int*)optval)) ); s, (*(int*)optval)) );
break; break;
default:
LWIP_ASSERT("unhandled optname", 0);
break;
} /* switch (optname) */ } /* switch (optname) */
break; break;
#endif /* LWIP_UDP */ #endif /* LWIP_UDP */
default:
LWIP_ASSERT("unhandled level", 0);
break;
} /* switch (level) */ } /* switch (level) */
sys_sem_signal(&sock->conn->op_completed); sys_sem_signal(&sock->conn->op_completed);
} }
@ -2193,6 +2221,9 @@ lwip_fcntl(int s, int cmd, int val)
ret = 0; ret = 0;
} }
break; break;
default:
LWIP_DEBUGF(SOCKETS_DEBUG, ("lwip_fcntl(%d, UNIMPL: %d, %d)\n", s, cmd, val));
break;
} }
return ret; return ret;
} }

View File

@ -163,8 +163,9 @@ ipaddr_aton(const char *cp, ip_addr_t *addr)
* a.b.c (with c treated as 16 bits) * a.b.c (with c treated as 16 bits)
* a.b (with b treated as 24 bits) * a.b (with b treated as 24 bits)
*/ */
if (pp >= parts + 3) if (pp >= parts + 3) {
return (0); return (0);
}
*pp++ = val; *pp++ = val;
c = *++cp; c = *++cp;
} else } else
@ -173,8 +174,9 @@ ipaddr_aton(const char *cp, ip_addr_t *addr)
/* /*
* Check for trailing characters. * Check for trailing characters.
*/ */
if (c != '\0' && !isspace(c)) if (c != '\0' && !isspace(c)) {
return (0); return (0);
}
/* /*
* Concoct the address according to * Concoct the address according to
* the number of parts specified. * the number of parts specified.
@ -188,22 +190,28 @@ ipaddr_aton(const char *cp, ip_addr_t *addr)
break; break;
case 2: /* a.b -- 8.24 bits */ case 2: /* a.b -- 8.24 bits */
if (val > 0xffffffUL) if (val > 0xffffffUL) {
return (0); return (0);
}
val |= parts[0] << 24; val |= parts[0] << 24;
break; break;
case 3: /* a.b.c -- 8.8.16 bits */ case 3: /* a.b.c -- 8.8.16 bits */
if (val > 0xffff) if (val > 0xffff) {
return (0); return (0);
}
val |= (parts[0] << 24) | (parts[1] << 16); val |= (parts[0] << 24) | (parts[1] << 16);
break; break;
case 4: /* a.b.c.d -- 8.8.8.8 bits */ case 4: /* a.b.c.d -- 8.8.8.8 bits */
if (val > 0xff) if (val > 0xff) {
return (0); return (0);
}
val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8); val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
break; break;
default:
LWIP_ASSERT("unhandled", 0);
break;
} }
if (addr) { if (addr) {
ip4_addr_set_u32(addr, htonl(val)); ip4_addr_set_u32(addr, htonl(val));

View File

@ -48,11 +48,11 @@
struct stats_ lwip_stats; struct stats_ lwip_stats;
void stats_init() void stats_init(void)
{ {
#ifdef LWIP_DEBUG #ifdef LWIP_DEBUG
#if MEMP_STATS #if MEMP_STATS
char * memp_names[] = { const char * memp_names[] = {
#define LWIP_MEMPOOL(name,num,size,desc) desc, #define LWIP_MEMPOOL(name,num,size,desc) desc,
#include "lwip/memp_std.h" #include "lwip/memp_std.h"
}; };

View File

@ -148,7 +148,7 @@ struct stats_ {
extern struct stats_ lwip_stats; extern struct stats_ lwip_stats;
void stats_init(); void stats_init(void);
#define STATS_INC(x) ++lwip_stats.x #define STATS_INC(x) ++lwip_stats.x
#define STATS_DEC(x) --lwip_stats.x #define STATS_DEC(x) --lwip_stats.x
@ -157,7 +157,7 @@ void stats_init();
lwip_stats.x.max = lwip_stats.x.used; \ lwip_stats.x.max = lwip_stats.x.used; \
} \ } \
} while(0) } while(0)
#else #else /* LWIP_STATS */
#define stats_init() #define stats_init()
#define STATS_INC(x) #define STATS_INC(x)
#define STATS_DEC(x) #define STATS_DEC(x)
@ -276,7 +276,7 @@ void stats_display_igmp(struct stats_igmp *igmp);
void stats_display_mem(struct stats_mem *mem, char *name); void stats_display_mem(struct stats_mem *mem, char *name);
void stats_display_memp(struct stats_mem *mem, int index); void stats_display_memp(struct stats_mem *mem, int index);
void stats_display_sys(struct stats_sys *sys); void stats_display_sys(struct stats_sys *sys);
#else #else /* LWIP_STATS_DISPLAY */
#define stats_display() #define stats_display()
#define stats_display_proto(proto, name) #define stats_display_proto(proto, name)
#define stats_display_igmp(igmp) #define stats_display_igmp(igmp)