net: Use lighter printk() instead of printf()

Use printk(), snprintk() instead of printf() and snprintf().
CONFIG_STDOUT_CONSOLE is anyway disabled by default so printf()
will not output anything without it.

Change-Id: I9ad778e318fe999e79ec34182f2de8574e45b7d4
Signed-off-by: Ravi kumar Veeramally <ravikumar.veeramally@linux.intel.com>
This commit is contained in:
Ravi kumar Veeramally 2017-01-23 13:05:40 +02:00 committed by Jukka Rissanen
commit 4540a73b59
12 changed files with 57 additions and 49 deletions

View file

@ -388,46 +388,46 @@ void prepare_register_debug_print(char *dst, int dst_len,
{
if (remote_addr && remote_addr->family == AF_INET6) {
#if defined(CONFIG_NET_IPV6)
snprintf(dst, dst_len,
snprintk(dst, dst_len, "%s",
net_sprint_ipv6_addr(&net_sin6(remote_addr)->
sin6_addr));
#else
snprintf(dst, dst_len, "?");
snprintk(dst, dst_len, "%s", "?");
#endif
} else if (remote_addr && remote_addr->family == AF_INET) {
#if defined(CONFIG_NET_IPV4)
snprintf(dst, dst_len,
snprintk(dst, dst_len, "%s",
net_sprint_ipv4_addr(&net_sin(remote_addr)->
sin_addr));
#else
snprintf(dst, dst_len, "?");
snprintk(dst, dst_len, "%s", "?");
#endif
} else {
snprintf(dst, dst_len, "-");
snprintk(dst, dst_len, "%s", "-");
}
if (local_addr && local_addr->family == AF_INET6) {
#if defined(CONFIG_NET_IPV6)
snprintf(src, src_len,
snprintk(src, src_len, "%s",
net_sprint_ipv6_addr(&net_sin6(local_addr)->
sin6_addr));
#else
snprintf(src, src_len, "?");
snprintk(src, src_len, "%s", "?");
#endif
} else if (local_addr && local_addr->family == AF_INET) {
#if defined(CONFIG_NET_IPV4)
snprintf(src, src_len,
snprintk(src, src_len, "%s",
net_sprint_ipv4_addr(&net_sin(local_addr)->
sin_addr));
#else
snprintf(src, src_len, "?");
snprintk(src, src_len, "%s", "?");
#endif
} else {
snprintf(src, src_len, "-");
snprintk(src, src_len, "%s", "-");
}
}
#endif /* CONFIG_NET_DEBUG_CONN */

View file

@ -32,7 +32,7 @@ static inline enum net_verdict handle_echo_request(struct net_buf *buf)
#if defined(CONFIG_NET_DEBUG_ICMPV4)
char out[sizeof("xxx.xxx.xxx.xxx")];
snprintf(out, sizeof(out),
snprintk(out, sizeof(out), "%s",
net_sprint_ipv4_addr(&NET_IPV4_BUF(buf)->dst));
NET_DBG("Received Echo Request from %s to %s",
net_sprint_ipv4_addr(&NET_IPV4_BUF(buf)->src), out);
@ -49,7 +49,7 @@ static inline enum net_verdict handle_echo_request(struct net_buf *buf)
NET_ICMP_BUF(buf)->chksum = ~net_calc_chksum_icmpv4(buf);
#if defined(CONFIG_NET_DEBUG_ICMPV4)
snprintf(out, sizeof(out),
snprintk(out, sizeof(out), "%s",
net_sprint_ipv4_addr(&NET_IPV4_BUF(buf)->dst));
NET_DBG("Sending Echo Reply from %s to %s",
net_sprint_ipv4_addr(&NET_IPV4_BUF(buf)->src), out);
@ -138,7 +138,7 @@ int net_icmpv4_send_echo_request(struct net_if *iface,
do {
char out[NET_IPV4_ADDR_LEN];
snprintf(out, sizeof(out),
snprintk(out, sizeof(out), "%s",
net_sprint_ipv4_addr(&NET_IPV4_BUF(buf)->dst));
NET_DBG("Sending ICMPv4 Echo Request type %d"
@ -252,7 +252,7 @@ int net_icmpv4_send_error(struct net_buf *orig, uint8_t type, uint8_t code)
do {
char out[sizeof("xxx.xxx.xxx.xxx")];
snprintf(out, sizeof(out),
snprintk(out, sizeof(out), "%s",
net_sprint_ipv4_addr(&NET_IPV4_BUF(buf)->dst));
NET_DBG("Sending ICMPv4 Error Message type %d code %d "
"from %s to %s", type, code,

View file

@ -69,7 +69,7 @@ static enum net_verdict handle_echo_request(struct net_buf *orig)
do {
char out[NET_IPV6_ADDR_LEN];
snprintf(out, sizeof(out),
snprintk(out, sizeof(out), "%s",
net_sprint_ipv6_addr(&NET_IPV6_BUF(orig)->dst));
NET_DBG("Received Echo Request from %s to %s",
net_sprint_ipv6_addr(&NET_IPV6_BUF(orig)->src), out);
@ -142,7 +142,7 @@ static enum net_verdict handle_echo_request(struct net_buf *orig)
do {
char out[NET_IPV6_ADDR_LEN];
snprintf(out, sizeof(out),
snprintk(out, sizeof(out), "%s",
net_sprint_ipv6_addr(&NET_IPV6_BUF(buf)->dst));
NET_DBG("Sending Echo Reply from %s to %s",
net_sprint_ipv6_addr(&NET_IPV6_BUF(buf)->src), out);
@ -260,7 +260,7 @@ int net_icmpv6_send_error(struct net_buf *orig, uint8_t type, uint8_t code,
#if defined(CONFIG_NET_DEBUG_ICMPV6)
do {
char out[NET_IPV6_ADDR_LEN];
snprintf(out, sizeof(out),
snprintk(out, sizeof(out), "%s",
net_sprint_ipv6_addr(&NET_IPV6_BUF(buf)->dst));
NET_DBG("Sending ICMPv6 Error Message type %d code %d param %d"
" from %s to %s", type, code, param,
@ -323,7 +323,7 @@ int net_icmpv6_send_echo_request(struct net_if *iface,
do {
char out[NET_IPV6_ADDR_LEN];
snprintf(out, sizeof(out),
snprintk(out, sizeof(out), "%s",
net_sprint_ipv6_addr(&NET_IPV6_BUF(buf)->dst));
NET_DBG("Sending ICMPv6 Echo Request type %d"
" from %s to %s", NET_ICMPV6_ECHO_REQUEST,

View file

@ -422,8 +422,8 @@ static inline void dbg_update_neighbor_lladdr(struct net_linkaddr *new_lladdr,
{
char out[sizeof("xx:xx:xx:xx:xx:xx:xx:xx")];
snprintf(out, sizeof(out), net_sprint_ll_addr(old_lladdr->addr,
old_lladdr->len));
snprintk(out, sizeof(out), "%s",
net_sprint_ll_addr(old_lladdr->addr, old_lladdr->len));
NET_DBG("Updating neighbor %s lladdr %s (was %s)",
net_sprint_ipv6_addr(addr),
@ -727,7 +727,8 @@ static inline void handle_ns_neighbor(struct net_buf *buf,
do { \
char out[NET_IPV6_ADDR_LEN]; \
\
snprintf(out, sizeof(out), net_sprint_ipv6_addr(dst)); \
snprintk(out, sizeof(out), "%s", \
net_sprint_ipv6_addr(dst)); \
\
NET_DBG("%s %s from %s to %s", action, \
pkt_str, net_sprint_ipv6_addr(src), out); \
@ -745,8 +746,10 @@ static inline void handle_ns_neighbor(struct net_buf *buf,
char out[NET_IPV6_ADDR_LEN]; \
char tgt[NET_IPV6_ADDR_LEN]; \
\
snprintf(out, sizeof(out), net_sprint_ipv6_addr(dst)); \
snprintf(tgt, sizeof(tgt), net_sprint_ipv6_addr(target)); \
snprintk(out, sizeof(out), "%s", \
net_sprint_ipv6_addr(dst)); \
snprintk(tgt, sizeof(tgt), "%s", \
net_sprint_ipv6_addr(target)); \
\
NET_DBG("%s %s from %s to %s, target %s", action, \
pkt_str, net_sprint_ipv6_addr(src), out, tgt); \

View file

@ -449,7 +449,7 @@ enum net_verdict net_arp_input(struct net_buf *buf)
#if defined(CONFIG_NET_DEBUG_ARP)
do {
char out[sizeof("xxx.xxx.xxx.xxx")];
snprintf(out, sizeof(out),
snprintk(out, sizeof(out), "%s",
net_sprint_ipv4_addr(&arp_hdr->src_ipaddr));
NET_DBG("ARP request from %s [%s] for %s",
out,

View file

@ -36,7 +36,7 @@ const struct net_eth_addr *net_eth_broadcast_addr(void)
do { \
char out[sizeof("xx:xx:xx:xx:xx:xx")]; \
\
snprintf(out, sizeof(out), \
snprintk(out, sizeof(out), "%s", \
net_sprint_ll_addr(net_nbuf_ll_src(buf)->addr, \
sizeof(struct net_eth_addr))); \
\

View file

@ -31,7 +31,7 @@
#if 0
#include <stdio.h>
#include <misc/printk.h>
static inline void hexdump(uint8_t *pkt, uint16_t length, uint8_t reserve)
{
@ -40,25 +40,25 @@ static inline void hexdump(uint8_t *pkt, uint16_t length, uint8_t reserve)
for (i = 0; i < length;) {
int j;
printf("\t");
printk("\t");
for (j = 0; j < 10 && i < length; j++, i++) {
#if defined(CONFIG_SYS_LOG_SHOW_COLOR)
if (i < reserve && reserve) {
printf(SYS_LOG_COLOR_YELLOW);
printk(SYS_LOG_COLOR_YELLOW);
} else {
printf(SYS_LOG_COLOR_OFF);
printk(SYS_LOG_COLOR_OFF);
}
#endif
printf("%02x ", *pkt++);
printk("%02x ", *pkt++);
}
#if defined(CONFIG_SYS_LOG_SHOW_COLOR)
if (i < reserve) {
printf(SYS_LOG_COLOR_OFF);
printk(SYS_LOG_COLOR_OFF);
}
#endif
printf("\n");
printk("\n");
}
}
@ -67,7 +67,7 @@ static void pkt_hexdump(struct net_buf *buf, bool each_frag_reserve)
uint16_t reserve = each_frag_reserve ? net_nbuf_ll_reserve(buf) : 0;
struct net_buf *frag;
printf("IEEE 802.15.4 packet content:\n");
printk("IEEE 802.15.4 packet content:\n");
frag = buf->frags;
while (frag) {

View file

@ -204,7 +204,8 @@ static inline enum net_verdict process_ipv6_pkt(struct net_buf *buf)
#if defined(CONFIG_NET_DEBUG_CORE)
do {
char out[NET_IPV6_ADDR_LEN];
snprintf(out, sizeof(out), net_sprint_ipv6_addr(&hdr->dst));
snprintk(out, sizeof(out), "%s",
net_sprint_ipv6_addr(&hdr->dst));
NET_DBG("IPv6 packet len %d received from %s to %s",
real_len, net_sprint_ipv6_addr(&hdr->src), out);
} while (0);
@ -406,7 +407,8 @@ static inline enum net_verdict process_ipv4_pkt(struct net_buf *buf)
#if defined(CONFIG_NET_DEBUG_CORE)
do {
char out[sizeof("xxx.xxx.xxx.xxx")];
snprintf(out, sizeof(out), net_sprint_ipv4_addr(&hdr->dst));
snprintk(out, sizeof(out), "%s",
net_sprint_ipv4_addr(&hdr->dst));
NET_DBG("IPv4 packet received from %s to %s",
net_sprint_ipv4_addr(&hdr->src), out);
} while (0);

View file

@ -11,7 +11,7 @@
*/
#include <errno.h>
#include <stdio.h>
#include <misc/printk.h>
#include <net/net_context.h>
#include <net/nbuf.h>
@ -118,23 +118,23 @@ static inline void net_hexdump(const char *str, const uint8_t *packet,
while (length--) {
if (n % 16 == 0) {
printf("%s %08X ", str, n);
printk("%s %08X ", str, n);
}
printf("%02X ", *packet++);
printk("%02X ", *packet++);
n++;
if (n % 8 == 0) {
if (n % 16 == 0) {
printf("\n");
printk("\n");
} else {
printf(" ");
printk(" ");
}
}
}
if (n % 16) {
printf("\n");
printk("\n");
}
}

View file

@ -243,7 +243,7 @@ static int nbr_nexthop_put(struct net_nbr *nbr)
\
NET_ASSERT_INFO(naddr, "Unknown nexthop address"); \
\
snprintf(out, sizeof(out), \
snprintk(out, sizeof(out), "%s", \
net_sprint_ipv6_addr(dst)); \
NET_DBG("%s route to %s via %s (iface %p)", str, out, \
net_sprint_ipv6_addr(naddr), route->iface); \
@ -363,7 +363,7 @@ struct net_route_entry *net_route_add(struct net_if *iface,
struct in6_addr *tmp;
struct net_linkaddr_storage *llstorage;
snprintf(out, sizeof(out),
snprintk(out, sizeof(out), "%s",
net_sprint_ipv6_addr(&route->addr));
tmp = net_route_get_nexthop(route);

View file

@ -121,7 +121,7 @@ net_rpl_of0_best_parent(struct net_if *iface,
do {
char out[NET_IPV6_ADDR_LEN];
snprintf(out, sizeof(out),
snprintk(out, sizeof(out), "%s",
net_sprint_ipv6_addr(
net_rpl_get_parent_addr(iface,
parent2)));

View file

@ -210,7 +210,7 @@ NET_NBR_TABLE_INIT(NET_NBR_LOCAL, rpl_parents, net_rpl_neighbor_pool,
do { \
char out[NET_IPV6_ADDR_LEN]; \
\
snprintf(out, sizeof(out), \
snprintk(out, sizeof(out), "%s", \
net_sprint_ipv6_addr(&NET_IPV6_BUF(buf)->dst)); \
NET_DBG("Received %s from %s to %s", req, \
net_sprint_ipv6_addr(&NET_IPV6_BUF(buf)->src), out); \
@ -221,8 +221,10 @@ NET_NBR_TABLE_INIT(NET_NBR_LOCAL, rpl_parents, net_rpl_neighbor_pool,
char out[NET_IPV6_ADDR_LEN]; \
char prf[NET_IPV6_ADDR_LEN]; \
\
snprintf(out, sizeof(out), net_sprint_ipv6_addr(dst)); \
snprintf(prf, sizeof(prf), net_sprint_ipv6_addr(prefix)); \
snprintk(out, sizeof(out), "%s", \
net_sprint_ipv6_addr(dst)); \
snprintk(prf, sizeof(prf), "%s", \
net_sprint_ipv6_addr(prefix)); \
NET_DBG("Send DAO with prefix %s from %s to %s", \
prf, net_sprint_ipv6_addr(src), out); \
} while (0)
@ -231,7 +233,8 @@ NET_NBR_TABLE_INIT(NET_NBR_LOCAL, rpl_parents, net_rpl_neighbor_pool,
do { \
char out[NET_IPV6_ADDR_LEN]; \
\
snprintf(out, sizeof(out), net_sprint_ipv6_addr(dst)); \
snprintk(out, sizeof(out), "%s", \
net_sprint_ipv6_addr(dst)); \
NET_DBG("Send DAO-ACK (id %d, seq %d) from %s to %s", \
id, seq, net_sprint_ipv6_addr(src), out); \
} while (0)
@ -384,7 +387,7 @@ static void net_rpl_print_neighbors(void)
do { \
char out[NET_IPV6_ADDR_LEN]; \
\
snprintf(out, sizeof(out), \
snprintk(out, sizeof(out), "%s", \
net_sprint_ipv6_addr(addr)); \
NET_DBG("%s route to %s via %s (iface %p)", str, out, \
net_sprint_ipv6_addr(nexthop), route->iface); \