From 0e466aa161c4f28a4f69665c3e91f50678143687 Mon Sep 17 00:00:00 2001 From: dlg Date: Fri, 5 Jan 2018 05:08:53 +0000 Subject: [PATCH] cast the result of the ternary ops in __swapXX to the relevant types. 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 | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/sys/sys/_endian.h b/sys/sys/_endian.h index c4429bbff1a..4a279688172 100644 --- a/sys/sys/_endian.h +++ b/sys/sys/_endian.h @@ -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 -- 2.20.1