From owner-svn-src-head@FreeBSD.ORG Thu May 20 06:16:13 2010 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BE84D1065674; Thu, 20 May 2010 06:16:13 +0000 (UTC) (envelope-from phk@FreeBSD.org) Received: from svn.freebsd.org (unknown [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id AEDBB8FC08; Thu, 20 May 2010 06:16:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o4K6GDFD010284; Thu, 20 May 2010 06:16:13 GMT (envelope-from phk@svn.freebsd.org) Received: (from phk@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o4K6GDN8010282; Thu, 20 May 2010 06:16:13 GMT (envelope-from phk@svn.freebsd.org) Message-Id: <201005200616.o4K6GDN8010282@svn.freebsd.org> From: Poul-Henning Kamp Date: Thu, 20 May 2010 06:16:13 +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: r208331 - head/sys/sys 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: Thu, 20 May 2010 06:16:13 -0000 Author: phk Date: Thu May 20 06:16:13 2010 New Revision: 208331 URL: http://svn.freebsd.org/changeset/base/208331 Log: Fix some way-past-brucification complaints from FlexeLint. Modified: head/sys/sys/endian.h Modified: head/sys/sys/endian.h ============================================================================== --- head/sys/sys/endian.h Thu May 20 06:05:40 2010 (r208330) +++ head/sys/sys/endian.h Thu May 20 06:16:13 2010 (r208331) @@ -33,6 +33,11 @@ #include #include +#ifndef _UINT8_T_DECLARED +typedef __uint8_t uint8_t; +#define _UINT8_T_DECLARED +#endif + #ifndef _UINT16_T_DECLARED typedef __uint16_t uint16_t; #define _UINT16_T_DECLARED @@ -94,7 +99,7 @@ typedef __uint64_t uint64_t; static __inline uint16_t be16dec(const void *pp) { - unsigned char const *p = (unsigned char const *)pp; + uint8_t const *p = (uint8_t const *)pp; return ((p[0] << 8) | p[1]); } @@ -102,15 +107,15 @@ be16dec(const void *pp) static __inline uint32_t be32dec(const void *pp) { - unsigned char const *p = (unsigned char const *)pp; + uint8_t const *p = (uint8_t const *)pp; - return ((p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]); + return (((unsigned)p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]); } static __inline uint64_t be64dec(const void *pp) { - unsigned char const *p = (unsigned char const *)pp; + uint8_t const *p = (uint8_t const *)pp; return (((uint64_t)be32dec(p) << 32) | be32dec(p + 4)); } @@ -118,7 +123,7 @@ be64dec(const void *pp) static __inline uint16_t le16dec(const void *pp) { - unsigned char const *p = (unsigned char const *)pp; + uint8_t const *p = (uint8_t const *)pp; return ((p[1] << 8) | p[0]); } @@ -126,15 +131,15 @@ le16dec(const void *pp) static __inline uint32_t le32dec(const void *pp) { - unsigned char const *p = (unsigned char const *)pp; + uint8_t const *p = (uint8_t const *)pp; - return ((p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0]); + return (((unsigned)p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0]); } static __inline uint64_t le64dec(const void *pp) { - unsigned char const *p = (unsigned char const *)pp; + uint8_t const *p = (uint8_t const *)pp; return (((uint64_t)le32dec(p + 4) << 32) | le32dec(p)); } @@ -142,7 +147,7 @@ le64dec(const void *pp) static __inline void be16enc(void *pp, uint16_t u) { - unsigned char *p = (unsigned char *)pp; + uint8_t *p = (uint8_t *)pp; p[0] = (u >> 8) & 0xff; p[1] = u & 0xff; @@ -151,7 +156,7 @@ be16enc(void *pp, uint16_t u) static __inline void be32enc(void *pp, uint32_t u) { - unsigned char *p = (unsigned char *)pp; + uint8_t *p = (uint8_t *)pp; p[0] = (u >> 24) & 0xff; p[1] = (u >> 16) & 0xff; @@ -162,16 +167,16 @@ be32enc(void *pp, uint32_t u) static __inline void be64enc(void *pp, uint64_t u) { - unsigned char *p = (unsigned char *)pp; + uint8_t *p = (uint8_t *)pp; - be32enc(p, u >> 32); - be32enc(p + 4, u & 0xffffffff); + be32enc(p, (uint32_t)(u >> 32)); + be32enc(p + 4, (uint32_t)(u & 0xffffffffU)); } static __inline void le16enc(void *pp, uint16_t u) { - unsigned char *p = (unsigned char *)pp; + uint8_t *p = (uint8_t *)pp; p[0] = u & 0xff; p[1] = (u >> 8) & 0xff; @@ -180,7 +185,7 @@ le16enc(void *pp, uint16_t u) static __inline void le32enc(void *pp, uint32_t u) { - unsigned char *p = (unsigned char *)pp; + uint8_t *p = (uint8_t *)pp; p[0] = u & 0xff; p[1] = (u >> 8) & 0xff; @@ -191,10 +196,10 @@ le32enc(void *pp, uint32_t u) static __inline void le64enc(void *pp, uint64_t u) { - unsigned char *p = (unsigned char *)pp; + uint8_t *p = (uint8_t *)pp; - le32enc(p, u & 0xffffffff); - le32enc(p + 4, u >> 32); + le32enc(p, (uint32_t)(u & 0xffffffffU)); + le32enc(p + 4, (uint32_t)(u >> 32)); } #endif /* _SYS_ENDIAN_H_ */