diff --git a/src/ArrowEffects.cpp b/src/ArrowEffects.cpp index 9dc15e8b3f..35e5a3ce8f 100644 --- a/src/ArrowEffects.cpp +++ b/src/ArrowEffects.cpp @@ -826,7 +826,7 @@ float ArrowEffects::GetXPos( const PlayerState* pPlayerState, int iColNum, float switch( pStyle->m_StyleType ) { case StyleType_OnePlayerTwoSides: - case StyleType_TwoPlayersSharedSides: // fall through? + case StyleType_TwoPlayersSharedSides: { // find the middle, and split based on iColNum // it's unknown if this will work for routine. @@ -838,7 +838,7 @@ float ArrowEffects::GetXPos( const PlayerState* pPlayerState, int iColNum, float } break; case StyleType_OnePlayerOneSide: - case StyleType_TwoPlayersTwoSides: // fall through + case StyleType_TwoPlayersTwoSides: { // the code was the same for both of these cases in StepNXA. if( pPlayerState->m_PlayerNumber == PLAYER_2 ) diff --git a/src/Background.cpp b/src/Background.cpp index ee74c84e1f..aa43aa5395 100644 --- a/src/Background.cpp +++ b/src/Background.cpp @@ -334,7 +334,7 @@ bool BackgroundImpl::Layer::CreateBackground( const Song *pSong, const Backgroun { default: LuaHelpers::ReportScriptErrorFmt( "CreateBackground() Unknown file type '%s'", vsResolved[0].c_str() ); - // fall through + [[fallthrough]]; case FT_Bitmap: case FT_Sprite: case FT_Movie: diff --git a/src/EditMenu.cpp b/src/EditMenu.cpp index ebb9a60734..945ae90708 100644 --- a/src/EditMenu.cpp +++ b/src/EditMenu.cpp @@ -185,7 +185,7 @@ void EditMenu::Load( const RString &sType ) // fill in data structures GetGroupsToShow( m_sGroups ); - + // In EditMode_Practice this will be filled in by OnRowValueChanged() if( EDIT_MODE.GetValue() != EditMode_Practice ) m_StepsTypes = CommonMetrics::STEPS_TYPES_TO_SHOW.GetValue(); @@ -384,7 +384,7 @@ void EditMenu::OnRowValueChanged( EditMenuRow row ) UpdateArrows(); EditMode mode = EDIT_MODE.GetValue(); - + switch( row ) { case ROW_GROUP: @@ -424,9 +424,9 @@ void EditMenu::OnRowValueChanged( EditMenuRow row ) GetSongsToShowForGroup(GetSelectedGroup(), m_pSongs); } } - + m_iSelection[ROW_SONG] = 0; - // fall through + [[fallthrough]]; case ROW_SONG: if(GetSelectedSong() == nullptr) { @@ -466,15 +466,15 @@ void EditMenu::OnRowValueChanged( EditMenuRow row ) { if(SongUtil::GetStepsByDifficulty( GetSelectedSong(), st, Difficulty_Invalid, false) != nullptr) m_StepsTypes.push_back(st); - + // Try to preserve the user's StepsType selection. if(st == orgSel) m_iSelection[ROW_STEPS_TYPE] = m_StepsTypes.size() - 1; } } } - - // fall through + + [[fallthrough]]; case ROW_STEPS_TYPE: if(GetSelectedStepsType() == StepsType_Invalid) { @@ -569,7 +569,7 @@ void EditMenu::OnRowValueChanged( EditMenuRow row ) } CLAMP( m_iSelection[ROW_STEPS], 0, m_vpSteps.size()-1 ); } - // fall through + [[fallthrough]]; case ROW_STEPS: if(GetSelectedSteps() == nullptr && mode == EditMode_Practice) { @@ -590,8 +590,8 @@ void EditMenu::OnRowValueChanged( EditMenuRow row ) m_StepsDisplay.SetFromStepsTypeAndMeterAndDifficultyAndCourseType( GetSelectedSourceStepsType(), 0, GetSelectedDifficulty(), CourseType_Invalid ); } } - // fall through - case ROW_SOURCE_STEPS_TYPE: + [[fallthrough]]; + case ROW_SOURCE_STEPS_TYPE: if(mode == EditMode_Practice) { m_textLabel[ROW_SOURCE_STEPS_TYPE].SetVisible(false); @@ -626,7 +626,7 @@ void EditMenu::OnRowValueChanged( EditMenuRow row ) StripLockedStepsAndDifficulty( m_vpSteps ); CLAMP( m_iSelection[ROW_SOURCE_STEPS], 0, m_vpSourceSteps.size()-1 ); } - // fall through + [[fallthrough]]; case ROW_SOURCE_STEPS: if(mode == EditMode_Practice) { @@ -690,7 +690,7 @@ void EditMenu::OnRowValueChanged( EditMenuRow row ) } m_iSelection[ROW_ACTION] = 0; } - // fall through + [[fallthrough]]; case ROW_ACTION: if(GetSelectedAction() == EditMenuAction_Invalid) { @@ -709,7 +709,7 @@ void EditMenu::OnRowValueChanged( EditMenuRow row ) /* * (c) 2001-2004 Chris Danford * All rights reserved. - * + * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -719,7 +719,7 @@ void EditMenu::OnRowValueChanged( EditMenuRow row ) * copyright notice(s) and this permission notice appear in all copies of * the Software and that both the above copyright notice(s) and this * permission notice appear in supporting documentation. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF diff --git a/src/IniFile.cpp b/src/IniFile.cpp index a12e58bcdf..2d2df2e8de 100644 --- a/src/IniFile.cpp +++ b/src/IniFile.cpp @@ -1,4 +1,4 @@ -/* +/* http://en.wikipedia.org/wiki/INI_file - names and values are trimmed on both sides - semicolons start a comment line @@ -128,7 +128,7 @@ bool IniFile::WriteFile( const RString &sPath ) const bool IniFile::WriteFile( RageFileBasic &f ) const { - FOREACH_CONST_Child( this, pKey ) + FOREACH_CONST_Child( this, pKey ) { if( f.PutLine( ssprintf("[%s]", pKey->GetName().c_str()) ) == -1 ) { @@ -199,7 +199,7 @@ bool IniFile::RenameKey(const RString &from, const RString &to) /* * (c) 2001-2004 Adam Clauss, Chris Danford * All rights reserved. - * + * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -209,7 +209,7 @@ bool IniFile::RenameKey(const RString &from, const RString &to) * copyright notice(s) and this permission notice appear in all copies of * the Software and that both the above copyright notice(s) and this * permission notice appear in supporting documentation. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF diff --git a/src/LuaManager.cpp b/src/LuaManager.cpp index e124f51352..3cdca5fb93 100644 --- a/src/LuaManager.cpp +++ b/src/LuaManager.cpp @@ -608,8 +608,8 @@ XNode *LuaHelpers::GetLuaInformation() sort( c.m_vMethods.begin(), c.m_vMethods.end() ); break; } + [[fallthrough]]; } - // fall through case LUA_TUSERDATA: // table or userdata: class instance { if( !luaL_callmeta(L, -1, "__type") ) diff --git a/src/NoteDataUtil.cpp b/src/NoteDataUtil.cpp index fddbe3a58a..929bc7a1d8 100644 --- a/src/NoteDataUtil.cpp +++ b/src/NoteDataUtil.cpp @@ -1515,8 +1515,8 @@ static void GetTrackMapping( StepsType st, NoteDataUtil::TrackMapping tt, int Nu needsBackwards = false; } if (needsBackwards) break; + [[fallthrough]]; } - [[fallthrough]]; case NoteDataUtil::mirror: { for( int t=0; t(&iLayer)) == 1 ) enum_add(iLayer, -1); // #BGCHANGES2 = BACKGROUND_LAYER_2 - + bool bValid = iLayer>=0 && iLayer sBits; split( params[j], "=", sBits, false ); - + // Need an identifer and a value for this to work if( sBits.size() < 2 ) continue; - + Trim( sBits[0] ); - + if( !sBits[0].CompareNoCase("TIME") ) attack.fStartSecond = strtof( sBits[1], nullptr ); else if( !sBits[0].CompareNoCase("LEN") ) @@ -405,16 +405,16 @@ void SMLoader::ProcessAttacks( AttackArray &attacks, MsdFile::value_t params ) { Trim(sBits[1]); attack.sModifiers = sBits[1]; - + if( end != -9999 ) { attack.fSecsRemaining = end - attack.fStartSecond; end = -9999; } - + if( attack.fSecsRemaining < 0.0f ) attack.fSecsRemaining = 0.0f; - + attacks.push_back( attack ); } } @@ -471,7 +471,7 @@ void SMLoader::ParseStops( std::vector> &out, const RStr { std::vector arrayFreezeExpressions; split( line, ",", arrayFreezeExpressions ); - + for( unsigned f=0; f arrayFreezeValues; @@ -947,7 +947,7 @@ bool SMLoader::LoadFromBGChangesVector( BackgroundChange &change, std::vectorStringToStepsType( stepsType ) && out.GetDescription() == description && (out.GetDifficulty() == StringToDifficulty(difficulty) || @@ -1085,7 +1085,7 @@ bool SMLoader::LoadNoteDataFromSimfile( const RString &path, Steps &out ) { continue; } - + RString noteData = sParams[6]; Trim( noteData ); out.SetSMNoteData( noteData ); @@ -1141,12 +1141,12 @@ bool SMLoader::LoadFromSimfile( const RString &sPath, Song &out, bool bFromCache } Steps* pNewNotes = out.CreateSteps(); - LoadFromTokens( - sParams[1], - sParams[2], - sParams[3], - sParams[4], - sParams[5], + LoadFromTokens( + sParams[1], + sParams[2], + sParams[3], + sParams[4], + sParams[5], sParams[6], *pNewNotes); @@ -1252,7 +1252,7 @@ bool SMLoader::LoadEditFromMsd( const MsdFile &msd, const RString &sEditFilePath return true; Steps* pNewNotes = pSong->CreateSteps(); - LoadFromTokens( + LoadFromTokens( sParams[1], sParams[2], sParams[3], sParams[4], sParams[5], sParams[6], *pNewNotes); @@ -1427,7 +1427,7 @@ void SMLoader::ParseBGChangesString(const RString& _sChanges, std::vectorGetSavedToDisk() && + bool bFileNameChanging = + pSteps->GetSavedToDisk() && pSteps->GetFilename() != sPath; if( bFileNameChanging && DoesFileExist(sPath) ) { @@ -551,7 +561,7 @@ bool NotesWriterSSC::WriteEditFileToMachine( const Song *pSong, Steps *pSteps, R /* * (c) 2011 Jason Felds * All rights reserved. - * + * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -561,7 +571,7 @@ bool NotesWriterSSC::WriteEditFileToMachine( const Song *pSong, Steps *pSteps, R * copyright notice(s) and this permission notice appear in all copies of * the Software and that both the above copyright notice(s) and this * permission notice appear in supporting documentation. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF diff --git a/src/Player.cpp b/src/Player.cpp index 1ec4bdd4f5..23d42735a1 100644 --- a/src/Player.cpp +++ b/src/Player.cpp @@ -2175,7 +2175,7 @@ void Player::Step( int col, int row, const RageTimer &tm, bool bHeld, bool bRele case 0: // autoplay is on, or this is a computer player iNumTracksHeld = 1; - // fall through + [[fallthrough]]; default: { float fCalsFor100Lbs = SCALE( iNumTracksHeld, 1, 2, 0.023f, 0.077f ); @@ -2286,7 +2286,6 @@ void Player::Step( int col, int row, const RageTimer &tm, bool bHeld, bool bRele break; } - // Fall through to default. [[fallthrough]]; default: if( (pTN->type == TapNoteType_Lift) == bRelease ) diff --git a/src/RageException.h b/src/RageException.h index 297d58aa86..c248cc8557 100644 --- a/src/RageException.h +++ b/src/RageException.h @@ -9,7 +9,9 @@ * The original documentation stated this was a class for some reason. */ namespace RageException { - void SM_NORETURN Throw( const char *fmt, ... ) PRINTF(1,2); + [[noreturn]] + void Throw( const char *fmt, ... ) PRINTF(1,2); + void SetCleanupHandler( void (*pHandler)(const RString &sError) ); } diff --git a/src/ScreenAttract.cpp b/src/ScreenAttract.cpp index 1479986346..3ae1662164 100644 --- a/src/ScreenAttract.cpp +++ b/src/ScreenAttract.cpp @@ -72,7 +72,7 @@ void ScreenAttract::Cancel( ScreenMessage smSendWhenDone ) bool ScreenAttract::AttractInput( const InputEventPlus &input, ScreenWithMenuElements *pScreen ) { - if( input.type != IET_FIRST_PRESS ) + if( input.type != IET_FIRST_PRESS ) return false; // don't care switch( input.MenuI ) @@ -80,7 +80,7 @@ bool ScreenAttract::AttractInput( const InputEventPlus &input, ScreenWithMenuEle case GAME_BUTTON_BACK: if( !BACK_GOES_TO_START_SCREEN ) break; - // fall through + [[fallthrough]]; case GAME_BUTTON_START: case GAME_BUTTON_COIN: // If we're not in a game and there aren't enough credits to start, @@ -161,7 +161,7 @@ void ScreenAttract::GoToStartScreen( RString sScreenName ) // lua start #include "LuaBinding.h" -/** @brief Allow Lua to have access to the ScreenAttract. */ +/** @brief Allow Lua to have access to the ScreenAttract. */ class LunaScreenAttract: public Luna { public: @@ -177,7 +177,7 @@ LUA_REGISTER_DERIVED_CLASS( ScreenAttract, ScreenWithMenuElements ) /* * (c) 2003-2004 Chris Danford * All rights reserved. - * + * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -187,7 +187,7 @@ LUA_REGISTER_DERIVED_CLASS( ScreenAttract, ScreenWithMenuElements ) * copyright notice(s) and this permission notice appear in all copies of * the Software and that both the above copyright notice(s) and this * permission notice appear in supporting documentation. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF diff --git a/src/ScreenEdit.cpp b/src/ScreenEdit.cpp index 3680075821..7f5ab3edf2 100644 --- a/src/ScreenEdit.cpp +++ b/src/ScreenEdit.cpp @@ -3239,8 +3239,7 @@ bool ScreenEdit::InputPlay( const InputEventPlus &input, EditButton EditB ) if( GAMESTATE->GetCurrentStyle(GAMESTATE->GetMasterPlayerNumber())->m_StyleType != StyleType_TwoPlayersSharedSides ) break; - // fall through to input handling logic: - [[fallthrough]]; + [[fallthrough]]; case PLAYER_1: { switch( gbt ) diff --git a/src/ScreenGameplay.cpp b/src/ScreenGameplay.cpp index 682bd4637d..e973e63ff1 100644 --- a/src/ScreenGameplay.cpp +++ b/src/ScreenGameplay.cpp @@ -1434,7 +1434,7 @@ void ScreenGameplay::LoadLights() return; } - /* fall through */ + // fall through } NoteDataUtil::LoadTransformedLights( TapNoteData1, m_CabinetLightsNoteData, GAMEMAN->GetStepsTypeInfo(StepsType_lights_cabinet).iNumTracks ); diff --git a/src/ScreenSelectMusic.cpp b/src/ScreenSelectMusic.cpp index adb6b61152..68f73dd2be 100644 --- a/src/ScreenSelectMusic.cpp +++ b/src/ScreenSelectMusic.cpp @@ -1852,7 +1852,7 @@ void ScreenSelectMusic::AfterMusicChange() // we want to load the sample music, but we don't want to // actually play it. fall through. -aj case SampleMusicPreviewMode_Normal: - case SampleMusicPreviewMode_LastSong: // fall through + case SampleMusicPreviewMode_LastSong: // play the sample music m_sSampleMusicToPlay = pSong->GetPreviewMusicPath(); if(!m_sSampleMusicToPlay.empty() && ActorUtil::GetFileType(m_sSampleMusicToPlay) != FT_Sound) diff --git a/src/ScreenSyncOverlay.cpp b/src/ScreenSyncOverlay.cpp index 80c977ff56..1e5c7d48e3 100644 --- a/src/ScreenSyncOverlay.cpp +++ b/src/ScreenSyncOverlay.cpp @@ -24,7 +24,7 @@ void ScreenSyncOverlay::Init() m_overlay.Load(THEME->GetPathB(m_sName, "overlay")); AddChild(m_overlay); - + Update( 0 ); } @@ -134,10 +134,20 @@ bool ScreenSyncOverlay::Input( const InputEventPlus &input ) bool bIncrease = true; switch( input.DeviceI.button ) { - case KEY_F4: a = RevertSyncChanges; break; - case KEY_F9: bIncrease = false; /* fall through */ - case KEY_F10: a = ChangeSongBPM; break; - case KEY_F11: bIncrease = false; /* fall through */ + case KEY_F4: + a = RevertSyncChanges; + break; + + case KEY_F9: + bIncrease = false; + [[fallthrough]]; + case KEY_F10: + a = ChangeSongBPM; + break; + + case KEY_F11: + bIncrease = false; + [[fallthrough]]; case KEY_F12: if( INPUTFILTER->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD, KEY_RSHIFT)) || INPUTFILTER->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD, KEY_LSHIFT)) ) @@ -292,7 +302,7 @@ void ScreenSyncOverlay::HideHelp() /* * (c) 2001-2005 Chris Danford * All rights reserved. - * + * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -302,7 +312,7 @@ void ScreenSyncOverlay::HideHelp() * copyright notice(s) and this permission notice appear in all copies of * the Software and that both the above copyright notice(s) and this * permission notice appear in supporting documentation. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF diff --git a/src/arch/Dialog/DialogDriver_Win32.cpp b/src/arch/Dialog/DialogDriver_Win32.cpp index 6a93be927d..5ab4f885fc 100644 --- a/src/arch/Dialog/DialogDriver_Win32.cpp +++ b/src/arch/Dialog/DialogDriver_Win32.cpp @@ -72,7 +72,7 @@ static INT_PTR CALLBACK OKWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lP { case IDOK: g_bHush = !!IsDlgButtonChecked( hWnd, IDC_HUSH ); - // fall through + [[fallthrough]]; case IDCANCEL: EndDialog( hWnd, 0 ); break; @@ -146,7 +146,7 @@ static INT_PTR CALLBACK ErrorWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM case WM_INITDIALOG: { DialogUtil::SetHeaderFont( hWnd, IDC_STATIC_HEADER_TEXT ); - + // Set static text RString sMessage = g_sErrorString; sMessage.Replace( "\n", "\r\n" ); @@ -183,8 +183,6 @@ static INT_PTR CALLBACK ErrorWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM break; case IDC_BUTTON_RESTART: Win32RestartProgram(); - // Possibly make W32RP a SM_NORETURN call? - FAIL_M("Win32RestartProgram failed?"); case IDOK: EndDialog( hWnd, 0 ); break; @@ -201,7 +199,7 @@ static INT_PTR CALLBACK ErrorWndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM { case IDC_STATIC_HEADER_TEXT: case IDC_STATIC_ICON: - hbr = (HBRUSH)::GetStockObject(WHITE_BRUSH); + hbr = (HBRUSH)::GetStockObject(WHITE_BRUSH); SetBkMode( hdc, OPAQUE ); SetBkColor( hdc, RGB(255,255,255) ); break; @@ -244,7 +242,7 @@ Dialog::Result DialogDriver_Win32::AbortRetryIgnore( RString sMessage, RString I default: FAIL_M(ssprintf("Unexpected response to Abort/Retry/Ignore dialog: %i", iRet)); } -} +} Dialog::Result DialogDriver_Win32::AbortRetry( RString sMessage, RString sID ) { @@ -261,7 +259,7 @@ Dialog::Result DialogDriver_Win32::AbortRetry( RString sMessage, RString sID ) default: FAIL_M(ssprintf("Unexpected response to Retry/Cancel dialog: %i", iRet)); } -} +} Dialog::Result DialogDriver_Win32::YesNo( RString sMessage, RString sID ) { @@ -283,7 +281,7 @@ Dialog::Result DialogDriver_Win32::YesNo( RString sMessage, RString sID ) /* * (c) 2003-2004 Glenn Maynard, Chris Danford * All rights reserved. - * + * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -293,7 +291,7 @@ Dialog::Result DialogDriver_Win32::YesNo( RString sMessage, RString sID ) * copyright notice(s) and this permission notice appear in all copies of * the Software and that both the above copyright notice(s) and this * permission notice appear in supporting documentation. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF diff --git a/src/archutils/Unix/CrashHandler.cpp b/src/archutils/Unix/CrashHandler.cpp index cf3bb6af9a..66341dcf43 100644 --- a/src/archutils/Unix/CrashHandler.cpp +++ b/src/archutils/Unix/CrashHandler.cpp @@ -69,7 +69,8 @@ static void GetExecutableName( char *buf, int bufsize ) } #endif -static void SM_NORETURN spawn_child_process( int from_parent ) +[[noreturn]] +static void spawn_child_process( int from_parent ) { /* We need to re-exec ourself, to get a clean process. Close all * FDs except for 0-2 and to_child, and then assign to_child to 3. */ @@ -107,7 +108,7 @@ static int retried_write( int fd, const void *buf, size_t count ) ret = write( fd, buf, count ); } while( ret == -1 && errno == EINTR && tries-- ); - + return ret; } @@ -134,7 +135,7 @@ static void parent_process( int to_child, const CrashData *crash ) /* 1. Write the CrashData. */ if( !parent_write(to_child, crash, sizeof(CrashData)) ) return; - + /* 2. Write info. */ const char *p = RageLog::GetInfo(); int size = strlen( p )+1; @@ -150,7 +151,7 @@ static void parent_process( int to_child, const CrashData *crash ) return; if( !parent_write(to_child, p, size) ) return; - + /* 4. Write RecentLogs. */ int cnt = 0; const char *ps[1024]; @@ -175,7 +176,7 @@ static void parent_process( int to_child, const CrashData *crash ) return; if( !parent_write(to_child, buf, size) ) return; - + /* 6. Write the crashed thread's name. */ p = RageThread::GetCurrentThreadName(); size = strlen( p )+1; @@ -188,7 +189,7 @@ static void parent_process( int to_child, const CrashData *crash ) /* The parent process is the crashed process. It'll send data to the * child, who will do stuff with it. The parent then waits for the - * child to quit, and exits. + * child to quit, and exits. * * We can do whatever fancy things we want in the child process. However, * let's not open any windows until we at least try to shut down OpenGL, @@ -216,7 +217,7 @@ static void RunCrashHandler( const CrashData *crash ) safe_print( fileno(stderr), "Crash handler failed: CrashHandlerHandleArgs was not called\n", nullptr ); _exit( 1 ); } - + /* Block SIGPIPE, so we get EPIPE. */ struct sigaction sa; memset( &sa, 0, sizeof(sa) ); @@ -261,7 +262,7 @@ static void RunCrashHandler( const CrashData *crash ) /* Stop other threads. XXX: This prints a spurious ptrace error if any threads * are already suspended, which happens in ForceCrashHandlerDeadlock(). */ RageThread::HaltAllThreads(); - + /* We need to be very careful, since we're under crash conditions. Let's fork * a process and exec ourself to get a clean environment to work in. */ int fds[2]; @@ -313,19 +314,19 @@ static void BacktraceAllThreads( CrashData& crash ) { int iCnt = 1; uint64_t iID; - + for( int i = 0; RageThread::EnumThreadIDs(i, iID); ++i ) { if( iID == GetInvalidThreadId() || iID == RageThread::GetCurrentThreadID() ) continue; - + BacktraceContext ctx; if( GetThreadBacktraceContext( iID, &ctx ) ) GetBacktrace( crash.BacktracePointers[iCnt], BACKTRACE_MAX_SIZE, &ctx ); strncpy( crash.m_ThreadName[iCnt], RageThread::GetThreadNameByID(iID), sizeof(crash.m_ThreadName[0])-1 ); - + ++iCnt; - + if( iCnt == CrashData::MAX_BACKTRACE_THREADS ) break; } @@ -426,7 +427,7 @@ void CrashHandler::InitializeCrashHandler() /* * (c) 2003-2004 Glenn Maynard * All rights reserved. - * + * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -436,7 +437,7 @@ void CrashHandler::InitializeCrashHandler() * copyright notice(s) and this permission notice appear in all copies of * the Software and that both the above copyright notice(s) and this * permission notice appear in supporting documentation. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF diff --git a/src/archutils/Win32/Crash.cpp b/src/archutils/Win32/Crash.cpp index 7654a09c7d..07da07ffa9 100644 --- a/src/archutils/Win32/Crash.cpp +++ b/src/archutils/Win32/Crash.cpp @@ -467,7 +467,7 @@ static bool PointsToValidCall( ULONG_PTR ptr ) return IsValidCall(buf+7, len); } -void CrashHandler::do_backtrace( const void **buf, size_t size, +void CrashHandler::do_backtrace( const void **buf, size_t size, HANDLE hProcess, HANDLE hThread, const CONTEXT *pContext ) { const void **pLast = buf + size - 1; @@ -535,7 +535,7 @@ void CrashHandler::do_backtrace( const void **buf, size_t size, MEMORY_BASIC_INFORMATION meminfo; VirtualQuery((void *)data, &meminfo, sizeof meminfo); - + if (!IsExecutableProtection(meminfo.Protect) || meminfo.State!=MEM_COMMIT) fValid = false; @@ -563,7 +563,8 @@ void CrashHandler::do_backtrace( const void **buf, size_t size, } // Trigger the crash handler. This works even in the debugger. -static void SM_NORETURN debug_crash() +[[noreturn]] +static void debug_crash() { // __try { #if defined(__MSC_VER) @@ -652,7 +653,7 @@ void CrashHandler::ForceCrash( const char *reason ) * (c) 1998-2001 Avery Lee * (c) 2003-2004 Glenn Maynard * All rights reserved. - * + * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -662,7 +663,7 @@ void CrashHandler::ForceCrash( const char *reason ) * copyright notice(s) and this permission notice appear in all copies of * the Software and that both the above copyright notice(s) and this * permission notice appear in supporting documentation. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF diff --git a/src/archutils/Win32/RestartProgram.h b/src/archutils/Win32/RestartProgram.h index deeac27a92..d5ffefb6ec 100644 --- a/src/archutils/Win32/RestartProgram.h +++ b/src/archutils/Win32/RestartProgram.h @@ -1,6 +1,7 @@ #ifndef RESTART_PROGRAM_H #define RESTART_PROGRAM_H +[[noreturn]] void Win32RestartProgram(); #endif @@ -8,7 +9,7 @@ void Win32RestartProgram(); /* * (c) 2002-2004 Chris Danford * All rights reserved. - * + * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -18,7 +19,7 @@ void Win32RestartProgram(); * copyright notice(s) and this permission notice appear in all copies of * the Software and that both the above copyright notice(s) and this * permission notice appear in supporting documentation. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF diff --git a/src/global.cpp b/src/global.cpp index 4d7ddc0dec..acce963038 100644 --- a/src/global.cpp +++ b/src/global.cpp @@ -25,7 +25,7 @@ using CrashHandler::DebugBreak; #include "archutils/Unix/CrashHandler.h" #endif -void SM_NORETURN sm_crash( const char *reason ) +void sm_crash( const char *reason ) { #if ( defined(_WINDOWS) && defined(CRASH_HANDLER) ) || defined(MACOSX) || defined(_XDBG) /* If we're being debugged, throw a debug break so it'll suspend the process. */ @@ -60,7 +60,7 @@ void SM_NORETURN sm_crash( const char *reason ) /* * (c) 2004 Glenn Maynard * All rights reserved. - * + * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including @@ -70,7 +70,7 @@ void SM_NORETURN sm_crash( const char *reason ) * copyright notice(s) and this permission notice appear in all copies of * the Software and that both the above copyright notice(s) and this * permission notice appear in supporting documentation. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF diff --git a/src/global.h b/src/global.h index e39ee81e55..e346dd530d 100644 --- a/src/global.h +++ b/src/global.h @@ -61,20 +61,6 @@ namespace Checkpoints #define CHECKPOINT_M(m) (Checkpoints::SetCheckpoint(__FILE__, __LINE__, m)) -/** - * @brief Define a macro to tell the compiler that a function doesn't return. - * - * This just improves compiler warnings. This should be placed near the - * beginning of the function prototype (although it looks better near the end, - * VC only accepts it at the beginning). */ -#if defined(_MSC_VER) -#define SM_NORETURN __declspec(noreturn) -#elif defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5)) -#define SM_NORETURN __attribute__ ((__noreturn__)) -#else -#define SM_NORETURN -#endif - /** * @brief A crash has occurred, and we're not getting out of it easily. * @@ -84,7 +70,8 @@ namespace Checkpoints * @param reason the crash reason as determined by prior function calls. * @return nothing: there is no escape without quitting the program. */ -void SM_NORETURN sm_crash( const char *reason = "Internal error" ); +[[noreturn]] +void sm_crash( const char *reason = "Internal error" ); /** * @brief Assertion that sets an optional message and brings up the crash diff --git a/src/smpackage/ZipArchive/ZipArchive.cpp b/src/smpackage/ZipArchive/ZipArchive.cpp index 5fd0905496..34538930ca 100644 --- a/src/smpackage/ZipArchive/ZipArchive.cpp +++ b/src/smpackage/ZipArchive/ZipArchive.cpp @@ -2429,6 +2429,7 @@ int CZipArchive::CWildcard::Match(LPCTSTR lpszPattern, LPCTSTR lpszText) /* must match this character exactly */ + [[fallthrough]]; default: if (*lpszPattern != *lpszText) return matchPattern;