From 0ac4d8249c60c88e8181bbfc28fbccc90a35a6dd Mon Sep 17 00:00:00 2001 From: wiidev Date: Sun, 1 Aug 2021 18:00:15 +0100 Subject: [PATCH] Fixes for GCC 11 --- source/Channels/channels.cpp | 10 +++- source/Channels/channels.h | 10 ++-- source/GUI/gui_checkboxbrowser.cpp | 2 +- source/GUI/gui_checkboxbrowser.hpp | 12 ++--- source/GameCube/GCDumper.hpp | 12 ++--- source/GameCube/GCGames.cpp | 6 +-- source/GameCube/GCGames.h | 16 +++--- source/banner/BannerAsync.cpp | 4 +- source/banner/BannerAsync.h | 6 +-- source/banner/CustomBanner.h | 4 +- source/banner/OpeningBNR.cpp | 4 +- source/cache/cache.cpp | 72 ++++++++++++------------- source/cache/cache.hpp | 24 ++++----- source/cheats/cheatmenu.cpp | 2 +- source/cheats/gct.cpp | 18 +++---- source/cheats/gct.h | 26 +++++---- source/homebrewboot/BootHomebrew.cpp | 6 +++ source/menu/WDMMenu.cpp | 10 ++-- source/menu/WDMMenu.hpp | 2 +- source/network/Wiinnertag.cpp | 10 ++-- source/network/Wiinnertag.h | 10 ++-- source/network/update.cpp | 2 +- source/patches/gamepatches.c | 7 +++ source/patches/patchcode.c | 6 +++ source/prompts/CategoryPrompt.cpp | 2 +- source/prompts/CategoryPrompt.hpp | 2 +- source/prompts/CategorySelectPrompt.cpp | 4 +- source/settings/CCategoryList.cpp | 16 +++--- source/settings/CCategoryList.hpp | 20 ++++--- source/settings/CGameCategories.cpp | 42 +++++++-------- source/settings/CGameCategories.hpp | 22 ++++---- source/usbloader/GameBooter.cpp | 6 +++ source/usbloader/WDMFile.hpp | 8 ++- source/usbloader/alternatedol.c | 6 +++ source/usbloader/disc.c | 7 +++ source/usbloader/neek.cpp | 5 ++ source/wad/nandtitle.cpp | 4 +- source/wad/nandtitle.h | 3 +- source/wstring.cpp | 14 +++-- source/xml/GameTDB.cpp | 42 +++++++-------- source/xml/GameTDB.hpp | 68 ++++++++++++----------- 41 files changed, 287 insertions(+), 265 deletions(-) diff --git a/source/Channels/channels.cpp b/source/Channels/channels.cpp index 278ee87a..68a8d95d 100755 --- a/source/Channels/channels.cpp +++ b/source/Channels/channels.cpp @@ -39,6 +39,12 @@ #include "cache/cache.hpp" #include "channels.h" +/* GCC 11 false positives */ +#if __GNUC__ > 10 +#pragma GCC diagnostic ignored "-Warray-bounds" +#pragma GCC diagnostic ignored "-Wstringop-overflow" +#endif + typedef struct _dolheader { u32 section_pos[18]; @@ -126,7 +132,7 @@ void Channels::InternalGetNandChannelList(u32 type) } } -vector &Channels::GetNandHeaders(void) +std::vector &Channels::GetNandHeaders(void) { if (NandChannels.empty()) this->GetChannelList(); @@ -134,7 +140,7 @@ vector &Channels::GetNandHeaders(void) return NandChannels; } -vector &Channels::GetEmuHeaders(void) +std::vector &Channels::GetEmuHeaders(void) { if (Settings.UseGameHeaderCache && isCacheFile(EMUNAND_HEADER_CACHE_FILE)) { diff --git a/source/Channels/channels.h b/source/Channels/channels.h index 2d884869..aa1725dd 100755 --- a/source/Channels/channels.h +++ b/source/Channels/channels.h @@ -30,8 +30,6 @@ #include #include "usbloader/disc.h" -using namespace std; - class Channels { public: @@ -46,8 +44,8 @@ public: void GetChannelList(); void GetEmuChannelList(); - vector & GetNandHeaders(void); - vector & GetEmuHeaders(void); + std::vector & GetNandHeaders(void); + std::vector & GetEmuHeaders(void); private: static Channels *instance; @@ -58,8 +56,8 @@ private: bool ParseTitleDir(char *path, int language); bool GetEmuChanTitle(char *tmdpath, int language, std::string &Title); - vector NandChannels; - vector EmuChannels; + std::vector NandChannels; + std::vector EmuChannels; }; #endif diff --git a/source/GUI/gui_checkboxbrowser.cpp b/source/GUI/gui_checkboxbrowser.cpp index 95dc2050..7f36884a 100644 --- a/source/GUI/gui_checkboxbrowser.cpp +++ b/source/GUI/gui_checkboxbrowser.cpp @@ -81,7 +81,7 @@ void GuiCheckboxBrowser::Clear() checkBoxList.clear(); } -bool GuiCheckboxBrowser::AddEntrie(const string &text, bool checked, int style, bool multistates) +bool GuiCheckboxBrowser::AddEntrie(const std::string &text, bool checked, int style, bool multistates) { LOCK(this); int currentSize = checkBoxList.size(); diff --git a/source/GUI/gui_checkboxbrowser.hpp b/source/GUI/gui_checkboxbrowser.hpp index 1f70850d..7ecadeef 100644 --- a/source/GUI/gui_checkboxbrowser.hpp +++ b/source/GUI/gui_checkboxbrowser.hpp @@ -29,14 +29,12 @@ #include "gui_checkbox.hpp" #include "gui_scrollbar.hpp" -using namespace std; - class GuiCheckboxBrowser : public GuiElement, public sigslot::has_slots<> { public: GuiCheckboxBrowser(int w, int h, int maxSize = 7); virtual ~GuiCheckboxBrowser(); - bool AddEntrie(const string &text, bool checked = false, int style = GuiCheckbox::CHECKSIGN, bool multistates = false); + bool AddEntrie(const std::string &text, bool checked = false, int style = GuiCheckbox::CHECKSIGN, bool multistates = false); int GetSelected() const { return pageIndex+selectedItem; } bool IsChecked(u32 i) { if(i >= checkBoxList.size()) return false; else return checkBoxList[i]->IsChecked(); } GuiCheckbox *GetCheckbox(u32 i) { if(i >= checkBoxList.size()) return NULL; else return checkBoxList[i]; } @@ -62,10 +60,10 @@ class GuiCheckboxBrowser : public GuiElement, public sigslot::has_slots<> GuiImage *backgroundImg; GuiImageData *markImgData; GuiImage *markImg; - vector textLineDrawn; - vector checkBoxDrawn; - vector textLineList; - vector checkBoxList; + std::vector textLineDrawn; + std::vector checkBoxDrawn; + std::vector textLineList; + std::vector checkBoxList; }; #endif diff --git a/source/GameCube/GCDumper.hpp b/source/GameCube/GCDumper.hpp index 4d6a232b..94d6c6f9 100644 --- a/source/GameCube/GCDumper.hpp +++ b/source/GameCube/GCDumper.hpp @@ -30,8 +30,6 @@ #include #include -using namespace std; - class GCDumper { public: @@ -42,14 +40,14 @@ public: int ReadDiscInfo(const u64 &game_offset); void SetForceAlign(bool b) { force_align32 = b; } void SetCompressed(bool b) { compressed = b; } - vector & GetDiscHeaders() { return discHeaders; } - vector & GetDiscSizes() { return gameSizes; } + std::vector & GetDiscHeaders() { return discHeaders; } + std::vector & GetDiscSizes() { return gameSizes; } private: s32 CopyDiscData(FILE *f, u64 offset, u32 length, u8 *buffer); - vector discHeaders; - vector gameSizes; - vector gameOffsets; + std::vector discHeaders; + std::vector gameSizes; + std::vector gameOffsets; bool force_align32; bool compressed; u32 discWrote; diff --git a/source/GameCube/GCGames.cpp b/source/GameCube/GCGames.cpp index bfac4667..fcbcd065 100644 --- a/source/GameCube/GCGames.cpp +++ b/source/GameCube/GCGames.cpp @@ -58,7 +58,7 @@ const char *GCGames::GetPath(const char *gameID) const return ""; } -void GCGames::LoadGameList(const string &path, vector &headerList, vector &pathList) +void GCGames::LoadGameList(const std::string &path, std::vector &headerList, std::vector &pathList) { struct discHdr tmpHdr; struct stat st; @@ -183,7 +183,7 @@ void GCGames::LoadGameList(const string &path, vector &headerLis if (*id != 0 && strlen(title) > 0) { - string gamePath = string(path) + dirname + (extracted ? "/" : strrchr(fpath, '/')); + std::string gamePath = std::string(path) + dirname + (extracted ? "/" : strrchr(fpath, '/')); memset(&tmpHdr, 0, sizeof(tmpHdr)); memcpy(tmpHdr.id, id, sizeof(tmpHdr.id)); snprintf(tmpHdr.title, sizeof(tmpHdr.title), "%s", title); @@ -206,7 +206,7 @@ void GCGames::LoadGameList(const string &path, vector &headerLis if (tmpHdr.gc_magic == GCGames::MAGIC) { - string gamePath = string(path) + dirname + (extracted ? "/" : strrchr(fpath, '/')); + std::string gamePath = std::string(path) + dirname + (extracted ? "/" : strrchr(fpath, '/')); tmpHdr.magic = tmpHdr.gc_magic; tmpHdr.type = extracted ? TYPE_GAME_GC_EXTRACTED : TYPE_GAME_GC_IMG; headerList.push_back(tmpHdr); diff --git a/source/GameCube/GCGames.h b/source/GameCube/GCGames.h index 38bc3e41..f3ce4404 100644 --- a/source/GameCube/GCGames.h +++ b/source/GameCube/GCGames.h @@ -26,8 +26,6 @@ int nintendontBuildDate(const char *NIN_loader_path, char* NINBuildDate); int nintendontVersion(const char *NIN_loader_path, char* NINVersion, int len); -using namespace std; - class GCGames { public: @@ -40,7 +38,7 @@ public: u32 LoadAllGames(void); - void LoadGameList(const string &path, vector &headerList, vector &pathList); + void LoadGameList(const std::string &path, std::vector &headerList, std::vector &pathList); bool RemoveGame(const char *gameID); bool RemoveSDGame(const char *gameID); @@ -48,14 +46,14 @@ public: const char *GetPath(const char *gameID) const; - vector & GetHeaders(void) + std::vector & GetHeaders(void) { LoadAllGames(); return HeaderList; } - vector & GetSDHeaders(void) { + std::vector & GetSDHeaders(void) { return sdGCList; } @@ -65,10 +63,10 @@ private: static GCGames *instance; - vector PathList; - vector HeaderList; - vector sdGCList; - vector sdGCPathList; + std::vector PathList; + std::vector HeaderList; + std::vector sdGCList; + std::vector sdGCPathList; }; #endif diff --git a/source/banner/BannerAsync.cpp b/source/banner/BannerAsync.cpp index 163d1f71..f23cf266 100644 --- a/source/banner/BannerAsync.cpp +++ b/source/banner/BannerAsync.cpp @@ -28,8 +28,8 @@ distribution. #include "OpeningBNR.hpp" #include "BannerAsync.h" -vector BannerAsync::List; -queue BannerAsync::DeleteList; +std::vector BannerAsync::List; +std::queue BannerAsync::DeleteList; lwp_t BannerAsync::Thread = LWP_THREAD_NULL; mutex_t BannerAsync::ListLock = LWP_THREAD_NULL; BannerAsync * BannerAsync::InUse = NULL; diff --git a/source/banner/BannerAsync.h b/source/banner/BannerAsync.h index 49ffdb2d..a16440b8 100644 --- a/source/banner/BannerAsync.h +++ b/source/banner/BannerAsync.h @@ -29,8 +29,6 @@ distribution. #include "usbloader/GameList.h" #include "Banner.h" -using namespace std; - class BannerAsync : public Banner { public: @@ -52,8 +50,8 @@ private: static void ThreadAdd(BannerAsync* banner); static void ThreadRemove(BannerAsync* banner); - static vector List; - static queue DeleteList; + static std::vector List; + static std::queue DeleteList; static lwp_t Thread; static mutex_t ListLock; static BannerAsync * InUse; diff --git a/source/banner/CustomBanner.h b/source/banner/CustomBanner.h index f3d4eea4..0c5d258d 100644 --- a/source/banner/CustomBanner.h +++ b/source/banner/CustomBanner.h @@ -20,8 +20,6 @@ #include #include "Banner.h" -using namespace std; - class CustomBanner : public Banner { public: @@ -37,7 +35,7 @@ public: void SetBannerPaneVisible(const char *pane, bool visible); private: u8 *LoadTextureFromPng(const u8 * img, u32 imgSize, int *width, int *height); - vector text_list; + std::vector text_list; }; #endif /*CUSTOM_BANNER_H_*/ diff --git a/source/banner/OpeningBNR.cpp b/source/banner/OpeningBNR.cpp index b57d7e19..e7c9918c 100644 --- a/source/banner/OpeningBNR.cpp +++ b/source/banner/OpeningBNR.cpp @@ -330,7 +330,7 @@ u8 *OpeningBNR::LoadGCBNR(const discHdr * header, u32 *len) } else if(header->type == TYPE_GAME_GC_EXTRACTED) { - string gamePath = path; + std::string gamePath = path; gamePath += "root/"; //! open default file first file = fopen((gamePath + "opening.bnr").c_str(), "rb"); @@ -446,7 +446,7 @@ CustomBanner *OpeningBNR::CreateGCBanner(const discHdr * header) // sets the description and converts encodings (Japan and Taiwan) if(header->id[3] == 'J' || header->id[3] == 'W') { - string description((char *) openingBnr->description[language].long_description); + std::string description((char *) openingBnr->description[language].long_description); banner->SetBannerText("T_short_descript", sj2utf8(description).c_str()); } else diff --git a/source/cache/cache.cpp b/source/cache/cache.cpp index 12ad497a..7670258f 100644 --- a/source/cache/cache.cpp +++ b/source/cache/cache.cpp @@ -21,9 +21,9 @@ void ResetGameHeaderCache() } // emuNAND -void SaveGameHeaderCache(vector &list) +void SaveGameHeaderCache(std::vector &list) { - string path = string(Settings.GameHeaderCachePath) + EMUNAND_HEADER_CACHE_FILE; + std::string path = std::string(Settings.GameHeaderCachePath) + EMUNAND_HEADER_CACHE_FILE; if (!CheckFile(Settings.GameHeaderCachePath)) CreateSubfolder(Settings.GameHeaderCachePath); @@ -38,9 +38,9 @@ void SaveGameHeaderCache(vector &list) fclose(cache); } -void LoadGameHeaderCache(vector &list) +void LoadGameHeaderCache(std::vector &list) { - string path = string(Settings.GameHeaderCachePath) + EMUNAND_HEADER_CACHE_FILE; + std::string path = std::string(Settings.GameHeaderCachePath) + EMUNAND_HEADER_CACHE_FILE; FILE *cache = fopen(path.c_str(), "rb"); @@ -66,9 +66,9 @@ void LoadGameHeaderCache(vector &list) } // Wii -void SaveGameHeaderCache(vector &list, vector &plist) +void SaveGameHeaderCache(std::vector &list, std::vector &plist) { - vector wiictmp; + std::vector wiictmp; struct wiiCache gtmp; for (u32 i = 0; i < list.size(); ++i) @@ -79,7 +79,7 @@ void SaveGameHeaderCache(vector &list, vector &plist) wiictmp.push_back(gtmp); } - string path = string(Settings.GameHeaderCachePath) + WII_HEADER_CACHE_FILE; + std::string path = std::string(Settings.GameHeaderCachePath) + WII_HEADER_CACHE_FILE; if (!CheckFile(Settings.GameHeaderCachePath)) CreateSubfolder(Settings.GameHeaderCachePath); @@ -94,9 +94,9 @@ void SaveGameHeaderCache(vector &list, vector &plist) fclose(cache); } -void LoadGameHeaderCache(vector &list, vector &plist) +void LoadGameHeaderCache(std::vector &list, std::vector &plist) { - string path = string(Settings.GameHeaderCachePath) + WII_HEADER_CACHE_FILE; + std::string path = std::string(Settings.GameHeaderCachePath) + WII_HEADER_CACHE_FILE; FILE *cache = fopen(path.c_str(), "rb"); @@ -124,9 +124,9 @@ void LoadGameHeaderCache(vector &list, vector &plist) } // GameCube -void SaveGameHeaderCache(vector &list, vector &plist) +void SaveGameHeaderCache(std::vector &list, std::vector &plist) { - vector gcctmp; + std::vector gcctmp; struct gcCache gtmp; for (u32 i = 0; i < list.size(); ++i) @@ -139,7 +139,7 @@ void SaveGameHeaderCache(vector &list, vector &plist) gcctmp.push_back(gtmp); } - string path = string(Settings.GameHeaderCachePath) + GAMECUBE_HEADER_CACHE_FILE; + std::string path = std::string(Settings.GameHeaderCachePath) + GAMECUBE_HEADER_CACHE_FILE; if (!CheckFile(Settings.GameHeaderCachePath)) CreateSubfolder(Settings.GameHeaderCachePath); @@ -154,9 +154,9 @@ void SaveGameHeaderCache(vector &list, vector &plist) fclose(cache); } -void LoadGameHeaderCache(vector &list, vector &plist) +void LoadGameHeaderCache(std::vector &list, std::vector &plist) { - string path = string(Settings.GameHeaderCachePath) + GAMECUBE_HEADER_CACHE_FILE; + std::string path = std::string(Settings.GameHeaderCachePath) + GAMECUBE_HEADER_CACHE_FILE; FILE *cache = fopen(path.c_str(), "rb"); @@ -178,15 +178,15 @@ void LoadGameHeaderCache(vector &list, vector &plist) fread((void *)&gcctmp, 1, sizeof(struct gcCache), cache); list.push_back(gcctmp.header); - string tmp((char *)gcctmp.path); + std::string tmp((char *)gcctmp.path); plist.push_back(tmp); } fclose(cache); } -void SaveFilteredListCache(vector &list, const wchar_t *gameFilter) +void SaveFilteredListCache(std::vector &list, const wchar_t *gameFilter) { - string path = string(Settings.GameHeaderCachePath) + FilteredListCacheFileName(gameFilter); + std::string path = std::string(Settings.GameHeaderCachePath) + FilteredListCacheFileName(gameFilter); if (!CheckFile(Settings.GameHeaderCachePath)) CreateSubfolder(Settings.GameHeaderCachePath); @@ -196,7 +196,7 @@ void SaveFilteredListCache(vector &list, const wchar_t *gameFi if (!cache) return; - vector tmplist; + std::vector tmplist; struct gameHdr tmp; for (u32 i = 0; i < list.size(); ++i) @@ -209,9 +209,9 @@ void SaveFilteredListCache(vector &list, const wchar_t *gameFi fclose(cache); } -void LoadFilteredListCache(vector &list, const wchar_t *gameFilter) +void LoadFilteredListCache(std::vector &list, const wchar_t *gameFilter) { - string path = string(Settings.GameHeaderCachePath) + FilteredListCacheFileName(gameFilter); + std::string path = std::string(Settings.GameHeaderCachePath) + FilteredListCacheFileName(gameFilter); if (!CheckFile(Settings.GameHeaderCachePath)) CreateSubfolder(Settings.GameHeaderCachePath); @@ -238,7 +238,7 @@ void LoadFilteredListCache(vector &list, const wchar_t *gameFi if (!found) { - vector &tmplist = gameList.GetFullGameList(); + std::vector &tmplist = gameList.GetFullGameList(); for (u32 c = 0; c < tmplist.size(); ++c) { struct discHdr *header = &tmplist[c]; @@ -253,7 +253,7 @@ void LoadFilteredListCache(vector &list, const wchar_t *gameFi if (!found) { - vector &tmplist = GCGames::Instance()->GetHeaders(); + std::vector &tmplist = GCGames::Instance()->GetHeaders(); for (u32 c = 0; c < tmplist.size(); ++c) { struct discHdr *header = &tmplist[c]; @@ -268,7 +268,7 @@ void LoadFilteredListCache(vector &list, const wchar_t *gameFi if (!found) { - vector &tmplist = Channels::Instance()->GetNandHeaders(); + std::vector &tmplist = Channels::Instance()->GetNandHeaders(); for (u32 c = 0; c < tmplist.size(); ++c) { struct discHdr *header = &tmplist[c]; @@ -283,7 +283,7 @@ void LoadFilteredListCache(vector &list, const wchar_t *gameFi if (!found) { - vector &tmplist = Channels::Instance()->GetEmuHeaders(); + std::vector &tmplist = Channels::Instance()->GetEmuHeaders(); for (u32 c = 0; c < tmplist.size(); ++c) { struct discHdr *header = &tmplist[c]; @@ -300,16 +300,16 @@ void LoadFilteredListCache(vector &list, const wchar_t *gameFi fclose(cache); } -string FilteredListCacheFileName(const wchar_t *gameFilter) +std::string FilteredListCacheFileName(const wchar_t *gameFilter) { - string tmp; + std::string tmp; tmp = "FL"; - tmp += "_" + to_string(Settings.LoaderMode); - tmp += "_" + to_string(Settings.GameSort); + tmp += "_" + std::to_string(Settings.LoaderMode); + tmp += "_" + std::to_string(Settings.GameSort); if (gameFilter) { - wstring ws(gameFilter); - string gf(ws.begin(), ws.end()); + std::wstring ws(gameFilter); + std::string gf(ws.begin(), ws.end()); if ((gf.length()) > 0) tmp += "_" + gf; } @@ -317,19 +317,19 @@ string FilteredListCacheFileName(const wchar_t *gameFilter) return tmp; } -string FilteredListCacheFileName() +std::string FilteredListCacheFileName() { - string tmp; + std::string tmp; tmp = "FL"; - tmp += "_" + to_string(Settings.LoaderMode); - tmp += "_" + to_string(Settings.GameSort); + tmp += "_" + std::to_string(Settings.LoaderMode); + tmp += "_" + std::to_string(Settings.GameSort); tmp += ".cache"; return tmp; } -bool isCacheFile(string filename) +bool isCacheFile(std::string filename) { - string path = string(Settings.GameHeaderCachePath) + filename; + std::string path = std::string(Settings.GameHeaderCachePath) + filename; if (CheckFile(path.c_str())) return true; diff --git a/source/cache/cache.hpp b/source/cache/cache.hpp index 394ab64e..308ae937 100644 --- a/source/cache/cache.hpp +++ b/source/cache/cache.hpp @@ -9,8 +9,6 @@ #define GAMECUBE_HEADER_CACHE_FILE "GAMECUBE.cache" #define EMUNAND_HEADER_CACHE_FILE "EMUNAND.cache" -using namespace std; - struct gameHdr { /* Game ID */ @@ -33,22 +31,22 @@ struct gcCache }; // emuNAND -void SaveGameHeaderCache(vector &list); -void LoadGameHeaderCache(vector &list); +void SaveGameHeaderCache(std::vector &list); +void LoadGameHeaderCache(std::vector &list); // Wii -void SaveGameHeaderCache(vector &list, vector &plist); -void LoadGameHeaderCache(vector &list, vector &plist); +void SaveGameHeaderCache(std::vector &list, std::vector &plist); +void LoadGameHeaderCache(std::vector &list, std::vector &plist); // GameCube -void SaveGameHeaderCache(vector &list, vector &plist); -void LoadGameHeaderCache(vector &list, vector &plist); +void SaveGameHeaderCache(std::vector &list, std::vector &plist); +void LoadGameHeaderCache(std::vector &list, std::vector &plist); void ResetGameHeaderCache(); -void SaveFilteredListCache(vector &list, const wchar_t *gameFilter); -void LoadFilteredListCache(vector &list, const wchar_t *gameFilter); +void SaveFilteredListCache(std::vector &list, const wchar_t *gameFilter); +void LoadFilteredListCache(std::vector &list, const wchar_t *gameFilter); -string FilteredListCacheFileName(const wchar_t *gameFilter); -string FilteredListCacheFileName(); -bool isCacheFile(string filename); +std::string FilteredListCacheFileName(const wchar_t *gameFilter); +std::string FilteredListCacheFileName(); +bool isCacheFile(std::string filename); diff --git a/source/cheats/cheatmenu.cpp b/source/cheats/cheatmenu.cpp index a249738a..a3ed5e9e 100644 --- a/source/cheats/cheatmenu.cpp +++ b/source/cheats/cheatmenu.cpp @@ -141,7 +141,7 @@ int CheatMenu(const char * gameID) { if (cntcheats > 0) { - vector vActiveCheats; + std::vector vActiveCheats; for (int i = 0; i < cntcheats; i++) { const char *strCheck = cheatslst.GetName(i); diff --git a/source/cheats/gct.cpp b/source/cheats/gct.cpp index 810894a7..7c304150 100644 --- a/source/cheats/gct.cpp +++ b/source/cheats/gct.cpp @@ -42,25 +42,25 @@ void GCTCheats::Clear(void) } -string GCTCheats::getGameName(void) +std::string GCTCheats::getGameName(void) { return sGameTitle; } -string GCTCheats::getGameID(void) +std::string GCTCheats::getGameID(void) { return sGameID; } -vector GCTCheats::getCheat(int nr) +std::vector GCTCheats::getCheat(int nr) { if((unsigned int)nr >= cheatList.size()) - return vector(); + return std::vector(); return cheatList[nr].sCheats; } -string GCTCheats::getCheatName(int nr) +std::string GCTCheats::getCheatName(int nr) { if((unsigned int)nr >= cheatList.size()) return ERRORRANGE; @@ -68,7 +68,7 @@ string GCTCheats::getCheatName(int nr) return cheatList[nr].sCheatName; } -string GCTCheats::getCheatComment(int nr) +std::string GCTCheats::getCheatComment(int nr) { if((unsigned int)nr >= cheatList.size()) return ERRORRANGE; @@ -76,7 +76,7 @@ string GCTCheats::getCheatComment(int nr) return cheatList[nr].sCheatComment; } -int GCTCheats::createGCT(const vector &vCheats, const char * filename) +int GCTCheats::createGCT(const std::vector &vCheats, const char * filename) { if (vCheats.size() == 0 || !filename) return 0; @@ -95,7 +95,7 @@ int GCTCheats::createGCT(const vector &vCheats, const char * filename) if((unsigned int)vCheats[c] >= cheatList.size()) continue; - vector &cheatBuf = cheatList[vCheats[c]].sCheats; + std::vector &cheatBuf = cheatList[vCheats[c]].sCheats; if(cheatBuf.size() > 0) fwrite((char*)&cheatBuf[0], cheatBuf.size() * sizeof(unsigned int), 1, pFile); @@ -223,7 +223,7 @@ bool GCTCheats::IsCheatIncluded(int iCheat, const unsigned char *gctBuf, unsigne if(!gctBuf || (unsigned int)iCheat >= cheatList.size()) return false; - vector &Cheat = cheatList[iCheat].sCheats; + std::vector &Cheat = cheatList[iCheat].sCheats; int len = Cheat.size() * sizeof(unsigned int); for(unsigned int i = sizeof(GCT_Header); i + len <= gctSize - sizeof(GCT_Footer); i += 4) diff --git a/source/cheats/gct.h b/source/cheats/gct.h index cfeac9d7..afa2a2f7 100644 --- a/source/cheats/gct.h +++ b/source/cheats/gct.h @@ -21,21 +21,19 @@ #include #include -using namespace std; - //!Handles Ocarina TXT Cheatfiles class GCTCheats { private: - string sGameID; - string sGameTitle; + std::string sGameID; + std::string sGameTitle; struct CheatEntry { - string sCheatName; - string sCheatComment; - vector sCheats; + std::string sCheatName; + std::string sCheatComment; + std::vector sCheats; }; - vector cheatList; + std::vector cheatList; public: //!Constructor GCTCheats(void); @@ -50,25 +48,25 @@ class GCTCheats //!\param cnt size of array //!\param filename name of GCT file //!\return error code - int createGCT(const vector &vCheats, const char * filename); + int createGCT(const std::vector &vCheats, const char * filename); //!Gets Count cheats //!\return Count cheats int getCnt() const { return cheatList.size(); } //!Gets Game Name //!\return Game Name - string getGameName(void); + std::string getGameName(void); //!Gets GameID //!\return GameID - string getGameID(void); + std::string getGameID(void); //!Gets cheat data //!\return cheat data - vector getCheat(int nr); + std::vector getCheat(int nr); //!Gets Cheat Name //!\return Cheat Name - string getCheatName(int nr); + std::string getCheatName(int nr); //!Gets Cheat Comment //!\return Cheat Comment - string getCheatComment(int nr); + std::string getCheatComment(int nr); //!Clear all loaded cheats void Clear(void); //!Check if string is a code diff --git a/source/homebrewboot/BootHomebrew.cpp b/source/homebrewboot/BootHomebrew.cpp index 21cec4f8..c8447995 100644 --- a/source/homebrewboot/BootHomebrew.cpp +++ b/source/homebrewboot/BootHomebrew.cpp @@ -15,6 +15,12 @@ #include "sys.h" #include "gecko.h" +/* GCC 11 false positives */ +#if __GNUC__ > 10 +#pragma GCC diagnostic ignored "-Warray-bounds" +#pragma GCC diagnostic ignored "-Wstringop-overflow" +#endif + #define EXECUTE_ADDR ((u8 *) 0x92000000) #define BOOTER_ADDR ((u8 *) 0x93000000) #define ARGS_ADDR ((u8 *) 0x93200000) diff --git a/source/menu/WDMMenu.cpp b/source/menu/WDMMenu.cpp index 7e2cc7ab..7f8a53d8 100644 --- a/source/menu/WDMMenu.cpp +++ b/source/menu/WDMMenu.cpp @@ -205,13 +205,13 @@ void WDMMenu::CheckGameFiles(const struct discHdr * header) WBFS_CloseDisc(disc); int position = 0; - vector > FilesNotInWDM; + std::vector > FilesNotInWDM; for(int i = 0; i < wdmFile->size(); ++i) { if(stringcompare(wdmFile->GetDolName(i), "main") == true) { - DOLOffsetList.push_back(pair(0, wdmFile->GetParameter(i))); + DOLOffsetList.push_back(std::pair(0, wdmFile->GetParameter(i))); Options->SetName(position, "%i.", position+1); Options->SetValue(position, wdmFile->GetReplaceName(i)); position++; @@ -239,7 +239,7 @@ void WDMMenu::CheckGameFiles(const struct discHdr * header) { if(stringcompare(wdmFile->GetDolName(j), NameCpy) == true) { - DOLOffsetList.push_back(pair(i, wdmFile->GetParameter(j))); + DOLOffsetList.push_back(std::pair(i, wdmFile->GetParameter(j))); Options->SetName(position, "%i.", position+1); Options->SetValue(position, wdmFile->GetReplaceName(j)); position++; @@ -248,13 +248,13 @@ void WDMMenu::CheckGameFiles(const struct discHdr * header) } if(j == wdmFile->size()) - FilesNotInWDM.push_back(pair(i, filename)); + FilesNotInWDM.push_back(std::pair(i, filename)); } } for(u32 i = 0; i < FilesNotInWDM.size(); ++i) { - DOLOffsetList.push_back(pair(FilesNotInWDM[i].first, 1)); + DOLOffsetList.push_back(std::pair(FilesNotInWDM[i].first, 1)); Options->SetName(position, "%i.", position+1); Options->SetValue(position, FilesNotInWDM[i].second.c_str()); position++; diff --git a/source/menu/WDMMenu.hpp b/source/menu/WDMMenu.hpp index fc78ad9d..2411ec3b 100644 --- a/source/menu/WDMMenu.hpp +++ b/source/menu/WDMMenu.hpp @@ -22,7 +22,7 @@ class WDMMenu : public GuiWindow static u32 AlternateDolParameter; WDMFile * wdmFile; - vector > DOLOffsetList; + std::vector > DOLOffsetList; GuiImageData * btnOutline; GuiTrigger * trigA; diff --git a/source/network/Wiinnertag.cpp b/source/network/Wiinnertag.cpp index cb819f78..ece1deba 100644 --- a/source/network/Wiinnertag.cpp +++ b/source/network/Wiinnertag.cpp @@ -32,12 +32,12 @@ using namespace tinyxml2; -Wiinnertag::Wiinnertag(const string &filepath) +Wiinnertag::Wiinnertag(const std::string &filepath) { ReadXML(filepath); } -bool Wiinnertag::ReadXML(const string &filepath) +bool Wiinnertag::ReadXML(const std::string &filepath) { XMLDocument xmlDoc; if(xmlDoc.LoadFile(filepath.c_str()) != 0) @@ -88,7 +88,7 @@ bool Wiinnertag::Send(const char *gameID) bool Wiinnertag::TagGame(const char *gameID) { - string fullpath = Settings.WiinnertagPath; + std::string fullpath = Settings.WiinnertagPath; if(fullpath.size() == 0) return false; @@ -100,14 +100,14 @@ bool Wiinnertag::TagGame(const char *gameID) return Tag.Send(gameID); } -bool Wiinnertag::CreateExample(const string &filepath) +bool Wiinnertag::CreateExample(const std::string &filepath) { if(filepath.size() == 0) return false; CreateSubfolder(filepath.c_str()); - string fullpath = filepath; + std::string fullpath = filepath; if(fullpath[fullpath.size()-1] != '/') fullpath += '/'; fullpath += "Wiinnertag.xml"; diff --git a/source/network/Wiinnertag.h b/source/network/Wiinnertag.h index 0cf0cdb9..d291327d 100644 --- a/source/network/Wiinnertag.h +++ b/source/network/Wiinnertag.h @@ -28,18 +28,16 @@ #include #include -using namespace std; - class Wiinnertag { public: - static bool CreateExample(const string &filepath); + static bool CreateExample(const std::string &filepath); static bool TagGame(const char *gameID); private: - Wiinnertag(const string &filepath); + Wiinnertag(const std::string &filepath); bool Send(const char *gameID); - bool ReadXML(const string &filepath); - vector > tagList; + bool ReadXML(const std::string &filepath); + std::vector > tagList; }; #endif diff --git a/source/network/update.cpp b/source/network/update.cpp index 319bc194..b8b657e7 100644 --- a/source/network/update.cpp +++ b/source/network/update.cpp @@ -118,7 +118,7 @@ int UpdateGameTDB() gprintf("Updating GameTDB...\n"); - string ZipPath = Settings.titlestxt_path; + std::string ZipPath = Settings.titlestxt_path; if (Settings.titlestxt_path[ZipPath.size() - 1] != '/') ZipPath += '/'; diff --git a/source/patches/gamepatches.c b/source/patches/gamepatches.c index 8cefb694..09390e55 100644 --- a/source/patches/gamepatches.c +++ b/source/patches/gamepatches.c @@ -13,6 +13,13 @@ #include "settings/SettingsEnums.h" #include "svnrev.h" +/* GCC 11 false positives */ +#if __GNUC__ > 10 +#pragma GCC diagnostic ignored "-Warray-bounds" +#pragma GCC diagnostic ignored "-Wstringop-overflow" +#pragma GCC diagnostic ignored "-Wstringop-overread" +#endif + typedef struct _appDOL { u8 *dst; diff --git a/source/patches/patchcode.c b/source/patches/patchcode.c index 4775cc49..0897e08a 100644 --- a/source/patches/patchcode.c +++ b/source/patches/patchcode.c @@ -37,6 +37,12 @@ #include "memory/memory.h" #include "gecko.h" +/* GCC 11 false positives */ +#if __GNUC__ > 10 +#pragma GCC diagnostic ignored "-Warray-bounds" +#pragma GCC diagnostic ignored "-Wstringop-overflow" +#endif + static u8 *codelistend = (u8 *)0x80003000; static u8 *codelist = (u8 *)0x800022A8; diff --git a/source/prompts/CategoryPrompt.cpp b/source/prompts/CategoryPrompt.cpp index 77418d6b..b39642ec 100644 --- a/source/prompts/CategoryPrompt.cpp +++ b/source/prompts/CategoryPrompt.cpp @@ -30,7 +30,7 @@ #include "themes/Resources.h" #include "menu/menus.h" -CategoryPrompt::CategoryPrompt(const string &title) +CategoryPrompt::CategoryPrompt(const std::string &title) : GuiWindow(0, 0) { changed = false; diff --git a/source/prompts/CategoryPrompt.hpp b/source/prompts/CategoryPrompt.hpp index 05f7de8c..a18742df 100644 --- a/source/prompts/CategoryPrompt.hpp +++ b/source/prompts/CategoryPrompt.hpp @@ -29,7 +29,7 @@ class CategoryPrompt : public GuiWindow, public sigslot::has_slots<> { public: - CategoryPrompt(const string &title); + CategoryPrompt(const std::string &title); virtual ~CategoryPrompt(); int Show(); bool categoriesChanged() const { return changed; } diff --git a/source/prompts/CategorySelectPrompt.cpp b/source/prompts/CategorySelectPrompt.cpp index fb8a2054..79c4ae80 100644 --- a/source/prompts/CategorySelectPrompt.cpp +++ b/source/prompts/CategorySelectPrompt.cpp @@ -51,7 +51,7 @@ void CategorySelectPrompt::onBrowserRefresh() do { bool checked = false; - const vector gameCat = GameCategories[gameHeader->id]; + const std::vector gameCat = GameCategories[gameHeader->id]; for(u32 i = 0; i < gameCat.size(); ++i) { @@ -82,7 +82,7 @@ void CategorySelectPrompt::OnCheckboxClick(GuiCheckbox *checkBox, int index) return; } - const vector gameCat = GameCategories[gameHeader->id]; + const std::vector gameCat = GameCategories[gameHeader->id]; u32 i; for(i = 0; i < gameCat.size(); ++i) diff --git a/source/settings/CCategoryList.cpp b/source/settings/CCategoryList.cpp index c52b7a50..e861af3a 100644 --- a/source/settings/CCategoryList.cpp +++ b/source/settings/CCategoryList.cpp @@ -47,20 +47,20 @@ void CCategoryList::clear() const char * CCategoryList::operator[](unsigned int id) { - map::iterator itr = nameList.find(id); + std::map::iterator itr = nameList.find(id); if(itr == nameList.end()) return NULL; return nameList[id].c_str(); } -bool CCategoryList::AddCategory(const string &name) +bool CCategoryList::AddCategory(const std::string &name) { if(findCategory(name)) return false; unsigned int i = 1; - map::iterator itr; + std::map::iterator itr; //! Find next free key while((itr = nameList.find(i)) != nameList.end()) @@ -72,7 +72,7 @@ bool CCategoryList::AddCategory(const string &name) return true; } -bool CCategoryList::SetCategory(unsigned int id, const string &name) +bool CCategoryList::SetCategory(unsigned int id, const std::string &name) { RemoveCategory(name); nameList[id] = name; @@ -80,9 +80,9 @@ bool CCategoryList::SetCategory(unsigned int id, const string &name) return true; } -void CCategoryList::RemoveCategory(const string &name) +void CCategoryList::RemoveCategory(const std::string &name) { - for (map::iterator itr = nameList.begin(); itr != nameList.end(); itr++) + for (std::map::iterator itr = nameList.begin(); itr != nameList.end(); itr++) { if(strcasecmp(name.c_str(), itr->second.c_str()) == 0) { @@ -94,13 +94,13 @@ void CCategoryList::RemoveCategory(const string &name) void CCategoryList::RemoveCategory(unsigned int id) { - map::iterator itr = nameList.find(id); + std::map::iterator itr = nameList.find(id); if(itr != nameList.end()) nameList.erase(itr); } -bool CCategoryList::findCategory(const string &name) +bool CCategoryList::findCategory(const std::string &name) { for (listIter = nameList.begin(); listIter != nameList.end(); listIter++) { diff --git a/source/settings/CCategoryList.hpp b/source/settings/CCategoryList.hpp index c5567a37..889863bd 100644 --- a/source/settings/CCategoryList.hpp +++ b/source/settings/CCategoryList.hpp @@ -27,35 +27,33 @@ #include #include -using namespace std; - class CCategoryList { public: CCategoryList(); - bool Load(string filepath); + bool Load(std::string filepath); bool Save(); - bool AddCategory(const string &name); - bool SetCategory(unsigned int id, const string &name); + bool AddCategory(const std::string &name); + bool SetCategory(unsigned int id, const std::string &name); void RemoveCategory(unsigned int id); - void RemoveCategory(const string &name); + void RemoveCategory(const std::string &name); bool goToFirst() { listIter = nameList.begin(); return true; } bool goToNext() { listIter++; return listIter != nameList.end(); } unsigned int getCurrentID() const { return listIter->first; } - const string &getCurrentName() const { return listIter->second; } + const std::string &getCurrentName() const { return listIter->second; } const char * operator[](unsigned int id); const char *at(unsigned int id) { return operator[](id); } void goToNextCicle() { listIter++; if(listIter == nameList.end()) listIter = nameList.begin(); } void goToPreviousCicle() { if(listIter == nameList.begin()) listIter = nameList.end(); listIter--; } - bool findCategory(const string &name); + bool findCategory(const std::string &name); bool findCategory(unsigned int id) { listIter = nameList.find(id); return listIter != nameList.end(); }; int pos() const { return distance(nameList.begin(), listIter); } int size() const { return nameList.size(); } void clear(); private: - string configPath; - map::const_iterator listIter; - map nameList; + std::string configPath; + std::map::const_iterator listIter; + std::map nameList; }; #endif diff --git a/source/settings/CGameCategories.cpp b/source/settings/CGameCategories.cpp index b566f0a9..123c1e94 100644 --- a/source/settings/CGameCategories.cpp +++ b/source/settings/CGameCategories.cpp @@ -46,11 +46,11 @@ CGameCategories::CGameCategories() { } -const vector &CGameCategories::operator[](const char *id) const +const std::vector &CGameCategories::operator[](const char *id) const { if(!id) return defaultCategory; - for(map >::const_iterator itr = List.begin(); itr != List.end(); itr++) + for(std::map >::const_iterator itr = List.begin(); itr != List.end(); itr++) { if(strncasecmp(itr->first.c_str(), id, 6) == 0) return itr->second; @@ -59,7 +59,7 @@ const vector &CGameCategories::operator[](const char *id) const return defaultCategory; } -bool CGameCategories::Load(string filepath) +bool CGameCategories::Load(std::string filepath) { if(filepath.size() == 0) return false; @@ -179,7 +179,7 @@ bool CGameCategories::Save() //! This is more memory efficient than making another copy of the elements. XMLElement *GameCategories = xmlDoc.NewElement("GameCategories"); - for(map >::iterator itr = List.begin(); itr != List.end(); itr++) + for(std::map >::iterator itr = List.begin(); itr != List.end(); itr++) { ShowProgress(progress, progressSize); @@ -232,17 +232,17 @@ bool CGameCategories::SetCategory(const char *gameID, unsigned int id) char gameID6[7]; snprintf(gameID6, sizeof(gameID6), gameID); - string stringGameID(gameID6); + std::string stringGameID(gameID6); return SetCategory(stringGameID, id); } -bool CGameCategories::SetCategory(const string &gameID, unsigned int id) +bool CGameCategories::SetCategory(const std::string &gameID, unsigned int id) { if(List[gameID].empty()) List[gameID] = defaultCategory; - vector tmpVect(List[gameID]); + std::vector tmpVect(List[gameID]); for(u32 i = 0; i < tmpVect.size(); ++i) { @@ -261,13 +261,13 @@ bool CGameCategories::ReplaceCategory(const char *gameID, unsigned int id) char gameID6[7]; snprintf(gameID6, sizeof(gameID6), gameID); - List[string(gameID6)] = defaultCategory; - List[string(gameID6)].push_back(id); + List[std::string(gameID6)] = defaultCategory; + List[std::string(gameID6)].push_back(id); return true; } -bool CGameCategories::ReplaceCategory(const string &gameID, unsigned int id) +bool CGameCategories::ReplaceCategory(const std::string &gameID, unsigned int id) { List[gameID] = defaultCategory; List[gameID].push_back(id); @@ -276,7 +276,7 @@ bool CGameCategories::ReplaceCategory(const string &gameID, unsigned int id) void CGameCategories::RemoveCategory(unsigned int id) { - for(map >::iterator itr = List.begin(); itr != List.end(); itr++) + for(std::map >::iterator itr = List.begin(); itr != List.end(); itr++) { for(u32 i = 0; i < itr->second.size(); ++i) { @@ -289,9 +289,9 @@ void CGameCategories::RemoveCategory(unsigned int id) } } -void CGameCategories::RemoveGameCategories(const string &gameID) +void CGameCategories::RemoveGameCategories(const std::string &gameID) { - for (map >::iterator itr = List.begin(); itr != List.end(); itr++) + for (std::map >::iterator itr = List.begin(); itr != List.end(); itr++) { if(gameID == itr->first) { @@ -304,16 +304,16 @@ void CGameCategories::RemoveCategory(const char *gameID, unsigned int id) { if(!gameID) return; - string gameID6; + std::string gameID6; for(int i = 0; i < 6 && gameID[i] != 0; ++i) gameID6.push_back(gameID[i]); RemoveCategory(gameID6, id); } -void CGameCategories::RemoveCategory(const string &gameID, unsigned int id) +void CGameCategories::RemoveCategory(const std::string &gameID, unsigned int id) { - for (map >::iterator itr = List.begin(); itr != List.end(); itr++) + for (std::map >::iterator itr = List.begin(); itr != List.end(); itr++) { if(gameID == itr->first) { @@ -337,11 +337,11 @@ bool CGameCategories::isInCategory(const char *gameID, unsigned int id) if(!gameID) return false; - string gameID6; + std::string gameID6; for(int i = 0; i < 6 && gameID[i] != 0; ++i) gameID6.push_back(gameID[i]); - for (map >::iterator itr = GameCategories.List.begin(); itr != GameCategories.List.end(); itr++) + for (std::map >::iterator itr = GameCategories.List.begin(); itr != GameCategories.List.end(); itr++) { if(itr->first == gameID6) { @@ -357,7 +357,7 @@ bool CGameCategories::isInCategory(const char *gameID, unsigned int id) return false; } -bool CGameCategories::ImportFromGameTDB(const string &xmlpath) +bool CGameCategories::ImportFromGameTDB(const std::string &xmlpath) { GameTDB XML_DB; @@ -374,8 +374,8 @@ bool CGameCategories::ImportFromGameTDB(const string &xmlpath) { ShowProgress(i, gameList.size()); - vector genreList; - string GameType; + std::vector genreList; + std::string GameType; if(XML_DB.GetGameType((const char *) gameList[i]->id, GameType)) { diff --git a/source/settings/CGameCategories.hpp b/source/settings/CGameCategories.hpp index 3fc65d2d..51ef6dda 100644 --- a/source/settings/CGameCategories.hpp +++ b/source/settings/CGameCategories.hpp @@ -37,22 +37,22 @@ class CGameCategories { public: CGameCategories(); - bool Load(string filepath); + bool Load(std::string filepath); bool Save(); - bool SetCategory(const string &gameID, unsigned int id); + bool SetCategory(const std::string &gameID, unsigned int id); bool SetCategory(const char *gameID, unsigned int id); bool SetCategory(const unsigned char *gameID, int unsigned id) { return SetCategory((const char *) gameID, id); }; - bool ReplaceCategory(const string &gameID, unsigned int id); + bool ReplaceCategory(const std::string &gameID, unsigned int id); bool ReplaceCategory(const char *gameID, unsigned int id); bool ReplaceCategory(const unsigned char *gameID, int unsigned id) { return SetCategory((const char *) gameID, id); }; void RemoveCategory(unsigned int id); - void RemoveCategory(const string &gameID, unsigned int id); + void RemoveCategory(const std::string &gameID, unsigned int id); void RemoveCategory(const char *gameID, unsigned int id); void RemoveCategory(const unsigned char *gameID, unsigned int id) { RemoveCategory((const char *) gameID, id); }; - void RemoveGameCategories(const string &gameID); - const vector &operator[](const char *gameID) const; - const vector &operator[](const unsigned char *gameID) const { return operator[]((const char *) gameID); } - bool ImportFromGameTDB(const string &xmlpath); + void RemoveGameCategories(const std::string &gameID); + const std::vector &operator[](const char *gameID) const; + const std::vector &operator[](const unsigned char *gameID) const { return operator[]((const char *) gameID); } + bool ImportFromGameTDB(const std::string &xmlpath); void clear() { List.clear(); CategoryList.clear(); }; static bool isInCategory(const char *gameID, unsigned int id); @@ -60,9 +60,9 @@ class CGameCategories protected: bool ValidVersion(XMLElement *xmlfile); - string configPath; - const vector defaultCategory; - map > List; + std::string configPath; + const std::vector defaultCategory; + std::map > List; }; extern CGameCategories GameCategories; diff --git a/source/usbloader/GameBooter.cpp b/source/usbloader/GameBooter.cpp index 7350a04c..24c046d3 100644 --- a/source/usbloader/GameBooter.cpp +++ b/source/usbloader/GameBooter.cpp @@ -56,6 +56,12 @@ #include "prompts/ProgressWindow.h" #include "neek.hpp" +/* GCC 11 false positives */ +#if __GNUC__ > 10 +#pragma GCC diagnostic ignored "-Warray-bounds" +#pragma GCC diagnostic ignored "-Wstringop-overflow" +#endif + //appentrypoint has to be global because of asm u32 AppEntrypoint = 0; diff --git a/source/usbloader/WDMFile.hpp b/source/usbloader/WDMFile.hpp index 5e0a876a..e0224f45 100644 --- a/source/usbloader/WDMFile.hpp +++ b/source/usbloader/WDMFile.hpp @@ -6,8 +6,6 @@ #include #include -using namespace std; - class WDMFile { public: @@ -19,12 +17,12 @@ class WDMFile private: struct WDMEntry { - string DolName; - string ReplaceName; + std::string DolName; + std::string ReplaceName; int Parameter; }; - vector WDMEntries; + std::vector WDMEntries; }; #endif diff --git a/source/usbloader/alternatedol.c b/source/usbloader/alternatedol.c index 0369fe0e..5394ac0e 100644 --- a/source/usbloader/alternatedol.c +++ b/source/usbloader/alternatedol.c @@ -9,6 +9,12 @@ #include "wdvd.h" #include "fstfile.h" +/* GCC 11 false positives */ +#if __GNUC__ > 10 +#pragma GCC diagnostic ignored "-Warray-bounds" +#pragma GCC diagnostic ignored "-Wstringop-overread" +#endif + typedef struct _dolheader { u32 text_pos[7]; diff --git a/source/usbloader/disc.c b/source/usbloader/disc.c index e0350077..e863ca07 100644 --- a/source/usbloader/disc.c +++ b/source/usbloader/disc.c @@ -19,6 +19,13 @@ #include "GameCube/NIN_Config.h" #include "gecko.h" +/* GCC 11 false positives */ +#if __GNUC__ > 10 +#pragma GCC diagnostic ignored "-Warray-bounds" +#pragma GCC diagnostic ignored "-Wstringop-overflow" +#pragma GCC diagnostic ignored "-Wstringop-overread" +#endif + // Global app entry point extern u32 AppEntrypoint; diff --git a/source/usbloader/neek.cpp b/source/usbloader/neek.cpp index 5cca2c88..4126fd59 100644 --- a/source/usbloader/neek.cpp +++ b/source/usbloader/neek.cpp @@ -28,6 +28,11 @@ #include "sys.h" #include "gecko.h" +/* GCC 11 false positives */ +#if __GNUC__ > 10 +#pragma GCC diagnostic ignored "-Wstringop-overread" +#endif + typedef struct { u32 hdrsize; u32 loadersize; diff --git a/source/wad/nandtitle.cpp b/source/wad/nandtitle.cpp index 491bf7b8..1e2c1b4a 100644 --- a/source/wad/nandtitle.cpp +++ b/source/wad/nandtitle.cpp @@ -248,7 +248,7 @@ int NandTitle::IndexOf(u64 tid) const char* NandTitle::NameOf(u64 tid) { - map::iterator itr = NameList.find(tid); + std::map::iterator itr = NameList.find(tid); if (itr != NameList.end()) return itr->second.c_str(); return NULL; @@ -258,7 +258,7 @@ const char* NandTitle::NameFromIndex(u32 i) { if (i >= titleIds.size()) return NULL; - map::iterator itr = NameList.find(titleIds.at(i)); + std::map::iterator itr = NameList.find(titleIds.at(i)); if (itr != NameList.end()) return itr->second.c_str(); return NULL; diff --git a/source/wad/nandtitle.h b/source/wad/nandtitle.h index 0fca9283..2cb06736 100644 --- a/source/wad/nandtitle.h +++ b/source/wad/nandtitle.h @@ -11,7 +11,6 @@ #include #include "wstring.hpp" -using namespace std; #define TITLE_ID(x,y) (((u64)(x) << 32) | (y)) #define TITLE_UPPER(x) ((u32)((x) >> 32)) @@ -106,7 +105,7 @@ class NandTitle static int InternalExtractDir(char *nandPath, std::string &filepath); std::vector titleIds; - std::map NameList; + std::map NameList; u32 currentIndex; u32 currentType; diff --git a/source/wstring.cpp b/source/wstring.cpp index 907768ca..62b63474 100644 --- a/source/wstring.cpp +++ b/source/wstring.cpp @@ -1,19 +1,17 @@ #include #include "wstring.hpp" -using namespace std; - wString::wString(const wchar_t *s) : std::basic_string, std::allocator >(s) { } -wString::wString(const basic_string , allocator > &ws) : - basic_string , allocator > (ws) +wString::wString(const basic_string , std::allocator > &ws) : + std::basic_string, std::allocator > (ws) { } -wString::wString(const string &s) +wString::wString(const std::string &s) { std::string::size_type size; @@ -23,7 +21,7 @@ wString::wString(const string &s) (*this)[i] = (unsigned char) s[i]; } -wString &wString::operator=(const string & s) +wString &wString::operator=(const std::string & s) { std::string::size_type size; @@ -68,9 +66,9 @@ void wString::fromUTF8(const char *s) } } -string wString::toUTF8(void) const +std::string wString::toUTF8(void) const { - string s; + std::string s; size_t len = 0; wchar_t wc; diff --git a/source/xml/GameTDB.cpp b/source/xml/GameTDB.cpp index b94a6f49..675456e6 100644 --- a/source/xml/GameTDB.cpp +++ b/source/xml/GameTDB.cpp @@ -73,8 +73,8 @@ bool GameTDB::OpenFile(const char * filepath) if(file) { int pos; - string OffsetsPath = filepath; - if((pos = OffsetsPath.find_last_of('/')) != (int) string::npos) + std::string OffsetsPath = filepath; + if((pos = OffsetsPath.find_last_of('/')) != (int) std::string::npos) OffsetsPath[pos] = '\0'; else OffsetsPath.clear(); //! Relative path @@ -88,7 +88,7 @@ bool GameTDB::OpenFile(const char * filepath) void GameTDB::CloseFile() { OffsetMap.clear(); - vector().swap(OffsetMap); + std::vector().swap(OffsetMap); if(GameNodeCache) delete [] GameNodeCache; @@ -104,7 +104,7 @@ bool GameTDB::LoadGameOffsets(const char * path) if(!path) return false; - string OffsetDBPath = path; + std::string OffsetDBPath = path; if(strlen(path) > 0 && path[strlen(path)-1] != '/') OffsetDBPath += '/'; OffsetDBPath += NAME_OFFSET_DB; @@ -467,7 +467,7 @@ bool GameTDB::ParseFile() return true; } -bool GameTDB::GetTitle(const char * id, string & title) +bool GameTDB::GetTitle(const char * id, std::string & title) { if(!id) return false; @@ -501,7 +501,7 @@ bool GameTDB::GetTitle(const char * id, string & title) return true; } -bool GameTDB::GetSynopsis(const char * id, string & synopsis) +bool GameTDB::GetSynopsis(const char * id, std::string & synopsis) { if(!id) return false; @@ -535,7 +535,7 @@ bool GameTDB::GetSynopsis(const char * id, string & synopsis) return true; } -bool GameTDB::GetRegion(const char * id, string & region) +bool GameTDB::GetRegion(const char * id, std::string & region) { if(!id) return false; @@ -558,7 +558,7 @@ bool GameTDB::GetRegion(const char * id, string & region) return true; } -bool GameTDB::GetDeveloper(const char * id, string & dev) +bool GameTDB::GetDeveloper(const char * id, std::string & dev) { if(!id) return false; @@ -581,7 +581,7 @@ bool GameTDB::GetDeveloper(const char * id, string & dev) return true; } -bool GameTDB::GetPublisher(const char * id, string & pub) +bool GameTDB::GetPublisher(const char * id, std::string & pub) { if(!id) return false; @@ -651,7 +651,7 @@ unsigned int GameTDB::GetPublishDate(const char * id) return ((year & 0xFFFF) << 16 | (month & 0xFF) << 8 | (day & 0xFF)); } -bool GameTDB::GetGenreList(const char * id, vector & genre) +bool GameTDB::GetGenreList(const char * id, std::vector & genre) { if(!id) return false; @@ -706,7 +706,7 @@ bool GameTDB::GetGenreList(const char * id, vector & genre) return true; } -void GameTDB::TranslateGenres(vector &GenreList) +void GameTDB::TranslateGenres(std::vector &GenreList) { char * data = GetGameNode("gnrmap"); if(!data) @@ -716,7 +716,7 @@ void GameTDB::TranslateGenres(vector &GenreList) { for(unsigned int n = 0; n < 2; n++) { - string nodeStart; + std::string nodeStart; if(n == 0) nodeStart = " &GenreList) if(!genreNodeEnd) continue; - string localStr = ""; @@ -904,7 +904,7 @@ int GameTDB::GetRating(const char * id) return rating; } -bool GameTDB::GetRatingValue(const char * id, string & rating_value) +bool GameTDB::GetRatingValue(const char * id, std::string & rating_value) { if(!id) return false; @@ -934,7 +934,7 @@ bool GameTDB::GetRatingValue(const char * id, string & rating_value) return true; } -int GameTDB::GetRatingDescriptorList(const char * id, vector & desc_list) +int GameTDB::GetRatingDescriptorList(const char * id, std::vector & desc_list) { if(!id) return -1; @@ -980,7 +980,7 @@ int GameTDB::GetRatingDescriptorList(const char * id, vector & desc_list return desc_list.size(); } -void GameTDB::TranslateDescriptors(vector &DescList) +void GameTDB::TranslateDescriptors(std::vector &DescList) { char * data = GetGameNode("dscmap"); if(!data) @@ -988,7 +988,7 @@ void GameTDB::TranslateDescriptors(vector &DescList) for(unsigned int i = 0; i < DescList.size(); ++i) { - string nodeStart = " &DescList) if(!genreNodeEnd) continue; - string localStr = ""; @@ -1060,7 +1060,7 @@ int GameTDB::GetWifiPlayers(const char * id) return players; } -int GameTDB::GetWifiFeatureList(const char * id, vector & feat_list) +int GameTDB::GetWifiFeatureList(const char * id, std::vector & feat_list) { if(!id) return -1; @@ -1133,7 +1133,7 @@ int GameTDB::GetPlayers(const char * id) return players; } -int GameTDB::GetAccessoirList(const char * id, vector & acc_list) +int GameTDB::GetAccessoirList(const char * id, std::vector & acc_list) { if(!id) return -1; @@ -1205,7 +1205,7 @@ int GameTDB::GetCaseColor(const char * id) return color; } -bool GameTDB::GetGameType(const char * id, string &GameType) +bool GameTDB::GetGameType(const char * id, std::string &GameType) { if(!id) return false; diff --git a/source/xml/GameTDB.hpp b/source/xml/GameTDB.hpp index 233bc495..55657b9d 100644 --- a/source/xml/GameTDB.hpp +++ b/source/xml/GameTDB.hpp @@ -27,31 +27,29 @@ #include #include -using namespace std; - typedef struct _Accessoir { - string Name; + std::string Name; bool Required; } Accessoir; typedef struct _GameXMLInfo { - string GameID; - string Region; - string Title; - string Synopsis; - string Developer; - string Publisher; + std::string GameID; + std::string Region; + std::string Title; + std::string Synopsis; + std::string Developer; + std::string Publisher; unsigned int PublishDate; - vector GenreList; + std::vector GenreList; int RatingType; - string RatingValue; - vector RatingDescriptorList; + std::string RatingValue; + std::vector RatingDescriptorList; int WifiPlayers; - vector WifiFeatureList; + std::vector WifiFeatureList; int Players; - vector AccessoirList; + std::vector AccessoirList; long CaseColor; } GameXMLInfo; @@ -83,55 +81,55 @@ class GameTDB //! Get the current set language code const char * GetLanguageCode() { return LangCode.c_str(); }; //! Get the title of a specific game id in the language defined in LangCode - bool GetTitle(const char * id, string & title); + bool GetTitle(const char * id, std::string & title); //! Get the synopsis of a specific game id in the language defined in LangCode - bool GetSynopsis(const char * id, string & synopsis); + bool GetSynopsis(const char * id, std::string & synopsis); //! Get the region of a game for a specific game id - bool GetRegion(const char * id, string & region); + bool GetRegion(const char * id, std::string & region); //! Get the developer of a game for a specific game id - bool GetDeveloper(const char * id, string & dev); + bool GetDeveloper(const char * id, std::string & dev); //! Get the publisher of a game for a specific game id - bool GetPublisher(const char * id, string & pub); + bool GetPublisher(const char * id, std::string & pub); //! Get the publish date of a game for a specific game id //! First 1 byte is the day, than 1 byte month and last 2 bytes is the year //! year = (return >> 16), month = (return >> 8) & 0xFF, day = return & 0xFF unsigned int GetPublishDate(const char * id); //! Get the genre list of a game for a specific game id - bool GetGenreList(const char * id, vector & genre); + bool GetGenreList(const char * id, std::vector & genre); //! Get the rating type for a specific game id - //! The rating type can be converted to a string with GameTDB::RatingToString(rating) + //! The rating type can be converted to a std::string with GameTDB::RatingTostd::string(rating) int GetRating(const char * id); //! Get the rating value for a specific game id - bool GetRatingValue(const char * id, string & rating_value); - //! Get the rating descriptor list inside a vector for a specific game id + bool GetRatingValue(const char * id, std::string & rating_value); + //! Get the rating descriptor list inside a std::vector for a specific game id //! Returns the amount of descriptors found or -1 if failed - int GetRatingDescriptorList(const char * id, vector & desc_list); + int GetRatingDescriptorList(const char * id, std::vector & desc_list); //! Get the wifi player count for a specific game id //! Returns the amount of wifi players or -1 if failed int GetWifiPlayers(const char * id); - //! Get the wifi feature list inside a vector for a specific game id + //! Get the wifi feature list inside a std::vector for a specific game id //! Returns the amount of wifi features found or -1 if failed - int GetWifiFeatureList(const char * id, vector & feat_list); + int GetWifiFeatureList(const char * id, std::vector & feat_list); //! Get the player count for a specific game id //! Returns the amount of players or -1 if failed int GetPlayers(const char * id); //! Returns the amount of accessoirs found or -1 if failed - //! Get the accessoir (inputs) list inside a vector for a specific game id - int GetAccessoirList(const char * id, vector & acc_list); + //! Get the accessoir (inputs) list inside a std::vector for a specific game id + int GetAccessoirList(const char * id, std::vector & acc_list); //! Get the box (case) color for a specific game id //! Returns the color in RGB (first 3 bytes) int GetCaseColor(const char * id); //! Get the complete game info in the GameXMLInfo struct bool GetGameXMLInfo(const char * id, GameXMLInfo * gameInfo); //! Get the type of the game. If blank the game is a Wii game. - bool GetGameType(const char * id, string &GameType); + bool GetGameType(const char * id, std::string &GameType); //! Translate genre list to configure language code - void TranslateGenres(vector &GenreList); + void TranslateGenres(std::vector &GenreList); //! Translate descriptors list to configure language code - void TranslateDescriptors(vector &DescList); - //! Convert a specific game rating to a string + void TranslateDescriptors(std::vector &DescList); + //! Convert a specific game rating to a std::string static const char * RatingToString(int rating); - //! Convert a rating string to a rating number + //! Convert a rating std::string to a rating number static int StringToRating(const char *rate_string); //! Convert a rating to another rating static int ConvertRating(const char *value, const char *from, const char *to); @@ -150,9 +148,9 @@ class GameTDB inline char * SeekLang(char * text, const char * langcode); inline char * GetNodeText(char * data, const char * nodestart, const char * nodeend); - vector OffsetMap; + std::vector OffsetMap; FILE * file; - string LangCode; + std::string LangCode; char * GameNodeCache; char GameIDCache[7]; };