diff --git a/src/AutoKeysounds.cpp b/src/AutoKeysounds.cpp index 17606e025f..d7a8d2618b 100644 --- a/src/AutoKeysounds.cpp +++ b/src/AutoKeysounds.cpp @@ -52,7 +52,7 @@ void AutoKeysounds::LoadAutoplaySoundsInto( RageSoundReader_Chain *pChain ) for( int t = 0; t < iNumTracks; t++ ) { int iRow = -1; - while(1) + for(;;) { /* Find the next row that either player has a note on. */ int iNextRow = INT_MAX; diff --git a/src/CreateZip.h b/src/CreateZip.h index 64333ee7b0..b8bf634e50 100644 --- a/src/CreateZip.h +++ b/src/CreateZip.h @@ -80,7 +80,7 @@ public: // ... meanwhile DWORD WINAPI ZipReceiverThread(void *dat) // { HANDLE hread = (HANDLE)dat; // char buf[1000]; -// while (true) +// for(;;) // { DWORD red; ReadFile(hread,buf,1000,&red,NULL); // // ... and do something with this zip data we're receiving // if (red==0) break; diff --git a/src/CsvFile.cpp b/src/CsvFile.cpp index 68fc44b100..93ce3bee28 100644 --- a/src/CsvFile.cpp +++ b/src/CsvFile.cpp @@ -31,7 +31,7 @@ bool CsvFile::ReadFile( RageFileBasic &f ) // hi,"hi2,","""hi3""" - while( 1 ) + for(;;) { RString line; switch( f.GetLine(line) ) diff --git a/src/DifficultyList.cpp b/src/DifficultyList.cpp index 192931c37e..1709f4fc8e 100644 --- a/src/DifficultyList.cpp +++ b/src/DifficultyList.cpp @@ -166,7 +166,7 @@ void StepsDisplayList::UpdatePositions() /* If less than total (and Rows.size()) are displayed, fill in the empty * space intelligently. */ - while(1) + for(;;) { const int sum = (first_end - first_start) + (second_end - second_start); if( sum >= (int) Rows.size() || sum >= total) diff --git a/src/FileDownload.cpp b/src/FileDownload.cpp index d8fbeb5872..26006842a5 100644 --- a/src/FileDownload.cpp +++ b/src/FileDownload.cpp @@ -238,7 +238,7 @@ void FileTransfer::HTTPUpdate() // Keep this as a code block, as there may be need to "if" it out some time. /* If you need a conditional for a large block of code, stick it in * a function and return. */ - while(1) + for(;;) { char Buffer[1024]; int iSize = m_wSocket.ReadData( Buffer, 1024 ); @@ -359,13 +359,15 @@ bool FileTransfer::ParseHTTPAddress( const RString &URL, RString &sProto, RStrin void FileTransfer::Finish() { - while( true ) + for(;;) { float fSleepSeconds = 0.1f; this->Update( fSleepSeconds ); usleep( int( fSleepSeconds * 1000000.0 ) ); if( this->IsFinished() ) + { break; + } } } diff --git a/src/GameState.cpp b/src/GameState.cpp index a631535a76..f5287b259e 100644 --- a/src/GameState.cpp +++ b/src/GameState.cpp @@ -2369,15 +2369,18 @@ bool GameState::ChangePreferredDifficulty( PlayerNumber pn, int dir ) const vector &v = CommonMetrics::DIFFICULTIES_TO_SHOW.GetValue(); Difficulty d = GetClosestShownDifficulty(pn); - while( 1 ) + for(;;) { d = enum_add2( d, dir ); if( d < 0 || d >= NUM_Difficulty ) + { return false; + } if( find(v.begin(), v.end(), d) != v.end() ) + { break; // found + } } - m_PreferredDifficulty[pn].Set( d ); return true; } @@ -2424,17 +2427,22 @@ bool GameState::ChangePreferredCourseDifficulty( PlayerNumber pn, int dir ) const vector &v = CommonMetrics::COURSE_DIFFICULTIES_TO_SHOW.GetValue(); CourseDifficulty cd = m_PreferredCourseDifficulty[pn]; - while( 1 ) + for(;;) { cd = enum_add2( cd, dir ); if( cd < 0 || cd >= NUM_Difficulty ) + { return false; + } if( find(v.begin(),v.end(),cd) == v.end() ) + { continue; /* not available */ + } if( !pCourse || pCourse->GetTrail( GetCurrentStyle(pn)->m_StepsType, cd ) ) + { break; + } } - return ChangePreferredCourseDifficulty( pn, cd ); } diff --git a/src/IniFile.cpp b/src/IniFile.cpp index 869218dec3..409224dd48 100644 --- a/src/IniFile.cpp +++ b/src/IniFile.cpp @@ -36,11 +36,11 @@ bool IniFile::ReadFile( RageFileBasic &f ) RString keyname; // keychild is used to cache the node that values are being added to. -Kyz XNode* keychild= NULL; - while( 1 ) + for(;;) { RString line; // Read lines until we reach a line that doesn't end in a backslash - while( true ) + for(;;) { RString s; switch( f.GetLine(s) ) @@ -57,8 +57,9 @@ bool IniFile::ReadFile( RageFileBasic &f ) line += s; if( line.empty() || line[line.size()-1] != '\\' ) + { break; - + } line.erase( line.end()-1 ); } diff --git a/src/InputQueue.cpp b/src/InputQueue.cpp index 83dfe46f26..6fd22a2240 100644 --- a/src/InputQueue.cpp +++ b/src/InputQueue.cpp @@ -187,7 +187,7 @@ bool InputQueueCode::Load( RString sButtonsNames ) bool bHold = false; bool bNotHold = false; - while(1) + for(;;) { if( sButtonName.Left(1) == "+" ) { diff --git a/src/LuaBinding.cpp b/src/LuaBinding.cpp index 533a56375c..355c6487f9 100644 --- a/src/LuaBinding.cpp +++ b/src/LuaBinding.cpp @@ -26,11 +26,12 @@ namespace /* Look at the first class. If it has a base class that needs to be registered, * go there first. */ LuaBinding *pBinding = mapToRegister.begin()->second; - while(1) + for(;;) { if( !pBinding->IsDerivedClass() ) + { break; - + } RString sBase = pBinding->GetBaseClassName(); map::const_iterator it = mapToRegister.find(sBase); if( it != mapToRegister.end() ) diff --git a/src/LyricsLoader.cpp b/src/LyricsLoader.cpp index d617df2144..ca2bb8da43 100644 --- a/src/LyricsLoader.cpp +++ b/src/LyricsLoader.cpp @@ -32,12 +32,14 @@ bool LyricsLoader::LoadFromLRCFile(const RString& sPath, Song& out) out.m_LyricSegments.clear(); - while( 1 ) + for(;;) { RString line; int ret = input.GetLine( line ); if( ret == 0 ) + { break; + } if( ret == -1 ) { LuaHelpers::ReportScriptErrorFmt("Error reading %s: %s", input.GetPath().c_str(), input.GetError().c_str() ); @@ -47,15 +49,18 @@ bool LyricsLoader::LoadFromLRCFile(const RString& sPath, Song& out) utf8_remove_bom( line ); if(!line.compare(0, 2, "//")) + { continue; - + } // (most tags are in the format of...) // "[data1] data2". Ignore whitespace at the beginning of the line. static Regex x("^ *\\[([^]]+)\\] *(.*)$"); vector matches; if(!x.Compare(line, matches)) + { continue; + } ASSERT( matches.size() == 2 ); RString &sValueName = matches[0]; diff --git a/src/NoteDataUtil.cpp b/src/NoteDataUtil.cpp index d7f67060e1..ad7a607de4 100644 --- a/src/NoteDataUtil.cpp +++ b/src/NoteDataUtil.cpp @@ -70,19 +70,22 @@ static void LoadFromSMNoteDataStringWithPlayer( NoteData& out, const RString &sS * would do as I would expect. */ split( sSMNoteData, ",", start, size, end, true ); // Ignore empty is important. if( start == end ) + { break; - + } // Partial string split. int measureLineStart = start, measureLineSize = -1; const int measureEnd = start + size; aMeasureLines.clear(); - while( true ) + for(;;) { // Ignore empty is clearly important here. split( sSMNoteData, "\n", measureLineStart, measureLineSize, measureEnd, true ); if( measureLineStart == measureEnd ) + { break; + } //RString &line = sSMNoteData.substr( measureLineStart, measureLineSize ); const char *beginLine = sSMNoteData.data() + measureLineStart; const char *endLine = beginLine + measureLineSize; @@ -706,11 +709,13 @@ void LightTransformHelper( const NoteData &in, NoteData &out, const vector * until we've extended to the end of the latest overlapping hold note. */ int iHoldStart = r; int iHoldEnd = -1; - while(1) + for(;;) { int iMaxTailRow = FindLongestOverlappingHoldNoteForAnyTrack( in, r ); if( iMaxTailRow == -1 ) + { break; + } iHoldEnd = iMaxTailRow; r = iMaxTailRow; } diff --git a/src/NoteField.cpp b/src/NoteField.cpp index a7836695a4..0b03ed1823 100644 --- a/src/NoteField.cpp +++ b/src/NoteField.cpp @@ -924,7 +924,7 @@ void NoteField::DrawPrimitives() FOREACH_BackgroundLayer( j ) iter[j] = GAMESTATE->m_pCurSong->GetBackgroundChanges(j).begin(); - while( 1 ) + for(;;) { float fLowestBeat = FLT_MAX; vector viLowestIndex; @@ -932,8 +932,9 @@ void NoteField::DrawPrimitives() FOREACH_BackgroundLayer( j ) { if( iter[j] == GAMESTATE->m_pCurSong->GetBackgroundChanges(j).end() ) + { continue; - + } float fBeat = iter[j]->m_fStartBeat; if( fBeat < fLowestBeat ) { @@ -950,7 +951,9 @@ void NoteField::DrawPrimitives() if( viLowestIndex.empty() ) { FOREACH_BackgroundLayer( j ) + { ASSERT( iter[j] == GAMESTATE->m_pCurSong->GetBackgroundChanges(j).end() ); + } break; } @@ -963,13 +966,17 @@ void NoteField::DrawPrimitives() const BackgroundChange& change = *iter[*bl]; RString s = change.GetTextDescription(); if( *bl!=0 ) + { s = ssprintf("%d: ",*bl) + s; + } vsBGChanges.push_back( s ); } DrawBGChangeText(fLowestBeat, join("\n",vsBGChanges), text_glow); } FOREACH_CONST( BackgroundLayer, viLowestIndex, bl ) + { iter[*bl]++; + } } } break; diff --git a/src/NoteSkinManager.cpp b/src/NoteSkinManager.cpp index f76e06741c..9d38562394 100644 --- a/src/NoteSkinManager.cpp +++ b/src/NoteSkinManager.cpp @@ -116,7 +116,7 @@ bool NoteSkinManager::LoadNoteSkinDataRecursive( const RString &sNoteSkinName_, int iDepth = 0; bool bLoadedCommon = false; bool bLoadedBase = false; - while(1) + for(;;) { ++iDepth; if(iDepth >= 20) diff --git a/src/RageFileBasic.cpp b/src/RageFileBasic.cpp index 8dce779506..88f4ca9e8b 100644 --- a/src/RageFileBasic.cpp +++ b/src/RageFileBasic.cpp @@ -327,12 +327,13 @@ int RageFileObj::GetLine( RString &sOut ) sOut = ""; if( m_bEOF ) + { return 0; - + } EnableReadBuffering(); bool bGotData = false; - while( 1 ) + for(;;) { bool bDone = false; @@ -361,12 +362,15 @@ int RageFileObj::GetLine( RString &sOut ) { char *RealEnd = p; if( bDone && p > m_pReadBuf && p[-1] == '\r' ) + { --RealEnd; /* not including \r */ + } sOut.append( m_pReadBuf, RealEnd ); if( bDone ) + { ++p; /* skip \n */ - + } const int iUsed = p-m_pReadBuf; if( iUsed ) { diff --git a/src/RageFileDriverDeflate.cpp b/src/RageFileDriverDeflate.cpp index cad4d240ea..3f85f763aa 100644 --- a/src/RageFileDriverDeflate.cpp +++ b/src/RageFileDriverDeflate.cpp @@ -224,12 +224,13 @@ RageFileObjDeflate::~RageFileObjDeflate() int RageFileObjDeflate::WriteInternal( const void *pBuffer, size_t iBytes ) { if( iBytes == 0 ) + { return 0; - + } m_pDeflate->next_in = (Bytef*) pBuffer; m_pDeflate->avail_in = iBytes; - while( 1 ) + for(;;) { char buf[1024*4]; m_pDeflate->next_out = (Bytef *) buf; @@ -238,8 +239,9 @@ int RageFileObjDeflate::WriteInternal( const void *pBuffer, size_t iBytes ) int err = deflate( m_pDeflate, Z_NO_FLUSH ); if( err != Z_OK ) + { FAIL_M( ssprintf("deflate: err %i", err) ); - + } if( m_pDeflate->avail_out < sizeof(buf) ) { int lBytes = sizeof(buf)-m_pDeflate->avail_out; @@ -257,9 +259,10 @@ int RageFileObjDeflate::WriteInternal( const void *pBuffer, size_t iBytes ) } if( m_pDeflate->avail_in == 0 && m_pDeflate->avail_out != 0 ) + { break; + } } - return iBytes; } @@ -270,7 +273,7 @@ int RageFileObjDeflate::FlushInternal() { m_pDeflate->avail_in = 0; - while( 1 ) + for(;;) { char buf[1024*4]; m_pDeflate->next_out = (Bytef *) buf; @@ -278,8 +281,9 @@ int RageFileObjDeflate::FlushInternal() int err = deflate( m_pDeflate, Z_FINISH ); if( err != Z_OK && err != Z_STREAM_END ) + { FAIL_M( ssprintf("deflate: err %i", err) ); - + } if( m_pDeflate->avail_out < sizeof(buf) ) { int iBytes = sizeof(buf)-m_pDeflate->avail_out; @@ -297,7 +301,9 @@ int RageFileObjDeflate::FlushInternal() } if( err == Z_STREAM_END && m_pDeflate->avail_out != 0 ) + { return m_pFile->Flush(); + } } } diff --git a/src/RageFileManager.cpp b/src/RageFileManager.cpp index 2ac4a5e354..84e175e415 100644 --- a/src/RageFileManager.cpp +++ b/src/RageFileManager.cpp @@ -117,13 +117,16 @@ static bool GrabDriver( RageFileDriver *pDriver ) { g_Mutex->Lock(); - while(1) + for(;;) { unsigned i; for( i = 0; i < g_pDrivers.size(); ++i ) + { if( g_pDrivers[i]->m_pDriver == pDriver ) + { break; - + } + } if( i == g_pDrivers.size() ) { g_Mutex->Unlock(); diff --git a/src/RageSoundReader_MP3.cpp b/src/RageSoundReader_MP3.cpp index b21dddd6a2..b5ac5eb04c 100644 --- a/src/RageSoundReader_MP3.cpp +++ b/src/RageSoundReader_MP3.cpp @@ -389,7 +389,7 @@ int RageSoundReader_MP3::do_mad_frame_decode( bool headers_only ) { int bytes_read = 0; - while(1) + for(;;) { int ret; @@ -861,7 +861,7 @@ int RageSoundReader_MP3::SetPosition_hard( int iFrame ) } /* Decode frames until the current frame contains the desired offset. */ - while(1) + for(;;) { /* If desired < next_frame_timer, this frame contains the position. Since we've * already decoded the frame, synth it, too. */ @@ -1035,13 +1035,17 @@ int RageSoundReader_MP3::GetLengthInternal( bool fast ) } MADLIB_rewind(); - while(1) + for(;;) { int ret = do_mad_frame_decode( true ); if( ret == -1 ) + { return -1; /* it set the error */ + } if( ret == 0 ) /* EOF */ + { break; + } } /* mad->Timer is the timestamp of the current frame; find the timestamp of diff --git a/src/RageSoundReader_Preload.cpp b/src/RageSoundReader_Preload.cpp index ff7e659bf1..91266c6e92 100644 --- a/src/RageSoundReader_Preload.cpp +++ b/src/RageSoundReader_Preload.cpp @@ -69,20 +69,24 @@ bool RageSoundReader_Preload::Open( RageSoundReader *pSource ) m_Buffer.Get()->reserve( iBytes ); } - while(1) + for(;;) { /* If the rate changes, we won't preload it. */ if( pSource->GetStreamToSourceRatio() != m_fRate ) + { return false; /* Don't bother trying to preload it. */ - + } float buffer[1024]; int iCnt = pSource->Read( buffer, ARRAYLEN(buffer) / m_iChannels ); if( iCnt == END_OF_FILE ) + { break; + } if( iCnt < 0 ) + { return false; - + } /* Add the buffer. */ if( m_bBufferIs16Bit ) { @@ -96,7 +100,9 @@ bool RageSoundReader_Preload::Open( RageSoundReader *pSource ) } if( m_Buffer.Get()->size() > iMaxSamples * samplesize ) + { return false; /* too big */ + } } m_iPosition = 0; diff --git a/src/RageSoundReader_Resample_Good.cpp b/src/RageSoundReader_Resample_Good.cpp index ecc176c108..4b97d328b5 100644 --- a/src/RageSoundReader_Resample_Good.cpp +++ b/src/RageSoundReader_Resample_Good.cpp @@ -110,12 +110,13 @@ namespace int GCD( int i1, int i2 ) { - while(1) + for(;;) { unsigned iRem = i2 % i1; if( iRem == 0 ) + { return i1; - + } i2 = i1; i1 = iRem; } diff --git a/src/RageSoundReader_SpeedChange.cpp b/src/RageSoundReader_SpeedChange.cpp index efee192010..a4825b3b9b 100644 --- a/src/RageSoundReader_SpeedChange.cpp +++ b/src/RageSoundReader_SpeedChange.cpp @@ -235,7 +235,7 @@ int RageSoundReader_SpeedChange::GetCursorAvail() const int RageSoundReader_SpeedChange::Read( float *pBuf, int iFrames ) { - while( 1 ) + for(;;) { if( m_iDataBufferAvailFrames == 0 && m_fTrailingSpeedRatio == m_fSpeedRatio && m_fSpeedRatio == 1.0f ) { @@ -250,9 +250,13 @@ int RageSoundReader_SpeedChange::Read( float *pBuf, int iFrames ) { int iRet = Step(); if( iRet < 0 ) + { return iRet; + } if( !GetCursorAvail() ) + { return END_OF_FILE; + } continue; } diff --git a/src/RageSurfaceUtils_Palettize.cpp b/src/RageSurfaceUtils_Palettize.cpp index a2982124c5..c22d6d8ed6 100644 --- a/src/RageSurfaceUtils_Palettize.cpp +++ b/src/RageSurfaceUtils_Palettize.cpp @@ -120,22 +120,27 @@ void RageSurfaceUtils::Palettize( RageSurface *&pImg, int iColors, bool bDither * [GRR POSSIBLE BUG: what about 32^4 ?] */ acolorhist_item *achv; int colors; - while(1) + for(;;) { achv = pam_computeacolorhist( pImg, MAXCOLORS, &colors ); if( achv != NULL ) + { break; + } pixval newmaxval = maxval / 2; int table[256]; for( int c = 0; c <= maxval; ++c ) + { table[c] = ( (uint8_t) c * newmaxval + maxval/2 ) / maxval; - + } for( int row = 0; row < pImg->h; ++row ) { apixel *pP = (apixel *) (pImg->pixels+row*pImg->pitch); for( int col = 0; col < pImg->w; ++col, ++pP ) + { PAM_DEPTH( *pP ); + } } maxval = newmaxval; } diff --git a/src/RageSurface_Load_GIF.cpp b/src/RageSurface_Load_GIF.cpp index 499e9d22c3..72c91e8024 100644 --- a/src/RageSurface_Load_GIF.cpp +++ b/src/RageSurface_Load_GIF.cpp @@ -117,7 +117,7 @@ RageSurfaceUtils::OpenResult RageSurface_Load_GIF( const RString &sPath, RageSur int transparency = -1; - while(1) + for(;;) { unsigned char type; if( !ReadOK(f, &type, 1) ) diff --git a/src/RageTimer.cpp b/src/RageTimer.cpp index 98bee8dfda..290a5b5908 100644 --- a/src/RageTimer.cpp +++ b/src/RageTimer.cpp @@ -3,7 +3,7 @@ * * As a timer, * RageTimer Timer; - * while(1) { + * for(;;) { * printf( "Will be approximately: %f", Timer.PeekDeltaTime()) ; * float fDeltaTime = Timer.GetDeltaTime(); * } diff --git a/src/RageUtil.cpp b/src/RageUtil.cpp index beb89d0d3b..9d9fd2cc52 100644 --- a/src/RageUtil.cpp +++ b/src/RageUtil.cpp @@ -881,7 +881,7 @@ void split( const wstring &sSource, const wstring &sDelimitor, vector & RString str="a,b,c"; int start = 0, size = -1; -while( 1 ) +for(;;) { do_split( str, ",", start, size ); if( start == str.size() ) @@ -2379,24 +2379,30 @@ bool FileCopy( const RString &sSrcFile, const RString &sDstFile ) bool FileCopy( RageFileBasic &in, RageFileBasic &out, RString &sError, bool *bReadError ) { - while(1) + for(;;) { RString data; if( in.Read(data, 1024*32) == -1 ) { sError = ssprintf( "read error: %s", in.GetError().c_str() ); if( bReadError != NULL ) + { *bReadError = true; + } return false; } if( data.empty() ) + { break; + } int i = out.Write(data); if( i == -1 ) { sError = ssprintf( "write error: %s", out.GetError().c_str() ); if( bReadError != NULL ) + { *bReadError = false; + } return false; } } @@ -2405,7 +2411,9 @@ bool FileCopy( RageFileBasic &in, RageFileBasic &out, RString &sError, bool *bRe { sError = ssprintf( "write error: %s", out.GetError().c_str() ); if( bReadError != NULL ) + { *bReadError = false; + } return false; } diff --git a/src/ScreenOptions.cpp b/src/ScreenOptions.cpp index 1f4e0b77b3..31fa458716 100644 --- a/src/ScreenOptions.cpp +++ b/src/ScreenOptions.cpp @@ -640,23 +640,32 @@ void ScreenOptions::PositionRows( bool bTween ) /* If less than total (and Rows.size()) are displayed, fill in the empty * space intelligently. */ - while(1) + for(;;) { const int sum = (first_end - first_start) + (second_end - second_start); if( sum >= (int) Rows.size() || sum >= total) + { break; // nothing more to display, or no room - + } /* First priority: expand the top of the second half until it meets * the first half. */ if( second_start > first_end ) + { second_start--; + } // Otherwise, expand either end. else if( first_start > 0 ) + { first_start--; + } else if( second_end < (int) Rows.size() ) + { second_end++; + } else + { FAIL_M("Do we have room to grow or don't we?"); + } } int pos = 0; diff --git a/src/ScreenPackages.cpp b/src/ScreenPackages.cpp index 32ac7178cf..b9d1562938 100644 --- a/src/ScreenPackages.cpp +++ b/src/ScreenPackages.cpp @@ -592,20 +592,22 @@ static LocalizedString WAITING_FOR_HEADER( "ScreenPackages", "Waiting for header void ScreenPackages::HTTPUpdate() { if( !m_bIsDownloading ) + { return; - + } int BytesGot=0; // Keep this as a code block // as there may be need to "if" it out some time. /* If you need a conditional for a large block of code, stick it in * a function and return. */ - while(1) + for(;;) { char Buffer[1024]; int iSize = m_wSocket.ReadData( Buffer, 1024 ); if( iSize <= 0 ) + { break; - + } m_sBUFFER.append( Buffer, iSize ); BytesGot += iSize; } diff --git a/src/ThemeManager.cpp b/src/ThemeManager.cpp index 42920f0e2f..1c05ec4395 100644 --- a/src/ThemeManager.cpp +++ b/src/ThemeManager.cpp @@ -295,7 +295,7 @@ void ThemeManager::LoadThemeMetrics( const RString &sThemeName_, const RString & m_sCurLanguage = sLanguage; bool bLoadedBase = false; - while(1) + for(;;) { ASSERT_M( g_vThemes.size() < 20, "Circular theme fallback references detected." ); @@ -315,13 +315,15 @@ void ThemeManager::LoadThemeMetrics( const RString &sThemeName_, const RString & } iniStrings.ReadFile( GetLanguageIniPath(sThemeName,SpecialFiles::BASE_LANGUAGE) ); if( sLanguage.CompareNoCase(SpecialFiles::BASE_LANGUAGE) ) + { iniStrings.ReadFile( GetLanguageIniPath(sThemeName,sLanguage) ); - + } bool bIsBaseTheme = !sThemeName.CompareNoCase(SpecialFiles::BASE_THEME_NAME); iniMetrics.GetValue( "Global", "IsBaseTheme", bIsBaseTheme ); if( bIsBaseTheme ) + { bLoadedBase = true; - + } /* Read the fallback theme. If no fallback theme is specified, and we haven't * already loaded it, fall back on SpecialFiles::BASE_THEME_NAME. * That way, default theme fallbacks can be disabled with @@ -330,9 +332,10 @@ void ThemeManager::LoadThemeMetrics( const RString &sThemeName_, const RString & if( !iniMetrics.GetValue("Global","FallbackTheme",sFallback) ) { if( sThemeName.CompareNoCase( SpecialFiles::BASE_THEME_NAME ) && !bLoadedBase ) + { sFallback = SpecialFiles::BASE_THEME_NAME; + } } - /* We actually want to load themes bottom-to-top, loading fallback themes * first, so derived themes overwrite metrics in fallback themes. But, we * need to load the derived theme first, to find out the name of the fallback @@ -342,7 +345,9 @@ void ThemeManager::LoadThemeMetrics( const RString &sThemeName_, const RString & XmlFileUtil::MergeIniUnder( &iniStrings, &g_pLoadedThemeData->iniStrings ); if( sFallback.empty() ) + { break; + } sThemeName = sFallback; } @@ -960,12 +965,13 @@ RString ThemeManager::GetMetricRaw( const IniFile &ini, const RString &sMetricsG const RString sMetricsGroup = sMetricsGroup_; const RString sValueName = sValueName_; - while( true ) + for(;;) { RString ret; if( ThemeManager::GetMetricRawRecursive(ini, sMetricsGroup, sValueName, ret) ) + { return ret; - + } RString sCurMetricPath = GetMetricsIniPath( m_sCurThemeName ); RString sDefaultMetricPath = GetMetricsIniPath( SpecialFiles::BASE_THEME_NAME ); diff --git a/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp b/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp index ee87412f18..bdf23563c9 100644 --- a/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp +++ b/src/arch/MovieTexture/MovieTexture_FFMpeg.cpp @@ -174,21 +174,28 @@ int MovieDecoder_FFMpeg::DecodeFrame( float fTargetTime ) m_fLastFrame=fTargetTime; } - while( 1 ) + for(;;) { int ret = DecodePacket( fTargetTime ); if( ret == 1 ) + { return 1; + } if( ret == -1 ) + { return -1; + } if( ret == 0 && m_iEOF > 0 ) + { return 0; /* eof */ - + } ASSERT( ret == 0 ); ret = ReadPacket(); if( ret < 0 ) + { return ret; /* error */ + } } } diff --git a/src/archutils/Unix/Backtrace.cpp b/src/archutils/Unix/Backtrace.cpp index 032ce36f07..f7a555f4b0 100644 --- a/src/archutils/Unix/Backtrace.cpp +++ b/src/archutils/Unix/Backtrace.cpp @@ -40,17 +40,25 @@ static const char *itoa(unsigned n) static intptr_t xtoi( const char *hex ) { intptr_t ret = 0; - while( 1 ) + for(;;) { int val = -1; if( *hex >= '0' && *hex <= '9' ) + { val = *hex - '0'; + } else if( *hex >= 'A' && *hex <= 'F' ) + { val = *hex - 'A' + 10; + } else if( *hex >= 'a' && *hex <= 'f' ) + { val = *hex - 'a' + 10; + } else + { break; + } hex++; ret *= 16; diff --git a/src/archutils/Unix/CrashHandler.cpp b/src/archutils/Unix/CrashHandler.cpp index 323abcd365..e842430640 100644 --- a/src/archutils/Unix/CrashHandler.cpp +++ b/src/archutils/Unix/CrashHandler.cpp @@ -31,17 +31,21 @@ static void safe_print( int fd, ... ) va_list ap; va_start( ap, fd ); - while( true ) + for(;;) { const char *p = va_arg( ap, const char * ); if( p == NULL ) + { break; + } size_t len = strlen( p ); while( len ) { ssize_t result = write( fd, p, strlen(p) ); if( result == -1 ) + { _exit( 1 ); + } len -= result; p += result; } diff --git a/src/global.cpp b/src/global.cpp index 080c7abd29..f9b6bef8d2 100644 --- a/src/global.cpp +++ b/src/global.cpp @@ -28,7 +28,7 @@ void NORETURN sm_crash( const char *reason ) if( IsDebuggerPresent() ) { DebugBreak(); - while(1); /* don't return */ + for(;;); /* don't return */ } #endif @@ -39,7 +39,7 @@ void NORETURN sm_crash( const char *reason ) /* This isn't actually reached. We just do this to convince the compiler that the * function really doesn't return. */ - while(1); + for(;;); #endif #if defined(_WINDOWS)