From 6be6533ac650e26f8b53fdc32341b297a1901383 Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Wed, 21 Oct 2015 11:35:43 +0200 Subject: [PATCH] base64: fix invalid narrowing conversion Fixes this error: src/web/base64.cpp:39:3: error: narrowing conversion of '-1' from 'int' to 'char' inside { } [-Wnarrowing] --- src/web/base64.cpp | 32 ++++++++++++++++---------------- src/web/base64.h | 8 ++++---- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/web/base64.cpp b/src/web/base64.cpp index 4d507f0..d2e17fe 100644 --- a/src/web/base64.cpp +++ b/src/web/base64.cpp @@ -2,7 +2,7 @@ namespace base64 { - const char _to_table[64] = + const unsigned char _to_table[64] = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', @@ -12,30 +12,30 @@ namespace base64 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/' }; - const char* to_table = _to_table; + const unsigned char* to_table = _to_table; - const char* to_table_end = + const unsigned char* to_table_end = _to_table + sizeof(_to_table); - const char _from_table[128] = + const unsigned char _from_table[128] = { - -1, -1, -1, -1, -1, -1, -1, -1, // 0 - -1, -1, -1, -1, -1, -1, -1, -1, // 8 - -1, -1, -1, -1, -1, -1, -1, -1, // 16 - -1, -1, -1, -1, -1, -1, -1, -1, // 24 - -1, -1, -1, -1, -1, -1, -1, -1, // 32 - -1, -1, -1, 62, -1, -1, -1, 63, // 40 + 255, 255, 255, 255, 255, 255, 255, 255, // 0 + 255, 255, 255, 255, 255, 255, 255, 255, // 8 + 255, 255, 255, 255, 255, 255, 255, 255, // 16 + 255, 255, 255, 255, 255, 255, 255, 255, // 24 + 255, 255, 255, 255, 255, 255, 255, 255, // 32 + 255, 255, 255, 62, 255, 255, 255, 63, // 40 52, 53, 54, 55, 56, 57, 58, 59, // 48 - 60, 61, -1, -1, -1, 0, -1, -1, // 56 - -1, 0, 1, 2, 3, 4, 5, 6, // 64 + 60, 61, 255, 255, 255, 0, 255, 255, // 56 + 255, 0, 1, 2, 3, 4, 5, 6, // 64 7, 8, 9, 10, 11, 12, 13, 14, // 72 15, 16, 17, 18, 19, 20, 21, 22, // 80 - 23, 24, 25, -1, -1, -1, -1, -1, // 88 - -1, 26, 27, 28, 29, 30, 31, 32, // 96 + 23, 24, 25, 255, 255, 255, 255, 255, // 88 + 255, 26, 27, 28, 29, 30, 31, 32, // 96 33, 34, 35, 36, 37, 38, 39, 40, // 104 41, 42, 43, 44, 45, 46, 47, 48, // 112 - 49, 50, 51, -1, -1, -1, -1, -1 // 120 + 49, 50, 51, 255, 255, 255, 255, 255 // 120 }; - const char* from_table = _from_table; + const unsigned char* from_table = _from_table; } diff --git a/src/web/base64.h b/src/web/base64.h index 7a91981..ccf263e 100644 --- a/src/web/base64.h +++ b/src/web/base64.h @@ -59,9 +59,9 @@ namespace base64 typedef unsigned uint32; typedef unsigned char uint8; - extern WT_API const char* to_table; - extern WT_API const char* to_table_end; - extern WT_API const char* from_table; + extern WT_API const unsigned char* to_table; + extern WT_API const unsigned char* to_table_end; + extern WT_API const unsigned char* from_table; template void encode(const InputIterator& begin, @@ -136,7 +136,7 @@ namespace base64 chars=0; while((chars<4) && (it != end)) { - uint8 c = static_cast(*it); + uint8 c = static_cast(*it); if (c == '=') break; // pad character marks the end of the stream ++it; -- 2.6.2