mirror of
https://github.com/oatpp/oatpp.git
synced 2025-02-23 17:40:28 +08:00
Merge pull request #821 from fhuberts/fix-Wconversion
Fix compiler warnings (-Wconversion)
This commit is contained in:
commit
75fc72b02c
@ -119,7 +119,7 @@ endif (CMAKE_CXX_COMPILER_ID MATCHES GNU)
|
||||
#
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES GNU)
|
||||
add_compiler_flags(4.6 "-Wcast-align")
|
||||
#add_compiler_flags(4.6 "-Wconversion")
|
||||
add_compiler_flags(4.6 "-Wconversion")
|
||||
#add_compiler_flags(4.6 "-Wdouble-promotion")
|
||||
add_compiler_flags(4.6 "-Winvalid-pch")
|
||||
add_compiler_flags(4.6 "-Wmissing-declarations")
|
||||
|
@ -436,11 +436,11 @@ v_int64 Caret::StateSaveGuard::getSavedErrorCode() {
|
||||
char c2 = m_data[m_pos + i];
|
||||
|
||||
if(c1 >= 'a' && c1 <= 'z'){
|
||||
c1 = 'A' + c1 - 'a';
|
||||
c1 = static_cast<char>(c1 - 'a' + 'A');
|
||||
}
|
||||
|
||||
if(c2 >= 'a' && c2 <= 'z'){
|
||||
c2 = 'A' + c2 - 'a';
|
||||
c2 = static_cast<char>(c2 - 'a' + 'A');
|
||||
}
|
||||
|
||||
if(c1 != c2){
|
||||
|
@ -36,13 +36,13 @@ const char* const Base64::ALPHABET_BASE64_URL_SAFE_AUXILIARY_CHARS = "._-";
|
||||
|
||||
v_char8 Base64::getAlphabetCharIndex(v_char8 a, const char* auxiliaryChars) {
|
||||
if(a >= 'A' && a <='Z') {
|
||||
return a - 'A';
|
||||
return static_cast<v_char8>(a - 'A');
|
||||
}
|
||||
if(a >= 'a' && a <='z') {
|
||||
return a - 'a' + 26;
|
||||
return static_cast<v_char8>(a - 'a' + 26);
|
||||
}
|
||||
if(a >= '0' && a <='9') {
|
||||
return a - '0' + 52;
|
||||
return static_cast<v_char8>(a - '0' + 52);
|
||||
}
|
||||
if(a == auxiliaryChars[0]) {
|
||||
return 62;
|
||||
@ -167,9 +167,9 @@ oatpp::String Base64::decode(const char* data, v_buff_size size, const char* aux
|
||||
v_char8 b2 = getAlphabetCharIndex(data[pos + 2], auxiliaryChars);
|
||||
v_char8 b3 = getAlphabetCharIndex(data[pos + 3], auxiliaryChars);
|
||||
|
||||
resultData[0] = (b0 << 2) | ((b1 >> 4) & 3);
|
||||
resultData[1] = ((b1 & 15) << 4) | ((b2 >> 2) & 15);
|
||||
resultData[2] = ((b2 & 3) << 6) | b3;
|
||||
resultData[0] = static_cast<v_char8>((b0 << 2) | ((b1 >> 4) & 3));
|
||||
resultData[1] = static_cast<v_char8>(((b1 & 15) << 4) | ((b2 >> 2) & 15));
|
||||
resultData[2] = static_cast<v_char8>(((b2 & 3) << 6) | b3);
|
||||
|
||||
resultData += 3;
|
||||
pos += 4;
|
||||
@ -180,12 +180,12 @@ oatpp::String Base64::decode(const char* data, v_buff_size size, const char* aux
|
||||
v_char8 b0 = getAlphabetCharIndex(data[pos], auxiliaryChars);
|
||||
v_char8 b1 = getAlphabetCharIndex(data[pos + 1], auxiliaryChars);
|
||||
v_char8 b2 = getAlphabetCharIndex(data[pos + 2], auxiliaryChars);
|
||||
resultData[0] = (b0 << 2) | ((b1 >> 4) & 3);
|
||||
resultData[1] = ((b1 & 15) << 4) | ((b2 >> 2) & 15);
|
||||
resultData[0] = static_cast<v_char8>((b0 << 2) | ((b1 >> 4) & 3));
|
||||
resultData[1] = static_cast<v_char8>(((b1 & 15) << 4) | ((b2 >> 2) & 15));
|
||||
} else if(posDiff == 2) {
|
||||
v_char8 b0 = getAlphabetCharIndex(data[pos], auxiliaryChars);
|
||||
v_char8 b1 = getAlphabetCharIndex(data[pos + 1], auxiliaryChars);
|
||||
resultData[0] = (b0 << 2) | ((b1 >> 4) & 3);
|
||||
resultData[0] = static_cast<v_char8>((b0 << 2) | ((b1 >> 4) & 3));
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -44,8 +44,8 @@ void Hex::writeUInt16(v_uint16 value, p_char8 buffer){
|
||||
}
|
||||
|
||||
void Hex::writeUInt32(v_uint32 value, p_char8 buffer){
|
||||
writeUInt16(value >> 16, buffer);
|
||||
writeUInt16(v_uint16(value), buffer + 4);
|
||||
writeUInt16(static_cast<v_uint16>(value >> 16), buffer);
|
||||
writeUInt16(static_cast<v_uint16>(value & 0xffff), buffer + 4);
|
||||
}
|
||||
|
||||
v_int32 Hex::readUInt16(const char* buffer, v_uint16& value) {
|
||||
@ -53,11 +53,11 @@ v_int32 Hex::readUInt16(const char* buffer, v_uint16& value) {
|
||||
for(v_int32 i = 0; i < 4; i++){
|
||||
v_char8 a = buffer[i];
|
||||
if(a >= '0' && a <= '9') {
|
||||
value |= (a - '0') << ((3 - i) << 2);
|
||||
value |= static_cast<v_uint16>((a - '0') << ((3 - i) << 2));
|
||||
} else if (a >= 'A' && a <= 'F') {
|
||||
value |= (a - 'A' + 10) << ((3 - i) << 2);
|
||||
value |= static_cast<v_uint16>((a - 'A' + 10) << ((3 - i) << 2));
|
||||
} else if (a >= 'a' && a <= 'f') {
|
||||
value |= (a - 'a' + 10) << ((3 - i) << 2);
|
||||
value |= static_cast<v_uint16>((a - 'a' + 10) << ((3 - i) << 2));
|
||||
} else {
|
||||
return ERROR_UNKNOWN_SYMBOL;
|
||||
}
|
||||
@ -109,13 +109,13 @@ void Hex::decode(data::stream::ConsistentOutputStream* stream,
|
||||
auto a = buffer[i];
|
||||
|
||||
if(a >= '0' && a <= '9') {
|
||||
byte |= (a - '0') << shift;
|
||||
byte |= static_cast<v_char8>((a - '0') << shift);
|
||||
shift -= 4;
|
||||
} else if (a >= 'A' && a <= 'F') {
|
||||
byte |= (a - 'A' + 10) << shift;
|
||||
byte |= static_cast<v_char8>((a - 'A' + 10) << shift);
|
||||
shift -= 4;
|
||||
} else if (a >= 'a' && a <= 'f') {
|
||||
byte |= (a - 'a' + 10) << shift;
|
||||
byte |= static_cast<v_char8>((a - 'a' + 10) << shift);
|
||||
shift -= 4;
|
||||
} else if(!allowSeparators) {
|
||||
throw DecodingError("Invalid Character");
|
||||
|
@ -106,7 +106,7 @@ v_int32 Unicode::encodeUtf8Char(const char* sequence, v_buff_size& length){
|
||||
v_char8 bitIndex = 0;
|
||||
for(v_buff_size i = length; i > 1; i--){
|
||||
code |= (sequence[i - 1] & 63) << bitIndex;
|
||||
bitIndex += 6;
|
||||
bitIndex = static_cast<v_char8>(bitIndex + 6);
|
||||
}
|
||||
return code;
|
||||
} else {
|
||||
@ -151,8 +151,8 @@ v_buff_size Unicode::decodeUtf8Char(v_int32 code, p_char8 buffer) {
|
||||
|
||||
void Unicode::codeToUtf16SurrogatePair(v_int32 code, v_int16& high, v_int16& low){
|
||||
code -= 0x010000;
|
||||
high = 0xD800 + ((code >> 10) & 1023);
|
||||
low = 0xDC00 + (code & 1023);
|
||||
high = static_cast<v_int16>(0xD800 + ((code >> 10) & 1023));
|
||||
low = static_cast<v_int16>(0xDC00 + (code & 1023));
|
||||
}
|
||||
|
||||
v_int32 Unicode::utf16SurrogatePairToCode(v_int16 high, v_int16 low){
|
||||
|
@ -81,7 +81,7 @@ Url::Authority Url::Parser::parseAuthority(oatpp::parser::Caret& caret) {
|
||||
if(portPos > hostPos) {
|
||||
result.host = oatpp::String(&data[hostPos], portPos - 1 - hostPos);
|
||||
char* end;
|
||||
result.port = std::strtol(&data[portPos], &end, 10);
|
||||
result.port = static_cast<v_int32>(std::strtol(&data[portPos], &end, 10));
|
||||
bool success = ((reinterpret_cast<v_buff_size>(end) - reinterpret_cast<v_buff_size>(&data[portPos])) == pos - portPos);
|
||||
if(!success) {
|
||||
caret.setError("Invalid port string");
|
||||
|
Loading…
Reference in New Issue
Block a user