[riot-notifications] [RIOT-OS/RIOT] posix_socket: initialize uninitialized fields (#11575)

Martine Lenders notifications at github.com
Tue Jun 4 20:14:56 CEST 2019


miri64 commented on this pull request.



> @@ -221,6 +221,7 @@ static int _sockaddr_to_ep(const struct sockaddr *address, socklen_t address_len
                 return -1;
             }
             struct sockaddr_in *in_addr = (struct sockaddr_in *)address;
+            memset(out, 0, *out);

But multiplying the memset for every call of this function (which is for).

```
sys/posix/sockets/posix_sockets.c:static int _sockaddr_to_ep(const struct sockaddr *address, socklen_t address_len,
sys/posix/sockets/posix_sockets.c:    if (_sockaddr_to_ep(address, address_len, &s->local) < 0) {
sys/posix/sockets/posix_sockets.c:        if (_sockaddr_to_ep(address, address_len, &r) < 0) {
sys/posix/sockets/posix_sockets.c:    if ((res = _sockaddr_to_ep(address, address_len, &ep)) < 0)
sys/posix/sockets/posix_sockets.c:                res = _sockaddr_to_ep(address, address_len, &ep);
```

So I think having it this way (for this *internal* function) is more memory efficient.

-- 
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/11575#discussion_r290429128
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190604/aff641a4/attachment.html>


More information about the notifications mailing list