From 3a9b6f4bb029b9ad0dbc3435ff7b5905ce95c517 Mon Sep 17 00:00:00 2001 From: Ted John Date: Thu, 12 Jan 2017 13:16:00 +0000 Subject: [PATCH] Fix more warnings --- src/openrct2/localisation/language.cpp | 12 ++++++------ src/openrct2/management/award.c | 2 +- src/openrct2/network/NetworkKey.cpp | 6 +++--- src/openrct2/network/http.cpp | 16 ---------------- src/openrct2/network/network.cpp | 7 ------- src/openrct2/network/twitch.cpp | 2 +- 6 files changed, 11 insertions(+), 34 deletions(-) diff --git a/src/openrct2/localisation/language.cpp b/src/openrct2/localisation/language.cpp index 8f88b6a9d5..54f0dbeace 100644 --- a/src/openrct2/localisation/language.cpp +++ b/src/openrct2/localisation/language.cpp @@ -34,11 +34,11 @@ bool gUseTrueTypeFont = false; static ILanguagePack * _languageFallback = nullptr; static ILanguagePack * _languageCurrent = nullptr; -const utf8 BlackUpArrowString[] = { (utf8)0xC2, (utf8)0x8E, (utf8)0xE2, (utf8)0x96, (utf8)0xB2, (utf8)0x00 }; -const utf8 BlackDownArrowString[] = { (utf8)0xC2, (utf8)0x8E, (utf8)0xE2, (utf8)0x96, (utf8)0xBC, (utf8)0x00 }; -const utf8 BlackLeftArrowString[] = { (utf8)0xC2, (utf8)0x8E, (utf8)0xE2, (utf8)0x97, (utf8)0x80, (utf8)0x00 }; -const utf8 BlackRightArrowString[] = { (utf8)0xC2, (utf8)0x8E, (utf8)0xE2, (utf8)0x96, (utf8)0xB6, (utf8)0x00 }; -const utf8 CheckBoxMarkString[] = { (utf8)0xE2, (utf8)0x9C, (utf8)0x93, (utf8)0x00 }; +const utf8 BlackUpArrowString[] = { (utf8)(uint8)0xC2, (utf8)(uint8)0x8E, (utf8)(uint8)0xE2, (utf8)(uint8)0x96, (utf8)(uint8)0xB2, (utf8)(uint8)0x00 }; +const utf8 BlackDownArrowString[] = { (utf8)(uint8)0xC2, (utf8)(uint8)0x8E, (utf8)(uint8)0xE2, (utf8)(uint8)0x96, (utf8)(uint8)0xBC, (utf8)(uint8)0x00 }; +const utf8 BlackLeftArrowString[] = { (utf8)(uint8)0xC2, (utf8)(uint8)0x8E, (utf8)(uint8)0xE2, (utf8)(uint8)0x97, (utf8)(uint8)0x80, (utf8)(uint8)0x00 }; +const utf8 BlackRightArrowString[] = { (utf8)(uint8)0xC2, (utf8)(uint8)0x8E, (utf8)(uint8)0xE2, (utf8)(uint8)0x96, (utf8)(uint8)0xB6, (utf8)(uint8)0x00 }; +const utf8 CheckBoxMarkString[] = { (utf8)(uint8)0xE2, (utf8)(uint8)0x9C, (utf8)(uint8)0x93, (utf8)(uint8)0x00 }; void utf8_remove_format_codes(utf8 * text, bool allowcolours) { @@ -144,7 +144,7 @@ static wchar_t convert_specific_language_character_to_unicode(int languageId, wc static utf8 * convert_multibyte_charset(const char * src, size_t srcMaxSize, int languageId) { - constexpr char CODEPOINT_DOUBLEBYTE = (char)0xFF; + constexpr char CODEPOINT_DOUBLEBYTE = (char)(uint8)0xFF; auto sb = StringBuilder(64); for (const char * ch = src; (ch < src + srcMaxSize) && (*ch != '\0');) diff --git a/src/openrct2/management/award.c b/src/openrct2/management/award.c index 80aabe37a3..d889031d01 100644 --- a/src/openrct2/management/award.c +++ b/src/openrct2/management/award.c @@ -441,7 +441,7 @@ static int award_is_deserved_most_disappointing(int awardType, int activeAwardTy disappointingRides = 0; FOR_ALL_RIDES(i, ride) { - if (ride->excitement == (ride_rating)0xFFFF || ride->popularity == 0xFF) + if (ride->excitement == (ride_rating)(uint16)0xFFFF || ride->popularity == 0xFF) continue; countedRides++; diff --git a/src/openrct2/network/NetworkKey.cpp b/src/openrct2/network/NetworkKey.cpp index 1c730b3f4a..f2a6ffaeb1 100644 --- a/src/openrct2/network/NetworkKey.cpp +++ b/src/openrct2/network/NetworkKey.cpp @@ -350,7 +350,7 @@ bool NetworkKey::Sign(const uint8 * md, const size_t len, char ** signature, siz *signature = nullptr; /* Create the Message Digest Context */ - if (!(mdctx = EVP_MD_CTX_create())) + if ((mdctx = EVP_MD_CTX_create()) == NULL) { log_error("Failed to create MD context"); return false; @@ -382,7 +382,7 @@ bool NetworkKey::Sign(const uint8 * md, const size_t len, char ** signature, siz unsigned char * sig; /* Allocate memory for the signature based on size in slen */ - if (!(sig = (unsigned char*)OPENSSL_malloc((int)(sizeof(unsigned char) * (*out_size))))) + if ((sig = (unsigned char*)OPENSSL_malloc((int)(sizeof(unsigned char) * (*out_size)))) == NULL) { log_error("Failed to crypto-allocate space fo signature"); EVP_MD_CTX_destroy(mdctx); @@ -408,7 +408,7 @@ bool NetworkKey::Verify(const uint8 * md, const size_t len, const char * sig, co EVP_MD_CTX * mdctx = nullptr; /* Create the Message Digest Context */ - if (!(mdctx = EVP_MD_CTX_create())) + if ((mdctx = EVP_MD_CTX_create()) == NULL) { log_error("Failed to create MD context"); return false; diff --git a/src/openrct2/network/http.cpp b/src/openrct2/network/http.cpp index f5949f42ea..604319a5cc 100644 --- a/src/openrct2/network/http.cpp +++ b/src/openrct2/network/http.cpp @@ -62,22 +62,6 @@ void http_dispose() curl_global_cleanup(); } -static size_t http_request_read_func(void *ptr, size_t size, size_t nmemb, void *userdata) -{ - read_buffer *readBuffer = (read_buffer*)userdata; - - size_t remainingBytes = readBuffer->length - readBuffer->position; - size_t readBytes = size * nmemb; - if (readBytes > remainingBytes) { - readBytes = remainingBytes; - } - - memcpy(ptr, readBuffer->ptr + readBuffer->position, readBytes); - - readBuffer->position += readBytes; - return readBytes; -} - static size_t http_request_write_func(void *ptr, size_t size, size_t nmemb, void *userdata) { write_buffer *writeBuffer = (write_buffer*)userdata; diff --git a/src/openrct2/network/network.cpp b/src/openrct2/network/network.cpp index 2616777153..6bd0d193f2 100644 --- a/src/openrct2/network/network.cpp +++ b/src/openrct2/network/network.cpp @@ -90,7 +90,6 @@ void network_chat_show_server_greeting(); static void network_get_keys_directory(utf8 *buffer, size_t bufferSize); static void network_get_private_key_path(utf8 *buffer, size_t bufferSize, const utf8 * playerName); static void network_get_public_key_path(utf8 *buffer, size_t bufferSize, const utf8 * playerName, const utf8 * hash); -static void network_get_keymap_path(utf8 *buffer, size_t bufferSize); Network::Network() { @@ -2493,12 +2492,6 @@ static void network_get_public_key_path(utf8 *buffer, size_t bufferSize, const u String::Append(buffer, bufferSize, ".pubkey"); } -static void network_get_keymap_path(utf8 *buffer, size_t bufferSize) -{ - platform_get_user_directory(buffer, NULL, bufferSize); - Path::Append(buffer, bufferSize, "keymappings.json"); -} - const utf8 * network_get_server_name() { return gNetwork.ServerName.c_str(); } const utf8 * network_get_server_description() { return gNetwork.ServerDescription.c_str(); } const utf8 * network_get_server_greeting() { return gNetwork.ServerGreeting.c_str(); } diff --git a/src/openrct2/network/twitch.cpp b/src/openrct2/network/twitch.cpp index f835300b84..3e3cc657fc 100644 --- a/src/openrct2/network/twitch.cpp +++ b/src/openrct2/network/twitch.cpp @@ -546,7 +546,7 @@ namespace Twitch if (gConfigTwitch.enable_news) { utf8 buffer[256]; - buffer[0] = (utf8)FORMAT_TOPAZ; + buffer[0] = (utf8)(uint8)FORMAT_TOPAZ; safe_strcpy(buffer + 1, message, sizeof(buffer) - 1); // Remove unsupported characters