furi_check - a new way to asserting (#204)
* hal-related task_is_isr_context function * furi_check implementation * change application to use furi_check * add second level of assertion * add TODO about ISR context * Applications: refactor furi_check and furi_assert. * Apploader: propwer widget usage. Menu: check on furi resource request. * refactor furi_check Co-authored-by: Aleksandr Kutuzov <aku@plooks.com> Co-authored-by: coreglitch <mail@s3f.ru>
This commit is contained in:
@@ -34,7 +34,7 @@ Widget* gui_widget_find_enabled(WidgetArray_t array) {
|
||||
}
|
||||
|
||||
void gui_update(Gui* gui) {
|
||||
assert(gui);
|
||||
furi_assert(gui);
|
||||
GuiMessage message;
|
||||
message.type = GuiMessageTypeRedraw;
|
||||
gui_event_messsage_send(gui->event, &message);
|
||||
@@ -83,7 +83,7 @@ bool gui_redraw_none(Gui* gui) {
|
||||
}
|
||||
|
||||
void gui_redraw(Gui* gui) {
|
||||
assert(gui);
|
||||
furi_assert(gui);
|
||||
gui_lock(gui);
|
||||
|
||||
if(!gui_redraw_fs(gui)) {
|
||||
@@ -98,7 +98,9 @@ void gui_redraw(Gui* gui) {
|
||||
}
|
||||
|
||||
void gui_input(Gui* gui, InputEvent* input_event) {
|
||||
assert(gui);
|
||||
furi_assert(gui);
|
||||
furi_assert(input_event);
|
||||
|
||||
gui_lock(gui);
|
||||
|
||||
Widget* widget = gui_widget_find_enabled(gui->layers[GuiLayerFullscreen]);
|
||||
@@ -113,19 +115,19 @@ void gui_input(Gui* gui, InputEvent* input_event) {
|
||||
}
|
||||
|
||||
void gui_lock(Gui* gui) {
|
||||
assert(gui);
|
||||
assert(osMutexAcquire(gui->mutex, osWaitForever) == osOK);
|
||||
furi_assert(gui);
|
||||
furi_check(osMutexAcquire(gui->mutex, osWaitForever) == osOK);
|
||||
}
|
||||
|
||||
void gui_unlock(Gui* gui) {
|
||||
assert(gui);
|
||||
assert(osMutexRelease(gui->mutex) == osOK);
|
||||
furi_assert(gui);
|
||||
furi_check(osMutexRelease(gui->mutex) == osOK);
|
||||
}
|
||||
|
||||
void gui_add_widget(GuiApi* gui_api, Widget* widget, GuiLayer layer) {
|
||||
assert(gui_api);
|
||||
assert(widget);
|
||||
assert(layer < GuiLayerMAX);
|
||||
furi_assert(gui_api);
|
||||
furi_assert(widget);
|
||||
furi_check(layer < GuiLayerMAX);
|
||||
Gui* gui = (Gui*)gui_api;
|
||||
|
||||
gui_lock(gui);
|
||||
@@ -136,8 +138,8 @@ void gui_add_widget(GuiApi* gui_api, Widget* widget, GuiLayer layer) {
|
||||
}
|
||||
|
||||
void gui_remove_widget(GuiApi* gui_api, Widget* widget) {
|
||||
assert(gui_api);
|
||||
assert(widget);
|
||||
furi_assert(gui_api);
|
||||
furi_assert(widget);
|
||||
Gui* gui = (Gui*)gui_api;
|
||||
|
||||
gui_lock(gui);
|
||||
@@ -164,7 +166,7 @@ Gui* gui_alloc() {
|
||||
gui->api.remove_widget = gui_remove_widget;
|
||||
// Allocate mutex
|
||||
gui->mutex = osMutexNew(NULL);
|
||||
assert(gui->mutex);
|
||||
furi_check(gui->mutex);
|
||||
// Event dispatcher
|
||||
gui->event = gui_event_alloc();
|
||||
// Drawing canvas api
|
||||
|
Reference in New Issue
Block a user