Skip to content

Commit bffbcb4

Browse files
authored
refactor: Apply integer value comparisons for strcmp and stricmp with clang-tidy (#1956)
1 parent 4951762 commit bffbcb4

File tree

58 files changed

+275
-275
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+275
-275
lines changed

Core/GameEngine/Source/Common/System/GameMemory.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2681,7 +2681,7 @@ MemoryPool *MemoryPoolFactory::findMemoryPool(const char *poolName)
26812681
{
26822682
for (MemoryPool *pool = m_firstPoolInFactory; pool; pool = pool->getNextPoolInList())
26832683
{
2684-
if (!strcmp(poolName, pool->getPoolName()))
2684+
if (strcmp(poolName, pool->getPoolName()) == 0)
26852685
{
26862686
DEBUG_ASSERTCRASH(poolName == pool->getPoolName(), ("hmm, ptrs should probably match here"));
26872687
return pool;

Core/GameEngine/Source/GameNetwork/GameSpy/PeerDefs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ void GameSpyInfo::addGroupRoom( GameSpyGroupRoom room )
340340
groupLabel.format("GUI:%s", room.m_name.str());
341341
room.m_translatedName = TheGameText->fetch(groupLabel);
342342
m_groupRooms[room.m_groupID] = room;
343-
if ( !stricmp("quickmatch", room.m_name.str()) )
343+
if ( stricmp("quickmatch", room.m_name.str()) == 0 )
344344
{
345345
DEBUG_LOG(("Group room %d (%s) is the QuickMatch room", room.m_groupID, room.m_name.str()));
346346
TheGameSpyConfig->setQMChannel(room.m_groupID);

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ Int PeerThreadClass::findServer( SBServer server )
471471
UnsignedInt oldPrivateIP = SBServerGetPrivateInetAddress(it->second);
472472
UnsignedShort oldPrivatePort = SBServerGetPrivateQueryPort(it->second);
473473
UnsignedInt oldPublicIP = SBServerGetPublicInetAddress(it->second);
474-
if (!strcmp(oldName, newName) &&
474+
if (strcmp(oldName, newName) == 0 &&
475475
oldPrivateIP == newPrivateIP &&
476476
oldPublicIP == newPublicIP &&
477477
oldPrivatePort == newPrivatePort)
@@ -1842,7 +1842,7 @@ void PeerThreadClass::handleQMMatch(PEER peer, Int mapIndex, Int seed,
18421842
Int i=0;
18431843
for (; i<MAX_SLOTS; ++i)
18441844
{
1845-
if (playerName[i] && stricmp(playerName[i], m_loginName.c_str()))
1845+
if (playerName[i] && stricmp(playerName[i], m_loginName.c_str()) != 0)
18461846
{
18471847
peerMessagePlayer( peer, playerName[i], "We're matched!", NormalMessage );
18481848
}
@@ -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
}
@@ -2705,7 +2705,7 @@ void playerLeftCallback(PEER peer, RoomType roomType, const char * nick, const c
27052705

27062706
if (t->getQMStatus() != QM_IDLE && t->getQMStatus() != QM_STOPPED)
27072707
{
2708-
if (!stricmp(t->getQMBotName().c_str(), nick))
2708+
if (stricmp(t->getQMBotName().c_str(), nick) == 0)
27092709
{
27102710
// matchbot left - bail
27112711
PeerResponse resp;
@@ -2845,9 +2845,9 @@ static void listingGamesCallback(PEER peer, PEERBool success, const char * name,
28452845
DEBUG_LOG(("Game name is '%s'", name));
28462846
const char *newname = SBServerGetStringValue(server, "gamename", (char *)name);
28472847
#if RTS_GENERALS
2848-
if (strcmp(newname, "ccgenerals"))
2848+
if (strcmp(newname, "ccgenerals") != 0)
28492849
#elif RTS_ZEROHOUR
2850-
if (strcmp(newname, "ccgenzh"))
2850+
if (strcmp(newname, "ccgenzh") != 0)
28512851
#endif
28522852
name = newname;
28532853
DEBUG_LOG(("Game name is now '%s'", name));

Core/GameEngine/Source/GameNetwork/NAT.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,7 +1169,7 @@ void NAT::processGlobalMessage(Int slotNum, const char *options) {
11691169
++ptr;
11701170
}
11711171
DEBUG_LOG(("NAT::processGlobalMessage - got message from slot %d, message is \"%s\"", slotNum, ptr));
1172-
if (!strncmp(ptr, "PROBED", strlen("PROBED"))) {
1172+
if (strncmp(ptr, "PROBED", strlen("PROBED")) == 0) {
11731173
// format: PROBED<node number>
11741174
// a probe has been sent at us, if we are waiting because of a netgear or something, we
11751175
// should start sending our own probes.
@@ -1180,7 +1180,7 @@ void NAT::processGlobalMessage(Int slotNum, const char *options) {
11801180
} else {
11811181
DEBUG_LOG(("NAT::processGlobalMessage - probed by node %d, not our target", node));
11821182
}
1183-
} else if (!strncmp(ptr, "CONNDONE", strlen("CONNDONE"))) {
1183+
} else if (strncmp(ptr, "CONNDONE", strlen("CONNDONE")) == 0) {
11841184
// format: CONNDONE<node number>
11851185
// we should get the node number of the player who's connection is done from the options
11861186
// and mark that down as part of the connectionStates.
@@ -1205,7 +1205,7 @@ void NAT::processGlobalMessage(Int slotNum, const char *options) {
12051205
} else {
12061206
DEBUG_LOG(("NAT::processGlobalMessage - got a connection done message that isn't from this round. node: %d sending node: %d", node, sendingNode));
12071207
}
1208-
} else if (!strncmp(ptr, "CONNFAILED", strlen("CONNFAILED"))) {
1208+
} else if (strncmp(ptr, "CONNFAILED", strlen("CONNFAILED")) == 0) {
12091209
// format: CONNFAILED<node number>
12101210
// we should get the node number of the player who's connection failed from the options
12111211
// and mark that down as part of the connectionStates.
@@ -1214,7 +1214,7 @@ void NAT::processGlobalMessage(Int slotNum, const char *options) {
12141214
DEBUG_LOG(("NAT::processGlobalMessage - node %d's connection failed, setting connection state to failed", node));
12151215
setConnectionState(node, NATCONNECTIONSTATE_FAILED);
12161216
}
1217-
} else if (!strncmp(ptr, "PORT", strlen("PORT"))) {
1217+
} else if (strncmp(ptr, "PORT", strlen("PORT")) == 0) {
12181218
// format: PORT<node number> <port number> <internal IP>
12191219
// we should get the node number and the mangled port number of the client we
12201220
// are supposed to be communicating with and start probing them. No, that was not

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(), ".") && 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(), ".") && 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/GameEngineDevice/Source/Win32Device/Common/Win32LocalFileSystem.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ void Win32LocalFileSystem::getFileListInDirectory(const AsciiString& currentDire
139139

140140
while (!done) {
141141
if (!(findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) &&
142-
(strcmp(findData.cFileName, ".") && strcmp(findData.cFileName, ".."))) {
142+
(strcmp(findData.cFileName, ".") != 0 && strcmp(findData.cFileName, "..") != 0)) {
143143
// if we haven't already, add this filename to the list.
144144
// a stl set should only allow one copy of each filename
145145
AsciiString newFilename;
@@ -165,7 +165,7 @@ void Win32LocalFileSystem::getFileListInDirectory(const AsciiString& currentDire
165165

166166
while (!done) {
167167
if ((findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) &&
168-
(strcmp(findData.cFileName, ".") && strcmp(findData.cFileName, ".."))) {
168+
(strcmp(findData.cFileName, ".") != 0 && strcmp(findData.cFileName, "..") != 0)) {
169169

170170
AsciiString tempsearchstr;
171171
tempsearchstr.concat(currentDirectory);

Core/Libraries/Source/WWVegas/WW3D2/texturethumbnail.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ static void Create_Hash_Name(StringClass& name, const StringClass& thumb_name)
3737
{
3838
name=thumb_name;
3939
int len=name.Get_Length();
40-
WWASSERT(!stricmp(&name[len-4],".tga") || !stricmp(&name[len-4],".dds"));
40+
WWASSERT(stricmp(&name[len-4],".tga") == 0 || stricmp(&name[len-4],".dds") == 0);
4141
name[len-4]='\0';
4242
_strlwr(name.Peek_Buffer());
4343
}

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)) || (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/WWVegas/WWLib/argv.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,15 +103,15 @@ const char *ArgvClass::Find_Again(const char *arg)
103103
if (Is_Exact_Size()) {
104104
// Case Sensitive, Exact Size.
105105
for (; CurrentPos < Argc; CurrentPos++) {
106-
if (!strcmp(arg, Argv[CurrentPos])) {
106+
if (strcmp(arg, Argv[CurrentPos]) == 0) {
107107
return Argv[CurrentPos];
108108
}
109109
}
110110
} else {
111111
// Case Sensitive, Match first strlen(arg).
112112
int len = strlen(arg);
113113
for (; CurrentPos < Argc; CurrentPos++) {
114-
if (!strncmp(arg, Argv[CurrentPos], len)) {
114+
if (strncmp(arg, Argv[CurrentPos], len) == 0) {
115115
return Argv[CurrentPos];
116116
}
117117
}
@@ -120,15 +120,15 @@ const char *ArgvClass::Find_Again(const char *arg)
120120
if (Is_Exact_Size()) {
121121
// Note case sensitive, Exact Size.
122122
for (; CurrentPos < Argc; CurrentPos++) {
123-
if (!stricmp(arg, Argv[CurrentPos])) {
123+
if (stricmp(arg, Argv[CurrentPos]) == 0) {
124124
return Argv[CurrentPos];
125125
}
126126
}
127127
} else {
128128
// Note case sensitive, Match first strlen(arg).
129129
int len = strlen(arg);
130130
for (; CurrentPos < Argc; CurrentPos++) {
131-
if (!strnicmp(arg, Argv[CurrentPos], len)) {
131+
if (strnicmp(arg, Argv[CurrentPos], len) == 0) {
132132
return Argv[CurrentPos];
133133
}
134134
}
@@ -201,7 +201,7 @@ int ArgvClass::Init(char *lpCmdLine, const char *fileprefix)
201201
bool was_file = false;
202202

203203
// See if we are to load a file with parameters in it.
204-
if (fp_cmp_len && !strncmp(fileprefix, ptr, fp_cmp_len)) {
204+
if (fp_cmp_len && strncmp(fileprefix, ptr, fp_cmp_len) == 0) {
205205
ptr += fp_cmp_len;
206206
if (*ptr) {
207207
was_file = Load_File(ptr);

Core/Libraries/Source/WWVegas/WWLib/cpudetect.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1113,7 +1113,7 @@ void CPUDetectClass::Init_Compact_Log()
11131113
Get_OS_Info(os_info,OSVersionPlatformId,OSVersionNumberMajor,OSVersionNumberMinor,OSVersionBuildNumber);
11141114
COMPACTLOG(("%s\t",os_info.Code));
11151115

1116-
if (!stricmp(os_info.SubCode,"UNKNOWN")) {
1116+
if (stricmp(os_info.SubCode,"UNKNOWN") == 0) {
11171117
COMPACTLOG(("%d\t",OSVersionBuildNumber&0xffff));
11181118
}
11191119
else {

0 commit comments

Comments
 (0)