[riot-notifications] [RIOT-OS/RIOT] posix_sockets.c: fix send() for connected UDP sockets (#11364)

Martine Lenders notifications at github.com
Wed Apr 10 11:07:01 CEST 2019


miri64 requested changes on this pull request.



> @@ -959,7 +959,13 @@ static ssize_t socket_sendto(socket_t *s, const void *buffer, size_t length,
 #endif
 #ifdef MODULE_SOCK_UDP
         case SOCK_DGRAM:
-            if ((res = sock_udp_send(&s->sock->udp, buffer, length, &ep)) < 0) {
+            if (address == NULL) {
+                res = sock_udp_get_remote((sock_udp_t *)s->sock, &ep);

Using `s->sock->udp` saves you the cast.

> @@ -959,7 +959,13 @@ static ssize_t socket_sendto(socket_t *s, const void *buffer, size_t length,
 #endif
 #ifdef MODULE_SOCK_UDP
         case SOCK_DGRAM:
-            if ((res = sock_udp_send(&s->sock->udp, buffer, length, &ep)) < 0) {
+            if (address == NULL) {
+                res = sock_udp_get_remote((sock_udp_t *)s->sock, &ep);

Also (but we can do this also in a follow-up), how about using a wrapper (e.g. `_sock_get_remote()`)? This way `SOCK_RAW` also would benefit.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/11364#pullrequestreview-224843504
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190410/95f67b24/attachment.html>


More information about the notifications mailing list