From b1197eef49bfb3dd6f91d928d2115d67817d1d5d Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Mon, 10 Sep 2018 09:11:57 +0100 Subject: [PATCH] Code cleanups. --- Conf.cpp | 19 +++++++++---------- DAPNETGateway.cpp | 2 +- DAPNETNetwork.cpp | 7 ++++--- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Conf.cpp b/Conf.cpp index 563da5f..1ea9f82 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -92,9 +92,9 @@ bool CConf::read() char* value = ::strtok(NULL, "\r\n"); if (section == SECTION_GENERAL) { if (::strcmp(key, "Callsign") == 0) { - for (int i=0; value[i]; i++) { - if (!isspace(value[i])) - m_callsign.insert(m_callsign.end(),1, value[i]); + for (unsigned int i = 0U; value[i] != '\0'; i++) { + if (!::isspace(value[i])) + m_callsign.insert(m_callsign.end(), 1, value[i]); } } else if (::strcmp(key, "WhiteList") == 0) { @@ -130,9 +130,9 @@ bool CConf::read() else if (::strcmp(key, "Port") == 0) m_dapnetPort = (unsigned int)::atoi(value); else if (::strcmp(key, "AuthKey") == 0) { - for (int i=0; value[i]; i++) { - if (!isspace(value[i])) - m_dapnetAuthKey.insert(m_dapnetAuthKey.end(),1, value[i]); + for (unsigned int i = 0U; value[i] != '\0'; i++) { + if (!::isspace(value[i])) + m_dapnetAuthKey.insert(m_dapnetAuthKey.end(), 1, value[i]); } } else if (::strcmp(key, "Debug") == 0) @@ -147,7 +147,7 @@ bool CConf::read() std::string CConf::getCallsign() const { - return m_callsign; + return m_callsign; } std::vector CConf::getWhiteList() const @@ -192,12 +192,12 @@ unsigned int CConf::getLogFileLevel() const std::string CConf::getLogFilePath() const { - return m_logFilePath; + return m_logFilePath; } std::string CConf::getLogFileRoot() const { - return m_logFileRoot; + return m_logFileRoot; } std::string CConf::getDAPNETAddress() const @@ -219,4 +219,3 @@ bool CConf::getDAPNETDebug() const { return m_dapnetDebug; } - diff --git a/DAPNETGateway.cpp b/DAPNETGateway.cpp index 0f89e18..a55a5a8 100644 --- a/DAPNETGateway.cpp +++ b/DAPNETGateway.cpp @@ -189,7 +189,7 @@ int CDAPNETGateway::run() #if !defined(_WIN32) && !defined(_WIN64) // In daemon mode there must be no output as STDOUT will be closed if (m_daemon) - displayLevel = 0; + displayLevel = 0U; #endif ret = ::LogInitialise(m_conf.getLogFilePath(), m_conf.getLogFileRoot(), m_conf.getLogFileLevel(), displayLevel); diff --git a/DAPNETNetwork.cpp b/DAPNETNetwork.cpp index 21079c0..ee54dc1 100644 --- a/DAPNETNetwork.cpp +++ b/DAPNETNetwork.cpp @@ -21,6 +21,8 @@ #include "Utils.h" #include "Log.h" +#include + #include #include #include @@ -58,10 +60,9 @@ bool CDAPNETNetwork::login() { LogMessage("Logging into DAPNET"); + std::transform(m_callsign.begin(), m_callsign.end(), m_callsign.begin(), ::tolower); + char login[200U]; - for(unsigned int i = 0; i < m_callsign.length(); ++i) { - m_callsign[i] = tolower(m_callsign[i]); - } ::snprintf(login, 200, "[MMDVM v%s %s %s]\r\n", m_version, m_callsign.c_str(), m_authKey.c_str()); return write((unsigned char*)login);