Skip to content

Commit 5e235f7

Browse files
committed
Missed some nullptrs.
1 parent 9264866 commit 5e235f7

18 files changed

+141
-141
lines changed

NXDNGateway/APRSWriter.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2010-2014,2016,2017,2018,2020 by Jonathan Naylor G4KLX
2+
* Copyright (C) 2010-2014,2016,2017,2018,2020,2025 by Jonathan Naylor G4KLX
33
*
44
* This program is free software; you can redistribute it and/or modify
55
* it under the terms of the GNU General Public License as published by
@@ -104,7 +104,7 @@ bool CAPRSWriter::open()
104104
return false;
105105
}
106106

107-
::gps_stream(&m_gpsdData, WATCH_ENABLE | WATCH_JSON, NULL);
107+
::gps_stream(&m_gpsdData, WATCH_ENABLE | WATCH_JSON, nullptr);
108108

109109
LogMessage("Connected to GPSD");
110110
}
@@ -123,7 +123,7 @@ bool CAPRSWriter::open()
123123

124124
void CAPRSWriter::write(const char* data)
125125
{
126-
assert(data != NULL);
126+
assert(data != nullptr);
127127

128128
if (m_debug)
129129
LogDebug("APRS ==> %s", data);
@@ -160,7 +160,7 @@ void CAPRSWriter::close()
160160

161161
#if defined(USE_GPSD)
162162
if (m_gpsdEnabled) {
163-
::gps_stream(&m_gpsdData, WATCH_DISABLE, NULL);
163+
::gps_stream(&m_gpsdData, WATCH_DISABLE, nullptr);
164164
::gps_close(&m_gpsdData);
165165
}
166166
#endif
@@ -241,7 +241,7 @@ void CAPRSWriter::sendIdFrameMobile()
241241
return;
242242

243243
#if GPSD_API_MAJOR_VERSION >= 7
244-
if (::gps_read(&m_gpsdData, NULL, 0) <= 0)
244+
if (::gps_read(&m_gpsdData, nullptr, 0) <= 0)
245245
return;
246246
#else
247247
if (::gps_read(&m_gpsdData) <= 0)

NXDNGateway/Conf.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,15 @@ CConf::~CConf()
100100
bool CConf::read()
101101
{
102102
FILE* fp = ::fopen(m_file.c_str(), "rt");
103-
if (fp == NULL) {
103+
if (fp == nullptr) {
104104
::fprintf(stderr, "Couldn't open the .ini file - %s\n", m_file.c_str());
105105
return false;
106106
}
107107

108108
SECTION section = SECTION::NONE;
109109

110110
char buffer[BUFFER_SIZE];
111-
while (::fgets(buffer, BUFFER_SIZE, fp) != NULL) {
111+
while (::fgets(buffer, BUFFER_SIZE, fp) != nullptr) {
112112
if (buffer[0U] == '#')
113113
continue;
114114

@@ -138,11 +138,11 @@ bool CConf::read()
138138
}
139139

140140
char* key = ::strtok(buffer, " \t=\r\n");
141-
if (key == NULL)
141+
if (key == nullptr)
142142
continue;
143143

144-
char* value = ::strtok(NULL, "\r\n");
145-
if (value == NULL)
144+
char* value = ::strtok(nullptr, "\r\n");
145+
if (value == nullptr)
146146
continue;
147147

148148
// Remove quotes from the value
@@ -154,7 +154,7 @@ bool CConf::read()
154154
char *p;
155155

156156
// if value is not quoted, remove after # (to make comment)
157-
if ((p = strchr(value, '#')) != NULL)
157+
if ((p = strchr(value, '#')) != nullptr)
158158
*p = '\0';
159159

160160
// remove trailing tab/space
@@ -257,10 +257,10 @@ bool CConf::read()
257257
m_networkNXDN2DMRPort = (unsigned short)::atoi(value);
258258
else if (::strcmp(key, "Static") == 0) {
259259
char* p = ::strtok(value, ",\r\n");
260-
while (p != NULL) {
260+
while (p != nullptr) {
261261
unsigned short tg = (unsigned short)::atoi(p);
262262
m_networkStatic.push_back(tg);
263-
p = ::strtok(NULL, ",\r\n");
263+
p = ::strtok(nullptr, ",\r\n");
264264
}
265265
} else if (::strcmp(key, "RFHangTime") == 0)
266266
m_networkRFHangTime = (unsigned int)::atoi(value);

NXDNGateway/GPSHandler.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ const unsigned int NXDN_DATA_MAX_LENGTH = 16U * NXDN_DATA_LENGTH;
3232
CGPSHandler::CGPSHandler(const std::string& callsign, const std::string& suffix, CAPRSWriter* writer) :
3333
m_callsign(callsign),
3434
m_writer(writer),
35-
m_data(NULL),
35+
m_data(nullptr),
3636
m_length(0U),
3737
m_source(),
3838
m_suffix(suffix)
3939
{
4040
assert(!callsign.empty());
41-
assert(writer != NULL);
41+
assert(writer != nullptr);
4242

4343
m_data = new unsigned char[NXDN_DATA_MAX_LENGTH];
4444

@@ -58,7 +58,7 @@ void CGPSHandler::processHeader(const std::string& source)
5858

5959
void CGPSHandler::processData(const unsigned char* data)
6060
{
61-
assert(data != NULL);
61+
assert(data != nullptr);
6262

6363
::memcpy(m_data + m_length, data + 1U, NXDN_DATA_LENGTH);
6464
m_length += NXDN_DATA_LENGTH;
@@ -93,7 +93,7 @@ bool CGPSHandler::processIcom()
9393
if (::memcmp(m_data + 1U, "$G", 2U) != 0)
9494
return false;
9595

96-
if (::strchr((char*)(m_data + 1U), '*') == NULL)
96+
if (::strchr((char*)(m_data + 1U), '*') == nullptr)
9797
return false;
9898

9999
// From here onwards we have something that looks like Icom GPS data
@@ -111,15 +111,15 @@ bool CGPSHandler::processIcom()
111111
::memset(pRMC, 0x00U, 20U * sizeof(char*));
112112
unsigned int nRMC = 0U;
113113

114-
char* p = NULL;
114+
char* p = nullptr;
115115
char* d = (char*)(m_data + 1U);
116-
while ((p = ::strtok(d, ",\r\n")) != NULL && nRMC < 20U) {
116+
while ((p = ::strtok(d, ",\r\n")) != nullptr && nRMC < 20U) {
117117
pRMC[nRMC++] = p;
118-
d = NULL;
118+
d = nullptr;
119119
}
120120

121121
// Is there any position data?
122-
if (pRMC[3U] == NULL || pRMC[4U] == NULL || pRMC[5U] == NULL || pRMC[6U] == NULL || ::strlen(pRMC[3U]) == 0U || ::strlen(pRMC[4U]) == 0U || ::strlen(pRMC[5U]) == 0 || ::strlen(pRMC[6U]) == 0)
122+
if (pRMC[3U] == nullptr || pRMC[4U] == nullptr || pRMC[5U] == nullptr || pRMC[6U] == nullptr || ::strlen(pRMC[3U]) == 0U || ::strlen(pRMC[4U]) == 0U || ::strlen(pRMC[5U]) == 0 || ::strlen(pRMC[6U]) == 0)
123123
return true;
124124

125125
// Is it a valid GPS fix?
@@ -136,7 +136,7 @@ bool CGPSHandler::processIcom()
136136
}
137137

138138
char output[300U];
139-
if (pRMC[7U] != NULL && pRMC[8U] != NULL && ::strlen(pRMC[7U]) > 0U && ::strlen(pRMC[8U]) > 0U) {
139+
if (pRMC[7U] != nullptr && pRMC[8U] != nullptr && ::strlen(pRMC[7U]) > 0U && ::strlen(pRMC[8U]) > 0U) {
140140
int bearing = ::atoi(pRMC[8U]);
141141
int speed = ::atoi(pRMC[7U]);
142142

NXDNGateway/IcomNetwork.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ bool CIcomNetwork::open()
5858

5959
bool CIcomNetwork::write(const unsigned char* data, unsigned int length)
6060
{
61-
assert(data != NULL);
61+
assert(data != nullptr);
6262

6363
unsigned char buffer[110U];
6464
::memset(buffer, 0x00U, 110U);
@@ -92,7 +92,7 @@ bool CIcomNetwork::write(const unsigned char* data, unsigned int length)
9292

9393
unsigned int CIcomNetwork::read(unsigned char* data)
9494
{
95-
assert(data != NULL);
95+
assert(data != nullptr);
9696

9797
unsigned char buffer[BUFFER_LENGTH];
9898
sockaddr_storage addr;

NXDNGateway/KenwoodNetwork.cpp

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2009-2014,2016,2018,2020 by Jonathan Naylor G4KLX
2+
* Copyright (C) 2009-2014,2016,2018,2020,2025 by Jonathan Naylor G4KLX
33
*
44
* This program is free software; you can redistribute it and/or modify
55
* it under the terms of the GNU General Public License as published by
@@ -45,7 +45,7 @@ m_seen1(false),
4545
m_seen2(false),
4646
m_seen3(false),
4747
m_seen4(false),
48-
m_sacch(NULL),
48+
m_sacch(nullptr),
4949
m_sessionId(1U),
5050
m_seqNo(0U),
5151
m_ssrc(0U),
@@ -106,7 +106,7 @@ bool CKenwoodNetwork::open()
106106

107107
bool CKenwoodNetwork::write(const unsigned char* data, unsigned int length)
108108
{
109-
assert(data != NULL);
109+
assert(data != nullptr);
110110

111111
switch (data[0U]) {
112112
case 0x81U: // Voice header or trailer
@@ -122,7 +122,7 @@ bool CKenwoodNetwork::write(const unsigned char* data, unsigned int length)
122122

123123
bool CKenwoodNetwork::processIcomVoiceHeader(const unsigned char* inData)
124124
{
125-
assert(inData != NULL);
125+
assert(inData != nullptr);
126126

127127
unsigned char outData[30U];
128128
::memset(outData, 0x00U, 30U);
@@ -166,7 +166,7 @@ bool CKenwoodNetwork::processIcomVoiceHeader(const unsigned char* inData)
166166

167167
bool CKenwoodNetwork::processIcomVoiceData(const unsigned char* inData)
168168
{
169-
assert(inData != NULL);
169+
assert(inData != nullptr);
170170

171171
unsigned char outData[40U], temp[10U];
172172
::memset(outData, 0x00U, 40U);
@@ -246,7 +246,7 @@ bool CKenwoodNetwork::processIcomVoiceData(const unsigned char* inData)
246246

247247
bool CKenwoodNetwork::writeRTPVoiceHeader(const unsigned char* data)
248248
{
249-
assert(data != NULL);
249+
assert(data != nullptr);
250250

251251
unsigned char buffer[50U];
252252
::memset(buffer, 0x00U, 50U);
@@ -293,7 +293,7 @@ bool CKenwoodNetwork::writeRTPVoiceHeader(const unsigned char* data)
293293

294294
bool CKenwoodNetwork::writeRTPVoiceTrailer(const unsigned char* data)
295295
{
296-
assert(data != NULL);
296+
assert(data != nullptr);
297297

298298
unsigned char buffer[50U];
299299
::memset(buffer, 0x00U, 50U);
@@ -339,7 +339,7 @@ bool CKenwoodNetwork::writeRTPVoiceTrailer(const unsigned char* data)
339339

340340
bool CKenwoodNetwork::writeRTPVoiceData(const unsigned char* data)
341341
{
342-
assert(data != NULL);
342+
assert(data != nullptr);
343343

344344
unsigned char buffer[60U];
345345
::memset(buffer, 0x00U, 60U);
@@ -397,7 +397,7 @@ bool CKenwoodNetwork::writeRTCPStart()
397397
m_startUSecs = st.wMilliseconds * 1000U;
398398
#else
399399
struct timeval tod;
400-
::gettimeofday(&tod, NULL);
400+
::gettimeofday(&tod, nullptr);
401401

402402
m_startSecs = tod.tv_sec;
403403
m_startUSecs = tod.tv_usec;
@@ -530,7 +530,7 @@ bool CKenwoodNetwork::writeRTCPHang()
530530

531531
unsigned int CKenwoodNetwork::read(unsigned char* data)
532532
{
533-
assert(data != NULL);
533+
assert(data != nullptr);
534534

535535
unsigned char dummy[BUFFER_LENGTH];
536536
readRTCP(dummy);
@@ -556,7 +556,7 @@ unsigned int CKenwoodNetwork::read(unsigned char* data)
556556

557557
unsigned int CKenwoodNetwork::readRTP(unsigned char* data)
558558
{
559-
assert(data != NULL);
559+
assert(data != nullptr);
560560

561561
unsigned char buffer[BUFFER_LENGTH];
562562

@@ -582,7 +582,7 @@ unsigned int CKenwoodNetwork::readRTP(unsigned char* data)
582582

583583
unsigned int CKenwoodNetwork::readRTCP(unsigned char* data)
584584
{
585-
assert(data != NULL);
585+
assert(data != nullptr);
586586

587587
unsigned char buffer[BUFFER_LENGTH];
588588

@@ -639,7 +639,7 @@ void CKenwoodNetwork::clock(unsigned int ms)
639639

640640
unsigned int CKenwoodNetwork::processKenwoodVoiceHeader(unsigned char* inData)
641641
{
642-
assert(inData != NULL);
642+
assert(inData != nullptr);
643643

644644
unsigned char outData[50U], temp[20U];
645645
::memset(outData, 0x00U, 50U);
@@ -696,7 +696,7 @@ unsigned int CKenwoodNetwork::processKenwoodVoiceHeader(unsigned char* inData)
696696

697697
unsigned int CKenwoodNetwork::processKenwoodVoiceData(unsigned char* inData)
698698
{
699-
assert(inData != NULL);
699+
assert(inData != nullptr);
700700

701701
unsigned char outData[50U], temp[20U];
702702
::memset(outData, 0x00U, 50U);
@@ -846,7 +846,7 @@ unsigned long CKenwoodNetwork::getTimeStamp() const
846846
timeStamp += ms * 80U;
847847
#else
848848
struct timeval tod;
849-
::gettimeofday(&tod, NULL);
849+
::gettimeofday(&tod, nullptr);
850850

851851
unsigned int ss = tod.tv_sec;
852852
unsigned int ms = tod.tv_usec / 1000U;
@@ -860,7 +860,7 @@ unsigned long CKenwoodNetwork::getTimeStamp() const
860860

861861
unsigned int CKenwoodNetwork::processKenwoodVoiceLateEntry(unsigned char* inData)
862862
{
863-
assert(inData != NULL);
863+
assert(inData != nullptr);
864864

865865
unsigned char sacch[4U];
866866
sacch[0U] = inData[12U];

NXDNGateway/Log.cpp

+9-9
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ static std::string m_filePath;
3737
static std::string m_fileRoot;
3838
static bool m_fileRotate = true;
3939

40-
static FILE* m_fpLog = NULL;
40+
static FILE* m_fpLog = nullptr;
4141
static bool m_daemon = false;
4242

4343
static unsigned int m_displayLevel = 2U;
@@ -59,10 +59,10 @@ static bool logOpenRotate()
5959
struct tm* tm = ::gmtime(&now);
6060

6161
if (tm->tm_mday == m_tm.tm_mday && tm->tm_mon == m_tm.tm_mon && tm->tm_year == m_tm.tm_year) {
62-
if (m_fpLog != NULL)
62+
if (m_fpLog != nullptr)
6363
return true;
6464
} else {
65-
if (m_fpLog != NULL)
65+
if (m_fpLog != nullptr)
6666
::fclose(m_fpLog);
6767
}
6868

@@ -73,7 +73,7 @@ static bool logOpenRotate()
7373
::sprintf(filename, "%s/%s-%04d-%02d-%02d.log", m_filePath.c_str(), m_fileRoot.c_str(), tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday);
7474
#endif
7575

76-
if ((m_fpLog = ::fopen(filename, "a+t")) != NULL) {
76+
if ((m_fpLog = ::fopen(filename, "a+t")) != nullptr) {
7777
status = true;
7878

7979
#if !defined(_WIN32) && !defined(_WIN64)
@@ -94,7 +94,7 @@ static bool logOpenNoRotate()
9494
if (m_fileLevel == 0U)
9595
return true;
9696

97-
if (m_fpLog != NULL)
97+
if (m_fpLog != nullptr)
9898
return true;
9999

100100
char filename[200U];
@@ -104,7 +104,7 @@ static bool logOpenNoRotate()
104104
::sprintf(filename, "%s/%s.log", m_filePath.c_str(), m_fileRoot.c_str());
105105
#endif
106106

107-
if ((m_fpLog = ::fopen(filename, "a+t")) != NULL) {
107+
if ((m_fpLog = ::fopen(filename, "a+t")) != nullptr) {
108108
status = true;
109109

110110
#if !defined(_WIN32) && !defined(_WIN64)
@@ -141,13 +141,13 @@ bool LogInitialise(bool daemon, const std::string& filePath, const std::string&
141141

142142
void LogFinalise()
143143
{
144-
if (m_fpLog != NULL)
144+
if (m_fpLog != nullptr)
145145
::fclose(m_fpLog);
146146
}
147147

148148
void Log(unsigned int level, const char* fmt, ...)
149149
{
150-
assert(fmt != NULL);
150+
assert(fmt != nullptr);
151151

152152
char buffer[501U];
153153
#if defined(_WIN32) || defined(_WIN64)
@@ -157,7 +157,7 @@ void Log(unsigned int level, const char* fmt, ...)
157157
::sprintf(buffer, "%c: %04u-%02u-%02u %02u:%02u:%02u.%03u ", LEVELS[level], st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond, st.wMilliseconds);
158158
#else
159159
struct timeval now;
160-
::gettimeofday(&now, NULL);
160+
::gettimeofday(&now, nullptr);
161161

162162
struct tm* tm = ::gmtime(&now.tv_sec);
163163

0 commit comments

Comments
 (0)