cast the result of the ternary ops in __swapXX to the relevant types.
authordlg <dlg@openbsd.org>
Fri, 5 Jan 2018 05:08:53 +0000 (05:08 +0000)
committerdlg <dlg@openbsd.org>
Fri, 5 Jan 2018 05:08:53 +0000 (05:08 +0000)
it appears clang and guenther@ have a different way of interpreting
the c standards around type promotion and ternary operators compared
to gcc and me.

"no you do it" guenther@

sys/sys/_endian.h

index c4429bb..4a27968 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: _endian.h,v 1.4 2018/01/03 23:20:10 dlg Exp $ */
+/*     $OpenBSD: _endian.h,v 1.5 2018/01/05 05:08:53 dlg Exp $ */
 
 /*-
  * Copyright (c) 1997 Niklas Hallqvist.  All rights reserved.
@@ -83,9 +83,12 @@ __swap64md(__uint64_t x)
 }
 #endif
 
-#define __swap16(x) (__builtin_constant_p(x) ? __swap16gen(x) : __swap16md(x))
-#define __swap32(x) (__builtin_constant_p(x) ? __swap32gen(x) : __swap32md(x))
-#define __swap64(x) (__builtin_constant_p(x) ? __swap64gen(x) : __swap64md(x))
+#define __swap16(x)                                                    \
+       (__uint16_t)(__builtin_constant_p(x) ? __swap16gen(x) : __swap16md(x))
+#define __swap32(x)                                                    
+       (__uint32_t)(__builtin_constant_p(x) ? __swap32gen(x) : __swap32md(x))
+#define __swap64(x)                                                    \
+       (__uint64_t)(__builtin_constant_p(x) ? __swap64gen(x) : __swap64md(x))
 
 #if _BYTE_ORDER == _LITTLE_ENDIAN