From 803de8d14ebcc15b4075c22e6473e477f7104050 Mon Sep 17 00:00:00 2001 From: Ravi kumar Veeramally Date: Mon, 30 May 2016 13:29:16 +0300 Subject: [PATCH] net: Fix return value from uip_udp_packet_sendto udp_socket_sendto returns always datalen irrespective of uip_udp_packet_sendto return value. Change-Id: Ib1c5a25ae89ddaa0826d35d4fd53f9c2ccea7b93 Signed-off-by: Ravi kumar Veeramally --- net/ip/contiki/ip/udp-socket.c | 3 +-- net/ip/net_core.c | 7 +++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/net/ip/contiki/ip/udp-socket.c b/net/ip/contiki/ip/udp-socket.c index 9cd9da16269..28180fa95fc 100644 --- a/net/ip/contiki/ip/udp-socket.c +++ b/net/ip/contiki/ip/udp-socket.c @@ -145,9 +145,8 @@ udp_socket_sendto(struct net_buf *buf, struct udp_socket *c, } if(c->udp_conn != NULL) { - uip_udp_packet_sendto(buf, c->udp_conn, data, datalen, + return uip_udp_packet_sendto(buf, c->udp_conn, data, datalen, to, UIP_HTONS(port)); - return datalen; } return -1; } diff --git a/net/ip/net_core.c b/net/ip/net_core.c index 303a6fe0434..677ece843d7 100644 --- a/net/ip/net_core.c +++ b/net/ip/net_core.c @@ -401,8 +401,11 @@ static inline int udp_prepare_and_send(struct net_context *context, ip_buf_appdatalen(buf), &NET_BUF_IP(buf)->destipaddr, uip_ntohs(NET_BUF_UDP(buf)->destport)); - if (!ret) { + if (ret <= 0) { + ret = -EINVAL; NET_DBG("Packet could not be sent properly.\n"); + } else { + ret = 0; } #ifdef CONFIG_NETWORKING_IPV6_NO_ND @@ -412,7 +415,7 @@ static inline int udp_prepare_and_send(struct net_context *context, } #endif - return !ret; + return ret; } #ifdef CONFIG_NETWORKING_WITH_TCP