From 727a3eb155794afe3870523c90dcbb137e2e2f15 Mon Sep 17 00:00:00 2001 From: Bryan Biedenkapp Date: Sat, 15 Oct 2022 16:35:06 -0400 Subject: [PATCH] convert more behaviors from C-like to C++11 (replace NULL with nullptr mostly); make some pointer safe changes to DMR; --- Defines.h | 2 +- HostMain.cpp | 10 +-- Log.cpp | 40 ++++----- Log.h | 2 +- RingBuffer.h | 4 +- Thread.cpp | 4 +- Utils.cpp | 26 +++--- dmr/Control.cpp | 24 ++--- dmr/Slot.cpp | 96 +++++++++----------- dmr/Slot.h | 12 +-- dmr/SlotType.cpp | 4 +- dmr/Sync.cpp | 4 +- dmr/data/Data.cpp | 8 +- dmr/data/DataHeader.cpp | 6 +- dmr/data/EMB.cpp | 4 +- dmr/data/EmbeddedData.cpp | 18 ++-- dmr/data/EmbeddedData.h | 2 +- dmr/edac/Trellis.cpp | 8 +- dmr/lc/CSBK.cpp | 4 +- dmr/lc/FullLC.cpp | 22 ++--- dmr/lc/FullLC.h | 4 +- dmr/lc/LC.cpp | 8 +- dmr/lc/PrivacyLC.cpp | 14 +-- dmr/lc/ShortLC.cpp | 20 ++--- dmr/packet/ControlSignaling.cpp | 6 +- dmr/packet/Data.cpp | 14 +-- dmr/packet/Voice.cpp | 72 +++++++-------- edac/AMBEFEC.cpp | 12 +-- edac/BCH.cpp | 2 +- edac/BPTC19696.cpp | 12 +-- edac/CRC.cpp | 36 ++++---- edac/Golay2087.cpp | 4 +- edac/Golay24128.cpp | 2 +- edac/Hamming.cpp | 24 ++--- edac/QR1676.cpp | 4 +- edac/RS129.cpp | 6 +- edac/RS634717.cpp | 8 +- edac/SHA256.cpp | 20 ++--- host/Host.cpp | 154 ++++++++++++++------------------ lookups/RSSIInterpolator.cpp | 4 +- modem/Modem.cpp | 46 +++++----- modem/port/UARTPort.cpp | 10 +-- modem/port/UDPPort.cpp | 4 +- network/BaseNetwork.cpp | 34 +++---- network/RemoteControl.cpp | 110 +++++++++++------------ network/UDPSocket.cpp | 4 +- p25/Control.h | 4 +- p25/data/DataBlock.cpp | 18 ++-- p25/data/DataHeader.cpp | 4 +- p25/data/LowSpeedData.cpp | 4 +- p25/dfsi/LC.cpp | 8 +- p25/dfsi/packet/DFSITrunk.cpp | 12 +-- p25/dfsi/packet/DFSIVoice.cpp | 12 +-- p25/edac/Trellis.cpp | 16 ++-- p25/lc/AMBT.cpp | 10 +-- p25/lc/LC.cpp | 26 +++--- p25/lc/TDULC.cpp | 4 +- p25/lc/TSBK.cpp | 14 +-- p25/lc/tsbk/TSBKFactory.cpp | 34 +++---- p25/packet/Data.cpp | 20 ++--- p25/packet/Trunk.cpp | 32 +++---- p25/packet/Voice.cpp | 16 ++-- remote/RemoteCommand.cpp | 8 +- 63 files changed, 571 insertions(+), 605 deletions(-) diff --git a/Defines.h b/Defines.h index 9b2da5cc..27a8ea96 100644 --- a/Defines.h +++ b/Defines.h @@ -228,7 +228,7 @@ inline std::string __IP_FROM_ULONG(const ulong64_t& value) { (buffer[offset + 1U] << 8) | \ (buffer[offset + 2U] << 0); -#define new_unique(type) std::unique_ptr(new type()) +#define new_unique(type, ...) std::unique_ptr(new type(__VA_ARGS__)) /// Creates a named unique buffer. #define __UNIQUE_BUFFER(name, type, length) \ diff --git a/HostMain.cpp b/HostMain.cpp index d624bdce..2574c5b0 100644 --- a/HostMain.cpp +++ b/HostMain.cpp @@ -99,7 +99,7 @@ bool g_fireDMRBeacon = false; bool g_fireP25Control = false; bool g_fireNXDNControl = false; -uint8_t* g_gitHashBytes = NULL; +uint8_t* g_gitHashBytes = nullptr; // --------------------------------------------------------------------------- // Global Functions @@ -134,7 +134,7 @@ void usage(const char* message, const char* arg) ::fprintf(stdout, __PROG_NAME__ " %s (" DESCR_DMR DESCR_P25 DESCR_NXDN "CW Id, Network) (built %s)\n", __VER__, __BUILD__); ::fprintf(stdout, "Copyright (c) 2017-2022 Bryan Biedenkapp, N2PLL and DVMProject (https://github.com/dvmproject) Authors.\n"); ::fprintf(stdout, "Portions Copyright (c) 2015-2021 by Jonathan Naylor, G4KLX and others\n\n"); - if (message != NULL) { + if (message != nullptr) { ::fprintf(stderr, "%s: ", g_progExe.c_str()); ::fprintf(stderr, message, arg); ::fprintf(stderr, "\n\n"); @@ -163,7 +163,7 @@ int checkArgs(int argc, char* argv[]) // iterate through arguments for (i = 1; i <= argc; i++) { - if (argv[i] == NULL) { + if (argv[i] == nullptr) { break; } @@ -224,7 +224,7 @@ int checkArgs(int argc, char* argv[]) exit(EXIT_SUCCESS); } else if (IS("-h")) { - usage(NULL, NULL); + usage(nullptr, nullptr); if (argc == 2) exit(EXIT_SUCCESS); } @@ -252,7 +252,7 @@ int main(int argc, char** argv) uint32_t hash = ::strtoul(__GIT_VER_HASH__, 0, 16); __SET_UINT32(hash, g_gitHashBytes, 0U); - if (argv[0] != NULL && *argv[0] != 0) + if (argv[0] != nullptr && *argv[0] != 0) g_progExe = std::string(argv[0]); if (argc > 1) { diff --git a/Log.cpp b/Log.cpp index 5874ef3e..8e7e147d 100644 --- a/Log.cpp +++ b/Log.cpp @@ -70,8 +70,8 @@ static std::string m_actFileRoot; static network::Network* m_network; -static FILE* m_fpLog = NULL; -static FILE* m_actFpLog = NULL; +static FILE* m_fpLog = nullptr; +static FILE* m_actFpLog = nullptr; static uint32_t m_displayLevel = 2U; static bool m_disableTimeDisplay = false; @@ -100,11 +100,11 @@ static bool LogOpen() struct tm* tm = ::gmtime(&now); if (tm->tm_mday == m_tm.tm_mday && tm->tm_mon == m_tm.tm_mon && tm->tm_year == m_tm.tm_year) { - if (m_fpLog != NULL) + if (m_fpLog != nullptr) return true; } else { - if (m_fpLog != NULL) + if (m_fpLog != nullptr) ::fclose(m_fpLog); } @@ -117,7 +117,7 @@ static bool LogOpen() m_fpLog = ::fopen(filename, "a+t"); m_tm = *tm; - return m_fpLog != NULL; + return m_fpLog != nullptr; } /// @@ -132,11 +132,11 @@ static bool ActivityLogOpen() struct tm* tm = ::gmtime(&now); if (tm->tm_mday == m_actTm.tm_mday && tm->tm_mon == m_actTm.tm_mon && tm->tm_year == m_actTm.tm_year) { - if (m_actFpLog != NULL) + if (m_actFpLog != nullptr) return true; } else { - if (m_actFpLog != NULL) + if (m_actFpLog != nullptr) ::fclose(m_actFpLog); } @@ -149,7 +149,7 @@ static bool ActivityLogOpen() m_actFpLog = ::fopen(filename, "a+t"); m_actTm = *tm; - return m_actFpLog != NULL; + return m_actFpLog != nullptr; } /// @@ -172,7 +172,7 @@ bool ActivityLogInitialise(const std::string& filePath, const std::string& fileR { m_actFilePath = filePath; m_actFileRoot = fileRoot; - m_network = NULL; + m_network = nullptr; return ::ActivityLogOpen(); } @@ -182,7 +182,7 @@ bool ActivityLogInitialise(const std::string& filePath, const std::string& fileR /// void ActivityLogFinalise() { - if (m_actFpLog != NULL) + if (m_actFpLog != nullptr) ::fclose(m_actFpLog); } @@ -194,8 +194,8 @@ void ActivityLogFinalise() /// Formatted string to write to activity log. void ActivityLog(const char *mode, const bool sourceRf, const char* msg, ...) { - assert(mode != NULL); - assert(msg != NULL); + assert(mode != nullptr); + assert(msg != nullptr); char buffer[ACT_LOG_BUFFER_LEN]; #if defined(_WIN32) || defined(_WIN64) @@ -226,7 +226,7 @@ void ActivityLog(const char *mode, const bool sourceRf, const char* msg, ...) ::fprintf(m_actFpLog, "%s\n", buffer); ::fflush(m_actFpLog); - if (m_network != NULL) { + if (m_network != nullptr) { m_network->writeActLog(buffer); } @@ -268,7 +268,7 @@ bool LogInitialise(const std::string& filePath, const std::string& fileRoot, uin /// void LogFinalise() { - if (m_fpLog != NULL) + if (m_fpLog != nullptr) ::fclose(m_fpLog); } @@ -280,7 +280,7 @@ void LogFinalise() /// Formatted string to write to activity log. void Log(uint32_t level, const char *module, const char* fmt, ...) { - assert(fmt != NULL); + assert(fmt != nullptr); char buffer[LOG_BUFFER_LEN]; #if defined(_WIN32) || defined(_WIN64) @@ -288,7 +288,7 @@ void Log(uint32_t level, const char *module, const char* fmt, ...) SYSTEMTIME st; ::GetSystemTime(&st); - if (module != NULL) { + if (module != nullptr) { ::sprintf(buffer, "%c: %04u-%02u-%02u %02u:%02u:%02u.%03u (%s) ", LEVELS[level], st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond, st.wMilliseconds, module); } else { @@ -296,7 +296,7 @@ void Log(uint32_t level, const char *module, const char* fmt, ...) } } else { - if (module != NULL) { + if (module != nullptr) { ::sprintf(buffer, "%c: (%s) ", LEVELS[level], module); } else { @@ -310,7 +310,7 @@ void Log(uint32_t level, const char *module, const char* fmt, ...) struct tm* tm = ::gmtime(&now.tv_sec); - if (module != NULL) { + if (module != nullptr) { ::sprintf(buffer, "%c: %04d-%02d-%02d %02d:%02d:%02d.%03lu (%s) ", LEVELS[level], tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, now.tv_usec / 1000U, module); } else { @@ -318,7 +318,7 @@ void Log(uint32_t level, const char *module, const char* fmt, ...) } } else { - if (module != NULL) { + if (module != nullptr) { ::sprintf(buffer, "%c: (%s) ", LEVELS[level], module); } else { @@ -334,7 +334,7 @@ void Log(uint32_t level, const char *module, const char* fmt, ...) va_end(vl); - if (m_network != NULL) { + if (m_network != nullptr) { // don't transfer debug data... if (level > 1U) { m_network->writeDiagLog(buffer); diff --git a/Log.h b/Log.h index b8eaadd7..26b8fbcc 100644 --- a/Log.h +++ b/Log.h @@ -56,7 +56,7 @@ #define LogDebug(_module, fmt, ...) Log(1U, _module, fmt, ##__VA_ARGS__) #define LogMessage(_module, fmt, ...) Log(2U, _module, fmt, ##__VA_ARGS__) -#define LogInfo(fmt, ...) Log(3U, NULL, fmt, ##__VA_ARGS__) +#define LogInfo(fmt, ...) Log(3U, nullptr, fmt, ##__VA_ARGS__) #define LogInfoEx(_module, fmt, ...) Log(3U, _module, fmt, ##__VA_ARGS__) #define LogWarning(_module, fmt, ...) Log(4U, _module, fmt, ##__VA_ARGS__) #define LogError(_module, fmt, ...) Log(5U, _module, fmt, ##__VA_ARGS__) diff --git a/RingBuffer.h b/RingBuffer.h index 499af455..8c2f9956 100644 --- a/RingBuffer.h +++ b/RingBuffer.h @@ -51,12 +51,12 @@ public: RingBuffer(uint32_t length, const char* name) : m_length(length), m_name(name), - m_buffer(NULL), + m_buffer(nullptr), m_iPtr(0U), m_oPtr(0U) { assert(length > 0U); - assert(name != NULL); + assert(name != nullptr); m_buffer = new T[length]; diff --git a/Thread.cpp b/Thread.cpp index 64509dff..cc0f375b 100644 --- a/Thread.cpp +++ b/Thread.cpp @@ -63,7 +63,7 @@ bool Thread::run() { m_handle = ::CreateThread(NULL, 0, &helper, this, 0, NULL); - return m_handle != NULL; + return m_handle != nullptr; } /// @@ -159,6 +159,6 @@ void* Thread::helper(void* arg) p->entry(); - return NULL; + return nullptr; } #endif diff --git a/Utils.cpp b/Utils.cpp index 8ff753ac..0a4bfc13 100644 --- a/Utils.cpp +++ b/Utils.cpp @@ -66,7 +66,7 @@ void getHostVersion() /// void Utils::dump(const std::string& title, const uint8_t* data, uint32_t length) { - assert(data != NULL); + assert(data != nullptr); dump(2U, title, data, length); } @@ -80,7 +80,7 @@ void Utils::dump(const std::string& title, const uint8_t* data, uint32_t length) /// void Utils::dump(int level, const std::string& title, const uint8_t* data, uint32_t length) { - assert(data != NULL); + assert(data != nullptr); ::Log(level, "DUMP", "%s (len %u)", title.c_str(), length); @@ -132,7 +132,7 @@ void Utils::dump(int level, const std::string& title, const uint8_t* data, uint3 /// void Utils::dump(const std::string& title, const bool* bits, uint32_t length) { - assert(bits != NULL); + assert(bits != nullptr); dump(2U, title, bits, length); } @@ -146,7 +146,7 @@ void Utils::dump(const std::string& title, const bool* bits, uint32_t length) /// void Utils::dump(int level, const std::string& title, const bool* bits, uint32_t length) { - assert(bits != NULL); + assert(bits != nullptr); uint8_t bytes[100U]; uint32_t nBytes = 0U; @@ -164,7 +164,7 @@ void Utils::dump(int level, const std::string& title, const bool* bits, uint32_t /// void Utils::symbols(const std::string& title, const uint8_t* data, uint32_t length) { - assert(data != NULL); + assert(data != nullptr); ::Log(2U, "SYMBOLS", "%s (len %u)", title.c_str(), length); @@ -230,7 +230,7 @@ void Utils::symbols(const std::string& title, const uint8_t* data, uint32_t leng /// void Utils::byteToBitsBE(uint8_t byte, bool* bits) { - assert(bits != NULL); + assert(bits != nullptr); bits[0U] = (byte & 0x80U) == 0x80U; bits[1U] = (byte & 0x40U) == 0x40U; @@ -249,7 +249,7 @@ void Utils::byteToBitsBE(uint8_t byte, bool* bits) /// void Utils::byteToBitsLE(uint8_t byte, bool* bits) { - assert(bits != NULL); + assert(bits != nullptr); bits[0U] = (byte & 0x01U) == 0x01U; bits[1U] = (byte & 0x02U) == 0x02U; @@ -268,7 +268,7 @@ void Utils::byteToBitsLE(uint8_t byte, bool* bits) /// void Utils::bitsToByteBE(const bool* bits, uint8_t& byte) { - assert(bits != NULL); + assert(bits != nullptr); byte = bits[0U] ? 0x80U : 0x00U; byte |= bits[1U] ? 0x40U : 0x00U; @@ -287,7 +287,7 @@ void Utils::bitsToByteBE(const bool* bits, uint8_t& byte) /// void Utils::bitsToByteLE(const bool* bits, uint8_t& byte) { - assert(bits != NULL); + assert(bits != nullptr); byte = bits[0U] ? 0x01U : 0x00U; byte |= bits[1U] ? 0x02U : 0x00U; @@ -308,8 +308,8 @@ void Utils::bitsToByteLE(const bool* bits, uint8_t& byte) /// uint32_t Utils::getBits(const uint8_t* in, uint8_t* out, uint32_t start, uint32_t stop) { - assert(in != NULL); - assert(out != NULL); + assert(in != nullptr); + assert(out != nullptr); uint32_t n = 0U; for (uint32_t i = start; i < stop; i++, n++) { @@ -341,8 +341,8 @@ uint32_t Utils::getBitRange(const uint8_t* in, uint8_t* out, uint32_t start, uin /// uint32_t Utils::setBits(const uint8_t* in, uint8_t* out, uint32_t start, uint32_t stop) { - assert(in != NULL); - assert(out != NULL); + assert(in != nullptr); + assert(out != nullptr); uint32_t n = 0U; for (uint32_t i = start; i < stop; i++, n++) { diff --git a/dmr/Control.cpp b/dmr/Control.cpp index 79d68711..2197ac6b 100644 --- a/dmr/Control.cpp +++ b/dmr/Control.cpp @@ -69,8 +69,8 @@ Control::Control(uint32_t colorCode, uint32_t callHang, uint32_t queueSize, bool m_colorCode(colorCode), m_modem(modem), m_network(network), - m_slot1(NULL), - m_slot2(NULL), + m_slot1(nullptr), + m_slot2(nullptr), m_idenTable(idenTable), m_ridLookup(ridLookup), m_tidLookup(tidLookup), @@ -81,11 +81,11 @@ Control::Control(uint32_t colorCode, uint32_t callHang, uint32_t queueSize, bool m_verbose(verbose), m_debug(debug) { - assert(modem != NULL); - assert(ridLookup != NULL); - assert(tidLookup != NULL); - assert(idenTable != NULL); - assert(rssiMapper != NULL); + assert(modem != nullptr); + assert(ridLookup != nullptr); + assert(tidLookup != nullptr); + assert(idenTable != nullptr); + assert(rssiMapper != nullptr); acl::AccessControl::init(m_ridLookup, m_tidLookup); Slot::init(this, colorCode, SiteData(), embeddedLCOnly, dumpTAData, callHang, modem, network, duplex, m_ridLookup, m_tidLookup, m_idenTable, rssiMapper, jitter, verbose); @@ -221,7 +221,7 @@ void Control::setCCHalted(bool ccHalted) /// True, if wakeup frames were processed, otherwise false. bool Control::processWakeup(const uint8_t* data) { - assert(data != NULL); + assert(data != nullptr); // wakeups always come in on slot 1 if (data[0U] != modem::TAG_DATA || data[1U] != (DMR_IDLE_RX | DMR_SYNC_DATA | DT_CSBK)) @@ -262,7 +262,7 @@ bool Control::processWakeup(const uint8_t* data) /// True, if data frame was processed, otherwise false. bool Control::processFrame(uint32_t slotNo, uint8_t *data, uint32_t len) { - assert(data != NULL); + assert(data != nullptr); switch (slotNo) { case 1U: @@ -282,7 +282,7 @@ bool Control::processFrame(uint32_t slotNo, uint8_t *data, uint32_t len) /// Length of data retrieved from DMR ring buffer. uint32_t Control::getFrame(uint32_t slotNo, uint8_t* data) { - assert(data != NULL); + assert(data != nullptr); switch (slotNo) { case 1U: @@ -300,7 +300,7 @@ uint32_t Control::getFrame(uint32_t slotNo, uint8_t* data) /// void Control::clock() { - if (m_network != NULL) { + if (m_network != nullptr) { data::Data data; bool ret = m_network->readDMR(data); if (ret) { @@ -338,7 +338,7 @@ Slot* Control::getTSCCSlot() const break; default: LogError(LOG_NET, "DMR, invalid slot, TSCC disabled, slotNo = %u", m_tsccSlotNo); - return NULL; + return nullptr; } } diff --git a/dmr/Slot.cpp b/dmr/Slot.cpp index 57078c97..ce87e4c1 100644 --- a/dmr/Slot.cpp +++ b/dmr/Slot.cpp @@ -54,7 +54,7 @@ const uint16_t TSCC_MAX_CNT = 511U; // Static Class Members // --------------------------------------------------------------------------- -Control* Slot::m_dmr = NULL; +Control* Slot::m_dmr = nullptr; uint32_t Slot::m_colorCode = 0U; @@ -64,26 +64,26 @@ uint32_t Slot::m_channelNo = 0U; bool Slot::m_embeddedLCOnly = false; bool Slot::m_dumpTAData = true; -modem::Modem* Slot::m_modem = NULL; -network::BaseNetwork* Slot::m_network = NULL; +modem::Modem* Slot::m_modem = nullptr; +network::BaseNetwork* Slot::m_network = nullptr; bool Slot::m_duplex = true; -lookups::IdenTableLookup* Slot::m_idenTable = NULL; -lookups::RadioIdLookup* Slot::m_ridLookup = NULL; -lookups::TalkgroupIdLookup* Slot::m_tidLookup = NULL; -lookups::AffiliationLookup *Slot::m_affiliations = NULL; +lookups::IdenTableLookup* Slot::m_idenTable = nullptr; +lookups::RadioIdLookup* Slot::m_ridLookup = nullptr; +lookups::TalkgroupIdLookup* Slot::m_tidLookup = nullptr; +lookups::AffiliationLookup *Slot::m_affiliations = nullptr; lookups::IdenTable Slot::m_idenEntry = lookups::IdenTable(); uint32_t Slot::m_hangCount = 3U * 17U; -lookups::RSSIInterpolator* Slot::m_rssiMapper = NULL; +lookups::RSSIInterpolator* Slot::m_rssiMapper = nullptr; uint32_t Slot::m_jitterTime = 360U; uint32_t Slot::m_jitterSlots = 6U; -uint8_t* Slot::m_idle = NULL; +uint8_t* Slot::m_idle = nullptr; uint8_t Slot::m_flco1; uint8_t Slot::m_id1 = 0U; @@ -123,13 +123,13 @@ Slot::Slot(uint32_t slotNo, uint32_t timeout, uint32_t tgHang, uint32_t queueSiz m_rfLastDstId(0U), m_netState(RS_NET_IDLE), m_netLastDstId(0U), - m_rfLC(NULL), - m_rfPrivacyLC(NULL), - m_rfDataHeader(NULL), + m_rfLC(nullptr), + m_rfPrivacyLC(nullptr), + m_rfDataHeader(nullptr), m_rfSeqNo(0U), - m_netLC(NULL), - m_netPrivacyLC(NULL), - m_netDataHeader(NULL), + m_netLC(nullptr), + m_netPrivacyLC(nullptr), + m_netDataHeader(nullptr), m_networkWatchdog(1000U, 0U, 1500U), m_rfTimeoutTimer(1000U, timeout), m_rfTGHang(1000U, tgHang), @@ -188,7 +188,7 @@ Slot::~Slot() /// bool Slot::processFrame(uint8_t *data, uint32_t len) { - assert(data != NULL); + assert(data != nullptr); if (data[0U] == modem::TAG_LOST && m_rfState == RS_RF_AUDIO) { if (m_rssi != 0U) { @@ -205,8 +205,8 @@ bool Slot::processFrame(uint8_t *data, uint32_t len) // release trunked grant (if necessary) Slot *m_tscc = m_dmr->getTSCCSlot(); - if (m_tscc != NULL) { - if (m_tscc->m_enableTSCC && m_rfLC != NULL) { + if (m_tscc != nullptr) { + if (m_tscc->m_enableTSCC && m_rfLC != nullptr) { m_tscc->m_affiliations->releaseGrant(m_rfLC->getDstId(), false); } } @@ -334,7 +334,7 @@ bool Slot::processFrame(uint8_t *data, uint32_t len) /// Length of frame data retreived. uint32_t Slot::getFrame(uint8_t* data) { - assert(data != NULL); + assert(data != nullptr); if (m_queue.isEmpty()) return 0U; @@ -403,7 +403,7 @@ void Slot::clock() uint32_t ms = m_interval.elapsed(); m_interval.start(); - if (m_network != NULL) { + if (m_network != nullptr) { if (m_network->getStatus() == network::NET_STAT_RUNNING) { m_siteData.setNetActive(true); } @@ -530,7 +530,7 @@ void Slot::clock() m_netFrames = 0U; m_netLost = 0U; - if (m_network != NULL) + if (m_network != nullptr) m_network->resetDMR(m_slotNo); m_rfState = RS_RF_LISTENING; @@ -602,12 +602,12 @@ void Slot::init(Control* dmr, uint32_t colorCode, SiteData siteData, bool embedd network::BaseNetwork* network, bool duplex, lookups::RadioIdLookup* ridLookup, lookups::TalkgroupIdLookup* tidLookup, lookups::IdenTableLookup* idenTable, lookups::RSSIInterpolator* rssiMapper, uint32_t jitter, bool verbose) { - assert(dmr != NULL); - assert(modem != NULL); - assert(ridLookup != NULL); - assert(tidLookup != NULL); - assert(idenTable != NULL); - assert(rssiMapper != NULL); + assert(dmr != nullptr); + assert(modem != nullptr); + assert(ridLookup != nullptr); + assert(tidLookup != nullptr); + assert(idenTable != nullptr); + assert(rssiMapper != nullptr); m_dmr = dmr; @@ -692,7 +692,7 @@ void Slot::setAlohaConfig(uint8_t nRandWait, uint8_t backOff) /// void Slot::addFrame(const uint8_t *data, bool net) { - assert(data != NULL); + assert(data != nullptr); if (!net) { if (m_netState != RS_NET_IDLE) @@ -730,8 +730,8 @@ void Slot::addFrame(const uint8_t *data, bool net) /// void Slot::writeNetwork(const uint8_t* data, uint8_t dataType, uint8_t errors) { - assert(data != NULL); - assert(m_rfLC != NULL); + assert(data != nullptr); + assert(m_rfLC != nullptr); writeNetwork(data, dataType, m_rfLC->getFLCO(), m_rfLC->getSrcId(), m_rfLC->getDstId(), errors); } @@ -748,12 +748,12 @@ void Slot::writeNetwork(const uint8_t* data, uint8_t dataType, uint8_t errors) void Slot::writeNetwork(const uint8_t* data, uint8_t dataType, uint8_t flco, uint32_t srcId, uint32_t dstId, uint8_t errors) { - assert(data != NULL); + assert(data != nullptr); if (m_netState != RS_NET_IDLE) return; - if (m_network == NULL) + if (m_network == nullptr) return; data::Data dmrData; @@ -814,7 +814,7 @@ void Slot::writeEndRF(bool writeEnd) m_data->m_pduDataOffset = 0U; - if (m_network != NULL) + if (m_network != nullptr) m_network->resetDMR(m_slotNo); m_rfTimeoutTimer.stop(); @@ -824,15 +824,9 @@ void Slot::writeEndRF(bool writeEnd) m_rfErrs = 0U; m_rfBits = 1U; - delete m_rfLC; - if (m_rfPrivacyLC != NULL) - delete m_rfPrivacyLC; - if (m_rfDataHeader != NULL) - delete m_rfDataHeader; - - m_rfLC = NULL; - m_rfPrivacyLC = NULL; - m_rfDataHeader = NULL; + m_rfLC = nullptr; + m_rfPrivacyLC = nullptr; + m_rfDataHeader = nullptr; } /// @@ -876,7 +870,7 @@ void Slot::writeEndNet(bool writeEnd) m_data->m_pduDataOffset = 0U; - if (m_network != NULL) + if (m_network != nullptr) m_network->resetDMR(m_slotNo); m_networkWatchdog.stop(); @@ -890,15 +884,9 @@ void Slot::writeEndNet(bool writeEnd) m_netErrs = 0U; m_netBits = 1U; - delete m_netLC; - if (m_netPrivacyLC != NULL) - delete m_netPrivacyLC; - if (m_netDataHeader != NULL) - delete m_netDataHeader; - - m_netLC = NULL; - m_netPrivacyLC = NULL; - m_netDataHeader = NULL; + m_netLC = nullptr; + m_netPrivacyLC = nullptr; + m_netDataHeader = nullptr; } /// @@ -974,7 +962,7 @@ void Slot::writeRF_ControlData(uint16_t frameCnt, uint8_t n) /// void Slot::setShortLC(uint32_t slotNo, uint32_t id, uint8_t flco, bool voice) { - assert(m_modem != NULL); + assert(m_modem != nullptr); switch (slotNo) { case 1U: @@ -1066,7 +1054,7 @@ void Slot::setShortLC(uint32_t slotNo, uint32_t id, uint8_t flco, bool voice) /// void Slot::setShortLC_TSCC(SiteData siteData, uint16_t counter) { - assert(m_modem != NULL); + assert(m_modem != nullptr); uint8_t lc[5U]; uint32_t lcValue = 0U; diff --git a/dmr/Slot.h b/dmr/Slot.h index cfdbc43d..b2845e38 100644 --- a/dmr/Slot.h +++ b/dmr/Slot.h @@ -134,15 +134,15 @@ namespace dmr RPT_NET_STATE m_netState; uint32_t m_netLastDstId; - lc::LC* m_rfLC; - lc::PrivacyLC* m_rfPrivacyLC; - data::DataHeader* m_rfDataHeader; + std::unique_ptr m_rfLC; + std::unique_ptr m_rfPrivacyLC; + std::unique_ptr m_rfDataHeader; uint8_t m_rfSeqNo; - lc::LC* m_netLC; - lc::PrivacyLC* m_netPrivacyLC; - data::DataHeader* m_netDataHeader; + std::unique_ptr m_netLC; + std::unique_ptr m_netPrivacyLC; + std::unique_ptr m_netDataHeader; Timer m_networkWatchdog; Timer m_rfTimeoutTimer; diff --git a/dmr/SlotType.cpp b/dmr/SlotType.cpp index 2e8fb6ac..5238515a 100644 --- a/dmr/SlotType.cpp +++ b/dmr/SlotType.cpp @@ -64,7 +64,7 @@ SlotType::~SlotType() /// void SlotType::decode(const uint8_t* data) { - assert(data != NULL); + assert(data != nullptr); uint8_t DMRSlotType[3U]; DMRSlotType[0U] = (data[12U] << 2) & 0xFCU; @@ -88,7 +88,7 @@ void SlotType::decode(const uint8_t* data) /// void SlotType::encode(uint8_t* data) const { - assert(data != NULL); + assert(data != nullptr); uint8_t DMRSlotType[3U]; DMRSlotType[0U] = (m_colorCode << 4) & 0xF0U; diff --git a/dmr/Sync.cpp b/dmr/Sync.cpp index ee727c28..a0822f79 100644 --- a/dmr/Sync.cpp +++ b/dmr/Sync.cpp @@ -48,7 +48,7 @@ using namespace dmr; /// Flag indicating whether this is duplex operation. void Sync::addDMRDataSync(uint8_t* data, bool duplex) { - assert(data != NULL); + assert(data != nullptr); if (duplex) { for (uint32_t i = 0U; i < 7U; i++) @@ -67,7 +67,7 @@ void Sync::addDMRDataSync(uint8_t* data, bool duplex) /// Flag indicating whether this is duplex operation. void Sync::addDMRAudioSync(uint8_t* data, bool duplex) { - assert(data != NULL); + assert(data != nullptr); if (duplex) { for (uint32_t i = 0U; i < 7U; i++) diff --git a/dmr/data/Data.cpp b/dmr/data/Data.cpp index ca9fd9d2..dc86dfde 100644 --- a/dmr/data/Data.cpp +++ b/dmr/data/Data.cpp @@ -52,7 +52,7 @@ Data::Data(const Data& data) : m_dataType(data.m_dataType), m_ber(data.m_ber), m_rssi(data.m_rssi), - m_data(NULL) + m_data(nullptr) { m_data = new uint8_t[2U * DMR_FRAME_LENGTH_BYTES]; ::memcpy(m_data, data.m_data, 2U * DMR_FRAME_LENGTH_BYTES); @@ -71,7 +71,7 @@ Data::Data() : m_dataType(0U), m_ber(0U), m_rssi(0U), - m_data(NULL) + m_data(nullptr) { m_data = new uint8_t[2U * DMR_FRAME_LENGTH_BYTES]; } @@ -114,7 +114,7 @@ Data& Data::operator=(const Data& data) /// Data buffer. void Data::setData(const uint8_t* buffer) { - assert(buffer != NULL); + assert(buffer != nullptr); ::memcpy(m_data, buffer, DMR_FRAME_LENGTH_BYTES); } @@ -125,7 +125,7 @@ void Data::setData(const uint8_t* buffer) /// Data buffer. uint32_t Data::getData(uint8_t* buffer) const { - assert(buffer != NULL); + assert(buffer != nullptr); ::memcpy(buffer, m_data, DMR_FRAME_LENGTH_BYTES); diff --git a/dmr/data/DataHeader.cpp b/dmr/data/DataHeader.cpp index c0b1f57f..3218b16f 100644 --- a/dmr/data/DataHeader.cpp +++ b/dmr/data/DataHeader.cpp @@ -75,7 +75,7 @@ DataHeader::DataHeader() : m_rspStatus(0U), m_srcPort(0U), m_dstPort(0U), - m_data(NULL), + m_data(nullptr), m_A(false), m_SF(false), m_PF(false), @@ -135,7 +135,7 @@ DataHeader& DataHeader::operator=(const DataHeader& header) /// True, if DMR data header was decoded, otherwise false. bool DataHeader::decode(const uint8_t* data) { - assert(data != NULL); + assert(data != nullptr); // decode BPTC (196,96) FEC edac::BPTC19696 bptc; @@ -253,7 +253,7 @@ bool DataHeader::decode(const uint8_t* data) /// void DataHeader::encode(uint8_t* data) const { - assert(data != NULL); + assert(data != nullptr); // perform no processing other then regenerating FEC if (m_DPF == DPF_PROPRIETARY) { diff --git a/dmr/data/EMB.cpp b/dmr/data/EMB.cpp index 39ff0741..8d494b55 100644 --- a/dmr/data/EMB.cpp +++ b/dmr/data/EMB.cpp @@ -66,7 +66,7 @@ EMB::~EMB() /// void EMB::decode(const uint8_t* data) { - assert(data != NULL); + assert(data != nullptr); uint8_t DMREMB[2U]; DMREMB[0U] = (data[13U] << 4) & 0xF0U; @@ -88,7 +88,7 @@ void EMB::decode(const uint8_t* data) /// void EMB::encode(uint8_t* data) const { - assert(data != NULL); + assert(data != nullptr); uint8_t DMREMB[2U]; DMREMB[0U] = (m_colorCode << 4) & 0xF0U; diff --git a/dmr/data/EmbeddedData.cpp b/dmr/data/EmbeddedData.cpp index ede72926..8d3164a3 100644 --- a/dmr/data/EmbeddedData.cpp +++ b/dmr/data/EmbeddedData.cpp @@ -51,8 +51,8 @@ EmbeddedData::EmbeddedData() : m_valid(false), m_FLCO(FLCO_GROUP), m_state(LCS_NONE), - m_data(NULL), - m_raw(NULL) + m_data(nullptr), + m_raw(nullptr) { m_raw = new bool[128U]; m_data = new bool[72U]; @@ -75,7 +75,7 @@ EmbeddedData::~EmbeddedData() /// bool EmbeddedData::addData(const uint8_t* data, uint8_t lcss) { - assert(data != NULL); + assert(data != nullptr); bool rawData[40U]; Utils::byteToBitsBE(data[14U], rawData + 0U); @@ -145,7 +145,7 @@ bool EmbeddedData::addData(const uint8_t* data, uint8_t lcss) /// uint8_t EmbeddedData::getData(uint8_t* data, uint8_t n) const { - assert(data != NULL); + assert(data != nullptr); if (n >= 1U && n < 5U) { n--; @@ -201,15 +201,15 @@ void EmbeddedData::setLC(const lc::LC& lc) /// Gets link control data. /// -lc::LC* EmbeddedData::getLC() const +std::unique_ptr EmbeddedData::getLC() const { if (!m_valid) - return NULL; + return nullptr; if (m_FLCO != FLCO_GROUP && m_FLCO != FLCO_PRIVATE) - return NULL; + return nullptr; - return new lc::LC(m_data); + return std::unique_ptr(new lc::LC(m_data)); } /// @@ -219,7 +219,7 @@ lc::LC* EmbeddedData::getLC() const /// bool EmbeddedData::getRawData(uint8_t* data) const { - assert(data != NULL); + assert(data != nullptr); if (!m_valid) return false; diff --git a/dmr/data/EmbeddedData.h b/dmr/data/EmbeddedData.h index ab4d9197..3cbd8cb9 100644 --- a/dmr/data/EmbeddedData.h +++ b/dmr/data/EmbeddedData.h @@ -69,7 +69,7 @@ namespace dmr /// Sets link control data. void setLC(const lc::LC& lc); /// Gets link control data. - lc::LC* getLC() const; + std::unique_ptr getLC() const; /// Get raw embeded data buffer. bool getRawData(uint8_t* data) const; diff --git a/dmr/edac/Trellis.cpp b/dmr/edac/Trellis.cpp index b7d11219..73db6fe4 100644 --- a/dmr/edac/Trellis.cpp +++ b/dmr/edac/Trellis.cpp @@ -78,8 +78,8 @@ Trellis::~Trellis() /// True, if decoded, otherwise false. bool Trellis::decode(const uint8_t* data, uint8_t* payload) { - assert(data != NULL); - assert(payload != NULL); + assert(data != nullptr); + assert(payload != nullptr); int8_t dibits[98U]; deinterleave(data, dibits); @@ -117,8 +117,8 @@ bool Trellis::decode(const uint8_t* data, uint8_t* payload) /// Trellis symbol bytes. void Trellis::encode(const uint8_t* payload, uint8_t* data) { - assert(payload != NULL); - assert(data != NULL); + assert(payload != nullptr); + assert(data != nullptr); uint8_t tribits[49U]; bitsToTribits(payload, tribits); diff --git a/dmr/lc/CSBK.cpp b/dmr/lc/CSBK.cpp index 691ea11b..6eb06c2e 100644 --- a/dmr/lc/CSBK.cpp +++ b/dmr/lc/CSBK.cpp @@ -83,7 +83,7 @@ CSBK::~CSBK() /// True, if DMR CSBK was decoded, otherwise false. bool CSBK::decode(const uint8_t* data) { - assert(data != NULL); + assert(data != nullptr); uint8_t csbk[DMR_CSBK_LENGTH_BYTES]; @@ -202,7 +202,7 @@ bool CSBK::decode(const uint8_t* data) /// void CSBK::encode(uint8_t* data) { - assert(data != NULL); + assert(data != nullptr); uint8_t csbk[DMR_CSBK_LENGTH_BYTES]; ::memset(csbk, 0x00U, DMR_CSBK_LENGTH_BYTES); diff --git a/dmr/lc/FullLC.cpp b/dmr/lc/FullLC.cpp index 5c96d80c..23a09da3 100644 --- a/dmr/lc/FullLC.cpp +++ b/dmr/lc/FullLC.cpp @@ -70,9 +70,9 @@ FullLC::~FullLC() /// /// /// -LC* FullLC::decode(const uint8_t* data, uint8_t type) +std::unique_ptr FullLC::decode(const uint8_t* data, uint8_t type) { - assert(data != NULL); + assert(data != nullptr); // decode BPTC (196,96) FEC uint8_t lcData[DMR_LC_HEADER_LENGTH_BYTES]; @@ -93,14 +93,14 @@ LC* FullLC::decode(const uint8_t* data, uint8_t type) default: LogError(LOG_DMR, "Unsupported LC type, type = %d", int(type)); - return NULL; + return nullptr; } // check RS (12,9) FEC if (!edac::RS129::check(lcData)) - return NULL; + return nullptr; - return new LC(lcData); + return std::unique_ptr(new LC(lcData)); } /// @@ -111,7 +111,7 @@ LC* FullLC::decode(const uint8_t* data, uint8_t type) /// void FullLC::encode(const LC& lc, uint8_t* data, uint8_t type) { - assert(data != NULL); + assert(data != nullptr); uint8_t lcData[DMR_LC_HEADER_LENGTH_BYTES]; lc.getData(lcData); @@ -148,9 +148,9 @@ void FullLC::encode(const LC& lc, uint8_t* data, uint8_t type) /// /// /// -PrivacyLC* FullLC::decodePI(const uint8_t* data) +std::unique_ptr FullLC::decodePI(const uint8_t* data) { - assert(data != NULL); + assert(data != nullptr); // decode BPTC (196,96) FEC uint8_t lcData[DMR_LC_HEADER_LENGTH_BYTES]; @@ -163,14 +163,14 @@ PrivacyLC* FullLC::decodePI(const uint8_t* data) lcData[11U] ^= PI_HEADER_CRC_MASK[1U]; if (!edac::CRC::checkCCITT162(lcData, DMR_LC_HEADER_LENGTH_BYTES)) - return NULL; + return nullptr; // restore the checksum lcData[10U] ^= PI_HEADER_CRC_MASK[0U]; lcData[11U] ^= PI_HEADER_CRC_MASK[1U]; } - return new PrivacyLC(lcData); + return std::unique_ptr(new PrivacyLC(lcData)); } /// @@ -181,7 +181,7 @@ PrivacyLC* FullLC::decodePI(const uint8_t* data) /// void FullLC::encodePI(const PrivacyLC& lc, uint8_t* data) { - assert(data != NULL); + assert(data != nullptr); uint8_t lcData[DMR_LC_HEADER_LENGTH_BYTES]; lc.getData(lcData); diff --git a/dmr/lc/FullLC.h b/dmr/lc/FullLC.h index e09ef72f..c4663914 100644 --- a/dmr/lc/FullLC.h +++ b/dmr/lc/FullLC.h @@ -54,12 +54,12 @@ namespace dmr ~FullLC(); /// Decode DMR full-link control data. - LC* decode(const uint8_t* data, uint8_t type); + std::unique_ptr decode(const uint8_t* data, uint8_t type); /// Encode DMR full-link control data. void encode(const LC& lc, uint8_t* data, uint8_t type); /// Decode DMR privacy control data. - PrivacyLC* decodePI(const uint8_t* data); + std::unique_ptr decodePI(const uint8_t* data); /// Encode DMR privacy control data. void encodePI(const PrivacyLC& lc, uint8_t* data); diff --git a/dmr/lc/LC.cpp b/dmr/lc/LC.cpp index ca3ce96a..59a32a5d 100644 --- a/dmr/lc/LC.cpp +++ b/dmr/lc/LC.cpp @@ -80,7 +80,7 @@ LC::LC(const uint8_t* data) : m_priority(CALL_PRIORITY_2), m_R(false) { - assert(data != NULL); + assert(data != nullptr); m_PF = (data[0U] & 0x80U) == 0x80U; m_R = (data[0U] & 0x40U) == 0x40U; @@ -115,7 +115,7 @@ LC::LC(const bool* bits) : m_priority(CALL_PRIORITY_2), m_R(false) { - assert(bits != NULL); + assert(bits != nullptr); m_PF = bits[0U]; m_R = bits[1U]; @@ -181,7 +181,7 @@ LC::~LC() /// void LC::getData(uint8_t* data) const { - assert(data != NULL); + assert(data != nullptr); data[0U] = (uint8_t)m_FLCO; @@ -214,7 +214,7 @@ void LC::getData(uint8_t* data) const /// void LC::getData(bool* bits) const { - assert(bits != NULL); + assert(bits != nullptr); uint8_t bytes[9U]; getData(bytes); diff --git a/dmr/lc/PrivacyLC.cpp b/dmr/lc/PrivacyLC.cpp index 62a9ff1d..c898fe80 100644 --- a/dmr/lc/PrivacyLC.cpp +++ b/dmr/lc/PrivacyLC.cpp @@ -48,9 +48,9 @@ PrivacyLC::PrivacyLC(const uint8_t* data) : m_group(false), m_algId(0U), m_kId(0U), - m_mi(NULL) + m_mi(nullptr) { - assert(data != NULL); + assert(data != nullptr); m_mi = new uint8_t[DMR_MI_LENGTH_BYTES]; @@ -77,9 +77,9 @@ PrivacyLC::PrivacyLC(const bool* bits) : m_group(false), m_algId(0U), m_kId(0U), - m_mi(NULL) + m_mi(nullptr) { - assert(bits != NULL); + assert(bits != nullptr); m_mi = new uint8_t[DMR_MI_LENGTH_BYTES]; @@ -122,7 +122,7 @@ PrivacyLC::PrivacyLC() : m_group(false), m_algId(0U), m_kId(0U), - m_mi(NULL) + m_mi(nullptr) { m_mi = new uint8_t[DMR_MI_LENGTH_BYTES]; } @@ -141,7 +141,7 @@ PrivacyLC::~PrivacyLC() /// void PrivacyLC::getData(uint8_t* data) const { - assert(data != NULL); + assert(data != nullptr); data[0U] = (m_group ? 0x20U : 0x00U) + (m_algId & 0x07U); // Algorithm ID @@ -165,7 +165,7 @@ void PrivacyLC::getData(uint8_t* data) const /// void PrivacyLC::getData(bool* bits) const { - assert(bits != NULL); + assert(bits != nullptr); uint8_t bytes[10U]; getData(bytes); diff --git a/dmr/lc/ShortLC.cpp b/dmr/lc/ShortLC.cpp index 654753d2..1a99bf72 100644 --- a/dmr/lc/ShortLC.cpp +++ b/dmr/lc/ShortLC.cpp @@ -47,8 +47,8 @@ using namespace dmr; /// Initializes a new instance of the ShortLC class. /// ShortLC::ShortLC() : - m_rawData(NULL), - m_deInterData(NULL) + m_rawData(nullptr), + m_deInterData(nullptr) { m_rawData = new bool[72U]; m_deInterData = new bool[68U]; @@ -71,8 +71,8 @@ ShortLC::~ShortLC() /// bool ShortLC::decode(const uint8_t* in, uint8_t* out) { - assert(in != NULL); - assert(out != NULL); + assert(in != nullptr); + assert(out != nullptr); // Get the raw binary decodeExtractBinary(in); @@ -98,8 +98,8 @@ bool ShortLC::decode(const uint8_t* in, uint8_t* out) /// void ShortLC::encode(const uint8_t* in, uint8_t* out) { - assert(in != NULL); - assert(out != NULL); + assert(in != nullptr); + assert(out != nullptr); // Extract Data encodeExtractData(in); @@ -124,7 +124,7 @@ void ShortLC::encode(const uint8_t* in, uint8_t* out) /// void ShortLC::decodeExtractBinary(const uint8_t* in) { - assert(in != NULL); + assert(in != nullptr); Utils::byteToBitsBE(in[0U], m_rawData + 0U); Utils::byteToBitsBE(in[1U], m_rawData + 8U); @@ -182,7 +182,7 @@ bool ShortLC::decodeErrorCheck() /// void ShortLC::decodeExtractData(uint8_t* data) const { - assert(data != NULL); + assert(data != nullptr); bool bData[40U]; @@ -212,7 +212,7 @@ void ShortLC::decodeExtractData(uint8_t* data) const /// void ShortLC::encodeExtractData(const uint8_t* in) const { - assert(in != NULL); + assert(in != nullptr); bool bData[40U]; Utils::byteToBitsBE(in[0U], bData + 0U); @@ -275,7 +275,7 @@ void ShortLC::encodeInterleave() /// void ShortLC::encodeExtractBinary(uint8_t* data) { - assert(data != NULL); + assert(data != nullptr); Utils::bitsToByteBE(m_rawData + 0U, data[0U]); Utils::bitsToByteBE(m_rawData + 8U, data[1U]); diff --git a/dmr/packet/ControlSignaling.cpp b/dmr/packet/ControlSignaling.cpp index 3a3db023..0558b96f 100644 --- a/dmr/packet/ControlSignaling.cpp +++ b/dmr/packet/ControlSignaling.cpp @@ -124,7 +124,7 @@ const uint32_t GRANT_TIMER_TIMEOUT = 15U; /// bool ControlSignaling::process(uint8_t* data, uint32_t len) { - assert(data != NULL); + assert(data != nullptr); // Get the type from the packet metadata uint8_t dataType = data[1U] & 0x0FU; @@ -617,7 +617,7 @@ ControlSignaling::~ControlSignaling() void ControlSignaling::writeRF_CSBK(lc::CSBK csbk, bool clearBeforeWrite) { Slot *m_tscc = m_slot->m_dmr->getTSCCSlot(); - if (m_tscc != NULL) { + if (m_tscc != nullptr) { if (!m_tscc->m_enableTSCC) return; @@ -727,7 +727,7 @@ bool ControlSignaling::writeRF_CSBK_Grant(uint32_t srcId, uint32_t dstId, uint8_ } // do we have a network connection and are we handling grants at the network? - if (m_tscc->m_network != NULL) { + if (m_tscc->m_network != nullptr) { if (m_tscc->m_network->isHandlingChGrants() && m_tscc->m_siteData.netActive() && !skipNetCheck) { return m_tscc->m_network->writeGrantReq(grp, srcId, dstId); } diff --git a/dmr/packet/Data.cpp b/dmr/packet/Data.cpp index 630da83b..c4ca94d3 100644 --- a/dmr/packet/Data.cpp +++ b/dmr/packet/Data.cpp @@ -77,7 +77,7 @@ using namespace dmr::packet; /// bool Data::process(uint8_t* data, uint32_t len) { - assert(data != NULL); + assert(data != nullptr); // Get the type from the packet metadata uint8_t dataType = data[1U] & 0x0FU; @@ -118,7 +118,7 @@ bool Data::process(uint8_t* data, uint32_t len) // release trunked grant (if necessary) Slot *m_tscc = m_slot->m_dmr->getTSCCSlot(); - if (m_tscc != NULL) { + if (m_tscc != nullptr) { if (m_tscc->m_enableTSCC) { m_tscc->m_affiliations->releaseGrant(m_slot->m_rfLC->getDstId(), false); } @@ -155,7 +155,7 @@ bool Data::process(uint8_t* data, uint32_t len) if (!valid) return false; - m_slot->m_rfDataHeader = dataHeader; + m_slot->m_rfDataHeader = std::unique_ptr(dataHeader); bool gi = dataHeader->getGI(); uint32_t srcId = dataHeader->getSrcId(); @@ -181,7 +181,7 @@ bool Data::process(uint8_t* data, uint32_t len) m_slot->m_rfFrames = dataHeader->getBlocks(); m_slot->m_rfSeqNo = 0U; - m_slot->m_rfLC = new lc::LC(gi ? FLCO_GROUP : FLCO_PRIVATE, srcId, dstId); + m_slot->m_rfLC = new_unique(lc::LC, gi ? FLCO_GROUP : FLCO_PRIVATE, srcId, dstId); // Regenerate the data header dataHeader->encode(data + 2U); @@ -372,7 +372,7 @@ void Data::processNetwork(const data::Data& dmrData) return; } - m_slot->m_netDataHeader = dataHeader; + m_slot->m_netDataHeader = std::unique_ptr(dataHeader); bool gi = dataHeader->getGI(); uint32_t srcId = dataHeader->getSrcId(); @@ -381,7 +381,7 @@ void Data::processNetwork(const data::Data& dmrData) CHECK_TG_HANG(dstId); m_slot->m_netFrames = dataHeader->getBlocks(); - m_slot->m_netLC = new lc::LC(gi ? FLCO_GROUP : FLCO_PRIVATE, srcId, dstId); + m_slot->m_netLC = new_unique(lc::LC, gi ? FLCO_GROUP : FLCO_PRIVATE, srcId, dstId); // Regenerate the data header dataHeader->encode(data + 2U); @@ -526,7 +526,7 @@ void Data::processNetwork(const data::Data& dmrData) /// Flag indicating whether DMR verbose logging is enabled. Data::Data(Slot* slot, network::BaseNetwork* network, bool dumpDataPacket, bool repeatDataPacket, bool debug, bool verbose) : m_slot(slot), - m_pduUserData(NULL), + m_pduUserData(nullptr), m_pduDataOffset(0U), m_lastRejectId(0U), m_dumpDataPacket(dumpDataPacket), diff --git a/dmr/packet/Voice.cpp b/dmr/packet/Voice.cpp index 47e24fef..47e86308 100644 --- a/dmr/packet/Voice.cpp +++ b/dmr/packet/Voice.cpp @@ -53,17 +53,15 @@ using namespace dmr::packet; // Macros // --------------------------------------------------------------------------- -#define CHECK_TRAFFIC_COLLISION_DELLC(_DST_ID) \ +#define CHECK_TRAFFIC_COLLISION(_DST_ID) \ if (m_slot->m_netState != RS_NET_IDLE && _DST_ID == m_slot->m_netLastDstId) { \ LogWarning(LOG_RF, "DMR Slot %u, Traffic collision detect, preempting new RF traffic to existing network traffic!", m_slot->m_slotNo); \ - delete lc; \ return false; \ } -#define CHECK_TG_HANG_DELLC(_DST_ID) \ +#define CHECK_TG_HANG(_DST_ID) \ if (m_slot->m_rfLastDstId != 0U) { \ if (m_slot->m_rfLastDstId != _DST_ID && (m_slot->m_rfTGHang.isRunning() && !m_slot->m_rfTGHang.hasExpired())) { \ - delete lc; \ return; \ } \ } @@ -80,7 +78,7 @@ using namespace dmr::packet; /// bool Voice::process(uint8_t* data, uint32_t len) { - assert(data != NULL); + assert(data != nullptr); bool dataSync = (data[1U] & DMR_SYNC_DATA) == DMR_SYNC_DATA; bool voiceSync = (data[1U] & DMR_SYNC_VOICE) == DMR_SYNC_VOICE; @@ -97,15 +95,15 @@ bool Voice::process(uint8_t* data, uint32_t len) return true; lc::FullLC fullLC; - lc::LC* lc = fullLC.decode(data + 2U, DT_VOICE_LC_HEADER); - if (lc == NULL) + std::unique_ptr lc = fullLC.decode(data + 2U, DT_VOICE_LC_HEADER); + if (lc == nullptr) return false; uint32_t srcId = lc->getSrcId(); uint32_t dstId = lc->getDstId(); uint8_t flco = lc->getFLCO(); - CHECK_TRAFFIC_COLLISION_DELLC(dstId); + CHECK_TRAFFIC_COLLISION(dstId); // validate source RID if (!acl::AccessControl::validateSrcId(srcId)) { @@ -117,7 +115,6 @@ bool Voice::process(uint8_t* data, uint32_t len) m_slot->m_rfLastDstId = 0U; m_slot->m_rfTGHang.stop(); - delete lc; m_slot->m_rfState = RS_RF_REJECTED; return false; } @@ -133,7 +130,6 @@ bool Voice::process(uint8_t* data, uint32_t len) m_slot->m_rfLastDstId = 0U; m_slot->m_rfTGHang.stop(); - delete lc; m_slot->m_rfState = RS_RF_REJECTED; return false; } @@ -147,7 +143,7 @@ bool Voice::process(uint8_t* data, uint32_t len) // and is not exact science! bool encrypted = (fid & 0x10U) == 0x10U; - m_slot->m_rfLC = lc; + m_slot->m_rfLC = std::move(lc); // The standby LC data m_slot->m_voice->m_rfEmbeddedLC.setLC(*m_slot->m_rfLC); @@ -212,14 +208,14 @@ bool Voice::process(uint8_t* data, uint32_t len) return false; lc::FullLC fullLC; - lc::PrivacyLC* lc = fullLC.decodePI(data + 2U); - if (lc == NULL) { + std::unique_ptr lc = fullLC.decodePI(data + 2U); + if (lc == nullptr) { LogWarning(LOG_RF, "DMR Slot %u, DT_VOICE_PI_HEADER, bad LC received, replacing", m_slot->m_slotNo); - lc = new lc::PrivacyLC(); + lc = new_unique(lc::PrivacyLC); lc->setDstId(m_slot->m_rfLC->getDstId()); } - m_slot->m_rfPrivacyLC = lc; + m_slot->m_rfPrivacyLC = std::move(lc); // Regenerate the LC data fullLC.encodePI(*m_slot->m_rfPrivacyLC, data + 2U); @@ -473,18 +469,17 @@ bool Voice::process(uint8_t* data, uint32_t len) return false; m_rfEmbeddedLC.addData(data + 2U, emb.getLCSS()); - lc::LC* lc = m_rfEmbeddedLC.getLC(); - if (lc != NULL) { + std::unique_ptr lc = m_rfEmbeddedLC.getLC(); + if (lc != nullptr) { uint32_t srcId = lc->getSrcId(); uint32_t dstId = lc->getDstId(); uint8_t flco = lc->getFLCO(); - CHECK_TRAFFIC_COLLISION_DELLC(dstId); + CHECK_TRAFFIC_COLLISION(dstId); // validate the source RID if (!acl::AccessControl::validateSrcId(srcId)) { LogWarning(LOG_RF, "DMR Slot %u, DT_VOICE denial, RID rejection, srcId = %u", m_slot->m_slotNo, srcId); - delete lc; m_slot->m_rfState = RS_RF_REJECTED; return false; } @@ -493,13 +488,12 @@ bool Voice::process(uint8_t* data, uint32_t len) if (flco == FLCO_GROUP) { if (!acl::AccessControl::validateTGId(m_slot->m_slotNo, dstId)) { LogWarning(LOG_RF, "DMR Slot %u, DT_VOICE denial, TGID rejection, srcId = %u, dstId = %u", m_slot->m_slotNo, srcId, dstId); - delete lc; m_slot->m_rfState = RS_RF_REJECTED; return false; } } - m_slot->m_rfLC = lc; + m_slot->m_rfLC = std::move(lc); // The standby LC data m_rfEmbeddedLC.setLC(*m_slot->m_rfLC); @@ -632,17 +626,17 @@ void Voice::processNetwork(const data::Data& dmrData) return; lc::FullLC fullLC; - lc::LC* lc = fullLC.decode(data + 2U, DT_VOICE_LC_HEADER); - if (lc == NULL) { + std::unique_ptr lc = fullLC.decode(data + 2U, DT_VOICE_LC_HEADER); + if (lc == nullptr) { LogWarning(LOG_NET, "DMR Slot %u, DT_VOICE_LC_HEADER, bad LC received from the network, replacing", m_slot->m_slotNo); - lc = new lc::LC(dmrData.getFLCO(), dmrData.getSrcId(), dmrData.getDstId()); + lc = new_unique(lc::LC, dmrData.getFLCO(), dmrData.getSrcId(), dmrData.getDstId()); } uint32_t srcId = lc->getSrcId(); uint32_t dstId = lc->getDstId(); uint8_t flco = lc->getFLCO(); - CHECK_TG_HANG_DELLC(dstId); + CHECK_TG_HANG(dstId); if (dstId != dmrData.getDstId() || srcId != dmrData.getSrcId() || flco != dmrData.getFLCO()) LogWarning(LOG_NET, "DMR Slot %u, DT_VOICE_LC_HEADER, header doesn't match the DMR RF header: %u->%s%u %u->%s%u", m_slot->m_slotNo, @@ -653,7 +647,7 @@ void Voice::processNetwork(const data::Data& dmrData) LogMessage(LOG_NET, "DMR Slot %u, DT_VOICE_LC_HEADER, srcId = %u, dstId = %u, FLCO = $%02X, FID = $%02X, PF = %u", m_slot->m_slotNo, lc->getSrcId(), lc->getDstId(), lc->getFLCO(), lc->getFID(), lc->getPF()); } - m_slot->m_netLC = lc; + m_slot->m_netLC = std::move(lc); // The standby LC data m_slot->m_voice->m_netEmbeddedLC.setLC(*m_slot->m_netLC); @@ -719,14 +713,14 @@ void Voice::processNetwork(const data::Data& dmrData) } else if (dataType == DT_VOICE_PI_HEADER) { if (m_slot->m_netState != RS_NET_AUDIO) { - lc::LC* lc = new lc::LC(dmrData.getFLCO(), dmrData.getSrcId(), dmrData.getDstId()); + std::unique_ptr lc = new_unique(lc::LC, dmrData.getFLCO(), dmrData.getSrcId(), dmrData.getDstId()); uint32_t srcId = lc->getSrcId(); uint32_t dstId = lc->getDstId(); - CHECK_TG_HANG_DELLC(dstId); + CHECK_TG_HANG(dstId); - m_slot->m_netLC = lc; + m_slot->m_netLC = std::move(lc); m_slot->m_voice->m_lastFrameValid = false; @@ -781,14 +775,14 @@ void Voice::processNetwork(const data::Data& dmrData) } lc::FullLC fullLC; - lc::PrivacyLC* lc = fullLC.decodePI(data + 2U); - if (lc == NULL) { + std::unique_ptr lc = fullLC.decodePI(data + 2U); + if (lc == nullptr) { LogWarning(LOG_NET, "DMR Slot %u, DT_VOICE_PI_HEADER, bad LC received, replacing", m_slot->m_slotNo); - lc = new lc::PrivacyLC(); + lc = new_unique(lc::PrivacyLC); lc->setDstId(dmrData.getDstId()); } - m_slot->m_netPrivacyLC = lc; + m_slot->m_netPrivacyLC = std::move(lc); // Regenerate the LC data fullLC.encodePI(*m_slot->m_netPrivacyLC, data + 2U); @@ -813,12 +807,12 @@ void Voice::processNetwork(const data::Data& dmrData) } else if (dataType == DT_VOICE_SYNC) { if (m_slot->m_netState == RS_NET_IDLE) { - lc::LC* lc = new lc::LC(dmrData.getFLCO(), dmrData.getSrcId(), dmrData.getDstId()); + std::unique_ptr lc = new_unique(lc::LC, dmrData.getFLCO(), dmrData.getSrcId(), dmrData.getDstId()); uint32_t dstId = lc->getDstId(); uint32_t srcId = lc->getSrcId(); - m_slot->m_netLC = lc; + m_slot->m_netLC = std::move(lc); // The standby LC data m_netEmbeddedLC.setLC(*m_slot->m_netLC); @@ -1072,17 +1066,17 @@ void Voice::processNetwork(const data::Data& dmrData) /// Flag indicating whether DMR verbose logging is enabled. Voice::Voice(Slot* slot, network::BaseNetwork* network, bool embeddedLCOnly, bool dumpTAData, bool debug, bool verbose) : m_slot(slot), - m_lastFrame(NULL), + m_lastFrame(nullptr), m_lastFrameValid(false), m_rfN(0U), m_lastRfN(0U), m_netN(0U), m_rfEmbeddedLC(), - m_rfEmbeddedData(NULL), + m_rfEmbeddedData(nullptr), m_rfEmbeddedReadN(0U), m_rfEmbeddedWriteN(1U), m_netEmbeddedLC(), - m_netEmbeddedData(NULL), + m_netEmbeddedData(nullptr), m_netEmbeddedReadN(0U), m_netEmbeddedWriteN(1U), m_rfTalkerId(TALKER_ID_NONE), @@ -1191,7 +1185,7 @@ void Voice::insertNullAudio(uint8_t* data) /// bool Voice::insertSilence(const uint8_t* data, uint8_t seqNo) { - assert(data != NULL); + assert(data != nullptr); // Do not send duplicate if (seqNo == m_netN) diff --git a/edac/AMBEFEC.cpp b/edac/AMBEFEC.cpp index 64163d40..22df851c 100644 --- a/edac/AMBEFEC.cpp +++ b/edac/AMBEFEC.cpp @@ -67,7 +67,7 @@ AMBEFEC::~AMBEFEC() /// Count of errors. uint32_t AMBEFEC::regenerateDMR(uint8_t* bytes) const { - assert(bytes != NULL); + assert(bytes != nullptr); uint32_t a1 = 0U, a2 = 0U, a3 = 0U; uint32_t b1 = 0U, b2 = 0U, b3 = 0U; @@ -174,7 +174,7 @@ uint32_t AMBEFEC::regenerateDMR(uint8_t* bytes) const /// Count of errors. uint32_t AMBEFEC::measureDMRBER(const uint8_t* bytes) const { - assert(bytes != NULL); + assert(bytes != nullptr); uint32_t a1 = 0U, a2 = 0U, a3 = 0U; uint32_t b1 = 0U, b2 = 0U, b3 = 0U; @@ -242,7 +242,7 @@ uint32_t AMBEFEC::measureDMRBER(const uint8_t* bytes) const /// Count of errors. uint32_t AMBEFEC::regenerateIMBE(uint8_t* bytes) const { - assert(bytes != NULL); + assert(bytes != nullptr); bool orig[144U]; bool temp[144U]; @@ -381,7 +381,7 @@ uint32_t AMBEFEC::regenerateIMBE(uint8_t* bytes) const /// Count of errors. uint32_t AMBEFEC::measureP25BER(const uint8_t* bytes) const { - assert(bytes != NULL); + assert(bytes != nullptr); bool orig[144U]; bool temp[144U]; @@ -514,7 +514,7 @@ uint32_t AMBEFEC::measureP25BER(const uint8_t* bytes) const /// Count of errors. uint32_t AMBEFEC::regenerateNXDN(uint8_t* bytes) const { - assert(bytes != NULL); + assert(bytes != nullptr); uint32_t a = 0U; uint32_t MASK = 0x800000U; @@ -571,7 +571,7 @@ uint32_t AMBEFEC::regenerateNXDN(uint8_t* bytes) const /// Count of errors. uint32_t AMBEFEC::measureNXDNBER(uint8_t* bytes) const { - assert(bytes != NULL); + assert(bytes != nullptr); uint32_t a = 0U; uint32_t MASK = 0x800000U; diff --git a/edac/BCH.cpp b/edac/BCH.cpp index fefe933d..2755ef75 100644 --- a/edac/BCH.cpp +++ b/edac/BCH.cpp @@ -127,7 +127,7 @@ BCH::~BCH() /// P25 NID data to encode with BCH. void BCH::encode(uint8_t* nid) { - assert(nid != NULL); + assert(nid != nullptr); int data[16]; for (int i = 0; i < 16; i++) diff --git a/edac/BPTC19696.cpp b/edac/BPTC19696.cpp index a168ab74..7a71cac6 100644 --- a/edac/BPTC19696.cpp +++ b/edac/BPTC19696.cpp @@ -47,8 +47,8 @@ using namespace edac; /// Initializes a new instance of the BPTC19696 class. /// BPTC19696::BPTC19696() : - m_rawData(NULL), - m_deInterData(NULL) + m_rawData(nullptr), + m_deInterData(nullptr) { m_rawData = new bool[196]; m_deInterData = new bool[196]; @@ -70,8 +70,8 @@ BPTC19696::~BPTC19696() /// Decoded data. void BPTC19696::decode(const uint8_t* in, uint8_t* out) { - assert(in != NULL); - assert(out != NULL); + assert(in != nullptr); + assert(out != nullptr); // Get the raw binary decodeExtractBinary(in); @@ -93,8 +93,8 @@ void BPTC19696::decode(const uint8_t* in, uint8_t* out) /// Encoded data. void BPTC19696::encode(const uint8_t* in, uint8_t* out) { - assert(in != NULL); - assert(out != NULL); + assert(in != nullptr); + assert(out != nullptr); // Extract Data encodeExtractData(in); diff --git a/edac/CRC.cpp b/edac/CRC.cpp index 9a9e22de..dcf4012d 100644 --- a/edac/CRC.cpp +++ b/edac/CRC.cpp @@ -198,7 +198,7 @@ const uint32_t CRC32_TABLE[] = { /// True, if CRC is valid, otherwise false. bool CRC::checkFiveBit(bool* in, uint32_t tcrc) { - assert(in != NULL); + assert(in != nullptr); uint32_t crc; encodeFiveBit(in, crc); @@ -213,7 +213,7 @@ bool CRC::checkFiveBit(bool* in, uint32_t tcrc) /// Computed CRC. void CRC::encodeFiveBit(const bool* in, uint32_t& tcrc) { - assert(in != NULL); + assert(in != nullptr); uint16_t total = 0U; for (uint32_t i = 0U; i < 72U; i += 8U) { @@ -236,7 +236,7 @@ void CRC::encodeFiveBit(const bool* in, uint32_t& tcrc) /// True, if CRC is valid, otherwise false. bool CRC::checkCCITT162(const uint8_t *in, uint32_t length) { - assert(in != NULL); + assert(in != nullptr); assert(length > 2U); union { @@ -267,7 +267,7 @@ bool CRC::checkCCITT162(const uint8_t *in, uint32_t length) /// Length of byte array. void CRC::addCCITT162(uint8_t* in, uint32_t length) { - assert(in != NULL); + assert(in != nullptr); assert(length > 2U); union { @@ -299,7 +299,7 @@ void CRC::addCCITT162(uint8_t* in, uint32_t length) /// True, if CRC is valid, otherwise false. bool CRC::checkCCITT161(const uint8_t *in, uint32_t length) { - assert(in != NULL); + assert(in != nullptr); assert(length > 2U); union { @@ -330,7 +330,7 @@ bool CRC::checkCCITT161(const uint8_t *in, uint32_t length) /// Length of byte array. void CRC::addCCITT161(uint8_t* in, uint32_t length) { - assert(in != NULL); + assert(in != nullptr); assert(length > 2U); union { @@ -361,7 +361,7 @@ void CRC::addCCITT161(uint8_t* in, uint32_t length) /// True, if CRC is valid, otherwise false. bool CRC::checkCRC32(const uint8_t *in, uint32_t length) { - assert(in != NULL); + assert(in != nullptr); assert(length > 4U); union { @@ -395,7 +395,7 @@ bool CRC::checkCRC32(const uint8_t *in, uint32_t length) /// Length of byte array. void CRC::addCRC32(uint8_t* in, uint32_t length) { - assert(in != NULL); + assert(in != nullptr); assert(length > 4U); union { @@ -432,7 +432,7 @@ void CRC::addCRC32(uint8_t* in, uint32_t length) /// Calculated 8-bit CRC value. uint8_t CRC::crc8(const uint8_t *in, uint32_t length) { - assert(in != NULL); + assert(in != nullptr); uint8_t crc = 0U; @@ -454,7 +454,7 @@ uint8_t CRC::crc8(const uint8_t *in, uint32_t length) /// Calculated 9-bit CRC value. uint16_t CRC::crc9(const uint8_t* in, uint32_t bitLength) { - assert(in != NULL); + assert(in != nullptr); uint16_t crc = 0x00U; @@ -488,7 +488,7 @@ uint16_t CRC::crc9(const uint8_t* in, uint32_t bitLength) /// True, if CRC is valid, otherwise false. bool CRC::checkCRC6(const uint8_t* in, uint32_t bitLength) { - assert(in != NULL); + assert(in != nullptr); uint8_t crc = createCRC6(in, bitLength); @@ -516,7 +516,7 @@ bool CRC::checkCRC6(const uint8_t* in, uint32_t bitLength) /// True, if CRC is valid, otherwise false. void CRC::addCRC6(uint8_t* in, uint32_t bitLength) { - assert(in != NULL); + assert(in != nullptr); uint8_t crc[1U]; crc[0U] = createCRC6(in, bitLength); @@ -540,7 +540,7 @@ void CRC::addCRC6(uint8_t* in, uint32_t bitLength) /// True, if CRC is valid, otherwise false. bool CRC::checkCRC12(const uint8_t* in, uint32_t bitLength) { - assert(in != NULL); + assert(in != nullptr); uint16_t crc = createCRC12(in, bitLength); uint8_t temp1[2U]; @@ -572,7 +572,7 @@ bool CRC::checkCRC12(const uint8_t* in, uint32_t bitLength) /// True, if CRC is valid, otherwise false. void CRC::addCRC12(uint8_t* in, uint32_t bitLength) { - assert(in != NULL); + assert(in != nullptr); uint16_t crc = createCRC12(in, bitLength); @@ -599,7 +599,7 @@ void CRC::addCRC12(uint8_t* in, uint32_t bitLength) /// True, if CRC is valid, otherwise false. bool CRC::checkCRC15(const uint8_t* in, uint32_t bitLength) { - assert(in != NULL); + assert(in != nullptr); uint16_t crc = createCRC15(in, bitLength); uint8_t temp1[2U]; @@ -631,7 +631,7 @@ bool CRC::checkCRC15(const uint8_t* in, uint32_t bitLength) /// True, if CRC is valid, otherwise false. void CRC::addCRC15(uint8_t* in, uint32_t bitLength) { - assert(in != NULL); + assert(in != nullptr); uint16_t crc = createCRC15(in, bitLength); @@ -658,7 +658,7 @@ void CRC::addCRC15(uint8_t* in, uint32_t bitLength) /// True, if CRC is valid, otherwise false. bool CRC::checkCRC16(const uint8_t* in, uint32_t bitLength) { - assert(in != NULL); + assert(in != nullptr); uint16_t crc = createCRC16(in, bitLength); uint8_t temp1[2U]; @@ -690,7 +690,7 @@ bool CRC::checkCRC16(const uint8_t* in, uint32_t bitLength) /// True, if CRC is valid, otherwise false. void CRC::addCRC16(uint8_t* in, uint32_t bitLength) { - assert(in != NULL); + assert(in != nullptr); uint16_t crc = createCRC16(in, bitLength); diff --git a/edac/Golay2087.cpp b/edac/Golay2087.cpp index a45c8188..88a14c47 100644 --- a/edac/Golay2087.cpp +++ b/edac/Golay2087.cpp @@ -239,7 +239,7 @@ const uint32_t DECODING_TABLE_1987[] = { /// uint8_t Golay2087::decode(const uint8_t* data) { - assert(data != NULL); + assert(data != nullptr); uint32_t code = (data[0U] << 11) + (data[1U] << 3) + (data[2U] >> 5); uint32_t syndrome = getSyndrome1987(code); @@ -257,7 +257,7 @@ uint8_t Golay2087::decode(const uint8_t* data) /// Data to encode with Golay FEC. void Golay2087::encode(uint8_t* data) { - assert(data != NULL); + assert(data != nullptr); uint32_t value = data[0U]; diff --git a/edac/Golay24128.cpp b/edac/Golay24128.cpp index abd541c8..6060c7e9 100644 --- a/edac/Golay24128.cpp +++ b/edac/Golay24128.cpp @@ -1124,7 +1124,7 @@ bool Golay24128::decode24128(uint32_t code, uint32_t& out) /// bool Golay24128::decode24128(uint8_t* bytes, uint32_t& out) { - assert(bytes != NULL); + assert(bytes != nullptr); uint32_t code = (bytes[0U] << 16) | (bytes[1U] << 8) | (bytes[2U] << 0); return decode24128(code, out); diff --git a/edac/Hamming.cpp b/edac/Hamming.cpp index a67eeedc..b4bd9343 100644 --- a/edac/Hamming.cpp +++ b/edac/Hamming.cpp @@ -45,7 +45,7 @@ using namespace edac; /// True, if bit errors are detected, otherwise false. bool Hamming::decode15113_1(bool* d) { - assert(d != NULL); + assert(d != nullptr); // Calculate the parity it should have bool c0 = d[0] ^ d[1] ^ d[2] ^ d[3] ^ d[4] ^ d[5] ^ d[6]; @@ -90,7 +90,7 @@ bool Hamming::decode15113_1(bool* d) /// Boolean bit array. void Hamming::encode15113_1(bool* d) { - assert(d != NULL); + assert(d != nullptr); // Calculate the checksum this row should have d[11] = d[0] ^ d[1] ^ d[2] ^ d[3] ^ d[4] ^ d[5] ^ d[6]; @@ -106,7 +106,7 @@ void Hamming::encode15113_1(bool* d) /// True, if bit errors are detected, otherwise false. bool Hamming::decode15113_2(bool* d) { - assert(d != NULL); + assert(d != nullptr); // Calculate the checksum this row should have bool c0 = d[0] ^ d[1] ^ d[2] ^ d[3] ^ d[5] ^ d[7] ^ d[8]; @@ -151,7 +151,7 @@ bool Hamming::decode15113_2(bool* d) /// Boolean bit array. void Hamming::encode15113_2(bool* d) { - assert(d != NULL); + assert(d != nullptr); // Calculate the checksum this row should have d[11] = d[0] ^ d[1] ^ d[2] ^ d[3] ^ d[5] ^ d[7] ^ d[8]; @@ -167,7 +167,7 @@ void Hamming::encode15113_2(bool* d) /// True, if bit errors are detected, otherwise false. bool Hamming::decode1393(bool* d) { - assert(d != NULL); + assert(d != nullptr); // Calculate the checksum this column should have bool c0 = d[0] ^ d[1] ^ d[3] ^ d[5] ^ d[6]; @@ -210,7 +210,7 @@ bool Hamming::decode1393(bool* d) /// Boolean bit array. void Hamming::encode1393(bool* d) { - assert(d != NULL); + assert(d != nullptr); // Calculate the checksum this column should have d[9] = d[0] ^ d[1] ^ d[3] ^ d[5] ^ d[6]; @@ -226,7 +226,7 @@ void Hamming::encode1393(bool* d) /// True, if bit errors are detected, otherwise false. bool Hamming::decode1063(bool* d) { - assert(d != NULL); + assert(d != nullptr); // Calculate the checksum this column should have bool c0 = d[0] ^ d[1] ^ d[2] ^ d[5]; @@ -266,7 +266,7 @@ bool Hamming::decode1063(bool* d) /// Boolean bit array. void Hamming::encode1063(bool* d) { - assert(d != NULL); + assert(d != nullptr); // Calculate the checksum this column should have d[6] = d[0] ^ d[1] ^ d[2] ^ d[5]; @@ -282,7 +282,7 @@ void Hamming::encode1063(bool* d) /// True, if bit errors are detected or no bit errors, otherwise false if unrecoverable errors are detected. bool Hamming::decode16114(bool* d) { - assert(d != NULL); + assert(d != nullptr); // Calculate the checksum this column should have bool c0 = d[0] ^ d[1] ^ d[2] ^ d[3] ^ d[5] ^ d[7] ^ d[8]; @@ -334,7 +334,7 @@ bool Hamming::decode16114(bool* d) /// Boolean bit array. void Hamming::encode16114(bool* d) { - assert(d != NULL); + assert(d != nullptr); d[11] = d[0] ^ d[1] ^ d[2] ^ d[3] ^ d[5] ^ d[7] ^ d[8]; d[12] = d[1] ^ d[2] ^ d[3] ^ d[4] ^ d[6] ^ d[8] ^ d[9]; @@ -350,7 +350,7 @@ void Hamming::encode16114(bool* d) /// True, if bit errors are detected or no bit errors, otherwise false if unrecoverable errors are detected. bool Hamming::decode17123(bool* d) { - assert(d != NULL); + assert(d != nullptr); // Calculate the checksum this column should have bool c0 = d[0] ^ d[1] ^ d[2] ^ d[3] ^ d[6] ^ d[7] ^ d[9]; @@ -403,7 +403,7 @@ bool Hamming::decode17123(bool* d) /// Boolean bit array. void Hamming::encode17123(bool* d) { - assert(d != NULL); + assert(d != nullptr); d[12] = d[0] ^ d[1] ^ d[2] ^ d[3] ^ d[6] ^ d[7] ^ d[9]; d[13] = d[0] ^ d[1] ^ d[2] ^ d[3] ^ d[4] ^ d[7] ^ d[8] ^ d[10]; diff --git a/edac/QR1676.cpp b/edac/QR1676.cpp index a1972e1b..2ca99cfe 100644 --- a/edac/QR1676.cpp +++ b/edac/QR1676.cpp @@ -92,7 +92,7 @@ const uint32_t DECODING_TABLE_1576[] = { /// uint8_t QR1676::decode(const uint8_t* data) { - assert(data != NULL); + assert(data != nullptr); uint32_t code = (data[0U] << 7) + (data[1U] >> 1); uint32_t syndrome = getSyndrome1576(code); @@ -110,7 +110,7 @@ uint8_t QR1676::decode(const uint8_t* data) /// void QR1676::encode(uint8_t* data) { - assert(data != NULL); + assert(data != nullptr); uint32_t value = (data[0U] >> 1) & 0x7FU; uint32_t cksum = ENCODING_TABLE_1676[value]; diff --git a/edac/RS129.cpp b/edac/RS129.cpp index d3727a59..6a2b71aa 100644 --- a/edac/RS129.cpp +++ b/edac/RS129.cpp @@ -111,7 +111,7 @@ const uint8_t LOG_TABLE[] = { /// bool RS129::check(const uint8_t* in) { - assert(in != NULL); + assert(in != nullptr); uint8_t parity[4U]; encode(in, 9U, parity); @@ -133,8 +133,8 @@ bool RS129::check(const uint8_t* in) /// void RS129::encode(const uint8_t* msg, uint32_t nbytes, uint8_t* parity) { - assert(msg != NULL); - assert(parity != NULL); + assert(msg != nullptr); + assert(parity != nullptr); for (uint32_t i = 0U; i < NPAR + 1U; i++) parity[i] = 0x00U; diff --git a/edac/RS634717.cpp b/edac/RS634717.cpp index ba2323c1..0e1b01f6 100644 --- a/edac/RS634717.cpp +++ b/edac/RS634717.cpp @@ -153,7 +153,7 @@ bool RS634717::decode241213(uint8_t* data) /// Raw data to encode with Reed-Solomon FEC. void RS634717::encode241213(uint8_t* data) { - assert(data != NULL); + assert(data != nullptr); uint8_t codeword[24U]; @@ -188,7 +188,7 @@ bool RS634717::decode24169(uint8_t* data) /// Raw data to encode with Reed-Solomon FEC. void RS634717::encode24169(uint8_t* data) { - assert(data != NULL); + assert(data != nullptr); uint8_t codeword[24U]; @@ -223,7 +223,7 @@ bool RS634717::decode362017(uint8_t* data) /// Raw data to encode with Reed-Solomon FEC. void RS634717::encode362017(uint8_t* data) { - assert(data != NULL); + assert(data != nullptr); uint8_t codeword[36U]; @@ -323,7 +323,7 @@ uint8_t RS634717::gf6Mult(uint8_t a, uint8_t b) const /// bool RS634717::decode(uint8_t* data, const uint32_t bitLength, const int firstData, const int roots) { - assert(data != NULL); + assert(data != nullptr); uint8_t HB[63U]; ::memset(HB, 0x00U, 63U); diff --git a/edac/SHA256.cpp b/edac/SHA256.cpp index 80663a9a..184ede64 100644 --- a/edac/SHA256.cpp +++ b/edac/SHA256.cpp @@ -101,7 +101,7 @@ static const uint32_t roundConstants[64] = { */ static inline void set_uint32(uint8_t* cp, uint32_t v) { - assert(cp != NULL); + assert(cp != nullptr); ::memcpy(cp, &v, sizeof v); } @@ -118,10 +118,10 @@ static inline void set_uint32(uint8_t* cp, uint32_t v) /// must be called before using hash in the call to sha256_hash /// SHA256::SHA256() : - m_state(NULL), - m_total(NULL), + m_state(nullptr), + m_total(nullptr), m_buflen(0U), - m_buffer(NULL) + m_buffer(nullptr) { m_state = new uint32_t[8U]; m_total = new uint32_t[2U]; @@ -154,7 +154,7 @@ SHA256::~SHA256() /// void SHA256::processBlock(const uint8_t* buffer, uint32_t len) { - assert(buffer != NULL); + assert(buffer != nullptr); const uint32_t *words = (uint32_t *)buffer; uint32_t nwords = len / sizeof(uint32_t); @@ -283,7 +283,7 @@ void SHA256::processBlock(const uint8_t* buffer, uint32_t len) /// void SHA256::processBytes(const uint8_t* buffer, uint32_t len) { - assert(buffer != NULL); + assert(buffer != nullptr); // When we already have some bits in our internal buffer concatenate // both inputs first. @@ -341,7 +341,7 @@ void SHA256::processBytes(const uint8_t* buffer, uint32_t len) /// uint8_t* SHA256::finish(uint8_t* buffer) { - assert(buffer != NULL); + assert(buffer != nullptr); conclude(); @@ -357,7 +357,7 @@ uint8_t* SHA256::finish(uint8_t* buffer) /// uint8_t* SHA256::read(uint8_t* buffer) { - assert(buffer != NULL); + assert(buffer != nullptr); for (uint32_t i = 0U; i < 8U; i++) set_uint32(buffer + i * sizeof(m_state[0]), SWAP(m_state[i])); @@ -377,8 +377,8 @@ uint8_t* SHA256::read(uint8_t* buffer) /// uint8_t* SHA256::buffer(const uint8_t* buffer, uint32_t len, uint8_t* resblock) { - assert(buffer != NULL); - assert(resblock != NULL); + assert(buffer != nullptr); + assert(resblock != nullptr); // Initialize the computation context. init(); diff --git a/host/Host.cpp b/host/Host.cpp index ac2aba35..e5707fdd 100644 --- a/host/Host.cpp +++ b/host/Host.cpp @@ -84,10 +84,10 @@ using namespace lookups; Host::Host(const std::string& confFile) : m_confFile(confFile), m_conf(), - m_modem(NULL), + m_modem(nullptr), m_modemRemote(false), - m_network(NULL), - m_modemRemotePort(NULL), + m_network(nullptr), + m_modemRemotePort(nullptr), m_state(STATE_IDLE), m_modeTimer(1000U), m_dmrTXTimer(1000U), @@ -113,9 +113,9 @@ Host::Host(const std::string& confFile) : m_txFrequency(0U), m_channelId(0U), m_channelNo(0U), - m_idenTable(NULL), - m_ridLookup(NULL), - m_tidLookup(NULL), + m_idenTable(nullptr), + m_ridLookup(nullptr), + m_tidLookup(nullptr), m_dmrBeacons(false), m_dmrTSCCData(false), m_dmrCtrlChannel(false), @@ -136,7 +136,7 @@ Host::Host(const std::string& confFile) : m_nxdnRAN(1U), m_activeTickDelay(5U), m_idleTickDelay(5U), - m_remoteControl(NULL) + m_remoteControl(nullptr) { UDPSocket::startup(); } @@ -355,7 +355,7 @@ int Host::run() Timer dmrBeaconIntervalTimer(1000U); Timer dmrBeaconDurationTimer(1000U); - dmr::Control* dmr = NULL; + std::unique_ptr dmr = nullptr; #if defined(ENABLE_DMR) LogInfo("DMR Parameters"); LogInfo(" Enabled: %s", m_dmrEnabled ? "yes" : "no"); @@ -441,9 +441,9 @@ int Host::run() g_fireDMRBeacon = true; } - dmr = new dmr::Control(m_dmrColorCode, callHang, queueSizeBytes, embeddedLCOnly, dumpTAData, m_timeout, m_rfTalkgroupHang, + dmr = std::unique_ptr(new dmr::Control(m_dmrColorCode, callHang, queueSizeBytes, embeddedLCOnly, dumpTAData, m_timeout, m_rfTalkgroupHang, m_modem, m_network, m_duplex, m_ridLookup, m_tidLookup, m_idenTable, rssi, jitter, dmrDumpDataPacket, dmrRepeatDataPacket, - dmrDumpCsbkData, dmrDebug, dmrVerbose); + dmrDumpCsbkData, dmrDebug, dmrVerbose)); dmr->setOptions(m_conf, m_dmrNetId, m_siteId, m_channelId, m_channelNo, true); if (dmrCtrlChannel) { @@ -465,7 +465,7 @@ int Host::run() Timer p25BcastIntervalTimer(1000U); Timer p25BcastDurationTimer(1000U); - p25::Control* p25 = NULL; + std::unique_ptr p25 = nullptr; #if defined(ENABLE_P25) LogInfo("P25 Parameters"); LogInfo(" Enabled: %s", m_p25Enabled ? "yes" : "no"); @@ -531,9 +531,9 @@ int Host::run() } } - p25 = new p25::Control(m_p25NAC, callHang, queueSizeBytes, m_modem, m_network, m_timeout, m_rfTalkgroupHang, + p25 = std::unique_ptr(new p25::Control(m_p25NAC, callHang, queueSizeBytes, m_modem, m_network, m_timeout, m_rfTalkgroupHang, m_duplex, m_ridLookup, m_tidLookup, m_idenTable, rssi, p25DumpDataPacket, p25RepeatDataPacket, - p25DumpTsbkData, p25Debug, p25Verbose); + p25DumpTsbkData, p25Debug, p25Verbose)); p25->setOptions(m_conf, m_cwCallsign, m_voiceChNo, m_p25PatchSuperGroup, m_p25NetId, m_p25SysId, m_p25RfssId, m_siteId, m_channelId, m_channelNo, true); @@ -554,7 +554,7 @@ int Host::run() Timer nxdnBcastIntervalTimer(1000U); Timer nxdnBcastDurationTimer(1000U); - nxdn::Control* nxdn = NULL; + std::unique_ptr nxdn = nullptr; #if defined(ENABLE_NXDN) LogInfo("NXDN Parameters"); LogInfo(" Enabled: %s", m_nxdnEnabled ? "yes" : "no"); @@ -613,9 +613,9 @@ int Host::run() } } - nxdn = new nxdn::Control(m_nxdnRAN, callHang, queueSizeBytes, m_timeout, m_rfTalkgroupHang, + nxdn = std::unique_ptr(new nxdn::Control(m_nxdnRAN, callHang, queueSizeBytes, m_timeout, m_rfTalkgroupHang, m_modem, m_network, m_duplex, m_ridLookup, m_tidLookup, m_idenTable, rssi, - nxdnDumpRcchData, nxdnDebug, nxdnVerbose); + nxdnDumpRcchData, nxdnDebug, nxdnVerbose)); nxdn->setOptions(m_conf, m_cwCallsign, m_voiceChNo, m_siteId, m_channelId, m_channelNo, true); if (nxdnCtrlChannel) { @@ -731,15 +731,15 @@ int Host::run() // fixed mode will force a state change if (m_fixedMode) { #if defined(ENABLE_DMR) - if (dmr != NULL) + if (dmr != nullptr) setState(STATE_DMR); #endif // defined(ENABLE_DMR) #if defined(ENABLE_P25) - if (p25 != NULL) + if (p25 != nullptr) setState(STATE_P25); #endif // defined(ENABLE_P25) #if defined(ENABLE_NXDN) - if (nxdn != NULL) + if (nxdn != nullptr) setState(STATE_NXDN); #endif // defined(ENABLE_NXDN) } @@ -778,7 +778,7 @@ int Host::run() elapsedMs += ms; m_modem->clock(ms); - if (m_network != NULL) + if (m_network != nullptr) m_network->clock(ms); Thread::sleep(IDLE_WARMUP_MS); @@ -813,7 +813,7 @@ int Host::run() // Macro to interrupt a running P25 control channel transmission #define INTERRUPT_P25_CONTROL \ - if (p25 != NULL) { \ + if (p25 != nullptr) { \ p25->setCCHalted(true); \ if (p25BcastDurationTimer.isRunning() && !p25BcastDurationTimer.isPaused()) { \ p25BcastDurationTimer.pause(); \ @@ -822,7 +822,7 @@ int Host::run() // Macro to interrupt a running DMR roaming beacon #define INTERRUPT_DMR_BEACON \ - if (dmr != NULL) { \ + if (dmr != nullptr) { \ if (dmrBeaconDurationTimer.isRunning() && !dmrBeaconDurationTimer.hasExpired()) { \ if (m_dmrTSCCData && !m_dmrCtrlChannel) { \ dmr->setCCHalted(true); \ @@ -834,7 +834,7 @@ int Host::run() // Macro to interrupt a running NXDN control channel transmission #define INTERRUPT_NXDN_CONTROL \ - if (nxdn != NULL) { \ + if (nxdn != nullptr) { \ nxdn->setCCHalted(true); \ if (nxdnBcastDurationTimer.isRunning() && !nxdnBcastDurationTimer.isPaused()) { \ nxdnBcastDurationTimer.pause(); \ @@ -843,7 +843,7 @@ int Host::run() // Macro to start DMR duplex idle transmission (or beacon) #define START_DMR_DUPLEX_IDLE(x) \ - if (dmr != NULL) { \ + if (dmr != nullptr) { \ if (m_duplex) { \ m_modem->writeDMRStart(x); \ m_dmrTXTimer.start(); \ @@ -877,15 +877,15 @@ int Host::run() } else { m_modeTimer.stop(); - if (dmr != NULL && m_state != STATE_DMR && !m_modem->hasTX()) { + if (dmr != nullptr && m_state != STATE_DMR && !m_modem->hasTX()) { LogDebug(LOG_HOST, "fixed mode state abnormal, m_state = %u, state = %u", m_state, STATE_DMR); setState(STATE_DMR); } - if (p25 != NULL && m_state != STATE_P25 && !m_modem->hasTX()) { + if (p25 != nullptr && m_state != STATE_P25 && !m_modem->hasTX()) { LogDebug(LOG_HOST, "fixed mode state abnormal, m_state = %u, state = %u", m_state, STATE_P25); setState(STATE_P25); } - if (nxdn != NULL && m_state != STATE_NXDN && !m_modem->hasTX()) { + if (nxdn != nullptr && m_state != STATE_NXDN && !m_modem->hasTX()) { LogDebug(LOG_HOST, "fixed mode state abnormal, m_state = %u, state = %u", m_state, STATE_NXDN); setState(STATE_NXDN); } @@ -897,7 +897,7 @@ int Host::run() /** Digital Mobile Radio */ #if defined(ENABLE_DMR) - if (dmr != NULL) { + if (dmr != nullptr) { // check if there is space on the modem for DMR slot 1 frames, // if there is read frames from the DMR controller and write it // to the modem @@ -925,7 +925,7 @@ int Host::run() } // if there is a P25 CC running; halt the CC - if (p25 != NULL) { + if (p25 != nullptr) { if (p25->getCCRunning() && !p25->getCCHalted()) { p25->setCCHalted(true); INTERRUPT_P25_CONTROL; @@ -933,7 +933,7 @@ int Host::run() } // if there is a NXDN CC running; halt the CC - if (nxdn != NULL) { + if (nxdn != nullptr) { if (nxdn->getCCRunning() && !nxdn->getCCHalted()) { nxdn->setCCHalted(true); INTERRUPT_NXDN_CONTROL; @@ -972,7 +972,7 @@ int Host::run() } // if there is a P25 CC running; halt the CC - if (p25 != NULL) { + if (p25 != nullptr) { if (p25->getCCRunning() && !p25->getCCHalted()) { p25->setCCHalted(true); INTERRUPT_P25_CONTROL; @@ -980,7 +980,7 @@ int Host::run() } // if there is a NXDN CC running; halt the CC - if (nxdn != NULL) { + if (nxdn != nullptr) { if (nxdn->getCCRunning() && !nxdn->getCCHalted()) { nxdn->setCCHalted(true); INTERRUPT_NXDN_CONTROL; @@ -999,7 +999,7 @@ int Host::run() // check if there is space on the modem for P25 frames, // if there is read frames from the P25 controller and write it // to the modem - if (p25 != NULL) { + if (p25 != nullptr) { ret = m_modem->hasP25Space(); if (ret) { len = p25->getFrame(data); @@ -1017,7 +1017,7 @@ int Host::run() INTERRUPT_DMR_BEACON; // if there is a NXDN CC running; halt the CC - if (nxdn != NULL) { + if (nxdn != nullptr) { if (nxdn->getCCRunning() && !nxdn->getCCHalted()) { nxdn->setCCHalted(true); INTERRUPT_NXDN_CONTROL; @@ -1073,7 +1073,7 @@ int Host::run() // check if there is space on the modem for NXDN frames, // if there is read frames from the NXDN controller and write it // to the modem - if (nxdn != NULL) { + if (nxdn != nullptr) { ret = m_modem->hasNXDNSpace(); if (ret) { len = nxdn->getFrame(data); @@ -1091,7 +1091,7 @@ int Host::run() INTERRUPT_DMR_BEACON; // if there is a P25 CC running; halt the CC - if (p25 != NULL) { + if (p25 != nullptr) { if (p25->getCCRunning() && !p25->getCCHalted()) { p25->setCCHalted(true); INTERRUPT_P25_CONTROL; @@ -1120,7 +1120,7 @@ int Host::run() /** Digital Mobile Radio */ #if defined(ENABLE_DMR) - if (dmr != NULL) { + if (dmr != nullptr) { // read DMR slot 1 frames from the modem, and if there is any // write those frames to the DMR controller len = m_modem->readDMRData1(data); @@ -1248,7 +1248,7 @@ int Host::run() #if defined(ENABLE_P25) // read P25 frames from modem, and if there are frames // write those frames to the P25 controller - if (p25 != NULL) { + if (p25 != nullptr) { len = m_modem->readP25Data(data); if (len > 0U) { if (m_state == STATE_IDLE) { @@ -1322,7 +1322,7 @@ int Host::run() // read NXDN frames from modem, and if there are frames // write those frames to the NXDN controller #if defined(ENABLE_NXDN) - if (nxdn != NULL) { + if (nxdn != nullptr) { len = m_modem->readNXDNData(data); if (len > 0U) { if (m_state == STATE_IDLE) { @@ -1355,19 +1355,19 @@ int Host::run() // -- Network, DMR, and P25 Clocking -- // ------------------------------------------------------ - if (m_network != NULL) + if (m_network != nullptr) m_network->clock(ms); #if defined(ENABLE_DMR) - if (dmr != NULL) + if (dmr != nullptr) dmr->clock(); #endif // defined(ENABLE_DMR) #if defined(ENABLE_P25) - if (p25 != NULL) + if (p25 != nullptr) p25->clock(ms); #endif // defined(ENABLE_P25) #if defined(ENABLE_NXDN) - if (nxdn != NULL) + if (nxdn != nullptr) nxdn->clock(ms); #endif // defined(ENABLE_NXDN) @@ -1375,8 +1375,8 @@ int Host::run() // -- Remote Control Processing -- // ------------------------------------------------------ - if (m_remoteControl != NULL) { - m_remoteControl->process(this, dmr, p25, nxdn); + if (m_remoteControl != nullptr) { + m_remoteControl->process(this, dmr.get(), p25.get(), nxdn.get()); } // ------------------------------------------------------ @@ -1432,7 +1432,7 @@ int Host::run() /** Digial Mobile Radio */ #if defined(ENABLE_DMR) - if (dmr != NULL) { + if (dmr != nullptr) { if (m_dmrTSCCData && m_dmrCtrlChannel) { if (m_state != STATE_DMR) setState(STATE_DMR); @@ -1501,7 +1501,7 @@ int Host::run() /** Project 25 */ #if defined(ENABLE_P25) - if (p25 != NULL) { + if (p25 != nullptr) { if (m_p25CCData) { p25BcastIntervalTimer.clock(ms); @@ -1568,7 +1568,7 @@ int Host::run() /** Next Generation Digital Narrowband */ #if defined(ENABLE_NXDN) - if (nxdn != NULL) { + if (nxdn != nullptr) { if (m_nxdnCCData) { nxdnBcastIntervalTimer.clock(ms); @@ -1635,7 +1635,7 @@ int Host::run() if (g_killed) { #if defined(ENABLE_DMR) - if (dmr != NULL) { + if (dmr != nullptr) { if (m_dmrCtrlChannel) { if (!hasTxShutdown) { m_modem->clearDMRData1(); @@ -1652,7 +1652,7 @@ int Host::run() #endif // defined(ENABLE_DMR) #if defined(ENABLE_P25) - if (p25 != NULL) { + if (p25 != nullptr) { if (m_p25CtrlChannel) { if (!hasTxShutdown) { m_modem->clearP25Data(); @@ -1668,7 +1668,7 @@ int Host::run() #endif // defined(ENABLE_P25) #if defined(ENABLE_NXDN) - if (nxdn != NULL) { + if (nxdn != nullptr) { if (m_nxdnCtrlChannel) { if (!hasTxShutdown) { m_modem->clearNXDNData(); @@ -1698,22 +1698,6 @@ int Host::run() } setState(HOST_STATE_QUIT); - -#if defined(ENABLE_DMR) - if (dmr != NULL) { - delete dmr; - } -#endif // defined(ENABLE_DMR) -#if defined(ENABLE_P25) - if (p25 != NULL) { - delete p25; - } -#endif // defined(ENABLE_P25) -#if defined(ENABLE_NXDN) - if (nxdn != NULL) { - delete nxdn; - } -#endif // defined(ENABLE_NXDN) return EXIT_SUCCESS; } @@ -2063,7 +2047,7 @@ bool Host::createModem() LogInfo("Modem Parameters"); LogInfo(" Port Type: %s", portType.c_str()); - port::IModemPort* modemPort = NULL; + port::IModemPort* modemPort = nullptr; std::transform(portType.begin(), portType.end(), portType.begin(), ::tolower); if (portType == NULL_PORT) { modemPort = new port::ModemNullPort(); @@ -2214,7 +2198,7 @@ bool Host::createModem() bool ret = m_modem->open(); if (!ret) { delete m_modem; - m_modem = NULL; + m_modem = nullptr; return false; } @@ -2316,7 +2300,7 @@ bool Host::createNetwork() bool ret = m_network->open(); if (!ret) { delete m_network; - m_network = NULL; + m_network = nullptr; LogError(LOG_HOST, "failed to initialize traffic networking!"); return false; } @@ -2332,13 +2316,13 @@ bool Host::createNetwork() bool ret = m_remoteControl->open(); if (!ret) { delete m_remoteControl; - m_remoteControl = NULL; + m_remoteControl = nullptr; LogError(LOG_HOST, "failed to initialize remote command networking! remote command control will be unavailable!"); // remote command control failing isn't fatal -- we'll allow this to return normally } } else { - m_remoteControl = NULL; + m_remoteControl = nullptr; } return true; @@ -2350,7 +2334,7 @@ bool Host::createNetwork() /// bool Host::rmtPortModemOpen(Modem* modem) { - assert(m_modemRemotePort != NULL); + assert(m_modemRemotePort != nullptr); bool ret = m_modemRemotePort->open(); if (!ret) @@ -2368,7 +2352,7 @@ bool Host::rmtPortModemOpen(Modem* modem) /// bool Host::rmtPortModemClose(Modem* modem) { - assert(m_modemRemotePort != NULL); + assert(m_modemRemotePort != nullptr); m_modemRemotePort->close(); @@ -2388,7 +2372,7 @@ bool Host::rmtPortModemClose(Modem* modem) /// bool Host::rmtPortModemHandler(Modem* modem, uint32_t ms, modem::RESP_TYPE_DVM rspType, bool rspDblLen, const uint8_t* buffer, uint16_t len) { - assert(m_modemRemotePort != NULL); + assert(m_modemRemotePort != nullptr); if (rspType == RTM_OK && len > 0U) { if (modem->getTrace()) @@ -2440,7 +2424,7 @@ bool Host::rmtPortModemHandler(Modem* modem, uint32_t ms, modem::RESP_TYPE_DVM r /// Mode enumeration to switch the host/modem state to. void Host::setState(uint8_t state) { - assert(m_modem != NULL); + assert(m_modem != nullptr); //if (m_state != state) { // LogDebug(LOG_HOST, "setState, m_state = %u, state = %u", m_state, state); @@ -2473,7 +2457,7 @@ void Host::setState(uint8_t state) case HOST_STATE_LOCKOUT: LogWarning(LOG_HOST, "Mode change, HOST_STATE_LOCKOUT"); - if (m_network != NULL) + if (m_network != nullptr) m_network->enable(false); if (m_state == STATE_DMR && m_duplex && m_modem->hasTX()) { @@ -2490,7 +2474,7 @@ void Host::setState(uint8_t state) case HOST_STATE_ERROR: LogWarning(LOG_HOST, "Mode change, HOST_STATE_ERROR"); - if (m_network != NULL) + if (m_network != nullptr) m_network->enable(false); if (m_state == STATE_DMR && m_duplex && m_modem->hasTX()) { @@ -2505,7 +2489,7 @@ void Host::setState(uint8_t state) break; default: - if (m_network != NULL) + if (m_network != nullptr) m_network->enable(true); if (m_state == STATE_DMR && m_duplex && m_modem->hasTX()) { @@ -2532,26 +2516,26 @@ void Host::setState(uint8_t state) if (m_state == HOST_STATE_QUIT) { ::LogInfoEx(LOG_HOST, "Host is shutting down"); - if (m_modem != NULL) { + if (m_modem != nullptr) { m_modem->close(); delete m_modem; } - if (m_tidLookup != NULL) { + if (m_tidLookup != nullptr) { m_tidLookup->stop(); delete m_tidLookup; } - if (m_ridLookup != NULL) { + if (m_ridLookup != nullptr) { m_ridLookup->stop(); delete m_ridLookup; } - if (m_network != NULL) { + if (m_network != nullptr) { m_network->close(); delete m_network; } - if (m_remoteControl != NULL) { + if (m_remoteControl != nullptr) { m_remoteControl->close(); delete m_remoteControl; } @@ -2570,7 +2554,7 @@ void Host::setState(uint8_t state) void Host::createLockFile(const char* mode) const { FILE* fp = ::fopen(g_lockFile.c_str(), "wt"); - if (fp != NULL) { + if (fp != nullptr) { ::fprintf(fp, "%s\n", mode); ::fclose(fp); } diff --git a/lookups/RSSIInterpolator.cpp b/lookups/RSSIInterpolator.cpp index ef7830ae..8f2662c1 100644 --- a/lookups/RSSIInterpolator.cpp +++ b/lookups/RSSIInterpolator.cpp @@ -66,13 +66,13 @@ RSSIInterpolator::~RSSIInterpolator() bool RSSIInterpolator::load(const std::string& filename) { FILE* fp = ::fopen(filename.c_str(), "rt"); - if (fp == NULL) { + if (fp == nullptr) { LogError(LOG_HOST, "Cannot open the RSSI data file - %s", filename.c_str()); return false; } char buffer[100U]; - while (::fgets(buffer, 100, fp) != NULL) { + while (::fgets(buffer, 100, fp) != nullptr) { if (buffer[0U] == '#') continue; diff --git a/modem/Modem.cpp b/modem/Modem.cpp index eba3519b..335dcfa2 100644 --- a/modem/Modem.cpp +++ b/modem/Modem.cpp @@ -170,15 +170,15 @@ Modem::Modem(port::IModemPort* port, bool duplex, bool rxInvert, bool txInvert, m_adcOverFlowCount(0U), m_dacOverFlowCount(0U), m_modemState(STATE_IDLE), - m_buffer(NULL), + m_buffer(nullptr), m_length(0U), m_rspOffset(0U), m_rspState(RESP_START), m_rspDoubleLength(false), m_rspType(CMD_GET_STATUS), - m_openPortHandler(NULL), - m_closePortHandler(NULL), - m_rspHandler(NULL), + m_openPortHandler(nullptr), + m_closePortHandler(nullptr), + m_rspHandler(nullptr), m_rxDMRData1(1000U, "Modem RX DMR1"), m_rxDMRData2(1000U, "Modem RX DMR2"), m_txDMRData1(1000U, "Modem TX DMR1"), @@ -205,7 +205,7 @@ Modem::Modem(port::IModemPort* port, bool duplex, bool rxInvert, bool txInvert, m_debug(debug), m_playoutTimer(1000U, 0U, packetPlayoutTime) { - assert(port != NULL); + assert(port != nullptr); m_buffer = new uint8_t[BUFFER_LENGTH]; } @@ -456,7 +456,7 @@ void Modem::setRXLevel(float rxLevel) /// void Modem::setResponseHandler(std::function handler) { - assert(handler != NULL); + assert(handler != nullptr); m_rspHandler = handler; } @@ -471,7 +471,7 @@ void Modem::setResponseHandler(std::function handler) /// void Modem::setOpenHandler(std::function handler) { - assert(handler != NULL); + assert(handler != nullptr); m_openPortHandler = handler; } @@ -482,7 +482,7 @@ void Modem::setOpenHandler(std::function handler) /// void Modem::setCloseHandler(std::function handler) { - assert(handler != NULL); + assert(handler != nullptr); m_closePortHandler = handler; } @@ -584,7 +584,7 @@ void Modem::clock(uint32_t ms) RESP_TYPE_DVM type = getResponse(); // do we have a custom response handler? - if (m_rspHandler != NULL) { + if (m_rspHandler != nullptr) { // execute custom response handler if (m_rspHandler(this, ms, type, m_rspDoubleLength, m_buffer, m_length)) { // all logic handled by handler -- return @@ -1002,7 +1002,7 @@ void Modem::close() m_port->close(); // do we have a close port handler? - if (m_closePortHandler != NULL) { + if (m_closePortHandler != nullptr) { m_closePortHandler(this); } } @@ -1014,7 +1014,7 @@ void Modem::close() /// Length of data read from ring buffer. uint32_t Modem::readDMRData1(uint8_t* data) { - assert(data != NULL); + assert(data != nullptr); if (m_rxDMRData1.isEmpty()) return 0U; @@ -1033,7 +1033,7 @@ uint32_t Modem::readDMRData1(uint8_t* data) /// Length of data read from ring buffer. uint32_t Modem::readDMRData2(uint8_t* data) { - assert(data != NULL); + assert(data != nullptr); if (m_rxDMRData2.isEmpty()) return 0U; @@ -1052,7 +1052,7 @@ uint32_t Modem::readDMRData2(uint8_t* data) /// Length of data read from ring buffer. uint32_t Modem::readP25Data(uint8_t* data) { - assert(data != NULL); + assert(data != nullptr); if (m_rxP25Data.isEmpty()) return 0U; @@ -1071,7 +1071,7 @@ uint32_t Modem::readP25Data(uint8_t* data) /// Length of data read from ring buffer. uint32_t Modem::readNXDNData(uint8_t* data) { - assert(data != NULL); + assert(data != nullptr); if (m_rxNXDNData.isEmpty()) return 0U; @@ -1235,7 +1235,7 @@ void Modem::clearNXDNData() void Modem::injectDMRData1(const uint8_t* data, uint32_t length) { #if defined(ENABLE_DMR) - assert(data != NULL); + assert(data != nullptr); assert(length > 0U); if (m_useDFSI) { @@ -1266,7 +1266,7 @@ void Modem::injectDMRData1(const uint8_t* data, uint32_t length) void Modem::injectDMRData2(const uint8_t* data, uint32_t length) { #if defined(ENABLE_DMR) - assert(data != NULL); + assert(data != nullptr); assert(length > 0U); if (m_useDFSI) { @@ -1297,7 +1297,7 @@ void Modem::injectDMRData2(const uint8_t* data, uint32_t length) void Modem::injectP25Data(const uint8_t* data, uint32_t length) { #if defined(ENABLE_P25) - assert(data != NULL); + assert(data != nullptr); assert(length > 0U); if (m_trace) @@ -1323,7 +1323,7 @@ void Modem::injectP25Data(const uint8_t* data, uint32_t length) void Modem::injectNXDNData(const uint8_t* data, uint32_t length) { #if defined(ENABLE_NXDN) - assert(data != NULL); + assert(data != nullptr); assert(length > 0U); if (m_trace) @@ -1350,7 +1350,7 @@ void Modem::injectNXDNData(const uint8_t* data, uint32_t length) bool Modem::writeDMRData1(const uint8_t* data, uint32_t length, bool immediate) { #if defined(ENABLE_DMR) - assert(data != NULL); + assert(data != nullptr); assert(length > 0U); const uint8_t MAX_LENGTH = 40U; @@ -1409,7 +1409,7 @@ bool Modem::writeDMRData1(const uint8_t* data, uint32_t length, bool immediate) bool Modem::writeDMRData2(const uint8_t* data, uint32_t length, bool immediate) { #if defined(ENABLE_DMR) - assert(data != NULL); + assert(data != nullptr); assert(length > 0U); const uint8_t MAX_LENGTH = 40U; @@ -1468,7 +1468,7 @@ bool Modem::writeDMRData2(const uint8_t* data, uint32_t length, bool immediate) bool Modem::writeP25Data(const uint8_t* data, uint32_t length, bool immediate) { #if defined(ENABLE_P25) - assert(data != NULL); + assert(data != nullptr); assert(length > 0U); const uint8_t MAX_LENGTH = 250U; @@ -1527,7 +1527,7 @@ bool Modem::writeP25Data(const uint8_t* data, uint32_t length, bool immediate) bool Modem::writeNXDNData(const uint8_t* data, uint32_t length, bool immediate) { #if defined(ENABLE_NXDN) - assert(data != NULL); + assert(data != nullptr); assert(length > 0U); const uint8_t MAX_LENGTH = 250U; @@ -1612,7 +1612,7 @@ bool Modem::writeDMRStart(bool tx) bool Modem::writeDMRShortLC(const uint8_t* lc) { #if defined(ENABLE_DMR) - assert(lc != NULL); + assert(lc != nullptr); uint8_t buffer[12U]; diff --git a/modem/port/UARTPort.cpp b/modem/port/UARTPort.cpp index 8bb27f29..4491d70c 100644 --- a/modem/port/UARTPort.cpp +++ b/modem/port/UARTPort.cpp @@ -180,7 +180,7 @@ bool UARTPort::open() int UARTPort::read(uint8_t* buffer, uint32_t length) { assert(m_handle != INVALID_HANDLE_VALUE); - assert(buffer != NULL); + assert(buffer != nullptr); uint32_t ptr = 0U; @@ -209,7 +209,7 @@ int UARTPort::read(uint8_t* buffer, uint32_t length) /// Actual length of data written to the serial port. int UARTPort::write(const uint8_t* buffer, uint32_t length) { - assert(buffer != NULL); + assert(buffer != nullptr); if (m_isOpen && m_handle == INVALID_HANDLE_VALUE) return 0; @@ -313,7 +313,7 @@ bool UARTPort::open() /// Actual length of data read from serial port. int UARTPort::read(uint8_t* buffer, uint32_t length) { - assert(buffer != NULL); + assert(buffer != nullptr); assert(m_fd != -1); if (length == 0U) @@ -370,7 +370,7 @@ int UARTPort::read(uint8_t* buffer, uint32_t length) /// Actual length of data written to the serial port. int UARTPort::write(const uint8_t* buffer, uint32_t length) { - assert(buffer != NULL); + assert(buffer != nullptr); if (m_isOpen && m_fd == -1) return 0; @@ -465,7 +465,7 @@ UARTPort::UARTPort(SERIAL_SPEED speed, bool assertRTS) : int UARTPort::readNonblock(uint8_t* buffer, uint32_t length) { assert(m_handle != INVALID_HANDLE_VALUE); - assert(buffer != NULL); + assert(buffer != nullptr); if (length == 0U) return 0; diff --git a/modem/port/UDPPort.cpp b/modem/port/UDPPort.cpp index a06a3896..7fde3e73 100644 --- a/modem/port/UDPPort.cpp +++ b/modem/port/UDPPort.cpp @@ -103,7 +103,7 @@ bool UDPPort::open() /// Actual length of data read from serial port. int UDPPort::read(uint8_t* buffer, uint32_t length) { - assert(buffer != NULL); + assert(buffer != nullptr); assert(length > 0U); uint8_t data[BUFFER_LENGTH]; @@ -147,7 +147,7 @@ int UDPPort::read(uint8_t* buffer, uint32_t length) /// Actual length of data written to the port. int UDPPort::write(const uint8_t* buffer, uint32_t length) { - assert(buffer != NULL); + assert(buffer != nullptr); assert(length > 0U); return m_socket.write(buffer, length, m_addr, m_addrLen) ? int(length) : -1; diff --git a/network/BaseNetwork.cpp b/network/BaseNetwork.cpp index 2aa54bb8..03597ea5 100644 --- a/network/BaseNetwork.cpp +++ b/network/BaseNetwork.cpp @@ -71,9 +71,9 @@ BaseNetwork::BaseNetwork(uint16_t localPort, uint32_t id, bool duplex, bool debu m_status(NET_STAT_INVALID), m_retryTimer(1000U, 10U), m_timeoutTimer(1000U, 60U), - m_buffer(NULL), - m_salt(NULL), - m_streamId(NULL), + m_buffer(nullptr), + m_salt(nullptr), + m_streamId(nullptr), m_p25StreamId(0U), m_nxdnStreamId(0U), m_rxDMRData(4000U, "DMR Net Buffer"), @@ -194,12 +194,12 @@ uint8_t* BaseNetwork::readP25(bool& ret, p25::lc::LC& control, p25::data::LowSpe { if (m_status != NET_STAT_RUNNING && m_status != NET_STAT_MST_RUNNING) { ret = false; - return NULL; + return nullptr; } if (m_rxP25Data.isEmpty()) { ret = false; - return NULL; + return nullptr; } uint8_t length = 0U; @@ -231,7 +231,7 @@ uint8_t* BaseNetwork::readP25(bool& ret, p25::lc::LC& control, p25::data::LowSpe lsd.setLSD1(lsd1); lsd.setLSD2(lsd2); - uint8_t* data = NULL; + uint8_t* data = nullptr; len = m_buffer[23U]; if (duid == p25::P25_DUID_PDU) { data = new uint8_t[length]; @@ -265,12 +265,12 @@ uint8_t* BaseNetwork::readNXDN(bool& ret, nxdn::lc::RTCH& lc, uint32_t& len) { if (m_status != NET_STAT_RUNNING && m_status != NET_STAT_MST_RUNNING) { ret = false; - return NULL; + return nullptr; } if (m_rxNXDNData.isEmpty()) { ret = false; - return NULL; + return nullptr; } uint8_t length = 0U; @@ -290,7 +290,7 @@ uint8_t* BaseNetwork::readNXDN(bool& ret, nxdn::lc::RTCH& lc, uint32_t& len) bool group = (m_buffer[15U] & 0x40U) == 0x40U ? false : true; lc.setGroup(group); - uint8_t* data = NULL; + uint8_t* data = nullptr; len = m_buffer[23U]; if (len <= 24) { @@ -547,7 +547,7 @@ bool BaseNetwork::writeActLog(const char* message) if (m_status != NET_STAT_RUNNING) return false; - assert(message != NULL); + assert(message != nullptr); char buffer[DATA_PACKET_LENGTH]; uint32_t len = ::strlen(message); @@ -571,7 +571,7 @@ bool BaseNetwork::writeDiagLog(const char* message) if (m_status != NET_STAT_RUNNING) return false; - assert(message != NULL); + assert(message != nullptr); char buffer[DATA_PACKET_LENGTH]; uint32_t len = ::strlen(message); @@ -722,7 +722,7 @@ bool BaseNetwork::writeP25LDU1(const uint32_t id, const uint32_t streamId, const if (m_status != NET_STAT_RUNNING && m_status != NET_STAT_MST_RUNNING) return false; - assert(data != NULL); + assert(data != nullptr); p25::dfsi::LC dfsiLC = p25::dfsi::LC(control, lsd); @@ -823,7 +823,7 @@ bool BaseNetwork::writeP25LDU2(const uint32_t id, const uint32_t streamId, const if (m_status != NET_STAT_RUNNING && m_status != NET_STAT_MST_RUNNING) return false; - assert(data != NULL); + assert(data != nullptr); p25::dfsi::LC dfsiLC = p25::dfsi::LC(control, lsd); @@ -970,7 +970,7 @@ bool BaseNetwork::writeP25TSDU(const uint32_t id, const uint32_t streamId, const if (m_status != NET_STAT_RUNNING && m_status != NET_STAT_MST_RUNNING) return false; - assert(data != NULL); + assert(data != nullptr); uint8_t buffer[DATA_PACKET_LENGTH]; ::memset(buffer, 0x00U, DATA_PACKET_LENGTH); @@ -1036,7 +1036,7 @@ bool BaseNetwork::writeP25PDU(const uint32_t id, const uint32_t streamId, const useSecondHeader = true; } - assert(data != NULL); + assert(data != nullptr); uint8_t buffer[DATA_PACKET_LENGTH]; ::memset(buffer, 0x00U, DATA_PACKET_LENGTH); @@ -1093,7 +1093,7 @@ bool BaseNetwork::writeNXDN(const uint32_t id, const uint32_t streamId, const nx if (m_status != NET_STAT_RUNNING && m_status != NET_STAT_MST_RUNNING) return false; - assert(data != NULL); + assert(data != nullptr); uint8_t buffer[DATA_PACKET_LENGTH]; ::memset(buffer, 0x00U, DATA_PACKET_LENGTH); @@ -1135,7 +1135,7 @@ bool BaseNetwork::writeNXDN(const uint32_t id, const uint32_t streamId, const nx /// True, if buffer is written to the network, otherwise false. bool BaseNetwork::write(const uint8_t* data, uint32_t length) { - assert(data != NULL); + assert(data != nullptr); assert(length > 0U); // if (m_debug) diff --git a/network/RemoteControl.cpp b/network/RemoteControl.cpp index 959fb213..6499532a 100644 --- a/network/RemoteControl.cpp +++ b/network/RemoteControl.cpp @@ -155,7 +155,7 @@ RemoteControl::RemoteControl(const std::string& address, uint16_t port, const st m_socket(address, port), m_p25MFId(p25::P25_MFG_STANDARD), m_password(password), - m_passwordHash(NULL), + m_passwordHash(nullptr), m_debug(debug) { assert(!address.empty()); @@ -238,7 +238,7 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25, nx return; } - if (m_passwordHash != NULL) { + if (m_passwordHash != nullptr) { uint8_t hash[32U]; ::memset(hash, 0x00U, 32U); if (::memcmp(m_passwordHash, buffer + 2U, 32U) != 0) { @@ -300,7 +300,7 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25, nx uint32_t portSpeed = uartConfig["speed"].as(115200U); reply += string_format("Host State: %u, DMR: %u, P25: %u, NXDN: %u, Port Type: %s, Modem Port: %s, Port Speed: %u, Proto Ver: %u", host->m_state, - dmr != NULL, p25 != NULL, nxdn != NULL, type.c_str(), modemPort.c_str(), portSpeed, host->m_modem->getVersion()); + dmr != nullptr, p25 != nullptr, nxdn != nullptr, type.c_str(), modemPort.c_str(), portSpeed, host->m_modem->getVersion()); } { @@ -372,7 +372,7 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25, nx } #if defined(ENABLE_DMR) else if (mode == RCD_MODE_OPT_FDMR) { - if (dmr != NULL) { + if (dmr != nullptr) { host->m_fixedMode = true; host->setState(STATE_DMR); reply = string_format("Fixed mode, mode %u", host->m_state); @@ -386,7 +386,7 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25, nx #endif // defined(ENABLE_DMR) #if defined(ENABLE_P25) else if (mode == RCD_MODE_OPT_FP25) { - if (p25 != NULL) { + if (p25 != nullptr) { host->m_fixedMode = true; host->setState(STATE_P25); reply = string_format("Fixed mode, mode %u", host->m_state); @@ -400,7 +400,7 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25, nx #endif // defined(ENABLE_P25) #if defined(ENABLE_NXDN) else if (mode == RCD_MODE_OPT_FNXDN) { - if (p25 != NULL) { + if (p25 != nullptr) { host->m_fixedMode = true; host->setState(STATE_NXDN); reply = string_format("Fixed mode, mode %u", host->m_state); @@ -446,7 +446,7 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25, nx } #if defined(ENABLE_DMR) else if (rcom == RCD_DMR_BEACON) { - if (dmr != NULL) { + if (dmr != nullptr) { if (host->m_dmrBeacons) { g_fireDMRBeacon = true; } @@ -463,7 +463,7 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25, nx #endif // defined(ENABLE_DMR) #if defined(ENABLE_P25) else if (rcom == RCD_P25_CC) { - if (p25 != NULL) { + if (p25 != nullptr) { if (host->m_p25CCData) { g_fireP25Control = true; } @@ -479,7 +479,7 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25, nx } else if (rcom == RCD_P25_CC_FALLBACK) { uint8_t fallback = getArgUInt8(args, 0U); - if (p25 != NULL) { + if (p25 != nullptr) { if (host->m_p25CCData) { p25->trunk()->setConvFallback((fallback == 1U) ? true : false); } @@ -496,7 +496,7 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25, nx #endif // defined(ENABLE_P25) #if defined(ENABLE_DMR) else if (rcom == RCD_DMR_RID_PAGE && argCnt >= 2U) { - if (dmr != NULL) { + if (dmr != nullptr) { uint32_t slotNo = getArgUInt32(args, 0U); uint32_t dstId = getArgUInt32(args, 1U); if (slotNo > 0U && slotNo < 3U) { @@ -519,7 +519,7 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25, nx } } else if (rcom == RCD_DMR_RID_CHECK && argCnt >= 2U) { - if (dmr != NULL) { + if (dmr != nullptr) { uint32_t slotNo = getArgUInt32(args, 0U); uint32_t dstId = getArgUInt32(args, 1U); if (slotNo > 0U && slotNo < 3U) { @@ -542,7 +542,7 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25, nx } } else if (rcom == RCD_DMR_RID_INHIBIT && argCnt >= 2U) { - if (dmr != NULL) { + if (dmr != nullptr) { uint32_t slotNo = getArgUInt32(args, 0U); uint32_t dstId = getArgUInt32(args, 1U); if (slotNo > 0U && slotNo < 3U) { @@ -565,7 +565,7 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25, nx } } else if (rcom == RCD_DMR_RID_UNINHIBIT && argCnt >= 2U) { - if (dmr != NULL) { + if (dmr != nullptr) { uint32_t slotNo = getArgUInt32(args, 0U); uint32_t dstId = getArgUInt32(args, 1U); if (slotNo > 0U && slotNo < 3U) { @@ -590,7 +590,7 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25, nx #endif // defined(ENABLE_DMR) #if defined(ENABLE_P25) else if (rcom == RCD_P25_SET_MFID && argCnt >= 1U) { - if (p25 != NULL) { + if (p25 != nullptr) { uint8_t mfId = getArgUInt8(args, 0U); if (mfId != 0U) { LogMessage(LOG_RCON, "Remote P25, mfgId = $%02X", mfId); @@ -607,7 +607,7 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25, nx } } else if (rcom == RCD_P25_RID_PAGE && argCnt >= 1U) { - if (p25 != NULL) { + if (p25 != nullptr) { uint32_t dstId = getArgUInt32(args, 0U); if (dstId != 0U) { // FIXME @@ -625,7 +625,7 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25, nx } } else if (rcom == RCD_P25_RID_CHECK && argCnt >= 1U) { - if (p25 != NULL) { + if (p25 != nullptr) { uint32_t dstId = getArgUInt32(args, 0U); if (dstId != 0U) { // FIXME @@ -643,7 +643,7 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25, nx } } else if (rcom == RCD_P25_RID_INHIBIT && argCnt >= 1U) { - if (p25 != NULL) { + if (p25 != nullptr) { uint32_t dstId = getArgUInt32(args, 0U); if (dstId != 0U) { // FIXME @@ -661,7 +661,7 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25, nx } } else if (rcom == RCD_P25_RID_UNINHIBIT && argCnt >= 1U) { - if (p25 != NULL) { + if (p25 != nullptr) { uint32_t dstId = getArgUInt32(args, 0U); if (dstId != 0U) { // FIXME @@ -679,7 +679,7 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25, nx } } else if (rcom == RCD_P25_RID_GAQ && argCnt >= 1U) { - if (p25 != NULL) { + if (p25 != nullptr) { uint32_t dstId = getArgUInt32(args, 0U); if (dstId != 0U) { // FIXME @@ -697,7 +697,7 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25, nx } } else if (rcom == RCD_P25_RID_UREG && argCnt >= 1U) { - if (p25 != NULL) { + if (p25 != nullptr) { uint32_t dstId = getArgUInt32(args, 0U); if (dstId != 0U) { // FIXME @@ -715,7 +715,7 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25, nx } } else if (rcom == RCD_P25_RELEASE_GRANTS) { - if (p25 != NULL) { + if (p25 != nullptr) { p25->affiliations().releaseGrant(0, true); } else { @@ -724,7 +724,7 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25, nx } } else if (rcom == RCD_P25_RELEASE_AFFS) { - if (p25 != NULL) { + if (p25 != nullptr) { uint32_t grp = getArgUInt32(args, 0U); if (grp == 0) { @@ -742,9 +742,9 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25, nx #endif // defined(ENABLE_P25) #if defined(ENABLE_DMR) else if (rcom == RCD_DMR_CC_DEDICATED) { - if (dmr != NULL) { + if (dmr != nullptr) { if (host->m_dmrTSCCData) { - if (p25 != NULL) { + if (p25 != nullptr) { reply = CMD_FAILED_STR "Can't enable DMR control channel while P25 is enabled!"; LogError(LOG_RCON, reply.c_str()); } @@ -765,7 +765,7 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25, nx } } else if (rcom == RCD_DMR_CC_BCAST) { - if (dmr != NULL) { + if (dmr != nullptr) { host->m_dmrTSCCData = !host->m_dmrTSCCData; reply = string_format("DMR CC broadcast is %s", host->m_dmrTSCCData ? "enabled" : "disabled"); LogInfoEx(LOG_RCON, reply.c_str()); @@ -778,9 +778,9 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25, nx #endif // defined(ENABLE_DMR) #if defined(ENABLE_P25) else if (rcom == RCD_P25_CC_DEDICATED) { - if (p25 != NULL) { + if (p25 != nullptr) { if (host->m_p25CCData) { - if (dmr != NULL) { + if (dmr != nullptr) { reply = CMD_FAILED_STR "Can't enable P25 control channel while DMR is enabled!"; LogError(LOG_RCON, reply.c_str()); } @@ -805,7 +805,7 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25, nx } } else if (rcom == RCD_P25_CC_BCAST) { - if (p25 != NULL) { + if (p25 != nullptr) { if (host->m_p25CCData) { host->m_p25CtrlBroadcast = !host->m_p25CtrlBroadcast; @@ -835,7 +835,7 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25, nx #if defined(ENABLE_DMR) else if (rcom == RCD_DMR_DEBUG) { if (argCnt < 2U) { - if (dmr != NULL) { + if (dmr != nullptr) { bool debug = dmr->getDebug(); bool verbose = dmr->getVerbose(); reply = string_format("dmr->debug = %u, dmr->verbose = %u", debug, verbose); @@ -848,7 +848,7 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25, nx else { uint8_t debug = getArgUInt8(args, 0U); uint8_t verbose = getArgUInt8(args, 1U); - if (dmr != NULL) { + if (dmr != nullptr) { dmr->setDebugVerbose((debug == 1U) ? true : false, (verbose == 1U) ? true : false); } else { @@ -859,7 +859,7 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25, nx } else if (rcom == RCD_DMR_DUMP_CSBK) { if (argCnt < 1U) { - if (dmr != NULL) { + if (dmr != nullptr) { bool csbkDump = dmr->getCSBKVerbose(); reply = string_format("dmr->dumpCsbkData = %u", csbkDump); } @@ -870,7 +870,7 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25, nx } else { uint8_t verbose = getArgUInt8(args, 0U); - if (dmr != NULL) { + if (dmr != nullptr) { dmr->setCSBKVerbose((verbose == 1U) ? true : false); } else { @@ -883,7 +883,7 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25, nx #if defined(ENABLE_P25) else if (rcom == RCD_P25_DEBUG) { if (argCnt < 2U) { - if (p25 != NULL) { + if (p25 != nullptr) { bool debug = p25->getDebug(); bool verbose = p25->getVerbose(); reply = string_format("p25->debug = %u, p25->verbose = %u", debug, verbose); @@ -896,7 +896,7 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25, nx else { uint8_t debug = getArgUInt8(args, 0U); uint8_t verbose = getArgUInt8(args, 1U); - if (p25 != NULL) { + if (p25 != nullptr) { p25->setDebugVerbose((debug == 1U) ? true : false, (verbose == 1U) ? true : false); } else { @@ -907,7 +907,7 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25, nx } else if (rcom == RCD_P25_DUMP_TSBK) { if (argCnt < 1U) { - if (p25 != NULL) { + if (p25 != nullptr) { bool tsbkDump = p25->trunk()->getTSBKVerbose(); reply = string_format("p25->dumpTsbkData = %u", tsbkDump); } @@ -918,7 +918,7 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25, nx } else { uint8_t verbose = getArgUInt8(args, 0U); - if (p25 != NULL) { + if (p25 != nullptr) { p25->trunk()->setTSBKVerbose((verbose == 1U) ? true : false); } else { @@ -931,7 +931,7 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25, nx #if defined(ENABLE_NXDN) else if (rcom == RCD_NXDN_DEBUG) { if (argCnt < 2U) { - if (nxdn != NULL) { + if (nxdn != nullptr) { bool debug = nxdn->getDebug(); bool verbose = nxdn->getVerbose(); reply = string_format("nxdn->debug = %u, nxdn->verbose = %u", debug, verbose); @@ -944,7 +944,7 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25, nx else { uint8_t debug = getArgUInt8(args, 0U); uint8_t verbose = getArgUInt8(args, 1U); - if (nxdn != NULL) { + if (nxdn != nullptr) { nxdn->setDebugVerbose((debug == 1U) ? true : false, (verbose == 1U) ? true : false); } else { @@ -955,7 +955,7 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25, nx } else if (rcom == RCD_NXDN_DUMP_RCCH) { if (argCnt < 1U) { - if (nxdn != NULL) { + if (nxdn != nullptr) { bool rcchDump = nxdn->getRCCHVerbose(); reply = string_format("nxdn->dumpRcchData = %u", rcchDump); } @@ -966,7 +966,7 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25, nx } else { uint8_t verbose = getArgUInt8(args, 0U); - if (nxdn != NULL) { + if (nxdn != nullptr) { nxdn->setRCCHVerbose((verbose == 1U) ? true : false); } else { @@ -978,14 +978,14 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25, nx #endif // defined(ENABLE_NXDN) #if defined(ENABLE_DMR) else if (rcom == RCD_DMRD_MDM_INJ && argCnt >= 1U) { - if (dmr != NULL) { + if (dmr != nullptr) { uint8_t slot = getArgUInt32(args, 0U); std::string argString = getArgString(args, 1U); const char* fileName = argString.c_str(); - if (fileName != NULL) { + if (fileName != nullptr) { FILE* file = ::fopen(fileName, "r"); - if (file != NULL) { - uint8_t* buffer = NULL; + if (file != nullptr) { + uint8_t* buffer = nullptr; int32_t fileSize = 0; // obtain file size @@ -995,7 +995,7 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25, nx // allocate a buffer and read file buffer = new uint8_t[fileSize]; - if (buffer != NULL) { + if (buffer != nullptr) { int32_t bytes = ::fread(buffer, 1U, fileSize, file); if (bytes == fileSize) { uint8_t sync[dmr::DMR_SYNC_LENGTH_BYTES]; @@ -1048,13 +1048,13 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25, nx #endif // defined(ENABLE_DMR) #if defined(ENABLE_P25) else if (rcom == RCD_P25D_MDM_INJ && argCnt >= 1U) { - if (p25 != NULL) { + if (p25 != nullptr) { std::string argString = getArgString(args, 0U); const char* fileName = argString.c_str(); - if (fileName != NULL) { + if (fileName != nullptr) { FILE* file = ::fopen(fileName, "r"); - if (file != NULL) { - uint8_t* buffer = NULL; + if (file != nullptr) { + uint8_t* buffer = nullptr; int32_t fileSize = 0; // obtain file size @@ -1064,7 +1064,7 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25, nx // allocate a buffer and read file buffer = new uint8_t[fileSize]; - if (buffer != NULL) { + if (buffer != nullptr) { int32_t bytes = ::fread(buffer, 1U, fileSize, file); if (bytes == fileSize) { uint8_t sync[p25::P25_SYNC_LENGTH_BYTES]; @@ -1109,13 +1109,13 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25, nx #endif // defined(ENABLE_P25) #if defined(ENABLE_NXDN) else if (rcom == RCD_NXDD_MDM_INJ && argCnt >= 1U) { - if (p25 != NULL) { + if (p25 != nullptr) { std::string argString = getArgString(args, 0U); const char* fileName = argString.c_str(); - if (fileName != NULL) { + if (fileName != nullptr) { FILE* file = ::fopen(fileName, "r"); - if (file != NULL) { - uint8_t* buffer = NULL; + if (file != nullptr) { + uint8_t* buffer = nullptr; int32_t fileSize = 0; // obtain file size @@ -1125,7 +1125,7 @@ void RemoteControl::process(Host* host, dmr::Control* dmr, p25::Control* p25, nx // allocate a buffer and read file buffer = new uint8_t[fileSize]; - if (buffer != NULL) { + if (buffer != nullptr) { int32_t bytes = ::fread(buffer, 1U, fileSize, file); if (bytes == fileSize) { uint8_t sync[nxdn::NXDN_FSW_BYTES_LENGTH]; diff --git a/network/UDPSocket.cpp b/network/UDPSocket.cpp index 7e126e31..508ab0fa 100644 --- a/network/UDPSocket.cpp +++ b/network/UDPSocket.cpp @@ -185,7 +185,7 @@ bool UDPSocket::open(const uint32_t index, const uint32_t af, const std::string& /// Actual length of data read from remote UDP socket. int UDPSocket::read(uint8_t* buffer, uint32_t length, sockaddr_storage& address, uint32_t& addrLen) { - assert(buffer != NULL); + assert(buffer != nullptr); assert(length > 0U); // Check that the readfrom() won't block @@ -269,7 +269,7 @@ int UDPSocket::read(uint8_t* buffer, uint32_t length, sockaddr_storage& address, /// Actual length of data written to remote UDP socket. bool UDPSocket::write(const uint8_t* buffer, uint32_t length, const sockaddr_storage& address, uint32_t addrLen) { - assert(buffer != NULL); + assert(buffer != nullptr); assert(length > 0U); bool result = false; diff --git a/p25/Control.h b/p25/Control.h index 4e53dc83..a5d4f8b3 100644 --- a/p25/Control.h +++ b/p25/Control.h @@ -142,8 +142,8 @@ namespace p25 uint32_t m_txNAC; uint32_t m_timeout; - std::unique_ptr m_modem; - std::unique_ptr m_network; + modem::Modem* m_modem; + network::BaseNetwork* m_network; bool m_inhibitIllegal; bool m_legacyGroupGrnt; diff --git a/p25/data/DataBlock.cpp b/p25/data/DataBlock.cpp index 123de462..3c30d7a9 100644 --- a/p25/data/DataBlock.cpp +++ b/p25/data/DataBlock.cpp @@ -52,7 +52,7 @@ DataBlock::DataBlock() : m_trellis(), m_fmt(PDU_FMT_CONFIRMED), m_headerSap(0U), - m_data(NULL) + m_data(nullptr) { m_data = new uint8_t[P25_PDU_CONFIRMED_DATA_LENGTH_BYTES]; } @@ -73,8 +73,8 @@ DataBlock::~DataBlock() /// True, if data block was decoded, otherwise false. bool DataBlock::decode(const uint8_t* data, const DataHeader header) { - assert(data != NULL); - assert(m_data != NULL); + assert(data != nullptr); + assert(m_data != nullptr); uint8_t buffer[P25_PDU_CONFIRMED_LENGTH_BYTES]; ::memset(buffer, 0x00U, P25_PDU_CONFIRMED_LENGTH_BYTES); @@ -178,8 +178,8 @@ bool DataBlock::decode(const uint8_t* data, const DataHeader header) /// Buffer to encode data block to. void DataBlock::encode(uint8_t* data) { - assert(data != NULL); - assert(m_data != NULL); + assert(data != nullptr); + assert(m_data != nullptr); if (m_fmt == PDU_FMT_CONFIRMED) { uint8_t buffer[P25_PDU_CONFIRMED_LENGTH_BYTES]; @@ -254,8 +254,8 @@ uint8_t DataBlock::getFormat() const /// void DataBlock::setData(const uint8_t* buffer) { - assert(buffer != NULL); - assert(m_data != NULL); + assert(buffer != nullptr); + assert(m_data != nullptr); if (m_fmt == PDU_FMT_CONFIRMED) { ::memcpy(m_data, buffer, P25_PDU_CONFIRMED_DATA_LENGTH_BYTES); @@ -272,8 +272,8 @@ void DataBlock::setData(const uint8_t* buffer) /// uint32_t DataBlock::getData(uint8_t* buffer) const { - assert(buffer != NULL); - assert(m_data != NULL); + assert(buffer != nullptr); + assert(m_data != nullptr); if (m_fmt == PDU_FMT_CONFIRMED) { ::memcpy(buffer, m_data, P25_PDU_CONFIRMED_DATA_LENGTH_BYTES); diff --git a/p25/data/DataHeader.cpp b/p25/data/DataHeader.cpp index b7446f94..c81853b6 100644 --- a/p25/data/DataHeader.cpp +++ b/p25/data/DataHeader.cpp @@ -87,7 +87,7 @@ DataHeader::~DataHeader() /// True, if PDU data header was decoded, otherwise false. bool DataHeader::decode(const uint8_t* data) { - assert(data != NULL); + assert(data != nullptr); uint8_t header[P25_PDU_HEADER_LENGTH_BYTES]; ::memset(header, 0x00U, P25_PDU_HEADER_LENGTH_BYTES); @@ -174,7 +174,7 @@ bool DataHeader::decode(const uint8_t* data) /// void DataHeader::encode(uint8_t* data) { - assert(data != NULL); + assert(data != nullptr); uint8_t header[P25_PDU_HEADER_LENGTH_BYTES]; ::memset(header, 0x00U, P25_PDU_HEADER_LENGTH_BYTES); diff --git a/p25/data/LowSpeedData.cpp b/p25/data/LowSpeedData.cpp index a43d74d5..3ae5a450 100644 --- a/p25/data/LowSpeedData.cpp +++ b/p25/data/LowSpeedData.cpp @@ -105,7 +105,7 @@ LowSpeedData& LowSpeedData::operator=(const LowSpeedData& data) /// void LowSpeedData::process(uint8_t* data) { - assert(data != NULL); + assert(data != nullptr); uint8_t lsd[4U]; P25Utils::decode(data, lsd, 1546U, 1578U); @@ -148,7 +148,7 @@ void LowSpeedData::process(uint8_t* data) /// void LowSpeedData::encode(uint8_t* data) const { - assert(data != NULL); + assert(data != nullptr); uint8_t lsd[4U]; lsd[0U] = m_lsd1; diff --git a/p25/dfsi/LC.cpp b/p25/dfsi/LC.cpp index 5319dac0..76a886bd 100644 --- a/p25/dfsi/LC.cpp +++ b/p25/dfsi/LC.cpp @@ -749,8 +749,8 @@ bool LC::decodeTSBK(const uint8_t* data) /// void LC::encodeTSBK(uint8_t* data) { - assert(m_tsbk != NULL); - assert(data != NULL); + assert(m_tsbk != nullptr); + assert(data != nullptr); uint8_t tsbk[P25_TSBK_LENGTH_BYTES]; m_tsbk->encode(tsbk, true, true); @@ -807,7 +807,7 @@ void LC::copy(const LC& data) /// True, if decoded, otherwise false. bool LC::decodeStart(const uint8_t* data) { - assert(data != NULL); + assert(data != nullptr); m_rtModeFlag = data[0U]; // RT Mode Flag m_startStopFlag = data[1U]; // Start/Stop Flag @@ -822,7 +822,7 @@ bool LC::decodeStart(const uint8_t* data) /// void LC::encodeStart(uint8_t* data) { - assert(data != NULL); + assert(data != nullptr); uint8_t rawFrame[P25_DFSI_START_LENGTH_BYTES]; ::memset(rawFrame, 0x00U, P25_DFSI_START_LENGTH_BYTES); diff --git a/p25/dfsi/packet/DFSITrunk.cpp b/p25/dfsi/packet/DFSITrunk.cpp index 2c10e379..96c5554f 100644 --- a/p25/dfsi/packet/DFSITrunk.cpp +++ b/p25/dfsi/packet/DFSITrunk.cpp @@ -50,7 +50,7 @@ using namespace p25::dfsi::packet; /// bool DFSITrunk::process(uint8_t* data, uint32_t len, lc::TSBK* preDecodedTSBK) { - assert(data != NULL); + assert(data != nullptr); uint8_t tsbk[P25_TSBK_LENGTH_BYTES]; ::memset(tsbk, 0x00U, P25_TSBK_LENGTH_BYTES); @@ -58,7 +58,7 @@ bool DFSITrunk::process(uint8_t* data, uint32_t len, lc::TSBK* preDecodedTSBK) if (!m_p25->m_control) return false; - if (preDecodedTSBK != NULL) { + if (preDecodedTSBK != nullptr) { return Trunk::process(data + 2U, len, preDecodedTSBK); } else { @@ -118,7 +118,7 @@ void DFSITrunk::writeRF_TSDU_SBF(lc::TSBK* tsbk, bool noNetwork, bool clearBefor if (!m_p25->m_control) return; - assert(tsbk != NULL); + assert(tsbk != nullptr); writeRF_DFSI_Start(P25_DFSI_TYPE_TSBK); @@ -187,7 +187,7 @@ void DFSITrunk::writeRF_TSDU_AMBT(lc::AMBT* ambt, bool clearBeforeWrite) if (!m_p25->m_control) return; - assert(ambt != NULL); + assert(ambt != nullptr); // for now this is ignored... } @@ -198,7 +198,7 @@ void DFSITrunk::writeRF_TSDU_AMBT(lc::AMBT* ambt, bool clearBeforeWrite) /// void DFSITrunk::writeNet_TSDU(lc::TSBK* tsbk) { - assert(tsbk != NULL); + assert(tsbk != nullptr); uint8_t buffer[P25_DFSI_TSBK_FRAME_LENGTH_BYTES + 2U]; ::memset(buffer, 0x00U, P25_DFSI_TSBK_FRAME_LENGTH_BYTES + 2U); @@ -212,7 +212,7 @@ void DFSITrunk::writeNet_TSDU(lc::TSBK* tsbk) m_p25->addFrame(buffer, P25_DFSI_TSBK_FRAME_LENGTH_BYTES + 2U, true); - if (m_network != NULL) + if (m_network != nullptr) m_network->resetP25(); } diff --git a/p25/dfsi/packet/DFSIVoice.cpp b/p25/dfsi/packet/DFSIVoice.cpp index 4d944c2b..bc5137d6 100644 --- a/p25/dfsi/packet/DFSIVoice.cpp +++ b/p25/dfsi/packet/DFSIVoice.cpp @@ -84,7 +84,7 @@ void DFSIVoice::resetNet() /// bool DFSIVoice::process(uint8_t* data, uint32_t len) { - assert(data != NULL); + assert(data != nullptr); bool valid = m_rfDFSILC.decodeNID(data + 2U); @@ -800,11 +800,11 @@ bool DFSIVoice::processNetwork(uint8_t* data, uint32_t len, lc::LC& control, dat /// Flag indicating whether P25 verbose logging is enabled. DFSIVoice::DFSIVoice(Control* p25, network::BaseNetwork* network, bool debug, bool verbose) : Voice(p25, network, debug, verbose), - m_trunk(NULL), + m_trunk(nullptr), m_rfDFSILC(), m_netDFSILC(), - m_dfsiLDU1(NULL), - m_dfsiLDU2(NULL) + m_dfsiLDU1(nullptr), + m_dfsiLDU2(nullptr) { m_dfsiLDU1 = new uint8_t[9U * 25U]; m_dfsiLDU2 = new uint8_t[9U * 25U]; @@ -848,7 +848,7 @@ void DFSIVoice::writeNet_TDU() ::ActivityLog("P25", false, "network end of transmission, %u frames", m_netFrames); } - if (m_network != NULL) + if (m_network != nullptr) m_network->resetP25(); ::memset(m_netLDU1, 0x00U, 9U * 25U); @@ -999,7 +999,7 @@ void DFSIVoice::writeNet_LDU1() // single-channel trunking or voice on control support? if (m_p25->m_control && m_p25->m_voiceOnControl) { if (!m_p25->m_trunk->writeRF_TSDU_Grant(srcId, dstId, serviceOptions, group, false, true)) { - if (m_network != NULL) + if (m_network != nullptr) m_network->resetP25(); ::memset(m_netLDU1, 0x00U, 9U * 25U); diff --git a/p25/edac/Trellis.cpp b/p25/edac/Trellis.cpp index 89ad26ba..d2f5c5f6 100644 --- a/p25/edac/Trellis.cpp +++ b/p25/edac/Trellis.cpp @@ -84,8 +84,8 @@ Trellis::~Trellis() /// True, if decoded, otherwise false. bool Trellis::decode34(const uint8_t* data, uint8_t* payload) { - assert(data != NULL); - assert(payload != NULL); + assert(data != nullptr); + assert(payload != nullptr); int8_t dibits[98U]; deinterleave(data, dibits); @@ -123,8 +123,8 @@ bool Trellis::decode34(const uint8_t* data, uint8_t* payload) /// Trellis symbol bytes. void Trellis::encode34(const uint8_t* payload, uint8_t* data) { - assert(payload != NULL); - assert(data != NULL); + assert(payload != nullptr); + assert(data != nullptr); uint8_t tribits[49U]; bitsToTribits(payload, tribits); @@ -154,8 +154,8 @@ void Trellis::encode34(const uint8_t* payload, uint8_t* data) /// True, if decoded, otherwise false. bool Trellis::decode12(const uint8_t* data, uint8_t* payload) { - assert(data != NULL); - assert(payload != NULL); + assert(data != nullptr); + assert(payload != nullptr); int8_t dibits[98U]; deinterleave(data, dibits); @@ -193,8 +193,8 @@ bool Trellis::decode12(const uint8_t* data, uint8_t* payload) /// Trellis symbol bytes. void Trellis::encode12(const uint8_t* payload, uint8_t* data) { - assert(payload != NULL); - assert(data != NULL); + assert(payload != nullptr); + assert(data != nullptr); uint8_t bits[49U]; bitsToDibits(payload, bits); diff --git a/p25/lc/AMBT.cpp b/p25/lc/AMBT.cpp index 5a23a06c..0a7d4c75 100644 --- a/p25/lc/AMBT.cpp +++ b/p25/lc/AMBT.cpp @@ -56,7 +56,7 @@ AMBT::AMBT() : TSBK() /// True, if TSBK was decoded, otherwise false. bool AMBT::decode(const uint8_t* data, bool rawTSBK) { - assert(data != NULL); + assert(data != nullptr); LogError(LOG_P25, "AMBT::decode(), bad call, not implemented"); @@ -71,7 +71,7 @@ bool AMBT::decode(const uint8_t* data, bool rawTSBK) /// void AMBT::encode(uint8_t* data, bool rawTSBK, bool noTrellis) { - assert(data != NULL); + assert(data != nullptr); LogError(LOG_P25, "AMBT::encode(), bad call, not implemented"); } @@ -111,8 +111,8 @@ ulong64_t AMBT::toValue(const data::DataHeader dataHeader, const uint8_t* pduUse /// True, if TSBK was decoded, otherwise false. bool AMBT::decode(const data::DataHeader dataHeader, const data::DataBlock* blocks, uint8_t* pduUserData) { - assert(blocks != NULL); - assert(pduUserData != NULL); + assert(blocks != nullptr); + assert(pduUserData != nullptr); if (dataHeader.getFormat() != PDU_FMT_AMBT) { LogError(LOG_P25, "TSBK::decodeMBT(), PDU is not a AMBT PDU"); @@ -156,7 +156,7 @@ bool AMBT::decode(const data::DataHeader dataHeader, const data::DataBlock* bloc /// void AMBT::encode(data::DataHeader& dataHeader, uint8_t* pduUserData) { - assert(pduUserData != NULL); + assert(pduUserData != nullptr); dataHeader.setFormat(PDU_FMT_AMBT); dataHeader.setMFId(m_mfId); diff --git a/p25/lc/LC.cpp b/p25/lc/LC.cpp index fd2ba5c0..8e91a180 100644 --- a/p25/lc/LC.cpp +++ b/p25/lc/LC.cpp @@ -76,7 +76,7 @@ LC::LC() : m_encryptOverride(false), m_tsbkVendorSkip(false), m_callTimer(0U), - m_mi(NULL) + m_mi(nullptr) { m_mi = new uint8_t[P25_MI_LENGTH_BYTES]; ::memset(m_mi, 0x00U, P25_MI_LENGTH_BYTES); @@ -96,9 +96,9 @@ LC::LC(const LC& data) : LC() /// LC::~LC() { - if (m_mi != NULL) { + if (m_mi != nullptr) { delete[] m_mi; - m_mi = NULL; + m_mi = nullptr; } } @@ -123,7 +123,7 @@ LC& LC::operator=(const LC& data) /// True, if HDU was decoded, otherwise false. bool LC::decodeHDU(const uint8_t* data) { - assert(data != NULL); + assert(data != nullptr); // deinterleave uint8_t rs[P25_HDU_LENGTH_BYTES + 1U]; @@ -196,8 +196,8 @@ bool LC::decodeHDU(const uint8_t* data) /// void LC::encodeHDU(uint8_t * data) { - assert(data != NULL); - assert(m_mi != NULL); + assert(data != nullptr); + assert(m_mi != nullptr); uint8_t rs[P25_HDU_LENGTH_BYTES]; ::memset(rs, 0x00U, P25_HDU_LENGTH_BYTES); @@ -244,7 +244,7 @@ void LC::encodeHDU(uint8_t * data) /// True, if LDU1 was decoded, otherwise false. bool LC::decodeLDU1(const uint8_t * data) { - assert(data != NULL); + assert(data != nullptr); uint8_t rs[P25_LDU_LC_LENGTH_BYTES + 1U]; @@ -298,7 +298,7 @@ bool LC::decodeLDU1(const uint8_t * data) /// void LC::encodeLDU1(uint8_t * data) { - assert(data != NULL); + assert(data != nullptr); uint8_t rs[P25_LDU_LC_LENGTH_BYTES]; ::memset(rs, 0x00U, P25_LDU_LC_LENGTH_BYTES); @@ -348,7 +348,7 @@ void LC::encodeLDU1(uint8_t * data) /// True, if LDU2 was decoded, otherwise false. bool LC::decodeLDU2(const uint8_t * data) { - assert(data != NULL); + assert(data != nullptr); uint8_t rs[P25_LDU_LC_LENGTH_BYTES + 1U]; @@ -425,8 +425,8 @@ bool LC::decodeLDU2(const uint8_t * data) /// void LC::encodeLDU2(uint8_t * data) { - assert(data != NULL); - assert(m_mi != NULL); + assert(data != nullptr); + assert(m_mi != nullptr); uint8_t rs[P25_LDU_LC_LENGTH_BYTES]; ::memset(rs, 0x00U, P25_LDU_LC_LENGTH_BYTES); @@ -479,7 +479,7 @@ void LC::encodeLDU2(uint8_t * data) /// void LC::setMI(const uint8_t* mi) { - assert(mi != NULL); + assert(mi != nullptr); ::memcpy(m_mi, mi, P25_MI_LENGTH_BYTES); } @@ -488,7 +488,7 @@ void LC::setMI(const uint8_t* mi) /// void LC::getMI(uint8_t* mi) const { - assert(mi != NULL); + assert(mi != nullptr); ::memcpy(mi, m_mi, P25_MI_LENGTH_BYTES); } diff --git a/p25/lc/TDULC.cpp b/p25/lc/TDULC.cpp index 464e2a9d..dd558dd4 100644 --- a/p25/lc/TDULC.cpp +++ b/p25/lc/TDULC.cpp @@ -141,7 +141,7 @@ TDULC& TDULC::operator=(const TDULC& data) /// True, if TDULC was decoded, otherwise false. bool TDULC::decode(const uint8_t* data) { - assert(data != NULL); + assert(data != nullptr); // deinterleave uint8_t rs[P25_TDULC_LENGTH_BYTES + 1U]; @@ -182,7 +182,7 @@ bool TDULC::decode(const uint8_t* data) /// True, if TDULC was decoded, otherwise false. void TDULC::encode(uint8_t * data) { - assert(data != NULL); + assert(data != nullptr); uint8_t rs[P25_TDULC_LENGTH_BYTES]; ::memset(rs, 0x00U, P25_TDULC_LENGTH_BYTES); diff --git a/p25/lc/TSBK.cpp b/p25/lc/TSBK.cpp index b3a4ff04..5c0efbd1 100644 --- a/p25/lc/TSBK.cpp +++ b/p25/lc/TSBK.cpp @@ -47,7 +47,7 @@ bool TSBK::m_warnCRC = true; bool TSBK::m_warnCRC = false; #endif -uint8_t *TSBK::m_siteCallsign = NULL; +uint8_t *TSBK::m_siteCallsign = nullptr; SiteData TSBK::m_siteData = SiteData(); // --------------------------------------------------------------------------- @@ -107,7 +107,7 @@ TSBK::TSBK() : m_rs(), m_trellis() { - if (m_siteCallsign == NULL) { + if (m_siteCallsign == nullptr) { m_siteCallsign = new uint8_t[P25_MOT_CALLSIGN_LENGTH_BYTES]; ::memset(m_siteCallsign, 0x00U, P25_MOT_CALLSIGN_LENGTH_BYTES); } @@ -131,7 +131,7 @@ TSBK::~TSBK() /// Callsign. void TSBK::setCallsign(std::string callsign) { - if (m_siteCallsign == NULL) { + if (m_siteCallsign == nullptr) { m_siteCallsign = new uint8_t[P25_MOT_CALLSIGN_LENGTH_BYTES]; ::memset(m_siteCallsign, 0x00U, P25_MOT_CALLSIGN_LENGTH_BYTES); } @@ -204,8 +204,8 @@ std::unique_ptr TSBK::fromValue(const ulong64_t tsbkValue) /// True, if TSBK was decoded, otherwise false. bool TSBK::decode(const uint8_t* data, uint8_t* tsbk, bool rawTSBK) { - assert(data != NULL); - assert(tsbk != NULL); + assert(data != nullptr); + assert(tsbk != nullptr); if (rawTSBK) { ::memcpy(tsbk, data, P25_TSBK_LENGTH_BYTES); @@ -275,8 +275,8 @@ bool TSBK::decode(const uint8_t* data, uint8_t* tsbk, bool rawTSBK) /// void TSBK::encode(uint8_t* data, const uint8_t* tsbk, bool rawTSBK, bool noTrellis) { - assert(data != NULL); - assert(tsbk != NULL); + assert(data != nullptr); + assert(tsbk != nullptr); uint8_t outTsbk[P25_TSBK_LENGTH_BYTES]; ::memset(outTsbk, 0x00U, P25_TSBK_LENGTH_BYTES); diff --git a/p25/lc/tsbk/TSBKFactory.cpp b/p25/lc/tsbk/TSBKFactory.cpp index dc257bdf..b4d9d7b8 100644 --- a/p25/lc/tsbk/TSBKFactory.cpp +++ b/p25/lc/tsbk/TSBKFactory.cpp @@ -73,7 +73,7 @@ TSBKFactory::~TSBKFactory() /// True, if TSBK was decoded, otherwise false. std::unique_ptr TSBKFactory::createTSBK(const uint8_t* data, bool rawTSBK) { - assert(data != NULL); + assert(data != nullptr); uint8_t tsbk[P25_TSBK_LENGTH_BYTES + 1U]; ::memset(tsbk, 0x00U, P25_TSBK_LENGTH_BYTES); @@ -120,11 +120,11 @@ std::unique_ptr TSBKFactory::createTSBK(const uint8_t* data, bool rawTSBK) } if (!ret) - return NULL; + return nullptr; } catch (...) { Utils::dump(2U, "P25, decoding excepted with input data", tsbk, P25_TSBK_LENGTH_BYTES); - return NULL; + return nullptr; } } @@ -160,7 +160,7 @@ std::unique_ptr TSBKFactory::createTSBK(const uint8_t* data, bool rawTSBK) } if (mfId == P25_MFG_MOT) { - return NULL; + return nullptr; } else { mfId = tsbk[1U]; @@ -178,7 +178,7 @@ std::unique_ptr TSBKFactory::createTSBK(const uint8_t* data, bool rawTSBK) } if (mfId == P25_MFG_DVM) { - return NULL; + return nullptr; } else { mfId = tsbk[1U]; @@ -238,7 +238,7 @@ std::unique_ptr TSBKFactory::createTSBK(const uint8_t* data, bool rawTSBK) break; } - return NULL; + return nullptr; } /// @@ -249,16 +249,16 @@ std::unique_ptr TSBKFactory::createTSBK(const uint8_t* data, bool rawTSBK) /// std::unique_ptr TSBKFactory::createAMBT(const data::DataHeader dataHeader, const data::DataBlock* blocks) { - assert(blocks != NULL); + assert(blocks != nullptr); if (dataHeader.getFormat() != PDU_FMT_AMBT) { LogError(LOG_P25, "TSBKFactory::createAMBT(), PDU is not a AMBT PDU"); - return NULL; + return nullptr; } if (dataHeader.getBlocksToFollow() == 0U) { LogError(LOG_P25, "TSBKFactory::createAMBT(), PDU contains no data blocks"); - return NULL; + return nullptr; } uint8_t lco = dataHeader.getAMBTOpcode(); // LCO @@ -293,7 +293,7 @@ std::unique_ptr TSBKFactory::createAMBT(const data::DataHeader dataHeader, } if (mfId == P25_MFG_MOT) { - return NULL; + return nullptr; } else { mfId = dataHeader.getMFId(); @@ -325,7 +325,7 @@ std::unique_ptr TSBKFactory::createAMBT(const data::DataHeader dataHeader, break; } - return NULL; + return nullptr; } // --------------------------------------------------------------------------- @@ -341,11 +341,11 @@ std::unique_ptr TSBKFactory::createAMBT(const data::DataHeader dataHeader, /// std::unique_ptr TSBKFactory::decode(TSBK* tsbk, const uint8_t* data, bool rawTSBK) { - assert(tsbk != NULL); - assert(data != NULL); + assert(tsbk != nullptr); + assert(data != nullptr); if (!tsbk->decode(data, rawTSBK)) { - return NULL; + return nullptr; } return std::unique_ptr(tsbk); @@ -360,11 +360,11 @@ std::unique_ptr TSBKFactory::decode(TSBK* tsbk, const uint8_t* data, bool /// std::unique_ptr TSBKFactory::decode(AMBT* ambt, const data::DataHeader dataHeader, const data::DataBlock* blocks) { - assert(ambt != NULL); - assert(blocks != NULL); + assert(ambt != nullptr); + assert(blocks != nullptr); if (!ambt->decodeMBT(dataHeader, blocks)) { - return NULL; + return nullptr; } return std::unique_ptr(ambt); diff --git a/p25/packet/Data.cpp b/p25/packet/Data.cpp index ddbf5075..45c78f22 100644 --- a/p25/packet/Data.cpp +++ b/p25/packet/Data.cpp @@ -79,7 +79,7 @@ void Data::resetRF() /// bool Data::process(uint8_t* data, uint32_t len) { - assert(data != NULL); + assert(data != nullptr); // decode the NID bool valid = m_p25->m_nid.decode(data + 2U); @@ -513,7 +513,7 @@ bool Data::hasLLIdFNEReg(uint32_t llId) const /// void Data::writeRF_PDU_User(data::DataHeader dataHeader, const uint8_t* pduUserData, bool clearBeforeWrite) { - assert(pduUserData != NULL); + assert(pduUserData != nullptr); uint32_t bitLength = ((dataHeader.getBlocksToFollow() + 1U) * P25_PDU_FEC_LENGTH_BITS) + P25_PREAMBLE_LENGTH_BITS; uint32_t offset = P25_PREAMBLE_LENGTH_BITS; @@ -612,23 +612,23 @@ Data::Data(Control* p25, network::BaseNetwork* network, bool dumpPDUData, bool r m_p25(p25), m_network(network), m_prevRfState(RS_RF_LISTENING), - m_rfData(NULL), + m_rfData(nullptr), m_rfDataHeader(), m_rfSecondHeader(), m_rfUseSecondHeader(false), m_rfDataBlockCnt(0U), - m_rfPDU(NULL), + m_rfPDU(nullptr), m_rfPDUCount(0U), m_rfPDUBits(0U), - m_netData(NULL), + m_netData(nullptr), m_netDataHeader(), m_netSecondHeader(), m_netUseSecondHeader(false), m_netDataOffset(0U), m_netDataBlockCnt(0U), - m_netPDU(NULL), + m_netPDU(nullptr), m_netPDUCount(0U), - m_pduUserData(NULL), + m_pduUserData(nullptr), m_pduUserDataLength(0U), m_fneRegTable(), m_connQueueTable(), @@ -674,9 +674,9 @@ Data::~Data() /// void Data::writeNetwork(const uint8_t currentBlock, const uint8_t *data, uint32_t len) { - assert(data != NULL); + assert(data != nullptr); - if (m_network == NULL) + if (m_network == nullptr) return; if (m_p25->m_rfTimeout.isRunning() && m_p25->m_rfTimeout.hasExpired()) @@ -694,7 +694,7 @@ void Data::writeNetwork(const uint8_t currentBlock, const uint8_t *data, uint32_ /// This simply takes data packed into m_rfPDU and transmits it. void Data::writeRF_PDU(const uint8_t* pdu, uint32_t bitLength, bool noNulls) { - assert(pdu != NULL); + assert(pdu != nullptr); assert(bitLength > 0U); uint8_t data[P25_MAX_PDU_COUNT * P25_LDU_FRAME_LENGTH_BYTES + 2U]; diff --git a/p25/packet/Trunk.cpp b/p25/packet/Trunk.cpp index 24673bd7..b6b93f45 100644 --- a/p25/packet/Trunk.cpp +++ b/p25/packet/Trunk.cpp @@ -123,7 +123,7 @@ using namespace p25::packet; } #define RF_TO_WRITE_NET(OSP) \ - if (m_network != NULL) { \ + if (m_network != nullptr) { \ uint8_t _buf[P25_TSDU_FRAME_LENGTH_BYTES]; \ writeNet_TSDU_From_RF(OSP, _buf); \ writeNetworkRF(OSP, _buf, true); \ @@ -153,7 +153,7 @@ const uint8_t CONV_FALLBACK_PACKET_DELAY = 8U; /// bool Trunk::process(uint8_t* data, uint32_t len, lc::TSBK* preDecodedTSBK) { - assert(data != NULL); + assert(data != nullptr); if (!m_p25->m_control) return false; @@ -909,7 +909,7 @@ void Trunk::writeAdjSSNetwork() return; } - if (m_network != NULL) { + if (m_network != nullptr) { if (m_verbose) { LogMessage(LOG_NET, P25_TSDU_STR ", TSBK_OSP_ADJ_STS_BCAST (Adjacent Site Status Broadcast), network announce, sysId = $%03X, rfss = $%02X, site = $%02X, chId = %u, chNo = %u, svcClass = $%02X", m_p25->m_siteData.sysId(), m_p25->m_siteData.rfssId(), m_p25->m_siteData.siteId(), m_p25->m_siteData.channelId(), m_p25->m_siteData.channelNo(), m_p25->m_siteData.serviceClass()); @@ -942,7 +942,7 @@ void Trunk::writeAdjSSNetwork() void Trunk::clock(uint32_t ms) { if (m_p25->m_control) { - if (m_p25->m_network != NULL) { + if (m_p25->m_network != nullptr) { if (m_p25->m_network->isHandlingChGrants() && m_p25->m_siteData.netActive()) { bool grp = true; uint32_t srcId = 0U; @@ -1184,7 +1184,7 @@ Trunk::Trunk(Control* p25, network::BaseNetwork* network, bool dumpTSBKData, boo m_patchSuperGroup(0xFFFFU), m_verifyAff(false), m_verifyReg(false), - m_rfMBF(NULL), + m_rfMBF(nullptr), m_mbfCnt(0U), m_mbfIdenCnt(0U), m_mbfAdjSSCnt(0U), @@ -1240,9 +1240,9 @@ Trunk::~Trunk() void Trunk::writeNetworkRF(lc::TSBK* tsbk, const uint8_t* data, bool autoReset) { assert(tsbk != nullptr); - assert(data != NULL); + assert(data != nullptr); - if (m_network == NULL) + if (m_network == nullptr) return; if (m_p25->m_rfTimeout.isRunning() && m_p25->m_rfTimeout.hasExpired()) @@ -1267,9 +1267,9 @@ void Trunk::writeNetworkRF(lc::TSBK* tsbk, const uint8_t* data, bool autoReset) /// void Trunk::writeNetworkRF(lc::TDULC& tduLc, const uint8_t* data, bool autoReset) { - assert(data != NULL); + assert(data != nullptr); - if (m_network == NULL) + if (m_network == nullptr) return; if (m_p25->m_rfTimeout.isRunning() && m_p25->m_rfTimeout.hasExpired()) @@ -1506,7 +1506,7 @@ void Trunk::writeNet_TDULC(lc::TDULC lc) ::ActivityLog("P25", false, "network end of transmission, %u frames", m_p25->m_voice->m_netFrames); } - if (m_network != NULL) + if (m_network != nullptr) m_network->resetP25(); m_p25->m_netTimeout.stop(); @@ -1668,7 +1668,7 @@ void Trunk::writeNet_TSDU(lc::TSBK* tsbk) m_p25->addFrame(buffer, P25_TSDU_FRAME_LENGTH_BYTES + 2U, true); - if (m_network != NULL) + if (m_network != nullptr) m_network->resetP25(); } @@ -2090,7 +2090,7 @@ void Trunk::queueRF_TSBK_Ctrl(uint8_t lco) break; } - if (tsbk != NULL) { + if (tsbk != nullptr) { tsbk->setLastBlock(true); // always set last block // are we transmitting CC as a multi-block? @@ -2125,7 +2125,7 @@ bool Trunk::writeRF_TSDU_Grant(uint32_t srcId, uint32_t dstId, uint8_t serviceOp } // do we have a network connection and are we handling grants at the network? - if (m_p25->m_network != NULL) { + if (m_p25->m_network != nullptr) { if (m_p25->m_network->isHandlingChGrants() && m_p25->m_siteData.netActive() && !skipNetCheck) { return m_p25->m_network->writeGrantReq(grp, srcId, dstId); } @@ -2639,8 +2639,8 @@ bool Trunk::writeNet_TSDU_Call_Term(uint32_t srcId, uint32_t dstId) /// void Trunk::writeNet_TSDU_From_RF(lc::TSBK* tsbk, uint8_t* data) { - assert(tsbk != NULL); - assert(data != NULL); + assert(tsbk != nullptr); + assert(data != nullptr); ::memset(data, 0x00U, P25_TSDU_FRAME_LENGTH_BYTES); @@ -2687,7 +2687,7 @@ void Trunk::denialInhibit(uint32_t srcId) /// void Trunk::addIdleBits(uint8_t* data, uint32_t length, bool b1, bool b2) { - assert(data != NULL); + assert(data != nullptr); for (uint32_t ss0Pos = P25_SS0_START; ss0Pos < length; ss0Pos += (P25_SS_INCREMENT * 5U)) { uint32_t ss1Pos = ss0Pos + 1U; diff --git a/p25/packet/Voice.cpp b/p25/packet/Voice.cpp index c754f56c..2ee2f4f8 100644 --- a/p25/packet/Voice.cpp +++ b/p25/packet/Voice.cpp @@ -101,7 +101,7 @@ void Voice::resetNet() /// bool Voice::process(uint8_t* data, uint32_t len) { - assert(data != NULL); + assert(data != nullptr); // Decode the NID bool valid = m_p25->m_nid.decode(data + 2U); @@ -873,10 +873,10 @@ Voice::Voice(Control* p25, network::BaseNetwork* network, bool debug, bool verbo m_rfLSD(), m_netLSD(), m_dfsiLC(), - m_netLDU1(NULL), - m_netLDU2(NULL), + m_netLDU1(nullptr), + m_netLDU2(nullptr), m_lastDUID(P25_DUID_TDU), - m_lastIMBE(NULL), + m_lastIMBE(nullptr), m_hadVoice(false), m_lastRejectId(0U), m_silenceThreshold(DEFAULT_SILENCE_THRESHOLD), @@ -911,9 +911,9 @@ Voice::~Voice() /// void Voice::writeNetwork(const uint8_t *data, uint8_t duid) { - assert(data != NULL); + assert(data != nullptr); - if (m_network == NULL) + if (m_network == nullptr) return; if (m_p25->m_rfTimeout.isRunning() && m_p25->m_rfTimeout.hasExpired()) @@ -998,7 +998,7 @@ void Voice::writeNet_TDU() ::ActivityLog("P25", false, "network end of transmission, %u frames", m_netFrames); } - if (m_network != NULL) + if (m_network != nullptr) m_network->resetP25(); ::memset(m_netLDU1, 0x00U, 9U * 25U); @@ -1168,7 +1168,7 @@ void Voice::writeNet_LDU1() (m_netLC.getPriority() & 0x07U); // Priority if (!m_p25->m_trunk->writeRF_TSDU_Grant(srcId, dstId, serviceOptions, group, false, true)) { - if (m_network != NULL) + if (m_network != nullptr) m_network->resetP25(); ::memset(m_netLDU1, 0x00U, 9U * 25U); diff --git a/remote/RemoteCommand.cpp b/remote/RemoteCommand.cpp index 81a92bbc..7b82fb88 100644 --- a/remote/RemoteCommand.cpp +++ b/remote/RemoteCommand.cpp @@ -97,7 +97,7 @@ void usage(const char* message, const char* arg) ::fprintf(stdout, __PROG_NAME__ " %s (built %s)\r\n", __VER__, __BUILD__); ::fprintf(stdout, "Copyright (c) 2017-2022 Bryan Biedenkapp, N2PLL and DVMProject (https://github.com/dvmproject) Authors.\n"); ::fprintf(stdout, "Portions Copyright (c) 2015-2021 by Jonathan Naylor, G4KLX and others\n\n"); - if (message != NULL) { + if (message != nullptr) { ::fprintf(stderr, "%s: ", g_progExe.c_str()); ::fprintf(stderr, message, arg); ::fprintf(stderr, "\n\n"); @@ -123,7 +123,7 @@ int checkArgs(int argc, char* argv[]) // iterate through arguments for (i = 1; i <= argc; i++) { - if (argv[i] == NULL) { + if (argv[i] == nullptr) { break; } @@ -176,7 +176,7 @@ int checkArgs(int argc, char* argv[]) exit(EXIT_SUCCESS); } else if (IS("-h")) { - usage(NULL, NULL); + usage(nullptr, nullptr); if (argc == 2) exit(EXIT_SUCCESS); } @@ -198,7 +198,7 @@ int checkArgs(int argc, char* argv[]) int main(int argc, char** argv) { - if (argv[0] != NULL && *argv[0] != 0) + if (argv[0] != nullptr && *argv[0] != 0) g_progExe = std::string(argv[0]); if (argc < 2) {