net: core: Drop NET_ASSERT_INFO() macro
A single assert macro can serve a purpose here. Signed-off-by: Oleg Zhurakivskyy <oleg.zhurakivskyy@intel.com>
This commit is contained in:
parent
fe7d6e2eae
commit
8a77b53053
|
@ -47,8 +47,7 @@ extern "C" {
|
|||
#define NET_WARN(fmt, ...) LOG_WRN(fmt, ##__VA_ARGS__)
|
||||
#define NET_INFO(fmt, ...) LOG_INF(fmt, ##__VA_ARGS__)
|
||||
|
||||
#define NET_ASSERT(cond) __ASSERT_NO_MSG(cond)
|
||||
#define NET_ASSERT_INFO(cond, fmt, ...) __ASSERT(cond, fmt, ##__VA_ARGS__)
|
||||
#define NET_ASSERT(cond, ...) __ASSERT(cond, "" __VA_ARGS__)
|
||||
|
||||
/** @endcond */
|
||||
|
||||
|
|
|
@ -268,8 +268,8 @@ static u32_t dhcpv4_send_request(struct net_if *iface)
|
|||
case NET_DHCPV4_SELECTING:
|
||||
case NET_DHCPV4_BOUND:
|
||||
/* Not possible */
|
||||
NET_ASSERT_INFO(0, "Invalid state %s",
|
||||
net_dhcpv4_state_name(iface->config.dhcpv4.state));
|
||||
NET_ASSERT(0, "Invalid state %s",
|
||||
net_dhcpv4_state_name(iface->config.dhcpv4.state));
|
||||
break;
|
||||
case NET_DHCPV4_REQUESTING:
|
||||
with_server_id = true;
|
||||
|
|
|
@ -1410,7 +1410,7 @@ static void ipv6_nd_reachable_timeout(struct k_work *work)
|
|||
|
||||
switch (data->state) {
|
||||
case NET_IPV6_NBR_STATE_STATIC:
|
||||
NET_ASSERT_INFO(false, "Static entry shall never timeout");
|
||||
NET_ASSERT(false, "Static entry shall never timeout");
|
||||
break;
|
||||
|
||||
case NET_IPV6_NBR_STATE_INCOMPLETE:
|
||||
|
@ -1489,7 +1489,7 @@ void net_ipv6_nbr_set_reachable_timer(struct net_if *iface,
|
|||
|
||||
time = net_if_ipv6_get_reachable_time(iface);
|
||||
|
||||
NET_ASSERT_INFO(time, "Zero reachable timeout!");
|
||||
NET_ASSERT(time, "Zero reachable timeout!");
|
||||
|
||||
NET_DBG("Starting reachable timer nbr %p data %p time %d ms",
|
||||
nbr, net_ipv6_nbr_data(nbr), time);
|
||||
|
|
|
@ -179,9 +179,9 @@ struct net_nbr *net_nbr_lookup(struct net_nbr_table *table,
|
|||
|
||||
struct net_linkaddr_storage *net_nbr_get_lladdr(u8_t idx)
|
||||
{
|
||||
NET_ASSERT_INFO(idx < CONFIG_NET_IPV6_MAX_NEIGHBORS,
|
||||
"idx %d >= max %d", idx,
|
||||
CONFIG_NET_IPV6_MAX_NEIGHBORS);
|
||||
NET_ASSERT(idx < CONFIG_NET_IPV6_MAX_NEIGHBORS,
|
||||
"idx %d >= max %d", idx,
|
||||
CONFIG_NET_IPV6_MAX_NEIGHBORS);
|
||||
|
||||
return &net_neighbor_lladdr[idx].lladdr;
|
||||
}
|
||||
|
|
|
@ -891,11 +891,10 @@ int net_context_connect(struct net_context *context,
|
|||
}
|
||||
|
||||
if (addr->sa_family != net_context_get_family(context)) {
|
||||
NET_ASSERT_INFO(addr->sa_family == \
|
||||
net_context_get_family(context),
|
||||
"Family mismatch %d should be %d",
|
||||
addr->sa_family,
|
||||
net_context_get_family(context));
|
||||
NET_ASSERT(addr->sa_family == net_context_get_family(context),
|
||||
"Family mismatch %d should be %d",
|
||||
addr->sa_family,
|
||||
net_context_get_family(context));
|
||||
ret = -EINVAL;
|
||||
goto unlock;
|
||||
}
|
||||
|
|
|
@ -59,8 +59,8 @@ static inline struct net_route_nexthop *net_nexthop_data(struct net_nbr *nbr)
|
|||
|
||||
static inline struct net_nbr *get_nexthop_nbr(struct net_nbr *start, int idx)
|
||||
{
|
||||
NET_ASSERT_INFO(idx < CONFIG_NET_MAX_NEXTHOPS, "idx %d >= max %d",
|
||||
idx, CONFIG_NET_MAX_NEXTHOPS);
|
||||
NET_ASSERT(idx < CONFIG_NET_MAX_NEXTHOPS, "idx %d >= max %d",
|
||||
idx, CONFIG_NET_MAX_NEXTHOPS);
|
||||
|
||||
return (struct net_nbr *)((u8_t *)start +
|
||||
((sizeof(struct net_nbr) + start->size) * idx));
|
||||
|
@ -212,9 +212,9 @@ static struct net_nbr *nbr_nexthop_get(struct net_if *iface,
|
|||
return NULL;
|
||||
}
|
||||
|
||||
NET_ASSERT_INFO(nbr->idx != NET_NBR_LLADDR_UNKNOWN,
|
||||
"Nexthop %s not in neighbor cache!",
|
||||
log_strdup(net_sprint_ipv6_addr(addr)));
|
||||
NET_ASSERT(nbr->idx != NET_NBR_LLADDR_UNKNOWN,
|
||||
"Nexthop %s not in neighbor cache!",
|
||||
log_strdup(net_sprint_ipv6_addr(addr)));
|
||||
|
||||
net_nbr_ref(nbr);
|
||||
|
||||
|
@ -242,7 +242,7 @@ static int nbr_nexthop_put(struct net_nbr *nbr)
|
|||
if (CONFIG_NET_ROUTE_LOG_LEVEL >= LOG_LEVEL_DBG) { \
|
||||
struct in6_addr *naddr = net_route_get_nexthop(route); \
|
||||
\
|
||||
NET_ASSERT_INFO(naddr, "Unknown nexthop address"); \
|
||||
NET_ASSERT(naddr, "Unknown nexthop address"); \
|
||||
\
|
||||
NET_DBG("%s route to %s via %s (iface %p)", str, \
|
||||
log_strdup(net_sprint_ipv6_addr(dst)), \
|
||||
|
@ -695,9 +695,9 @@ bool net_route_mcast_del(struct net_route_entry_mcast *route)
|
|||
return false;
|
||||
}
|
||||
|
||||
NET_ASSERT_INFO(route->is_used,
|
||||
"Multicast route %p to %s was already removed", route,
|
||||
log_strdup(net_sprint_ipv6_addr(&route->group)));
|
||||
NET_ASSERT(route->is_used,
|
||||
"Multicast route %p to %s was already removed", route,
|
||||
log_strdup(net_sprint_ipv6_addr(&route->group)));
|
||||
|
||||
route->is_used = false;
|
||||
|
||||
|
|
|
@ -1725,7 +1725,7 @@ int net_tcp_get(struct net_context *context)
|
|||
{
|
||||
context->tcp = net_tcp_alloc(context);
|
||||
if (!context->tcp) {
|
||||
NET_ASSERT_INFO(context->tcp, "Cannot allocate TCP context");
|
||||
NET_ASSERT(context->tcp, "Cannot allocate TCP context");
|
||||
return -ENOBUFS;
|
||||
}
|
||||
|
||||
|
@ -2481,8 +2481,8 @@ NET_CONN_CB(tcp_syn_rcvd)
|
|||
} else if (new_context->remote.sa_family == AF_INET6) {
|
||||
addrlen = sizeof(struct sockaddr_in6);
|
||||
} else {
|
||||
NET_ASSERT_INFO(false, "Invalid protocol family %d",
|
||||
new_context->remote.sa_family);
|
||||
NET_ASSERT(false, "Invalid protocol family %d",
|
||||
new_context->remote.sa_family);
|
||||
net_context_unref(new_context);
|
||||
return NET_DROP;
|
||||
}
|
||||
|
|
|
@ -387,8 +387,7 @@ static void tcp_send_process(struct k_timer *timer)
|
|||
|
||||
static void tcp_send_timer_cancel(struct tcp *conn)
|
||||
{
|
||||
NET_ASSERT_INFO(conn->in_retransmission == true,
|
||||
"Not in retransmission");
|
||||
NET_ASSERT(conn->in_retransmission == true, "Not in retransmission");
|
||||
|
||||
k_timer_stop(&conn->send_timer);
|
||||
|
||||
|
@ -434,7 +433,7 @@ static const char *tcp_state_to_str(enum tcp_state state, bool prefix)
|
|||
_(TCP_CLOSED);
|
||||
}
|
||||
#undef _
|
||||
NET_ASSERT_INFO(s, "Invalid TCP state: %u", state);
|
||||
NET_ASSERT(s, "Invalid TCP state: %u", state);
|
||||
out:
|
||||
return prefix ? s : (s + 4);
|
||||
}
|
||||
|
@ -445,7 +444,7 @@ static void tcp_win_append(struct tcp_win *w, const char *name,
|
|||
struct net_buf *buf = tcp_nbuf_alloc(&tcp_nbufs, len);
|
||||
size_t prev_len = w->len;
|
||||
|
||||
NET_ASSERT_INFO(len, "Zero length data");
|
||||
NET_ASSERT(len, "Zero length data");
|
||||
|
||||
memcpy(net_buf_add(buf, len), data, len);
|
||||
|
||||
|
@ -476,7 +475,7 @@ static struct net_buf *tcp_win_peek(struct tcp_win *w, const char *name,
|
|||
struct net_buf, user_data);
|
||||
}
|
||||
|
||||
NET_ASSERT_INFO(len == 0, "Unfulfilled request, len: %zu", len);
|
||||
NET_ASSERT(len == 0, "Unfulfilled request, len: %zu", len);
|
||||
|
||||
NET_DBG("%s len=%zu", name, net_buf_frags_len(out));
|
||||
|
||||
|
@ -1104,8 +1103,8 @@ next_state:
|
|||
case TCP_FIN_WAIT1:
|
||||
case TCP_FIN_WAIT2:
|
||||
default:
|
||||
NET_ASSERT_INFO(false, "%s is unimplemented",
|
||||
tcp_state_to_str(conn->state, true));
|
||||
NET_ASSERT(false, "%s is unimplemented",
|
||||
tcp_state_to_str(conn->state, true));
|
||||
}
|
||||
|
||||
if (fl) {
|
||||
|
@ -1412,10 +1411,10 @@ static struct net_buf *tcp_win_pop(struct tcp_win *w, const char *name,
|
|||
{
|
||||
struct net_buf *buf, *out = NULL;
|
||||
|
||||
NET_ASSERT_INFO(len, "Invalid request, len: %zu", len);
|
||||
NET_ASSERT(len, "Invalid request, len: %zu", len);
|
||||
|
||||
NET_ASSERT_INFO(len <= w->len, "Insufficient window length, "
|
||||
"len: %zu, req: %zu", w->len, len);
|
||||
NET_ASSERT(len <= w->len, "Insufficient window length, "
|
||||
"len: %zu, req: %zu", w->len, len);
|
||||
while (len) {
|
||||
|
||||
buf = tcp_slist(&w->bufs, get, struct net_buf, user_data);
|
||||
|
@ -1427,7 +1426,7 @@ static struct net_buf *tcp_win_pop(struct tcp_win *w, const char *name,
|
|||
len -= buf->len;
|
||||
}
|
||||
|
||||
NET_ASSERT_INFO(len == 0, "Unfulfilled request, len: %zu", len);
|
||||
NET_ASSERT(len == 0, "Unfulfilled request, len: %zu", len);
|
||||
|
||||
NET_DBG("%s len=%zu", name, net_buf_frags_len(out));
|
||||
|
||||
|
@ -1440,7 +1439,7 @@ static ssize_t tcp_recv(int fd, void *buf, size_t len, int flags)
|
|||
ssize_t bytes_received = conn->rcv->len;
|
||||
struct net_buf *data = tcp_win_pop(conn->rcv, "RCV", bytes_received);
|
||||
|
||||
NET_ASSERT_INFO(bytes_received <= len, "Unimplemented");
|
||||
NET_ASSERT(bytes_received <= len, "Unimplemented");
|
||||
|
||||
net_buf_linearize(buf, len, data, 0, net_buf_frags_len(data));
|
||||
|
||||
|
@ -1620,7 +1619,7 @@ bool tp_input(struct net_pkt *pkt)
|
|||
tcp_step();
|
||||
break;
|
||||
default:
|
||||
NET_ASSERT_INFO(false, "Unimplemented tp command: %s", tp->msg);
|
||||
NET_ASSERT(false, "Unimplemented tp command: %s", tp->msg);
|
||||
}
|
||||
|
||||
if (json_len) {
|
||||
|
|
|
@ -488,7 +488,7 @@ static void test_send_ns_extra_options(void)
|
|||
pkt = net_pkt_alloc_with_buffer(iface, sizeof(icmpv6_ns_invalid),
|
||||
AF_UNSPEC, 0, K_FOREVER);
|
||||
|
||||
NET_ASSERT_INFO(pkt, "Out of TX packets");
|
||||
NET_ASSERT(pkt, "Out of TX packets");
|
||||
|
||||
net_pkt_write(pkt, icmpv6_ns_invalid, sizeof(icmpv6_ns_invalid));
|
||||
net_pkt_lladdr_clear(pkt);
|
||||
|
@ -511,7 +511,7 @@ static void test_send_ns_no_options(void)
|
|||
pkt = net_pkt_alloc_with_buffer(iface, sizeof(icmpv6_ns_no_sllao),
|
||||
AF_UNSPEC, 0, K_FOREVER);
|
||||
|
||||
NET_ASSERT_INFO(pkt, "Out of TX packets");
|
||||
NET_ASSERT(pkt, "Out of TX packets");
|
||||
|
||||
net_pkt_write(pkt, icmpv6_ns_no_sllao, sizeof(icmpv6_ns_no_sllao));
|
||||
net_pkt_lladdr_clear(pkt);
|
||||
|
@ -627,7 +627,7 @@ static void test_hbho_message(void)
|
|||
pkt = net_pkt_alloc_with_buffer(iface, sizeof(ipv6_hbho),
|
||||
AF_UNSPEC, 0, K_FOREVER);
|
||||
|
||||
NET_ASSERT_INFO(pkt, "Out of TX packets");
|
||||
NET_ASSERT(pkt, "Out of TX packets");
|
||||
|
||||
net_pkt_write(pkt, ipv6_hbho, sizeof(ipv6_hbho));
|
||||
net_pkt_lladdr_clear(pkt);
|
||||
|
@ -678,7 +678,7 @@ static void test_hbho_message_1(void)
|
|||
pkt = net_pkt_alloc_with_buffer(iface, sizeof(ipv6_hbho_1),
|
||||
AF_UNSPEC, 0, K_FOREVER);
|
||||
|
||||
NET_ASSERT_INFO(pkt, "Out of TX packets");
|
||||
NET_ASSERT(pkt, "Out of TX packets");
|
||||
|
||||
net_pkt_write(pkt, ipv6_hbho_1, sizeof(ipv6_hbho_1));
|
||||
|
||||
|
@ -738,7 +738,7 @@ static void test_hbho_message_2(void)
|
|||
pkt = net_pkt_alloc_with_buffer(iface, sizeof(ipv6_hbho_2),
|
||||
AF_UNSPEC, 0, K_FOREVER);
|
||||
|
||||
NET_ASSERT_INFO(pkt, "Out of TX packets");
|
||||
NET_ASSERT(pkt, "Out of TX packets");
|
||||
|
||||
|
||||
net_pkt_write(pkt, ipv6_hbho_2, sizeof(ipv6_hbho_2));
|
||||
|
@ -901,7 +901,7 @@ static void test_hbho_message_3(void)
|
|||
pkt = net_pkt_alloc_with_buffer(iface, sizeof(ipv6_hbho_3),
|
||||
AF_UNSPEC, 0, K_FOREVER);
|
||||
|
||||
NET_ASSERT_INFO(pkt, "Out of TX packets");
|
||||
NET_ASSERT(pkt, "Out of TX packets");
|
||||
|
||||
net_pkt_write(pkt, ipv6_hbho_3, sizeof(ipv6_hbho_3));
|
||||
net_pkt_lladdr_clear(pkt);
|
||||
|
|
Loading…
Reference in a new issue