From 6fb6e8bd3f4f33aba8b7438fc0a71866dd9fd78f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=82=E3=81=8F?= Date: Wed, 31 Mar 2021 21:05:00 +0300 Subject: [PATCH] Consistent furi_assert usage across project. (#392) --- applications/dolphin/dolphin.c | 4 ++-- applications/gui/view_port.c | 8 ++++---- applications/menu/menu.c | 2 +- applications/power/power.c | 6 +++--- core/furi/check.h | 8 +++----- core/furi/record.c | 10 +++++----- core/furi/stdglue.c | 6 +++--- firmware/targets/f4/api-hal/api-hal-delay.c | 9 +++++---- firmware/targets/f5/api-hal/api-hal-delay.c | 9 +++++---- 9 files changed, 31 insertions(+), 31 deletions(-) diff --git a/applications/dolphin/dolphin.c b/applications/dolphin/dolphin.c index b12c4d14..2eb9baf0 100644 --- a/applications/dolphin/dolphin.c +++ b/applications/dolphin/dolphin.c @@ -140,13 +140,13 @@ static void meta_menu_callback(void* context, uint8_t index) { } static void lock_icon_callback(Canvas* canvas, void* context) { - assert(context); + furi_assert(context); Dolphin* dolphin = context; canvas_draw_icon(canvas, 0, 0, dolphin->lock_icon); } static void draw_passport_callback(Canvas* canvas, void* context) { - assert(context); + furi_assert(context); Dolphin* dolphin = context; char level[20]; diff --git a/applications/gui/view_port.c b/applications/gui/view_port.c index d1b69895..094504a4 100644 --- a/applications/gui/view_port.c +++ b/applications/gui/view_port.c @@ -20,22 +20,22 @@ void view_port_free(ViewPort* view_port) { } void view_port_set_width(ViewPort* view_port, uint8_t width) { - assert(view_port); + furi_assert(view_port); view_port->width = width; } uint8_t view_port_get_width(ViewPort* view_port) { - assert(view_port); + furi_assert(view_port); return view_port->width; } void view_port_set_height(ViewPort* view_port, uint8_t height) { - assert(view_port); + furi_assert(view_port); view_port->height = height; } uint8_t view_port_get_height(ViewPort* view_port) { - assert(view_port); + furi_assert(view_port); return view_port->height; } diff --git a/applications/menu/menu.c b/applications/menu/menu.c index cb81cdc6..b5093128 100644 --- a/applications/menu/menu.c +++ b/applications/menu/menu.c @@ -124,7 +124,7 @@ void menu_view_port_callback(Canvas* canvas, void* context) { } void menu_set_icon(Menu* menu, Icon* icon) { - assert(menu); + furi_assert(menu); if(menu->icon) { icon_stop_animation(menu->icon); diff --git a/applications/power/power.c b/applications/power/power.c index 10d6256d..0b4dc302 100644 --- a/applications/power/power.c +++ b/applications/power/power.c @@ -34,13 +34,13 @@ struct Power { }; void power_draw_usb_callback(Canvas* canvas, void* context) { - assert(context); + furi_assert(context); Power* power = context; canvas_draw_icon(canvas, 0, 0, power->usb_icon); } void power_draw_battery_callback(Canvas* canvas, void* context) { - assert(context); + furi_assert(context); Power* power = context; canvas_draw_icon(canvas, 0, 0, power->battery_icon); with_view_model( @@ -138,7 +138,7 @@ Power* power_alloc() { } void power_free(Power* power) { - assert(power); + furi_assert(power); free(power); } diff --git a/core/furi/check.h b/core/furi/check.h index 0f012cd2..00a0e34d 100644 --- a/core/furi/check.h +++ b/core/furi/check.h @@ -28,14 +28,12 @@ extern "C" { // We have two levels of assertion // One - furi_check, which always runs, the only difference is in the level of debug information // The second is furi_assert, which doesn't compile in release mode -#ifdef NDEBUG #define furi_check(__e) ((__e) ? (void)0 : __furi_check()) + +#ifdef NDEBUG #define furi_assert(__e) ((void)0) #else -#define furi_check(__e) \ - ((__e) ? (void)0 : __furi_check_debug(__FILE__, __LINE__, __FURI_CHECK_FUNC, #__e)) -#define furi_assert(__e) \ - ((__e) ? (void)0 : __furi_check_debug(__FILE__, __LINE__, __FURI_CHECK_FUNC, #__e)) +#define furi_assert(__e) ((__e) ? (void)0 : __furi_check()) #endif // !NDEBUG diff --git a/core/furi/record.c b/core/furi/record.c index facf48b4..92134091 100644 --- a/core/furi/record.c +++ b/core/furi/record.c @@ -33,7 +33,7 @@ void furi_record_init() { } FuriRecord* furi_record_get_or_create(string_t name_str) { - assert(furi_record_data); + furi_assert(furi_record_data); FuriRecord* record = FuriRecordDict_get(furi_record_data->records, name_str); if(!record) { FuriRecord new_record; @@ -47,7 +47,7 @@ FuriRecord* furi_record_get_or_create(string_t name_str) { } void furi_record_create(const char* name, void* data) { - assert(furi_record_data); + furi_assert(furi_record_data); osThreadId_t thread_id = osThreadGetId(); string_t name_str; @@ -71,7 +71,7 @@ void furi_record_create(const char* name, void* data) { } bool furi_record_destroy(const char* name) { - assert(furi_record_data); + furi_assert(furi_record_data); osThreadId_t thread_id = osThreadGetId(); string_t name_str; @@ -92,7 +92,7 @@ bool furi_record_destroy(const char* name) { } void* furi_record_open(const char* name) { - assert(furi_record_data); + furi_assert(furi_record_data); osThreadId_t thread_id = osThreadGetId(); string_t name_str; @@ -117,7 +117,7 @@ void* furi_record_open(const char* name) { } void furi_record_close(const char* name) { - assert(furi_record_data); + furi_assert(furi_record_data); osThreadId_t thread_id = osThreadGetId(); string_t name_str; diff --git a/core/furi/stdglue.c b/core/furi/stdglue.c index 9c383179..648b80eb 100644 --- a/core/furi/stdglue.c +++ b/core/furi/stdglue.c @@ -26,7 +26,7 @@ typedef struct { static FuriStdglue* furi_stdglue = NULL; static ssize_t stdout_write(void* _cookie, const char* data, size_t size) { - assert(furi_stdglue); + furi_assert(furi_stdglue); osKernelState_t state = osKernelGetState(); osThreadId_t thread_id = osThreadGetId(); if(state == osKernelRunning && thread_id && @@ -88,7 +88,7 @@ void furi_stdglue_init() { } bool furi_stdglue_set_global_stdout_callback(FuriStdglueWriteCallback callback) { - assert(furi_stdglue); + furi_assert(furi_stdglue); osThreadId_t thread_id = osThreadGetId(); if(thread_id) { furi_check(osMutexAcquire(furi_stdglue->mutex, osWaitForever) == osOK); @@ -106,7 +106,7 @@ bool furi_stdglue_set_global_stdout_callback(FuriStdglueWriteCallback callback) } bool furi_stdglue_set_thread_stdout_callback(FuriStdglueWriteCallback callback) { - assert(furi_stdglue); + furi_assert(furi_stdglue); osThreadId_t thread_id = osThreadGetId(); if(thread_id) { furi_check(osMutexAcquire(furi_stdglue->mutex, osWaitForever) == osOK); diff --git a/firmware/targets/f4/api-hal/api-hal-delay.c b/firmware/targets/f4/api-hal/api-hal-delay.c index bd7241a3..a6d90d8d 100644 --- a/firmware/targets/f4/api-hal/api-hal-delay.c +++ b/firmware/targets/f4/api-hal/api-hal-delay.c @@ -1,6 +1,7 @@ #include "api-hal-delay.h" -#include "assert.h" -#include "cmsis_os2.h" + +#include +#include static uint32_t clk_per_microsecond; @@ -24,5 +25,5 @@ void delay(float milliseconds) { uint32_t ticks = milliseconds / (1000.0f / osKernelGetTickFreq()); osStatus_t result = osDelay(ticks); (void)result; - assert(result == osOK); -} \ No newline at end of file + furi_assert(result == osOK); +} diff --git a/firmware/targets/f5/api-hal/api-hal-delay.c b/firmware/targets/f5/api-hal/api-hal-delay.c index bd7241a3..a6d90d8d 100644 --- a/firmware/targets/f5/api-hal/api-hal-delay.c +++ b/firmware/targets/f5/api-hal/api-hal-delay.c @@ -1,6 +1,7 @@ #include "api-hal-delay.h" -#include "assert.h" -#include "cmsis_os2.h" + +#include +#include static uint32_t clk_per_microsecond; @@ -24,5 +25,5 @@ void delay(float milliseconds) { uint32_t ticks = milliseconds / (1000.0f / osKernelGetTickFreq()); osStatus_t result = osDelay(ticks); (void)result; - assert(result == osOK); -} \ No newline at end of file + furi_assert(result == osOK); +}