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:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ bool infrared_scene_edit_button_select_on_event(void* context, SceneManagerEvent
|
||||
} else if(edit_mode == InfraredEditModeDelete) {
|
||||
scene_manager_next_scene(scene_manager, InfraredSceneEditDelete);
|
||||
} else {
|
||||
furi_assert(0);
|
||||
furi_crash();
|
||||
}
|
||||
consumed = true;
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ void infrared_scene_edit_delete_on_enter(void* context) {
|
||||
infrared_remote_get_name(remote),
|
||||
infrared_remote_get_signal_count(remote));
|
||||
} else {
|
||||
furi_assert(0);
|
||||
furi_crash();
|
||||
}
|
||||
|
||||
dialog_ex_set_text(dialog_ex, infrared->text_store[0], 64, 31, AlignCenter, AlignCenter);
|
||||
@@ -101,7 +101,7 @@ bool infrared_scene_edit_delete_on_event(void* context, SceneManagerEvent event)
|
||||
success = infrared_remote_remove(remote);
|
||||
app_state->current_button_index = InfraredButtonIndexNone;
|
||||
} else {
|
||||
furi_crash(NULL);
|
||||
furi_crash();
|
||||
}
|
||||
|
||||
if(success) {
|
||||
|
||||
@@ -33,7 +33,7 @@ bool infrared_scene_edit_delete_done_on_event(void* context, SceneManagerEvent e
|
||||
view_dispatcher_stop(infrared->view_dispatcher);
|
||||
}
|
||||
} else {
|
||||
furi_assert(0);
|
||||
furi_crash();
|
||||
}
|
||||
consumed = true;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ void infrared_scene_edit_rename_on_enter(void* context) {
|
||||
|
||||
furi_string_free(folder_path);
|
||||
} else {
|
||||
furi_crash(NULL);
|
||||
furi_crash();
|
||||
}
|
||||
|
||||
text_input_set_result_callback(
|
||||
@@ -81,7 +81,7 @@ bool infrared_scene_edit_rename_on_event(void* context, SceneManagerEvent event)
|
||||
} else if(edit_target == InfraredEditTargetRemote) {
|
||||
success = infrared_rename_current_remote(infrared, infrared->text_store[0]);
|
||||
} else {
|
||||
furi_crash(NULL);
|
||||
furi_crash();
|
||||
}
|
||||
|
||||
if(success) {
|
||||
|
||||
@@ -456,7 +456,7 @@ void animation_manager_unload_and_stall_animation(AnimationManager* animation_ma
|
||||
}
|
||||
furi_timer_stop(animation_manager->idle_animation_timer);
|
||||
} else {
|
||||
furi_assert(0);
|
||||
furi_crash();
|
||||
}
|
||||
|
||||
FURI_LOG_I(
|
||||
@@ -528,7 +528,7 @@ void animation_manager_load_and_continue_animation(AnimationManager* animation_m
|
||||
}
|
||||
} else {
|
||||
/* Unknown state is an error. But not in release version.*/
|
||||
furi_assert(0);
|
||||
furi_crash();
|
||||
}
|
||||
|
||||
/* if can't restore previous animation - select new */
|
||||
@@ -564,7 +564,7 @@ static void animation_manager_switch_to_one_shot_view(AnimationManager* animatio
|
||||
} else if(stats.level == 2) {
|
||||
one_shot_view_start_animation(animation_manager->one_shot_view, &A_Levelup2_128x64);
|
||||
} else {
|
||||
furi_assert(0);
|
||||
furi_crash();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -78,7 +78,7 @@ static bool desktop_view_pin_input_input(InputEvent* event, void* context) {
|
||||
}
|
||||
break;
|
||||
default:
|
||||
furi_assert(0);
|
||||
furi_crash();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -129,7 +129,7 @@ static void desktop_view_pin_input_draw_cells(Canvas* canvas, DesktopViewPinInpu
|
||||
canvas_draw_icon_ex(canvas, x + 2, y + 3, &I_Pin_arrow_up_7x9, IconRotation90);
|
||||
break;
|
||||
default:
|
||||
furi_assert(0);
|
||||
furi_crash();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ void canvas_set_font(Canvas* canvas, Font font) {
|
||||
} else if(font == FontBigNumbers) {
|
||||
u8g2_SetFont(&canvas->fb, u8g2_font_profont22_tn);
|
||||
} else {
|
||||
furi_crash(NULL);
|
||||
furi_crash();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,7 +175,7 @@ void canvas_draw_str_aligned(
|
||||
x -= (u8g2_GetStrWidth(&canvas->fb, str) / 2);
|
||||
break;
|
||||
default:
|
||||
furi_crash(NULL);
|
||||
furi_crash();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -189,7 +189,7 @@ void canvas_draw_str_aligned(
|
||||
y += (u8g2_GetAscent(&canvas->fb) / 2);
|
||||
break;
|
||||
default:
|
||||
furi_crash(NULL);
|
||||
furi_crash();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -530,7 +530,7 @@ void canvas_set_orientation(Canvas* canvas, CanvasOrientation orientation) {
|
||||
rotate_cb = U8G2_R1;
|
||||
break;
|
||||
default:
|
||||
furi_assert(0);
|
||||
furi_crash();
|
||||
}
|
||||
|
||||
if(need_swap) FURI_SWAP(canvas->width, canvas->height);
|
||||
|
||||
@@ -232,7 +232,7 @@ static size_t
|
||||
} else if(horizontal == AlignRight) {
|
||||
px_left = x;
|
||||
} else {
|
||||
furi_assert(0);
|
||||
furi_crash();
|
||||
}
|
||||
|
||||
if(len_px > px_left) {
|
||||
|
||||
@@ -79,7 +79,7 @@ static uint8_t byte_input_get_row_size(uint8_t row_index) {
|
||||
row_size = COUNT_OF(keyboard_keys_row_2);
|
||||
break;
|
||||
default:
|
||||
furi_crash(NULL);
|
||||
furi_crash();
|
||||
}
|
||||
|
||||
return row_size;
|
||||
@@ -102,7 +102,7 @@ static const ByteInputKey* byte_input_get_row(uint8_t row_index) {
|
||||
row = keyboard_keys_row_2;
|
||||
break;
|
||||
default:
|
||||
furi_crash(NULL);
|
||||
furi_crash();
|
||||
}
|
||||
|
||||
return row;
|
||||
|
||||
@@ -98,7 +98,7 @@ void popup_start_timer(void* context) {
|
||||
if(timer_period == 0) timer_period = 1;
|
||||
|
||||
if(furi_timer_start(popup->timer, timer_period) != FuriStatusOk) {
|
||||
furi_assert(0);
|
||||
furi_crash();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ static uint8_t get_row_size(uint8_t row_index) {
|
||||
row_size = COUNT_OF(keyboard_keys_row_3);
|
||||
break;
|
||||
default:
|
||||
furi_crash(NULL);
|
||||
furi_crash();
|
||||
}
|
||||
|
||||
return row_size;
|
||||
@@ -121,7 +121,7 @@ static const TextInputKey* get_row(uint8_t row_index) {
|
||||
row = keyboard_keys_row_3;
|
||||
break;
|
||||
default:
|
||||
furi_crash(NULL);
|
||||
furi_crash();
|
||||
}
|
||||
|
||||
return row;
|
||||
|
||||
@@ -82,7 +82,7 @@ void view_allocate_model(View* view, ViewModelType type, size_t size) {
|
||||
model->data = malloc(size);
|
||||
view->model = model;
|
||||
} else {
|
||||
furi_crash(NULL);
|
||||
furi_crash();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ void view_free_model(View* view) {
|
||||
free(model);
|
||||
view->model = NULL;
|
||||
} else {
|
||||
furi_crash(NULL);
|
||||
furi_crash();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -207,7 +207,7 @@ void view_dispatcher_attach_to_gui(
|
||||
} else if(type == ViewDispatcherTypeFullscreen) {
|
||||
gui_add_view_port(gui, view_dispatcher->view_port, GuiLayerFullscreen);
|
||||
} else {
|
||||
furi_check(NULL);
|
||||
furi_crash();
|
||||
}
|
||||
view_dispatcher->gui = gui;
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ static void rpc_system_app_start_process(const PB_Main* request, void* context)
|
||||
} else if(status == LoaderStatusOk) {
|
||||
result = PB_CommandStatus_OK;
|
||||
} else {
|
||||
furi_crash(NULL);
|
||||
furi_crash();
|
||||
}
|
||||
} else {
|
||||
result = PB_CommandStatus_ERROR_INVALID_PARAMETERS;
|
||||
|
||||
@@ -68,7 +68,7 @@ bool desktop_settings_scene_pin_auth_on_event(void* context, SceneManagerEvent e
|
||||
} else if(state == SCENE_STATE_PIN_AUTH_DISABLE) {
|
||||
scene_manager_next_scene(app->scene_manager, DesktopSettingsAppScenePinDisable);
|
||||
} else {
|
||||
furi_assert(0);
|
||||
furi_crash();
|
||||
}
|
||||
consumed = true;
|
||||
break;
|
||||
|
||||
@@ -39,7 +39,7 @@ void desktop_settings_scene_pin_error_on_enter(void* context) {
|
||||
} else if(state == SCENE_STATE_PIN_ERROR_WRONG) {
|
||||
desktop_view_pin_input_set_label_primary(app->pin_input_view, 35, 8, "Wrong PIN!");
|
||||
} else {
|
||||
furi_assert(0);
|
||||
furi_crash();
|
||||
}
|
||||
desktop_view_pin_input_set_label_secondary(app->pin_input_view, 0, 8, NULL);
|
||||
desktop_view_pin_input_set_label_button(app->pin_input_view, "Retry");
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ bool desktop_settings_scene_pin_setup_howto_on_event(void* context, SceneManager
|
||||
consumed = true;
|
||||
break;
|
||||
default:
|
||||
furi_crash(NULL);
|
||||
furi_crash();
|
||||
}
|
||||
}
|
||||
return consumed;
|
||||
|
||||
+1
-1
@@ -52,7 +52,7 @@ bool desktop_settings_scene_pin_setup_howto2_on_event(void* context, SceneManage
|
||||
break;
|
||||
}
|
||||
default:
|
||||
furi_crash(NULL);
|
||||
furi_crash();
|
||||
}
|
||||
}
|
||||
return consumed;
|
||||
|
||||
@@ -264,7 +264,7 @@ void hid_hal_keyboard_press(Hid* instance, uint16_t event) {
|
||||
} else if(instance->transport == HidTransportUsb) {
|
||||
furi_hal_hid_kb_press(event);
|
||||
} else {
|
||||
furi_crash(NULL);
|
||||
furi_crash();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -275,7 +275,7 @@ void hid_hal_keyboard_release(Hid* instance, uint16_t event) {
|
||||
} else if(instance->transport == HidTransportUsb) {
|
||||
furi_hal_hid_kb_release(event);
|
||||
} else {
|
||||
furi_crash(NULL);
|
||||
furi_crash();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -286,7 +286,7 @@ void hid_hal_keyboard_release_all(Hid* instance) {
|
||||
} else if(instance->transport == HidTransportUsb) {
|
||||
furi_hal_hid_kb_release_all();
|
||||
} else {
|
||||
furi_crash(NULL);
|
||||
furi_crash();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -297,7 +297,7 @@ void hid_hal_consumer_key_press(Hid* instance, uint16_t event) {
|
||||
} else if(instance->transport == HidTransportUsb) {
|
||||
furi_hal_hid_consumer_key_press(event);
|
||||
} else {
|
||||
furi_crash(NULL);
|
||||
furi_crash();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -308,7 +308,7 @@ void hid_hal_consumer_key_release(Hid* instance, uint16_t event) {
|
||||
} else if(instance->transport == HidTransportUsb) {
|
||||
furi_hal_hid_consumer_key_release(event);
|
||||
} else {
|
||||
furi_crash(NULL);
|
||||
furi_crash();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -319,7 +319,7 @@ void hid_hal_consumer_key_release_all(Hid* instance) {
|
||||
} else if(instance->transport == HidTransportUsb) {
|
||||
furi_hal_hid_kb_release_all();
|
||||
} else {
|
||||
furi_crash(NULL);
|
||||
furi_crash();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -330,7 +330,7 @@ void hid_hal_mouse_move(Hid* instance, int8_t dx, int8_t dy) {
|
||||
} else if(instance->transport == HidTransportUsb) {
|
||||
furi_hal_hid_mouse_move(dx, dy);
|
||||
} else {
|
||||
furi_crash(NULL);
|
||||
furi_crash();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -341,7 +341,7 @@ void hid_hal_mouse_scroll(Hid* instance, int8_t delta) {
|
||||
} else if(instance->transport == HidTransportUsb) {
|
||||
furi_hal_hid_mouse_scroll(delta);
|
||||
} else {
|
||||
furi_crash(NULL);
|
||||
furi_crash();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -352,7 +352,7 @@ void hid_hal_mouse_press(Hid* instance, uint16_t event) {
|
||||
} else if(instance->transport == HidTransportUsb) {
|
||||
furi_hal_hid_mouse_press(event);
|
||||
} else {
|
||||
furi_crash(NULL);
|
||||
furi_crash();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -363,7 +363,7 @@ void hid_hal_mouse_release(Hid* instance, uint16_t event) {
|
||||
} else if(instance->transport == HidTransportUsb) {
|
||||
furi_hal_hid_mouse_release(event);
|
||||
} else {
|
||||
furi_crash(NULL);
|
||||
furi_crash();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -375,7 +375,7 @@ void hid_hal_mouse_release_all(Hid* instance) {
|
||||
furi_hal_hid_mouse_release(HID_MOUSE_BTN_LEFT);
|
||||
furi_hal_hid_mouse_release(HID_MOUSE_BTN_RIGHT);
|
||||
} else {
|
||||
furi_crash(NULL);
|
||||
furi_crash();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user