Furi: cleanup crash use (#3175)

* Furi: optional message in furi_crash and furi_halt
* Consistent furi_crash use
* UnitTests: crash instead of assert
* furi: check: fixed macro for default arg
* unit_tests: fixed crashes everywhere
* lib: infrared: fixed PVS warnings
* furi: eliminated __FURI_ASSERT_MESSAGE_FLAG
* Furi: update check.h docs
* Furi: add check.h usage note
* Docs: grammar

---------

Co-authored-by: hedger <hedger@nanode.su>
This commit is contained in:
あく
2023-10-31 19:40:32 +09:00
committed by GitHub
parent c8180747db
commit 9af81ce8d0
37 changed files with 159 additions and 107 deletions
+2 -2
View File
@@ -28,7 +28,7 @@ void bt_test_alloc() {
}
void bt_test_free() {
furi_assert(bt_test);
furi_check(bt_test);
free(bt_test->nvm_ram_buff_ref);
free(bt_test->nvm_ram_buff_dut);
bt_keys_storage_free(bt_test->bt_keys_storage);
@@ -89,7 +89,7 @@ static void bt_test_keys_remove_test_file() {
}
MU_TEST(bt_test_keys_storage_serial_profile) {
furi_assert(bt_test);
furi_check(bt_test);
bt_test_keys_remove_test_file();
bt_test_keys_storage_profile();
@@ -27,7 +27,7 @@ static void infrared_test_alloc() {
}
static void infrared_test_free() {
furi_assert(test);
furi_check(test);
infrared_free_decoder(test->decoder_handler);
infrared_free_encoder(test->encoder_handler);
flipper_format_free(test->ff);
+1 -1
View File
@@ -34,7 +34,7 @@ static void nfc_test_alloc() {
}
static void nfc_test_free() {
furi_assert(nfc_test);
furi_check(nfc_test);
furi_record_close(RECORD_STORAGE);
free(nfc_test);
@@ -122,7 +122,7 @@ Nfc* nfc_alloc() {
}
void nfc_free(Nfc* instance) {
furi_assert(instance);
furi_check(instance);
free(instance);
}
@@ -165,9 +165,9 @@ NfcError nfc_iso14443a_listener_set_col_res_data(
uint8_t uid_len,
uint8_t* atqa,
uint8_t sak) {
furi_assert(instance);
furi_assert(uid);
furi_assert(atqa);
furi_check(instance);
furi_check(uid);
furi_check(atqa);
nfc_prepare_col_res_data(instance, uid, uid_len, atqa, sak);
@@ -176,7 +176,7 @@ NfcError nfc_iso14443a_listener_set_col_res_data(
static int32_t nfc_worker_poller(void* context) {
Nfc* instance = context;
furi_assert(instance->callback);
furi_check(instance->callback);
instance->state = NfcStateReady;
NfcCommand command = NfcCommandContinue;
@@ -196,7 +196,7 @@ static int32_t nfc_worker_poller(void* context) {
}
static void nfc_worker_listener_pass_col_res(Nfc* instance, uint8_t* rx_data, uint16_t rx_bits) {
furi_assert(instance->col_res_status != Iso14443_3aColResStatusDone);
furi_check(instance->col_res_status != Iso14443_3aColResStatusDone);
BitBuffer* tx_buffer = bit_buffer_alloc(NFC_MAX_BUFFER_SIZE);
bool processed = false;
@@ -255,7 +255,7 @@ static void nfc_worker_listener_pass_col_res(Nfc* instance, uint8_t* rx_data, ui
static int32_t nfc_worker_listener(void* context) {
Nfc* instance = context;
furi_assert(instance->callback);
furi_check(instance->callback);
NfcMessage message = {};
@@ -295,17 +295,17 @@ static int32_t nfc_worker_listener(void* context) {
}
void nfc_start(Nfc* instance, NfcEventCallback callback, void* context) {
furi_assert(instance);
furi_assert(instance->worker_thread == NULL);
furi_check(instance);
furi_check(instance->worker_thread == NULL);
if(instance->mode == NfcModeListener) {
furi_assert(listener_queue == NULL);
furi_check(listener_queue == NULL);
// Check that poller didn't start
furi_assert(poller_queue == NULL);
furi_check(poller_queue == NULL);
} else {
furi_assert(poller_queue == NULL);
furi_check(poller_queue == NULL);
// Check that poller is started after listener
furi_assert(listener_queue);
furi_check(listener_queue);
}
instance->callback = callback;
@@ -334,8 +334,8 @@ void nfc_start(Nfc* instance, NfcEventCallback callback, void* context) {
}
void nfc_stop(Nfc* instance) {
furi_assert(instance);
furi_assert(instance->worker_thread);
furi_check(instance);
furi_check(instance->worker_thread);
if(instance->mode == NfcModeListener) {
NfcMessage message = {.type = NfcMessageTypeAbort};
@@ -361,10 +361,10 @@ void nfc_stop(Nfc* instance) {
// Called from worker thread
NfcError nfc_listener_tx(Nfc* instance, const BitBuffer* tx_buffer) {
furi_assert(instance);
furi_assert(poller_queue);
furi_assert(listener_queue);
furi_assert(tx_buffer);
furi_check(instance);
furi_check(poller_queue);
furi_check(listener_queue);
furi_check(tx_buffer);
NfcMessage message = {};
message.type = NfcMessageTypeTx;
@@ -382,11 +382,11 @@ NfcError nfc_iso14443a_listener_tx_custom_parity(Nfc* instance, const BitBuffer*
NfcError
nfc_poller_trx(Nfc* instance, const BitBuffer* tx_buffer, BitBuffer* rx_buffer, uint32_t fwt) {
furi_assert(instance);
furi_assert(tx_buffer);
furi_assert(rx_buffer);
furi_assert(poller_queue);
furi_assert(listener_queue);
furi_check(instance);
furi_check(tx_buffer);
furi_check(rx_buffer);
furi_check(poller_queue);
furi_check(listener_queue);
UNUSED(fwt);
NfcError error = NfcErrorNone;
@@ -396,7 +396,7 @@ NfcError
message.data.data_bits = bit_buffer_get_size(tx_buffer);
bit_buffer_write_bytes(tx_buffer, message.data.data, bit_buffer_get_size_bytes(tx_buffer));
// Tx
furi_assert(furi_message_queue_put(listener_queue, &message, FuriWaitForever) == FuriStatusOk);
furi_check(furi_message_queue_put(listener_queue, &message, FuriWaitForever) == FuriStatusOk);
// Rx
FuriStatus status = furi_message_queue_get(poller_queue, &message, 50);