ref: ed79787d16ee8bb5afe5bd4bf829e51894e5eace
parent: f83bec968b08889825adb21535e4299eaa21e009
author: Ralph Giles <giles@mozilla.com>
date: Sun Nov 4 17:52:47 EST 2012
Simplify native-endian reader. We don't need the union, we can memcpy directly into an int. NB this assumes at least a 32 bit int, since the actual header field is 32 bits. Also minor related comment updates
--- a/src/opusrtp.c
+++ b/src/opusrtp.c
@@ -335,13 +335,10 @@
static int rne32(const unsigned char *p)
{
/* On x86 we could just cast, but that might not meet
- * arm's alignment requirements. */
- union {
- unsigned char c[4];
- int d;
- } m;
- memcpy(m.c, p, 4);
- return m.d;
+ * arm alignment requirements. */
+ int d = 0;
+ memcpy(&d, p, 4);
+ return d;
}
int parse_eth_header(const unsigned char *packet, int size, eth_header *eth)
@@ -370,7 +367,7 @@
fprintf(stderr, "Packet too short for loopback\n");
return -1;
}
- /* protocol is in host byte order */
+ /* protocol is in host byte order on osx. may be big endian on openbsd? */
loop->family = rne32(packet);
return 0;