Skip to content

Commit 9026f12

Browse files
committed
refactor(clang-tidy): additional bugprone-suspicious-string-compare fixes
1 parent ea1c3e5 commit 9026f12

File tree

19 files changed

+45
-45
lines changed

19 files changed

+45
-45
lines changed

Core/GameEngine/Source/GameNetwork/GameSpy/Thread/PeerThread.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2590,7 +2590,7 @@ static void roomKeyChangedCallback(PEER peer, RoomType roomType, const char *nic
25902590
}
25912591

25922592
#ifdef DEBUG_LOGGING
2593-
if (strcmp(key, "username") && strcmp(key, "b_flags"))
2593+
if (strcmp(key, "username") != 0 && strcmp(key, "b_flags") != 0)
25942594
{
25952595
DEBUG_LOG(("roomKeyChangedCallback() - %s set %s=%s", nick, key, val));
25962596
}

Core/GameEngineDevice/Source/StdDevice/Common/StdLocalFileSystem.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ void StdLocalFileSystem::getFileListInDirectory(const AsciiString& currentDirect
241241
while (!done) {
242242
std::string filenameStr = iter->path().filename().string();
243243
if (!iter->is_directory() && iter->path().extension() == searchExt &&
244-
(strcmp(filenameStr.c_str(), ".") != 0 && strcmp(filenameStr.c_str(), ".."))) {
244+
(strcmp(filenameStr.c_str(), ".") != 0 && strcmp(filenameStr.c_str(), "..") != 0)) {
245245
// if we haven't already, add this filename to the list.
246246
// a stl set should only allow one copy of each filename
247247
AsciiString newFilename = iter->path().string().c_str();
@@ -268,7 +268,7 @@ void StdLocalFileSystem::getFileListInDirectory(const AsciiString& currentDirect
268268
while (!done) {
269269
std::string filenameStr = iter->path().filename().string();
270270
if(iter->is_directory() &&
271-
(strcmp(filenameStr.c_str(), ".") != 0 && strcmp(filenameStr.c_str(), ".."))) {
271+
(strcmp(filenameStr.c_str(), ".") != 0 && strcmp(filenameStr.c_str(), "..") != 0)) {
272272
AsciiString tempsearchstr(filenameStr.c_str());
273273

274274
// recursively add files in subdirectories if required.

Core/Libraries/Source/WWVegas/WWDownload/Download.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ HRESULT CDownload::DownloadFile(LPCSTR server, LPCSTR username, LPCSTR password,
4747
// If we're still connected, make sure we're on the right server
4848
if (m_Status == DOWNLOADSTATUS_FINDINGFILE)
4949
{
50-
if ((strcmp(m_Server, server) != 0) || (strcmp(m_Login, username)))
50+
if ((strcmp(m_Server, server) != 0) || (strcmp(m_Login, username) != 0))
5151
{
5252
// Damn, a server switch. Close conn & fix state
5353
m_Ftp->DisconnectFromServer();

Core/Libraries/Source/debug/netserv/netserv.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ int CALLBACK WinMain(HINSTANCE,HINSTANCE,LPSTR,int)
297297
char *input=InputConsole();
298298
if (input)
299299
{
300-
if (!strcmp(input,"quit"))
300+
if (strcmp(input,"quit") == 0)
301301
break;
302302
}
303303

Core/Libraries/Source/debug/test2/test2.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class TestCmdInterface: public DebugCmdInterface
5151
virtual bool Execute(class Debug& dbg, const char *cmd, CommandMode cmdmode,
5252
unsigned argn, const char * const * argv)
5353
{
54-
if (strcmp(cmd,"box"))
54+
if (strcmp(cmd,"box") != 0)
5555
return false;
5656

5757
MessageBox(NULL,"Hello world!","Command",MB_OK);

Core/Tools/Autorun/GETCD.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ int GetCDClass::Get_CD_Drive_For_This_Volume ( const char *volume_label )
200200
volume_name[11] = '\0';
201201
}
202202

203-
if ( !_stricmp( volume_label, volume_name )) {
203+
if ( _stricmp( volume_label, volume_name ) == 0) {
204204
return( cd_drive );
205205
}
206206

@@ -385,7 +385,7 @@ bool CD_Volume_Verification ( int cd_drive, char *volume_label, char *volume_to_
385385
strncpy( volume_label, volume_name, 128 );
386386
}
387387

388-
if ( !_stricmp( volume_to_find, volume_name )) {
388+
if ( _stricmp( volume_to_find, volume_name ) == 0) {
389389
return TRUE;
390390
}
391391

Core/Tools/Babylon/Babylon.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ BOOL CALLBACK EnumAllWindowsProcExact(HWND hWnd, LPARAM lParam)
220220

221221
GetWindowText(hWnd, szText, sizeof(szText));
222222

223-
if ( !strncmp (szText, szSearchTitle, strlen ( szSearchTitle)))
223+
if ( strncmp (szText, szSearchTitle, strlen ( szSearchTitle)) == 0)
224224
{
225225
* (BOOL *) lParam = TRUE;
226226
FoundWindow = hWnd;

Core/Tools/Babylon/BabylonDlg.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -980,27 +980,27 @@ static int parseComment ( FILE *file, char *buffer, INFO *info )
980980
return new_lines;
981981
}
982982

983-
if ( !stricmp ( token, "COMMENT" ) )
983+
if ( stricmp ( token, "COMMENT" ) == 0 )
984984
{
985985
new_lines += getString ( file, buffer, info->comment );
986986
}
987-
else if ( !stricmp ( token, "CONTEXT" ) )
987+
else if ( stricmp ( token, "CONTEXT" ) == 0 )
988988
{
989989
new_lines += getString ( file, buffer, info->context );
990990
}
991-
else if ( !stricmp ( token, "SPEAKER" ) )
991+
else if ( stricmp ( token, "SPEAKER" ) == 0 )
992992
{
993993
new_lines += getString ( file, buffer, info->speaker );
994994
}
995-
else if ( !stricmp ( token, "LISTENER" ) )
995+
else if ( stricmp ( token, "LISTENER" ) == 0 )
996996
{
997997
new_lines += getString ( file, buffer, info->listener );
998998
}
999-
else if ( !stricmp ( token, "MAXLEN" ) )
999+
else if ( stricmp ( token, "MAXLEN" ) == 0 )
10001000
{
10011001
info->maxlen = atoi ( buffer );
10021002
}
1003-
else if ( !stricmp ( token, "WAVE" ) )
1003+
else if ( stricmp ( token, "WAVE" ) == 0 )
10041004
{
10051005
new_lines += getString ( file, buffer, info->wave );
10061006
}
@@ -1024,7 +1024,7 @@ static int getLabelCount( char *filename )
10241024
if( fscanf( fp, "%s", buffer ) == EOF )
10251025
break;
10261026

1027-
if ( !stricmp( buffer, "END" ) )
1027+
if ( stricmp( buffer, "END" ) == 0 )
10281028
{
10291029
count++;
10301030
}
@@ -1083,7 +1083,7 @@ int CBabylonDlg::LoadStrFile ( TransDB *db, const char *filename, void (*cb) ( v
10831083
line_number++;
10841084
removeLeadingAndTrailing ( buffer );
10851085

1086-
if ( !stricmp ( buffer, "END" ) )
1086+
if ( stricmp ( buffer, "END" ) == 0 )
10871087
{
10881088
break;
10891089
}
@@ -1607,7 +1607,7 @@ int CBabylonDlg::UpdateLabel( BabylonLabel *source, BabylonLabel *destination, U
16071607
if ( (stext = (BabylonText *) dtext->Matched ()) )
16081608
{
16091609
// stext is the newer version;
1610-
if ( wcscmp ( dtext->Get (), stext->Get ()))
1610+
if ( wcscmp ( dtext->Get (), stext->Get ()) != 0)
16111611
{
16121612
if ( update )
16131613
{
@@ -1617,7 +1617,7 @@ int CBabylonDlg::UpdateLabel( BabylonLabel *source, BabylonLabel *destination, U
16171617
label_modified = TRUE;
16181618
info.changes ++;
16191619
}
1620-
if ( wcsicmp ( dtext->Wave (), stext->Wave ()))
1620+
if ( wcsicmp ( dtext->Wave (), stext->Wave ()) != 0)
16211621
{
16221622
if ( update )
16231623
{

Core/Tools/Babylon/TransDB.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ LANGINFO *GetLangInfo ( char *language )
9696

9797
while ( item->langid != LANGID_UNKNOWN )
9898
{
99-
if ( !stricmp ( language, item->name ) )
99+
if ( stricmp ( language, item->name ) == 0 )
100100
{
101101
return item;
102102
}
@@ -330,7 +330,7 @@ BabylonText* TransDB::FindSubText ( OLECHAR *pattern, int item )
330330
while ( text )
331331
{
332332

333-
if ( !wcsnicmp ( text->Get (), pattern, 15 ))
333+
if ( wcsnicmp ( text->Get (), pattern, 15 ) == 0)
334334
{
335335
if ( !item )
336336
{
@@ -692,7 +692,7 @@ BabylonText* BabylonLabel::FindText ( OLECHAR *find_text )
692692

693693
while ( txt )
694694
{
695-
if ( !wcscmp ( txt->Get(), find_text ))
695+
if ( wcscmp ( txt->Get(), find_text ) == 0)
696696
{
697697
return txt;
698698
}
@@ -836,25 +836,25 @@ void BabylonLabel::AddToTree ( CTreeCtrl *tc, HTREEITEM parent, int changes
836836
txt = NextText ( sh );
837837
}
838838

839-
if ( strcmp ( CommentSB(), "" ) )
839+
if ( strcmp ( CommentSB(), "" ) != 0 )
840840
{
841841
sprintf ( buffer, "COMMENT : %s", CommentSB() );
842842
tc->InsertItem ( buffer, litem );
843843
}
844844

845-
if ( strcmp ( ContextSB(), "" ) )
845+
if ( strcmp ( ContextSB(), "" ) != 0 )
846846
{
847847
sprintf ( buffer, "CONTEXT : %s", ContextSB() );
848848
tc->InsertItem ( buffer, litem );
849849
}
850850

851-
if ( strcmp ( SpeakerSB(), "" ) )
851+
if ( strcmp ( SpeakerSB(), "" ) != 0 )
852852
{
853853
sprintf ( buffer, "SPEAKER : %s", SpeakerSB() );
854854
tc->InsertItem ( buffer, litem );
855855
}
856856

857-
if ( strcmp ( ListenerSB(), "" ) )
857+
if ( strcmp ( ListenerSB(), "" ) != 0 )
858858
{
859859
sprintf ( buffer, "LISTENER: %s", ListenerSB() );
860860
tc->InsertItem ( buffer, litem );
@@ -1341,7 +1341,7 @@ void BabylonText::AddToTree ( CTreeCtrl *tc, HTREEITEM parent, int changes
13411341
tc->InsertItem ( buffer, item );
13421342
}
13431343

1344-
if ( strcmp ( WaveSB(), "" ) )
1344+
if ( strcmp ( WaveSB(), "" ) != 0 )
13451345
{
13461346
sprintf ( buffer, "WAVE : %s", WaveSB() );
13471347
tc->InsertItem ( buffer, item );
@@ -1411,7 +1411,7 @@ void Translation::AddToTree ( CTreeCtrl *tc, HTREEITEM parent, int changes
14111411

14121412
item = tc->InsertItem ( buffer, parent );
14131413

1414-
if ( strcmp ( CommentSB(), "" ) )
1414+
if ( strcmp ( CommentSB(), "" ) != 0 )
14151415
{
14161416
sprintf ( buffer, "COMMENT: %s", CommentSB() );
14171417
tc->InsertItem ( buffer, item );

Core/Tools/assetcull/assetcull.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ static bool filesEqual(const char *fn1, const char *fn2)
6969
if (fread(buf1,cur,1,f1)!=1||
7070
fread(buf2,cur,1,f2)!=1)
7171
break;
72-
if (memcmp(buf1,buf2,cur))
72+
if (memcmp(buf1,buf2,cur) != 0)
7373
break;
7474
k+=cur;
7575
}
@@ -105,7 +105,7 @@ static int recursiveCull(FILE *batchFile,
105105
{
106106
if (fd.attrib&_A_SUBDIR)
107107
{
108-
if (strcmp(fd.name,".")&&
108+
if (strcmp(fd.name,".") != 0&&
109109
strcmp(fd.name,".."))
110110
subdir.push_back(fd.name);
111111
}

0 commit comments

Comments
 (0)