From 3b365f4ce0300347fb036bdb440b30d12ac21d38 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Sun, 24 Mar 2019 12:19:05 +0000 Subject: [PATCH] Fix a type and some type mismatches. --- DMRNetwork.cpp | 2 +- DStarNetwork.cpp | 2 +- Modem.cpp | 8 ++++---- RemoteControl.cpp | 8 +++++--- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/DMRNetwork.cpp b/DMRNetwork.cpp index 7a62702..64057f8 100644 --- a/DMRNetwork.cpp +++ b/DMRNetwork.cpp @@ -659,7 +659,7 @@ bool CDMRNetwork::writeInterrupt(unsigned int slotNo) ::sprintf((char*)buffer + 11U, ":%u", slotNo); - return write(buffer, ::strlen((char*)buffer)); + return write(buffer, 13U); } bool CDMRNetwork::wantsBeacon() diff --git a/DStarNetwork.cpp b/DStarNetwork.cpp index de0af69..9174e59 100644 --- a/DStarNetwork.cpp +++ b/DStarNetwork.cpp @@ -159,7 +159,7 @@ bool CDStarNetwork::writePoll(const char* text) buffer[4] = 0x0A; // Poll with text - unsigned int length = ::strlen(text); + unsigned int length = (unsigned int)::strlen(text); // Include the nul at the end also ::memcpy(buffer + 5U, text, length + 1U); diff --git a/Modem.cpp b/Modem.cpp index 7fe5ae1..37367e6 100644 --- a/Modem.cpp +++ b/Modem.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011-2018 by Jonathan Naylor G4KLX + * Copyright (C) 2011-2019 by Jonathan Naylor G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1274,7 +1274,7 @@ bool CModem::writePOCSAGInfo(unsigned int ric, const std::string& message) { assert(m_serial != NULL); - size_t length = message.size(); + unsigned int length = (unsigned int)message.size(); unsigned char buffer[250U]; @@ -1297,7 +1297,7 @@ bool CModem::writeIPInfo(const std::string& address) { assert(m_serial != NULL); - size_t length = address.size(); + unsigned int length = (unsigned int)address.size(); unsigned char buffer[25U]; @@ -1722,7 +1722,7 @@ bool CModem::sendCWId(const std::string& callsign) { assert(m_serial != NULL); - unsigned int length = callsign.length(); + unsigned int length = (unsigned int)callsign.length(); if (length > 200U) length = 200U; diff --git a/RemoteControl.cpp b/RemoteControl.cpp index 5a47b74..d25b03e 100644 --- a/RemoteControl.cpp +++ b/RemoteControl.cpp @@ -90,7 +90,7 @@ REMOTE_COMMAND CRemoteControl::getCommand() } else if (m_args.at(0U) == "page" && m_args.size() >= PAGE_ARGS) { // Page command is in the form of "page " m_command = RCD_PAGE; - } else if (m_args.at(0U) == "dmr" && m_args.size() >= DMR_ARGS) { + } else if (m_args.at(0U) == "dmr" && m_args.size() >= DMR_INTERRUPT_ARGS) { // DMR commands are in the form of "dmr interrupt <0|1|2>" if (m_args.at(1U) == "interupt") m_command = RCD_DMR_INTERRUPT; @@ -109,6 +109,8 @@ REMOTE_COMMAND CRemoteControl::getCommand() unsigned int CRemoteControl::getArgCount() const { + unsigned int argsSize = (unsigned int)m_args.size(); + switch (m_command) { case RCD_MODE_IDLE: case RCD_MODE_LOCKOUT: @@ -117,10 +119,10 @@ unsigned int CRemoteControl::getArgCount() const case RCD_MODE_YSF: case RCD_MODE_P25: case RCD_MODE_NXDN: - return m_args.size() - SET_MODE_ARGS; + return argsSize - SET_MODE_ARGS; case RCD_PAGE: case RCD_DMR_INTERRUPT: - return m_args.size() - 1U; + return argsSize - 1U; default: return 0U; }