cast the result of the ternary operators in __swapXX to the right type
authordlg <dlg@openbsd.org>
Thu, 11 Jan 2018 23:13:37 +0000 (23:13 +0000)
committerdlg <dlg@openbsd.org>
Thu, 11 Jan 2018 23:13:37 +0000 (23:13 +0000)
ok kettenis@
let's try it deraadt@

sys/sys/_endian.h

index 04c071f..e1ce82e 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: _endian.h,v 1.7 2018/01/07 15:17:42 kettenis Exp $    */
+/*     $OpenBSD: _endian.h,v 1.8 2018/01/11 23:13:37 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