Fix minor endian issue (XCC)
authorBarret Rhoden <brho@cs.berkeley.edu>
Mon, 19 Sep 2016 15:29:33 +0000 (11:29 -0400)
committerBarret Rhoden <brho@cs.berkeley.edu>
Mon, 19 Sep 2016 15:29:33 +0000 (11:29 -0400)
That first assignment to sin_port in recvfrom was overwritten and
confusing.

Signed-off-by: Barret Rhoden <brho@cs.berkeley.edu>
tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/recvfrom.c
tools/compilers/gcc-glibc/glibc-2.19-akaros/sysdeps/akaros/sendto.c

index a191c50..0bf8a50 100644 (file)
@@ -51,8 +51,8 @@ static ssize_t __recvfrom_udp(int fd, const struct iovec *iov, int iovcnt,
                p += 16;
                p += 16;        /* skip local addr */
                p += 16;        /* skip ipifc */
-               remote->sin_port = (p[0] << 0) | (p[1] << 8);
-               remote->sin_port = *(uint16_t *) p;
+               /* sin_port and p are both in network-ordering */
+               remote->sin_port = *(uint16_t*)p;
                *fromlen = sizeof(struct sockaddr_in);
        }
        return ret;
index c7c48ff..a36cb24 100644 (file)
@@ -53,6 +53,7 @@ static ssize_t __sendto_udp(Rock *r, int fd, const struct iovec *iov, int
         * local IP addr, the kernel will pick the one closest to dest */
        p += 16;
        p += 16;        /* skip ipifc */
+       /* remote_port and p are both in network-ordering */
        *(uint16_t*)p = remote_port;
        p += 2;
        p += 2; /* skip local port */