[LoRaWAN] Cppcheck fixes

This commit is contained in:
jgromes 2025-01-18 18:14:56 +01:00
parent 1324b53f7b
commit 64f0f5028b
3 changed files with 5 additions and 4 deletions

View file

@ -2417,7 +2417,8 @@ void LoRaWANNode::postprocessMacLinkAdr(uint8_t* ack, uint8_t cLen) {
int16_t LoRaWANNode::getMacCommand(uint8_t cid, LoRaWANMacCommand_t* cmd) {
for(size_t i = 0; i < RADIOLIB_LORAWAN_NUM_MAC_COMMANDS; i++) {
if(MacTable[i].cid == cid) {
memcpy(reinterpret_cast<void*>(cmd), (void*)&MacTable[i], sizeof(LoRaWANMacCommand_t));
LoRaWANMacCommand_t* cmdPtr = const_cast<LoRaWANMacCommand_t*>(&MacTable[i]);
memcpy(reinterpret_cast<void*>(cmd), reinterpret_cast<void*>(cmdPtr), sizeof(LoRaWANMacCommand_t));
return(RADIOLIB_ERR_NONE);
}
}

View file

@ -82,7 +82,7 @@ void RadioLibAES128::generateCMAC(const uint8_t* in, size_t len, uint8_t* cmac)
delete[] buff;
}
bool RadioLibAES128::verifyCMAC(uint8_t* in, size_t len, const uint8_t* cmac) {
bool RadioLibAES128::verifyCMAC(const uint8_t* in, size_t len, const uint8_t* cmac) {
uint8_t cmacReal[RADIOLIB_AES128_BLOCK_SIZE];
this->generateCMAC(in, len, cmacReal);
for(size_t i = 0; i < RADIOLIB_AES128_BLOCK_SIZE; i++) {
@ -192,7 +192,7 @@ void RadioLibAES128::blockLeftshift(uint8_t* dst, const uint8_t* src) {
}
void RadioLibAES128::generateSubkeys(uint8_t* key1, uint8_t* key2) {
uint8_t const_Zero[] = {
const uint8_t const_Zero[] = {
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00,

View file

@ -142,7 +142,7 @@ class RadioLibAES128 {
\param cmac CMAC to verify.
\returns True if valid, false otherwise.
*/
bool verifyCMAC(uint8_t* in, size_t len, const uint8_t* cmac);
bool verifyCMAC(const uint8_t* in, size_t len, const uint8_t* cmac);
private:
uint8_t* keyPtr = nullptr;