From owner-svn-src-head@FreeBSD.ORG Fri Mar 9 20:34:31 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id DFFA01065674; Fri, 9 Mar 2012 20:34:31 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B17C98FC0C; Fri, 9 Mar 2012 20:34:31 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q29KYVxm024018; Fri, 9 Mar 2012 20:34:31 GMT (envelope-from dim@svn.freebsd.org) Received: (from dim@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q29KYVjv024014; Fri, 9 Mar 2012 20:34:31 GMT (envelope-from dim@svn.freebsd.org) Message-Id: <201203092034.q29KYVjv024014@svn.freebsd.org> From: Dimitry Andric Date: Fri, 9 Mar 2012 20:34:31 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r232745 - in head/sys: powerpc/include sparc64/include x86/include X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 09 Mar 2012 20:34:32 -0000 Author: dim Date: Fri Mar 9 20:34:31 2012 New Revision: 232745 URL: http://svn.freebsd.org/changeset/base/232745 Log: Add casts to __uint16_t to the __bswap16() macros on all arches which didn't already have them. This is because the ternary expression will return int, due to the Usual Arithmetic Conversions. Such casts are not needed for the 32 and 64 bit variants. While here, add additional parentheses around the x86 variant, to protect against unintended consequences. MFC after: 2 weeks Modified: head/sys/powerpc/include/endian.h head/sys/sparc64/include/endian.h head/sys/x86/include/endian.h Modified: head/sys/powerpc/include/endian.h ============================================================================== --- head/sys/powerpc/include/endian.h Fri Mar 9 19:42:48 2012 (r232744) +++ head/sys/powerpc/include/endian.h Fri Mar 9 20:34:31 2012 (r232745) @@ -124,8 +124,8 @@ __bswap64_var(__uint64_t _x) ((_x << 40) & ((__uint64_t)0xff << 48)) | ((_x << 56))); } -#define __bswap16(x) (__is_constant(x) ? __bswap16_const(x) : \ - __bswap16_var(x)) +#define __bswap16(x) ((__uint16_t)(__is_constant(x) ? __bswap16_const(x) : \ + __bswap16_var(x))) #define __bswap32(x) (__is_constant(x) ? __bswap32_const(x) : \ __bswap32_var(x)) #define __bswap64(x) (__is_constant(x) ? __bswap64_const(x) : \ Modified: head/sys/sparc64/include/endian.h ============================================================================== --- head/sys/sparc64/include/endian.h Fri Mar 9 19:42:48 2012 (r232744) +++ head/sys/sparc64/include/endian.h Fri Mar 9 20:34:31 2012 (r232745) @@ -109,8 +109,8 @@ __bswap64_var(__uint64_t _x) ((_x << 40) & ((__uint64_t)0xff << 48)) | ((_x << 56))); } -#define __bswap16(x) (__is_constant(x) ? __bswap16_const(x) : \ - __bswap16_var(x)) +#define __bswap16(x) ((__uint16_t)(__is_constant(x) ? __bswap16_const(x) : \ + __bswap16_var(x))) #define __bswap32(x) (__is_constant(x) ? __bswap32_const(x) : \ __bswap32_var(x)) #define __bswap64(x) (__is_constant(x) ? __bswap64_const(x) : \ Modified: head/sys/x86/include/endian.h ============================================================================== --- head/sys/x86/include/endian.h Fri Mar 9 19:42:48 2012 (r232744) +++ head/sys/x86/include/endian.h Fri Mar 9 20:34:31 2012 (r232745) @@ -71,8 +71,8 @@ #ifdef __GNUCLIKE_BUILTIN_CONSTANT_P #define __bswap16(x) \ - (__uint16_t)(__builtin_constant_p(x) ? \ - __bswap16_gen((__uint16_t)(x)) : __bswap16_var(x)) + ((__uint16_t)(__builtin_constant_p(x) ? \ + __bswap16_gen((__uint16_t)(x)) : __bswap16_var(x))) #define __bswap32(x) \ (__builtin_constant_p(x) ? \ __bswap32_gen((__uint32_t)(x)) : __bswap32_var(x))