From: millert Date: Fri, 21 Apr 2017 19:04:22 +0000 (+0000) Subject: Cast the result of the __swapXX macros to the proper type. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=7d47ff537ffc3ff98d4129ffb577c4f700459f8a;p=openbsd Cast the result of the __swapXX macros to the proper type. The ternary operator was causing the result to be promoted to int for __swap16. Fixes warning with clang. OK guenther@ --- diff --git a/sys/sys/_endian.h b/sys/sys/_endian.h index c2e16a4a06f..25366cc188a 100644 --- a/sys/sys/_endian.h +++ b/sys/sys/_endian.h @@ -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. @@ -110,22 +110,22 @@ #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