Fix build (-Werror) on platforms where char is unsigned.

Noticed by landry@ on macppc.
This commit is contained in:
zhuk 2013-12-08 20:06:16 +00:00
parent 9c402cb6ac
commit 775315e69d
2 changed files with 66 additions and 2 deletions

View File

@ -1,7 +1,7 @@
# $OpenBSD: Makefile,v 1.2 2013/11/25 17:12:43 zhuk Exp $
# $OpenBSD: Makefile,v 1.3 2013/12/08 20:06:16 zhuk Exp $
COMMENT = RTP (RFC3550) library
DISTNAME = ortp-0.22.0
REVISION = 0
REVISION = 1
SHARED_LIBS = ortp 0.0

View File

@ -0,0 +1,64 @@
$OpenBSD: patch-src_b64_c,v 1.1 2013/12/08 20:06:16 zhuk Exp $
Fix build (-Werror) on platforms where char is unsigned.
--- src/b64.c.orig Sun Dec 8 23:52:27 2013
+++ src/b64.c Mon Dec 9 00:03:52 2013
@@ -181,7 +181,7 @@ static size_t b64_encode_( unsigned char const *src
for(; NUM_PLAIN_DATA_BYTES <= srcSize; srcSize -= NUM_PLAIN_DATA_BYTES)
{
- char characters[NUM_ENCODED_DATA_BYTES];
+ unsigned char characters[NUM_ENCODED_DATA_BYTES];
/*
*
@@ -197,38 +197,38 @@ static size_t b64_encode_( unsigned char const *src
*/
/* characters[0] is the 6 left-most bits of src[0] */
- characters[0] = (char)((src[0] & 0xfc) >> 2);
+ characters[0] = ((src[0] & 0xfc) >> 2);
/* characters[0] is the right-most 2 bits of src[0] and the left-most 4 bits of src[1] */
- characters[1] = (char)(((src[0] & 0x03) << 4) + ((src[1] & 0xf0) >> 4));
+ characters[1] = (((src[0] & 0x03) << 4) + ((src[1] & 0xf0) >> 4));
/* characters[0] is the right-most 4 bits of src[1] and the 2 left-most bits of src[2] */
- characters[2] = (char)(((src[1] & 0x0f) << 2) + ((src[2] & 0xc0) >> 6));
+ characters[2] = (((src[1] & 0x0f) << 2) + ((src[2] & 0xc0) >> 6));
/* characters[3] is the right-most 6 bits of src[2] */
- characters[3] = (char)(src[2] & 0x3f);
+ characters[3] = (src[2] & 0x3f);
#ifndef __WATCOMC__
- assert(characters[0] >= 0 && characters[0] < 64);
- assert(characters[1] >= 0 && characters[1] < 64);
- assert(characters[2] >= 0 && characters[2] < 64);
- assert(characters[3] >= 0 && characters[3] < 64);
+ assert(characters[0] < 64);
+ assert(characters[1] < 64);
+ assert(characters[2] < 64);
+ assert(characters[3] < 64);
#endif /* __WATCOMC__ */
src += NUM_PLAIN_DATA_BYTES;
- *p++ = b64_chars[(unsigned char)characters[0]];
+ *p++ = b64_chars[characters[0]];
assert(NULL != strchr(b64_chars, *(p-1)));
++len;
assert(len != lineLen);
- *p++ = b64_chars[(unsigned char)characters[1]];
+ *p++ = b64_chars[characters[1]];
assert(NULL != strchr(b64_chars, *(p-1)));
++len;
assert(len != lineLen);
- *p++ = b64_chars[(unsigned char)characters[2]];
+ *p++ = b64_chars[characters[2]];
assert(NULL != strchr(b64_chars, *(p-1)));
++len;
assert(len != lineLen);
- *p++ = b64_chars[(unsigned char)characters[3]];
+ *p++ = b64_chars[characters[3]];
assert(NULL != strchr(b64_chars, *(p-1)));
if( ++len == lineLen &&