From 2c509e87b10babb607eff23a8e603d67b24151b0 Mon Sep 17 00:00:00 2001 From: Tom Early Date: Fri, 20 May 2022 08:56:18 -0700 Subject: [PATCH] remove some calls to strcmp() --- QnetDVRPTR.cpp | 4 ++-- QnetGateway.cpp | 2 +- QnetLink.cpp | 12 ++++++------ ircddb/IRCDDBApp.cpp | 3 +-- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/QnetDVRPTR.cpp b/QnetDVRPTR.cpp index 35a81d1..b9ab5f2 100644 --- a/QnetDVRPTR.cpp +++ b/QnetDVRPTR.cpp @@ -40,7 +40,7 @@ #include "DStarDecode.h" #include "QnetDVRPTR.h" -#define DVRPTR_VERSION "QnetDVRPTR-20307" +#define DVRPTR_VERSION "QnetDVRPTR-20520" #define BAUD B115200 #define IP_SIZE 15 @@ -1949,7 +1949,7 @@ bool CQnetDVRPTR::check_serial() char temp_dvrptr_serial[16]; sprintf(temp_dvrptr_serial, "%02X.%02X.%02X.%02X", puffer[4], puffer[5], puffer[6], puffer[7]); printf("Device %s has serial=[%s]\n", dvrptr_device, temp_dvrptr_serial); - if (strcmp(temp_dvrptr_serial, DVRPTR_SERIAL.c_str()) == 0) + if (0 == DVRPTR_SERIAL.compare(temp_dvrptr_serial)) { printf("Device %s serial number matches DVRPTR_SERIAL in dvrptr.cfg\n", dvrptr_device); match = true; diff --git a/QnetGateway.cpp b/QnetGateway.cpp index 1808776..e0552a9 100644 --- a/QnetGateway.cpp +++ b/QnetGateway.cpp @@ -50,7 +50,7 @@ #include "QnetGateway.h" #include "Utilities.h" -const std::string GW_VERSION("QnetGateway-20320"); +const std::string GW_VERSION("QnetGateway-20520"); int CQnetGateway::FindIndex(const int i) const { diff --git a/QnetLink.cpp b/QnetLink.cpp index cd8be4a..22c133c 100644 --- a/QnetLink.cpp +++ b/QnetLink.cpp @@ -54,7 +54,7 @@ #include "QnetLink.h" #include "Utilities.h" -#define LINK_VERSION "QnetLink-607" +#define LINK_VERSION "QnetLink-20520" CQnetLink::CQnetLink() { @@ -1308,7 +1308,7 @@ void CQnetLink::ProcessXRF(unsigned char *buf, const int length) // delete the user if exists for (auto dt_lh_pos = dt_lh_list.begin(); dt_lh_pos != dt_lh_list.end(); dt_lh_pos++) { - if (0 == strcmp((char *)dt_lh_pos->second.c_str(), tmp1)) + if (0 == dt_lh_pos->second.compare(tmp1)) { dt_lh_list.erase(dt_lh_pos); break; @@ -1651,7 +1651,7 @@ void CQnetLink::ProcessDCS(unsigned char *dcs_buf, const int length) // delete the user if exists for (auto dt_lh_pos=dt_lh_list.begin(); dt_lh_pos!=dt_lh_list.end(); dt_lh_pos++) { - if (strcmp(dt_lh_pos->second.c_str(), tmp1) == 0) + if (dt_lh_pos->second.compare(tmp1) == 0) { dt_lh_list.erase(dt_lh_pos); break; @@ -2552,7 +2552,7 @@ void CQnetLink::ProcessREF(unsigned char *buf, const int length) // delete the user if exists for (auto dt_lh_pos = dt_lh_list.begin(); dt_lh_pos != dt_lh_list.end(); dt_lh_pos++) { - if (strcmp((char *)dt_lh_pos->second.c_str(), tmp1) == 0) + if (dt_lh_pos->second.compare(tmp1) == 0) { dt_lh_list.erase(dt_lh_pos); break; @@ -2893,7 +2893,7 @@ void CQnetLink::Process() // delete the user if exists for (auto dt_lh_pos=dt_lh_list.begin(); dt_lh_pos!=dt_lh_list.end(); dt_lh_pos++) { - if (strcmp(dt_lh_pos->second.c_str(), tmp1) == 0) + if (dt_lh_pos->second.compare(tmp1) == 0) { dt_lh_list.erase(dt_lh_pos); break; @@ -3357,7 +3357,7 @@ void CQnetLink::Process() char tmp2[36]; for (auto dt_lh_pos = dt_lh_list.begin(); dt_lh_pos != dt_lh_list.end(); dt_lh_pos++) { - if (strcmp((char *)dt_lh_pos->second.c_str(), tmp1) == 0) + if (dt_lh_pos->second.compare(tmp1) == 0) { strcpy(tmp2, (char *)dt_lh_pos->first.c_str()); p_tmp2 = strstr(tmp2, "=l"); diff --git a/ircddb/IRCDDBApp.cpp b/ircddb/IRCDDBApp.cpp index 2aa2633..3bfd198 100644 --- a/ircddb/IRCDDBApp.cpp +++ b/ircddb/IRCDDBApp.cpp @@ -547,8 +547,7 @@ std::string IRCDDBApp::getTableIDString(int tableID, bool spaceBeforeNumber) void IRCDDBApp::msgQuery(IRCMessage *m) { - - if (0 == strcmp(m->getPrefixNick().substr(0,2).c_str(), "s-") && (m->numParams >= 2)) // server msg + if (0==m->getPrefixNick().compare(0, 2, "s-") && m->numParams>1) // server msg { std::string msg = m->params[1]; std::vector tkz = stringTokenizer(msg);