Apply suggestions from code review
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
This commit is contained in:
parent
4de6656bc4
commit
2082b01a3c
@ -45,15 +45,16 @@ class UdpNameSync : public Usermod {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 == strcmp(mainseg.name, segmentName)) return; //same name, do nothing
|
const char* curName = mainseg.name ? mainseg.name : "";
|
||||||
|
if (strcmp(curName, segmentName) == 0) return; // same name, do nothing
|
||||||
|
|
||||||
notifierUdp.beginPacket(broadcastIp, udpPort);
|
notifierUdp.beginPacket(broadcastIp, udpPort);
|
||||||
DEBUG_PRINT(F("UdpNameSync: saving segment name "));
|
DEBUG_PRINT(F("UdpNameSync: saving segment name "));
|
||||||
DEBUG_PRINTLN(mainseg.name);
|
DEBUG_PRINTLN(mainseg.name);
|
||||||
byte length = strlen(mainseg.name);
|
size_t length = strlen(mainseg.name);
|
||||||
strlcpy(segmentName, mainseg.name, length+1);
|
strlcpy(segmentName, mainseg.name, sizeof(segmentName));
|
||||||
strlcpy((char *)&udpOut[1], segmentName, length+1);
|
strlcpy((char *)&udpOut[1], segmentName, sizeof(udpOut) - 1); // leave room for header byte
|
||||||
notifierUdp.write(udpOut, length + 2);
|
notifierUdp.write(udpOut, 2 + strnlen((char *)&udpOut[1], sizeof(udpOut) - 1));
|
||||||
notifierUdp.endPacket();
|
notifierUdp.endPacket();
|
||||||
DEBUG_PRINT(F("UdpNameSync: Sent segment name : "));
|
DEBUG_PRINT(F("UdpNameSync: Sent segment name : "));
|
||||||
DEBUG_PRINTLN(segmentName);
|
DEBUG_PRINTLN(segmentName);
|
||||||
|
|||||||
@ -68,7 +68,7 @@ bool UsermodManager::onEspNowMessage(uint8_t* sender, uint8_t* payload, uint8_t
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
bool UsermodManager::onUdpPacket(uint8_t* payload, uint8_t len) {
|
bool UsermodManager::onUdpPacket(uint8_t* payload, size_t len) {
|
||||||
for (auto mod = _usermod_table_begin; mod < _usermod_table_end; ++mod) if ((*mod)->onUdpPacket(payload, len)) return true;
|
for (auto mod = _usermod_table_begin; mod < _usermod_table_end; ++mod) if ((*mod)->onUdpPacket(payload, len)) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user