From 406695097563592e66b4fca95bcab4f0b37c4ebf Mon Sep 17 00:00:00 2001 From: Peter Tissen Date: Tue, 8 Apr 2014 19:29:17 +0200 Subject: [PATCH] Various warning fixes and devirtualization * Remove ArrayString * devirtualize GetCount and SetCount, they're no longer needed * set storage duration of fmt::placeholder to extern to be consistent * make length unsigned and the return value of sprintf signed * remove dead code "s.Close()" is never reached * devirtualize WrteToLog() * devirtualize Ini functions --- Utilities/Array.h | 94 +---------------------------------------- Utilities/StrFmt.cpp | 6 +-- Utilities/StrFmt.h | 4 +- rpcs3/Crypto/unself.cpp | 2 - rpcs3/Gui/ConLog.h | 2 +- rpcs3/Ini.h | 26 ++++++------ 6 files changed, 21 insertions(+), 113 deletions(-) diff --git a/Utilities/Array.h b/Utilities/Array.h index b7226cf2cd..ad5e715d7d 100644 --- a/Utilities/Array.h +++ b/Utilities/Array.h @@ -142,9 +142,9 @@ public: return m_array[num]; } - virtual u32 GetCount() const { return m_count; } + u32 GetCount() const { return m_count; } - virtual void SetCount(const u32 count, bool memzero = true) + void SetCount(const u32 count, bool memzero = true) { if(m_count >= count) return; @@ -199,96 +199,6 @@ protected: } }; -class ArrayString : public Array -{ -public: - ArrayString() : Array() - { - } - - ArrayString(const wxString& value) : Array() - { - *this = value; - } - - ArrayString(const char* value) : Array() - { - *this = value; - } - - virtual u32 GetCount() const - { - return m_array ? strlen(m_array) : 0; - } - - virtual void SetCount(const u32 count, bool memzero = true) - { - if(m_count && count < m_count - 1) - { - m_array[count] = '\0'; - } - else - { - Array::SetCount(count + 1, memzero); - } - } - - ArrayString& operator = (const char* right) - { - Clear(); - - if(right) - { - size_t len = strlen(right); - - if(len) - { - SetCount(len); - memcpy(m_array, right, len * sizeof(char)); - m_array[len] = '\0'; - } - } - - return *this; - } - - ArrayString& operator = (const ArrayString& right) - { - Clear(); - - if(size_t len = right.GetCount()) - { - SetCount(len); - memcpy(m_array, right.GetPtr(), len * sizeof(char)); - m_array[len] = '\0'; - } - - return *this; - } - - ArrayString& operator = (const wxString& right) - { - Clear(); - - if(size_t len = right.Len()) - { - SetCount(len); - memcpy(m_array, right.c_str(), len * sizeof(char)); - m_array[len] = '\0'; - } - - return *this; - } - - ArrayString* Clone() const - { - ArrayString* new_array = new ArrayString(); - (*new_array) = m_array; - - return new_array; - } -}; - template struct Stack : public Array { Stack() : Array() diff --git a/Utilities/StrFmt.cpp b/Utilities/StrFmt.cpp index 58ed16f145..e67437ae00 100644 --- a/Utilities/StrFmt.cpp +++ b/Utilities/StrFmt.cpp @@ -1,20 +1,20 @@ #include "stdafx.h" #include "StrFmt.h" -static const std::string fmt::placeholder = "???"; +extern const std::string fmt::placeholder = "???"; //wrapper to deal with advance sprintf formating options with automatic length finding //can't take strings by reference because of "va_start", so overload it with char * std::string fmt::FormatV(const char *fmt, va_list args) { - int length = 256; + size_t length = 256; std::string str; for (;;) { std::vector buffptr(length); - size_t printlen = vsnprintf(buffptr.data(), length, fmt, args); + int printlen = vsnprintf(buffptr.data(), length, fmt, args); if (printlen >= 0 && printlen < length) { str = std::string(buffptr.data(), printlen); diff --git a/Utilities/StrFmt.h b/Utilities/StrFmt.h index 0c705bd544..a812ccaa74 100644 --- a/Utilities/StrFmt.h +++ b/Utilities/StrFmt.h @@ -78,13 +78,13 @@ namespace fmt{ template string Format(const string &fmt, Args&& ... parameters) { - int length = 256; + size_t length = 256; string str; for (;;) { std::vector buffptr(length); - size_t printlen = snprintf(buffptr.data(), length, fmt.c_str(), std::forward(parameters)...); + int printlen = snprintf(buffptr.data(), length, fmt.c_str(), std::forward(parameters)...); if (printlen >= 0 && printlen < length) { str = string(buffptr.data(), printlen); diff --git a/rpcs3/Crypto/unself.cpp b/rpcs3/Crypto/unself.cpp index cb678b28e8..72a38fa8fa 100644 --- a/rpcs3/Crypto/unself.cpp +++ b/rpcs3/Crypto/unself.cpp @@ -622,8 +622,6 @@ bool CheckDebugSelf(const std::string& self, const std::string& elf) s.Seek(0); return false; } - - s.Close(); } bool DecryptSelf(const std::string& elf, const std::string& self) diff --git a/rpcs3/Gui/ConLog.h b/rpcs3/Gui/ConLog.h index c0aff95a21..d39eb47d64 100644 --- a/rpcs3/Gui/ConLog.h +++ b/rpcs3/Gui/ConLog.h @@ -11,7 +11,7 @@ class LogWriter //wxString m_prefix; //wxString m_value; - virtual void WriteToLog(const std::string& prefix, const std::string& value, u8 lvl); + void WriteToLog(const std::string& prefix, const std::string& value, u8 lvl); public: LogWriter(); diff --git a/rpcs3/Ini.h b/rpcs3/Ini.h index 997975f13b..a2a0da1d7c 100644 --- a/rpcs3/Ini.h +++ b/rpcs3/Ini.h @@ -25,19 +25,19 @@ protected: wxConfigBase* m_Config; Ini(); - virtual void Save(const wxString& key, int value); - virtual void Save(const wxString& key, bool value); - virtual void Save(const wxString& key, wxSize value); - virtual void Save(const wxString& key, wxPoint value); - virtual void Save(const wxString& key, const std::string& value); - virtual void Save(const wxString& key, WindowInfo value); + void Save(const wxString& key, int value); + void Save(const wxString& key, bool value); + void Save(const wxString& key, wxSize value); + void Save(const wxString& key, wxPoint value); + void Save(const wxString& key, const std::string& value); + void Save(const wxString& key, WindowInfo value); - virtual int Load(const wxString& key, const int def_value); - virtual bool Load(const wxString& key, const bool def_value); - virtual wxSize Load(const wxString& key, const wxSize def_value); - virtual wxPoint Load(const wxString& key, const wxPoint def_value); - virtual std::string Load(const wxString& key, const std::string& def_value); - virtual WindowInfo Load(const wxString& key, const WindowInfo& def_value); + int Load(const wxString& key, const int def_value); + bool Load(const wxString& key, const bool def_value); + wxSize Load(const wxString& key, const wxSize def_value); + wxPoint Load(const wxString& key, const wxPoint def_value); + std::string Load(const wxString& key, const std::string& def_value); + WindowInfo Load(const wxString& key, const WindowInfo& def_value); }; template struct IniEntry : public Ini @@ -95,7 +95,7 @@ public: IniEntry CPUDecoderMode; IniEntry CPUIgnoreRWErrors; IniEntry GSRenderMode; - IniEntry GSResolution; + IniEntry GSResolution; IniEntry GSAspectRatio; IniEntry GSVSyncEnable; IniEntry GSLogPrograms;