Cast the result of the __swapXX macros to the proper type.
authormillert <millert@openbsd.org>
Fri, 21 Apr 2017 19:04:22 +0000 (19:04 +0000)
committermillert <millert@openbsd.org>
Fri, 21 Apr 2017 19:04:22 +0000 (19:04 +0000)
The ternary operator was causing the result to be promoted to
int for __swap16.  Fixes warning with clang.  OK guenther@

sys/sys/_endian.h

index c2e16a4..25366cc 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: _endian.h,v 1.1 2014/07/12 16:25:08 guenther Exp $    */
+/*     $OpenBSD: _endian.h,v 1.2 2017/04/21 19:04:22 millert Exp $     */
 
 /*-
  * Copyright (c) 1997 Niklas Hallqvist.  All rights reserved.
 #define __swap16(x) __statement({                                      \
        __uint16_t __swap16_x = (x);                                    \
                                                                        \
-       __builtin_constant_p(x) ? __swap16gen(__swap16_x) :             \
-           __swap16md(__swap16_x)                                    \
+       (__uint16_t)(__builtin_constant_p(x) ? __swap16gen(__swap16_x) :\
+           __swap16md(__swap16_x));                                    \
 })
 
 #define __swap32(x) __statement({                                      \
        __uint32_t __swap32_x = (x);                                    \
                                                                        \
-       __builtin_constant_p(x) ? __swap32gen(__swap32_x) :             \
-           __swap32md(__swap32_x)                                    \
+       (__uint32_t)(__builtin_constant_p(x) ? __swap32gen(__swap32_x) :\
+           __swap32md(__swap32_x));                                    \
 })
 
 #define __swap64(x) __statement({                                      \
        __uint64_t __swap64_x = (x);                                    \
                                                                        \
-       __builtin_constant_p(x) ? __swap64gen(__swap64_x) :             \
-           __swap64md(__swap64_x)                                    \
+       (__uint64_t)(__builtin_constant_p(x) ? __swap64gen(__swap64_x) :\
+           __swap64md(__swap64_x));                                    \
 })
 
 #else