From 2a15a2eac28126f7d33764a3041ad0abe014685d Mon Sep 17 00:00:00 2001 From: bladeoner Date: Wed, 22 Mar 2023 18:11:19 +0100 Subject: [PATCH] Silence build warnings (#488) --- .github/workflows/build.yml | 4 ++-- Makefile.gc | 2 +- Makefile.wii | 2 +- source/fceugx.cpp | 2 +- source/fceultra/input.cpp | 5 +---- source/fceultra/state.cpp | 24 ++++++++++++------------ source/fceultra/state.h | 5 +++-- 7 files changed, 21 insertions(+), 23 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b30f382..b84ee2a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,7 +20,7 @@ jobs: - name: Build Wii if: ${{ matrix.image == 'Wii' }} run: | - make -f Makefile.wii -j2 + make -f Makefile.wii -j1 - name: Copy Wii artifacts if: ${{ matrix.image == 'Wii' }} @@ -46,7 +46,7 @@ jobs: - name: Build GameCube if: ${{ matrix.image == 'GameCube' }} run: | - make -f Makefile.gc -j2 + make -f Makefile.gc -j1 - name: Copy GameCube artifact if: ${{ matrix.image == 'GameCube' }} diff --git a/Makefile.gc b/Makefile.gc index 8ecf7aa..b03cc6a 100644 --- a/Makefile.gc +++ b/Makefile.gc @@ -35,7 +35,7 @@ SHAREDFLAGS = -g -O3 -Wall $(MACHDEP) $(INCLUDE) `freetype-config --cflags` \ -Wno-format -Wno-format-overflow -Wno-stringop-overflow -Wno-format-truncation \ -Wno-unused-parameter -Wno-strict-aliasing -Wno-write-strings -Wno-stringop-truncation -Wno-sign-compare \ -Wno-unused-variable -Wno-parentheses -Wno-unused-function -Wno-switch -Wno-unused-but-set-variable \ - -Wno-narrowing -Wno-misleading-indentation -Wno-restrict -Wno-maybe-uninitialized + -Wno-narrowing -Wno-misleading-indentation -Wno-restrict -Wno-maybe-uninitialized -Wno-infinite-recursion CFLAGS = $(SHAREDFLAGS) -Wno-incompatible-pointer-types CXXFLAGS = $(SHAREDFLAGS) -Wno-catch-value -Wno-class-memaccess LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map diff --git a/Makefile.wii b/Makefile.wii index d4d8f94..624b03a 100644 --- a/Makefile.wii +++ b/Makefile.wii @@ -35,7 +35,7 @@ SHAREDFLAGS = -g -O3 -Wall $(MACHDEP) $(INCLUDE) `freetype-config --cflags` \ -Wno-format -Wno-format-overflow -Wno-stringop-overflow -Wno-format-truncation \ -Wno-unused-parameter -Wno-strict-aliasing -Wno-write-strings -Wno-stringop-truncation -Wno-sign-compare \ -Wno-unused-variable -Wno-parentheses -Wno-unused-function -Wno-switch -Wno-unused-but-set-variable \ - -Wno-narrowing -Wno-misleading-indentation -Wno-restrict -Wno-maybe-uninitialized + -Wno-narrowing -Wno-misleading-indentation -Wno-restrict -Wno-maybe-uninitialized -Wno-infinite-recursion CFLAGS = $(SHAREDFLAGS) -Wno-incompatible-pointer-types CXXFLAGS = $(SHAREDFLAGS) -Wno-catch-value -Wno-class-memaccess LDFLAGS = -g $(MACHDEP) -Wl,-Map,$(notdir $@).map diff --git a/source/fceugx.cpp b/source/fceugx.cpp index 5b06b80..c199aa4 100644 --- a/source/fceugx.cpp +++ b/source/fceugx.cpp @@ -430,7 +430,7 @@ int main(int argc, char *argv[]) FCEUI_SetGameGenie(1); // 0 - OFF, 1 - ON FDSBIOS=(uint8 *)malloc(8192); - memset(FDSBIOS, 0, sizeof(FDSBIOS)); // clear FDS BIOS memory + memset(FDSBIOS, 0, sizeof(*FDSBIOS)); // clear FDS BIOS memory FCEUI_SetSoundQuality(1); // 0 - low, 1 - high, 2 - high (alt.) int currentTiming = 0; diff --git a/source/fceultra/input.cpp b/source/fceultra/input.cpp index 30073f1..7445c87 100644 --- a/source/fceultra/input.cpp +++ b/source/fceultra/input.cpp @@ -1324,10 +1324,7 @@ static void MovieSubtitleToggle(void) static void UndoRedoSavestate(void) { - // FIXME this will always evaluate to true, should this be - // if (*lastSavestateMade...) to check if it holds a string or just - // a '\0'? - if (lastSavestateMade && (undoSS || redoSS)) + if ( !lastSavestateMade.empty() && (undoSS || redoSS)) SwapSaveState(); } diff --git a/source/fceultra/state.cpp b/source/fceultra/state.cpp index e8e0ab0..fa572ed 100644 --- a/source/fceultra/state.cpp +++ b/source/fceultra/state.cpp @@ -70,11 +70,11 @@ static int StateShow; //tells the save system innards that we're loading the old format bool FCEU_state_loading_old_format = false; -char lastSavestateMade[2048]; //Stores the filename of the last savestate made (needed for UndoSavestate) +std::string lastSavestateMade; //Stores the filename of the last savestate made (needed for UndoSavestate) bool undoSS = false; //This will be true if there is lastSavestateMade, it was made since ROM was loaded, a backup state for lastSavestateMade exists bool redoSS = false; //This will be true if UndoSaveState is run, will turn false when a new savestate is made -char lastLoadstateMade[2048]; //Stores the filename of the last state loaded (needed for Undo/Redo loadstate) +std::string lastLoadstateMade; //Stores the filename of the last state loaded (needed for Undo/Redo loadstate) bool undoLS = false; //This will be true if a backupstate was made and it was made since ROM was loaded bool redoLS = false; //This will be true if a backupstate was loaded, meaning redoLoadState can be run @@ -478,7 +478,7 @@ void FCEUSS_Save(const char *fname, bool display_message) if (CheckFileExists(fn) && backupSavestates) //adelikat: If the files exists and we are allowed to make backup savestates { CreateBackupSaveState(fn); //Make a backup of previous savestate before overwriting it - strcpy(lastSavestateMade,fn); //Remember what the last savestate filename was (for undoing later) + lastSavestateMade.assign(fn); //Remember what the last savestate filename was (for undoing later) undoSS = true; //Backup was created so undo is possible } else @@ -736,7 +736,7 @@ bool FCEUSS_Load(const char *fname, bool display_message) { strcpy(fn, FCEU_MakeFName(FCEUMKF_STATE,CurrentState,fname).c_str()); st=FCEUD_UTF8_fstream(fn,"rb"); - strcpy(lastLoadstateMade,fn); + lastLoadstateMade.assign(fn); } if (st == NULL || (st->get_fp() == NULL)) @@ -1056,13 +1056,13 @@ void SwapSaveState() //Both files must exist //-------------------------------------------------------------------------------------------- - if (!lastSavestateMade) + if (lastSavestateMade.empty()) { FCEUI_DispMessage("Can't Undo",0); FCEUI_printf("Undo savestate was attempted but unsuccessful because there was not a recently used savestate.\n"); return; //If there is no last savestate, can't undo } - string backup = GenerateBackupSaveStateFn(lastSavestateMade); //Get filename of backup state + string backup = GenerateBackupSaveStateFn(lastSavestateMade.c_str()); //Get filename of backup state if (!CheckFileExists(backup.c_str())) { FCEUI_DispMessage("Can't Undo",0); @@ -1076,9 +1076,9 @@ void SwapSaveState() string temp = backup; //Put backup filename in temp temp.append("x"); //Add x - rename(backup.c_str(),temp.c_str()); //rename backup file to temp file - rename(lastSavestateMade,backup.c_str()); //rename current as backup - rename(temp.c_str(),lastSavestateMade); //rename backup as current + rename(backup.c_str(),temp.c_str()); //rename backup file to temp file + rename(lastSavestateMade.c_str(),backup.c_str()); //rename current as backup + rename(temp.c_str(),lastSavestateMade.c_str()); //rename backup as current undoSS = true; //Just in case, if this was run, then there is definately a last savestate and backup if (redoSS) //This was a redo function, so if run again it will be an undo again @@ -1161,10 +1161,10 @@ void LoadBackup() void RedoLoadState() { if (!redoLS) return; - if (lastLoadstateMade && redoLS) + if (!lastLoadstateMade.empty() && redoLS) { - FCEUSS_Load(lastLoadstateMade); - FCEUI_printf("Redoing %s\n",lastLoadstateMade); + FCEUSS_Load(lastLoadstateMade.c_str()); + FCEUI_printf("Redoing %s\n",lastLoadstateMade.c_str()); } redoLS = false; //Flag that RedoLoadState can not be run again undoLS = true; //Flag that LoadBackup can be run again diff --git a/source/fceultra/state.h b/source/fceultra/state.h index 325553f..4157dc9 100644 --- a/source/fceultra/state.h +++ b/source/fceultra/state.h @@ -17,6 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include enum ENUM_SSLOADPARAMS { @@ -67,10 +68,10 @@ void LoadBackup(); //Loads the backupsavestate void RedoLoadState(); //reloads a loadstate if backupsavestate was run void SwapSaveState(); //Swaps a savestate with its backup state -extern char lastSavestateMade[2048]; //Filename of last savestate used +extern std::string lastSavestateMade; //Filename of last savestate used extern bool undoSS; //undo savestate flag extern bool redoSS; //redo savestate flag -extern char lastLoadstateMade[2048]; //Filename of last state loaded +extern std::string lastLoadstateMade; //Filename of last state loaded extern bool undoLS; //undo loadstate flag extern bool redoLS; //redo savestate flag extern bool backupSavestates; //Whether or not to make backups, true by default