Skip to content

Commit

Permalink
[LoRaWAN] Cppcheck fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jgromes committed Jan 18, 2025
1 parent 1324b53 commit 64f0f50
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/protocols/LoRaWAN/LoRaWAN.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/utils/Cryptography.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/utils/Cryptography.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 64f0f50

Please sign in to comment.