mirror of
https://github.com/meshtastic/firmware.git
synced 2025-08-03 04:15:53 +00:00
Don't use assert() with side effects in a couple more places (#7009)
* Don't use assert for Lock * Don't use assert for MQTT messages * Split assert in getMacAddr to always run the function --------- Co-authored-by: Ben Meadors <benmmeadors@gmail.com>
This commit is contained in:
parent
a1a5503fe9
commit
4e6418b635
@ -9,17 +9,23 @@ namespace concurrency
|
|||||||
Lock::Lock() : handle(xSemaphoreCreateBinary())
|
Lock::Lock() : handle(xSemaphoreCreateBinary())
|
||||||
{
|
{
|
||||||
assert(handle);
|
assert(handle);
|
||||||
assert(xSemaphoreGive(handle));
|
if (xSemaphoreGive(handle) == false) {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Lock::lock()
|
void Lock::lock()
|
||||||
{
|
{
|
||||||
assert(xSemaphoreTake(handle, portMAX_DELAY));
|
if (xSemaphoreTake(handle, portMAX_DELAY) == false) {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Lock::unlock()
|
void Lock::unlock()
|
||||||
{
|
{
|
||||||
assert(xSemaphoreGive(handle));
|
if (xSemaphoreGive(handle) == false) {
|
||||||
|
abort();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
Lock::Lock() {}
|
Lock::Lock() {}
|
||||||
|
@ -763,7 +763,10 @@ void MQTT::onSend(const meshtastic_MeshPacket &mp_encrypted, const meshtastic_Me
|
|||||||
}
|
}
|
||||||
entry->topic = std::move(topic);
|
entry->topic = std::move(topic);
|
||||||
entry->envBytes.assign(bytes, numBytes);
|
entry->envBytes.assign(bytes, numBytes);
|
||||||
assert(mqttQueue.enqueue(entry, 0));
|
if (mqttQueue.enqueue(entry, 0) == false) {
|
||||||
|
LOG_CRIT("Failed to add a message to mqttQueue!");
|
||||||
|
abort();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,9 +56,11 @@ void updateBatteryLevel(uint8_t level) {}
|
|||||||
void getMacAddr(uint8_t *dmac)
|
void getMacAddr(uint8_t *dmac)
|
||||||
{
|
{
|
||||||
#if defined(CONFIG_IDF_TARGET_ESP32C6) && defined(CONFIG_SOC_IEEE802154_SUPPORTED)
|
#if defined(CONFIG_IDF_TARGET_ESP32C6) && defined(CONFIG_SOC_IEEE802154_SUPPORTED)
|
||||||
assert(esp_base_mac_addr_get(dmac) == ESP_OK);
|
auto res = esp_base_mac_addr_get(dmac);
|
||||||
|
assert(res == ESP_OK);
|
||||||
#else
|
#else
|
||||||
assert(esp_efuse_mac_get_default(dmac) == ESP_OK);
|
auto res = esp_efuse_mac_get_default(dmac);
|
||||||
|
assert(res == ESP_OK);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user