From 9216e6c47d45714581dde33360127b28b2c8b158 Mon Sep 17 00:00:00 2001 From: Flavio Santes Date: Tue, 20 Dec 2016 13:15:00 -0600 Subject: [PATCH] net: Add ARG_UNUSED This patch adds the ARG_UNUSED macros to some function arguments to avoid compiler warnings. Change-Id: Iae2cd3018c9442ffa9268fdfd33eb9a21f55087c Signed-off-by: Flavio Santes --- include/net/net_ip.h | 2 ++ subsys/net/ip/icmpv4.c | 5 +++- subsys/net/ip/icmpv6.c | 2 ++ subsys/net/ip/ipv6.c | 2 ++ subsys/net/ip/nbr.c | 2 ++ subsys/net/ip/net_context.c | 2 ++ subsys/net/ip/net_private.h | 12 +++++++++ subsys/net/ip/net_shell.c | 50 ++++++++++++++++++++++++++++++------- subsys/net/ip/tcp.c | 4 +++ subsys/net/ip/utils.c | 2 ++ 10 files changed, 73 insertions(+), 10 deletions(-) diff --git a/include/net/net_ip.h b/include/net/net_ip.h index a948b4130cd..bdd3178b9c3 100644 --- a/include/net/net_ip.h +++ b/include/net/net_ip.h @@ -222,6 +222,8 @@ static inline char *net_addr_type2str(enum net_addr_type type) #else static inline char *net_addr_type2str(enum net_addr_type type) { + ARG_UNUSED(type); + return NULL; } #endif diff --git a/subsys/net/ip/icmpv4.c b/subsys/net/ip/icmpv4.c index f961dd539d7..f0d53c04aa2 100644 --- a/subsys/net/ip/icmpv4.c +++ b/subsys/net/ip/icmpv4.c @@ -172,6 +172,9 @@ int net_icmpv4_send_echo_request(struct net_if *iface, enum net_verdict net_icmpv4_input(struct net_buf *buf, uint16_t len, uint8_t type, uint8_t code) { + ARG_UNUSED(code); + ARG_UNUSED(len); + switch (type) { case NET_ICMPV4_ECHO_REQUEST: return handle_echo_request(buf); @@ -184,7 +187,7 @@ int net_icmpv4_send_error(struct net_buf *orig, uint8_t type, uint8_t code) { struct net_buf *buf, *frag; struct net_if *iface = net_nbuf_iface(orig); - int extra_len, reserve; + size_t extra_len, reserve; struct in_addr addr, *src, *dst; if (NET_IPV4_BUF(orig)->proto == IPPROTO_ICMP) { diff --git a/subsys/net/ip/icmpv6.c b/subsys/net/ip/icmpv6.c index c394ef41496..27d53b0f003 100644 --- a/subsys/net/ip/icmpv6.c +++ b/subsys/net/ip/icmpv6.c @@ -358,6 +358,8 @@ enum net_verdict net_icmpv6_input(struct net_buf *buf, uint16_t len, sys_snode_t *node; struct net_icmpv6_handler *cb; + ARG_UNUSED(len); + SYS_SLIST_FOR_EACH_NODE(&handlers, node) { cb = (struct net_icmpv6_handler *)node; diff --git a/subsys/net/ip/ipv6.c b/subsys/net/ip/ipv6.c index 93713465dfb..3981b5186e4 100644 --- a/subsys/net/ip/ipv6.c +++ b/subsys/net/ip/ipv6.c @@ -1115,6 +1115,8 @@ static inline bool handle_na_neighbor(struct net_buf *buf, struct net_linkaddr_storage *cached_lladdr; struct net_buf *pending; + ARG_UNUSED(hdr); + nbr = nbr_lookup(&net_neighbor.table, net_nbuf_iface(buf), &NET_ICMPV6_NS_BUF(buf)->tgt); diff --git a/subsys/net/ip/nbr.c b/subsys/net/ip/nbr.c index 094225d0b17..ccde9cc1786 100644 --- a/subsys/net/ip/nbr.c +++ b/subsys/net/ip/nbr.c @@ -145,6 +145,8 @@ int net_nbr_link(struct net_nbr *nbr, struct net_if *iface, int net_nbr_unlink(struct net_nbr *nbr, struct net_linkaddr *lladdr) { + ARG_UNUSED(lladdr); + if (nbr->idx == NET_NBR_LLADDR_UNKNOWN) { return -EALREADY; } diff --git a/subsys/net/ip/net_context.c b/subsys/net/ip/net_context.c index a55b01ffc72..c56e1c0d537 100644 --- a/subsys/net/ip/net_context.c +++ b/subsys/net/ip/net_context.c @@ -1832,6 +1832,8 @@ static int recv_udp(struct net_context *context, uint16_t lport = 0; int ret; + ARG_UNUSED(timeout); + if (context->conn_handler) { net_conn_unregister(context->conn_handler); context->conn_handler = NULL; diff --git a/subsys/net/ip/net_private.h b/subsys/net/ip/net_private.h index 1080377903e..d8f9762c16c 100644 --- a/subsys/net/ip/net_private.h +++ b/subsys/net/ip/net_private.h @@ -162,26 +162,38 @@ static inline void net_hexdump_frags(const char *str, struct net_buf *buf) static inline char *net_sprint_ll_addr(const uint8_t *ll, uint8_t ll_len) { + ARG_UNUSED(ll); + ARG_UNUSED(ll_len); + return NULL; } static inline char *net_sprint_ip_addr_ptr(const uint8_t *ptr, uint8_t len) { + ARG_UNUSED(ptr); + ARG_UNUSED(len); + return NULL; } static inline char *net_sprint_ipv6_addr(const struct in6_addr *addr) { + ARG_UNUSED(addr); + return NULL; } static inline char *net_sprint_ipv4_addr(const struct in_addr *addr) { + ARG_UNUSED(addr); + return NULL; } static inline char *net_sprint_ip_addr(const struct net_addr *addr) { + ARG_UNUSED(addr); + return NULL; } diff --git a/subsys/net/ip/net_shell.c b/subsys/net/ip/net_shell.c index 84fd1bb5b11..0fe83f9c6b0 100644 --- a/subsys/net/ip/net_shell.c +++ b/subsys/net/ip/net_shell.c @@ -107,6 +107,8 @@ static inline const char *dhcpv4state2str(enum net_dhcpv4_state state) static void tx_stack(struct net_if *iface, unsigned char *stack, size_t stack_size) { + ARG_UNUSED(iface); + #if defined(CONFIG_INIT_STACKS) unsigned int stack_offset, pcnt, unused; @@ -118,6 +120,9 @@ static void tx_stack(struct net_if *iface, unsigned char *stack, stack_size + stack_offset, unused, stack_size - unused, stack_size, pcnt); #else + ARG_UNUSED(stack_size); + ARG_UNUSED(stack); + printf("TX stack usage not available.\n"); #endif } @@ -132,6 +137,8 @@ static void iface_cb(struct net_if *iface, void *user_data) struct net_if_mcast_addr *mcast; int i, count; + ARG_UNUSED(user_data); + printf("Interface %p\n", iface); printf("====================\n"); @@ -339,6 +346,8 @@ static void route_cb(struct net_route_entry *entry, void *user_data) static void iface_per_route_cb(struct net_if *iface, void *user_data) { + ARG_UNUSED(user_data); + net_route_foreach(route_cb, iface); } #endif /* CONFIG_NET_ROUTE */ @@ -535,6 +544,9 @@ static int shell_cmd_conn(int argc, char *argv[]) { int count = 0; + ARG_UNUSED(argc); + ARG_UNUSED(argv); + printf("Context \tLocal \tRemote \tIface \t" "Flags\n"); @@ -562,6 +574,9 @@ static int shell_cmd_conn(int argc, char *argv[]) static int shell_cmd_iface(int argc, char *argv[]) { + ARG_UNUSED(argc); + ARG_UNUSED(argv); + net_if_foreach(iface_cb, NULL); return 0; @@ -572,6 +587,9 @@ static int shell_cmd_mem(int argc, char *argv[]) size_t tx_size, rx_size, data_size; int tx, rx, data; + ARG_UNUSED(argc); + ARG_UNUSED(argv); + net_nbuf_get_info(&tx_size, &rx_size, &data_size, &tx, &rx, &data); printf("Fragment length %d bytes\n", CONFIG_NET_NBUF_DATA_SIZE); @@ -613,6 +631,8 @@ static int shell_cmd_ping(int argc, char *argv[]) char *host; int ret; + ARG_UNUSED(argc); + if (!strcmp(argv[0], "ping")) { host = argv[1]; } else { @@ -686,6 +706,9 @@ static int shell_cmd_ping(int argc, char *argv[]) static int shell_cmd_route(int argc, char *argv[]) { + ARG_UNUSED(argc); + ARG_UNUSED(argv); + #if defined(CONFIG_NET_ROUTE) net_if_foreach(iface_per_route_cb, NULL); #else @@ -706,6 +729,9 @@ static int shell_cmd_stacks(int argc, char *argv[]) #endif struct net_stack_info *info; + ARG_UNUSED(argc); + ARG_UNUSED(argv); + for (info = __net_stack_start; info != __net_stack_end; info++) { net_analyze_stack_get_values(info->stack, info->size, &stack_offset, &pcnt, &unused); @@ -727,6 +753,9 @@ static int shell_cmd_stacks(int argc, char *argv[]) static int shell_cmd_stats(int argc, char *argv[]) { + ARG_UNUSED(argc); + ARG_UNUSED(argv); + #if defined(CONFIG_NET_STATISTICS) net_print_statistics(); #else @@ -738,6 +767,9 @@ static int shell_cmd_stats(int argc, char *argv[]) static int shell_cmd_help(int argc, char *argv[]) { + ARG_UNUSED(argc); + ARG_UNUSED(argv); + /* Keep the commands in alphabetical order */ printf("net conn\n\tPrint information about network connections\n"); printf("net iface\n\tPrint information about network interfaces\n"); @@ -751,15 +783,15 @@ static int shell_cmd_help(int argc, char *argv[]) static struct shell_cmd net_commands[] = { /* Keep the commands in alphabetical order */ - { "conn", shell_cmd_conn }, - { "help", shell_cmd_help }, - { "iface", shell_cmd_iface }, - { "mem", shell_cmd_mem }, - { "ping", shell_cmd_ping }, - { "route", shell_cmd_route }, - { "stacks", shell_cmd_stacks }, - { "stats", shell_cmd_stats }, - { NULL, NULL } + { "conn", shell_cmd_conn, NULL }, + { "help", shell_cmd_help, NULL }, + { "iface", shell_cmd_iface, NULL }, + { "mem", shell_cmd_mem, NULL }, + { "ping", shell_cmd_ping, NULL }, + { "route", shell_cmd_route, NULL }, + { "stacks", shell_cmd_stacks, NULL }, + { "stats", shell_cmd_stats, NULL }, + { NULL, NULL, NULL } }; void net_shell_init(void) diff --git a/subsys/net/ip/tcp.c b/subsys/net/ip/tcp.c index aeb5ae1ef99..a13ea39d074 100644 --- a/subsys/net/ip/tcp.c +++ b/subsys/net/ip/tcp.c @@ -320,6 +320,8 @@ static struct net_buf *prepare_segment(struct net_tcp *tcp, static inline uint32_t get_recv_wnd(struct net_tcp *tcp) { + ARG_UNUSED(tcp); + /* We don't queue received data inside the stack, we hand off * packets to synchronous callbacks (who can queue if they * want, but it's not our business). So the available window @@ -575,6 +577,8 @@ const char * const net_tcp_state_str(enum net_tcp_state state) case NET_TCP_CLOSING: return "CLOSING"; } +#else + ARG_UNUSED(state); #endif return ""; diff --git a/subsys/net/ip/utils.c b/subsys/net/ip/utils.c index 0a145472d17..947af0ad270 100644 --- a/subsys/net/ip/utils.c +++ b/subsys/net/ip/utils.c @@ -398,6 +398,8 @@ static inline uint16_t calc_chksum_buf(uint16_t sum, struct net_buf *buf, int16_t len = frag->len - proto_len; uint8_t *ptr = frag->data + proto_len; + ARG_UNUSED(upper_layer_len); + if (len < 0) { NET_DBG("1st fragment len %u < IP header len %u", frag->len, proto_len);