Skip to content

Commit

Permalink
implement some changes suggested by CLang; fix writePeerStatus() not …
Browse files Browse the repository at this point in the history
…using RTP_END_OF_CALL_SEQ;
  • Loading branch information
gatekeep committed Jul 22, 2024
1 parent 9f4aa44 commit 4f55a89
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 19 deletions.
8 changes: 4 additions & 4 deletions src/common/dmr/SiteData.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ namespace dmr
m_siteId = DMRUtils::siteId(siteId, siteModel);

// parId clamping
if (parId == 0U)
parId = 3U;
if (parId > 3U)
parId = 3U;
if (m_parId == 0U)
m_parId = 3U;
if (m_parId > 3U)
m_parId = 3U;
}

/**
Expand Down
22 changes: 13 additions & 9 deletions src/common/network/BaseNetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ bool BaseNetwork::writeActLog(const char* message)
char buffer[DATA_PACKET_LENGTH];
uint32_t len = ::strlen(message);

::strcpy(buffer + 11U, message);
::strncpy(buffer + 11U, message, len);

return writeMaster({ NET_FUNC::TRANSFER, NET_SUBFUNC::TRANSFER_SUBFUNC_ACTIVITY }, (uint8_t*)buffer, (uint32_t)len + 12U,
return writeMaster({ NET_FUNC::TRANSFER, NET_SUBFUNC::TRANSFER_SUBFUNC_ACTIVITY }, (uint8_t*)buffer, (uint32_t)len + 11U,
RTP_END_OF_CALL_SEQ, 0U, false, m_useAlternatePortForDiagnostics);
}

Expand All @@ -141,9 +141,9 @@ bool BaseNetwork::writeDiagLog(const char* message)
char buffer[DATA_PACKET_LENGTH];
uint32_t len = ::strlen(message);

::strcpy(buffer + 11U, message);
::strncpy(buffer + 11U, message, len);

return writeMaster({ NET_FUNC::TRANSFER, NET_SUBFUNC::TRANSFER_SUBFUNC_DIAG }, (uint8_t*)buffer, (uint32_t)len + 12U,
return writeMaster({ NET_FUNC::TRANSFER, NET_SUBFUNC::TRANSFER_SUBFUNC_DIAG }, (uint8_t*)buffer, (uint32_t)len + 11U,
RTP_END_OF_CALL_SEQ, 0U, false, m_useAlternatePortForDiagnostics);
}

Expand All @@ -166,10 +166,10 @@ bool BaseNetwork::writePeerStatus(json::object obj)
char buffer[DATA_PACKET_LENGTH];
uint32_t len = ::strlen(json.c_str());

::strcpy(buffer + 11U, json.c_str());
::strncpy(buffer + 11U, json.c_str(), len);

return writeMaster({ NET_FUNC::TRANSFER, NET_SUBFUNC::TRANSFER_SUBFUNC_STATUS }, (uint8_t*)buffer, (uint32_t)len + 12U,
0U, 0U, false, m_useAlternatePortForDiagnostics);
return writeMaster({ NET_FUNC::TRANSFER, NET_SUBFUNC::TRANSFER_SUBFUNC_STATUS }, (uint8_t*)buffer, (uint32_t)len + 11U,
RTP_END_OF_CALL_SEQ, 0U, false, m_useAlternatePortForDiagnostics);
}

/* Writes a group affiliation to the network. */
Expand Down Expand Up @@ -699,10 +699,14 @@ UInt8Array BaseNetwork::createDMR_Message(uint32_t& length, const uint32_t strea
buffer[14U] = 0U; // Control Bits

// Individual slot disabling
if (slotNo == 1U && !m_slot1)
if (slotNo == 1U && !m_slot1) {
delete[] buffer;
return nullptr;
if (slotNo == 2U && !m_slot2)
}
if (slotNo == 2U && !m_slot2) {
delete[] buffer;
return nullptr;
}

buffer[15U] = slotNo == 1U ? 0x00U : 0x80U; // Slot Number

Expand Down
2 changes: 1 addition & 1 deletion src/common/network/udp/Socket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ std::string Socket::getLocalAddress()

int err = -1;
if ((err = getifaddrs(&ifaddr)) == -1) {
LogError(LOG_NET, "Cannot retreive system network interfaces");
LogError(LOG_NET, "Cannot retreive system network interfaces, err: %d", err);
return "0.0.0.0";
}

Expand Down
2 changes: 0 additions & 2 deletions src/common/p25/lc/TSBK.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,6 @@ bool TSBK::decode(const uint8_t* data, uint8_t* payload, bool rawTSBK)
if ((tsbk[P25_TSBK_LENGTH_BYTES - 2U] != 0x00U) && (tsbk[P25_TSBK_LENGTH_BYTES - 1U] != 0x00U)) {
LogWarning(LOG_P25, "TSBK::decode(), failed CRC CCITT-162 check");
}

ret = true; // ignore CRC error
}
else {
LogError(LOG_P25, "TSBK::decode(), failed CRC CCITT-162 check");
Expand Down
7 changes: 4 additions & 3 deletions src/fne/HostFNE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -565,9 +565,10 @@ bool HostFNE::createMasterNetwork()
LogError(LOG_HOST, "failed to initialize diagnostic log networking!");
m_useAlternatePortForDiagnostics = false; // this isn't fatal so just disable alternate port
}

if (encrypted) {
m_diagNetwork->setPresharedKey(presharedKey);
else {
if (encrypted) {
m_diagNetwork->setPresharedKey(presharedKey);
}
}
}

Expand Down

0 comments on commit 4f55a89

Please sign in to comment.