Procházet zdrojové kódy

Consistent furi_assert usage across project. (#392)

あく před 4 roky
rodič
revize
6fb6e8bd3f

+ 2 - 2
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];

+ 4 - 4
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;
 }
 

+ 1 - 1
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);

+ 3 - 3
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);
 }
 

+ 3 - 5
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
 

+ 5 - 5
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;

+ 3 - 3
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);

+ 5 - 4
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 <furi.h>
+#include <cmsis_os2.h>
 
 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);
-}
+    furi_assert(result == osOK);
+}

+ 5 - 4
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 <furi.h>
+#include <cmsis_os2.h>
 
 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);
-}
+    furi_assert(result == osOK);
+}