summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libc/unistd/swab.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/libc/unistd/swab.c b/libc/unistd/swab.c
index 41845d4cb..70ea464c2 100644
--- a/libc/unistd/swab.c
+++ b/libc/unistd/swab.c
@@ -11,8 +11,13 @@
void swab (const void *source, void *dest, ssize_t count)
{
const unsigned short *from = source, *from_end = from + (count >> 1);
+ unsigned short junk;
unsigned short *to = dest;
- while (from < from_end)
- *to++ = bswap_16 (*from++);
+ while (from < from_end) {
+ /* Don't put '*from++'into the bswap_16() macros
+ * or mad things will happen on macro expansion */
+ junk=*from++;
+ *to++ = bswap_16 (junk);
+ }
}