Consistent furi_assert usage across project. (#392)
This commit is contained in:
		
							parent
							
								
									81ace53cc1
								
							
						
					
					
						commit
						6fb6e8bd3f
					
				| @ -140,13 +140,13 @@ static void meta_menu_callback(void* context, uint8_t index) { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static void lock_icon_callback(Canvas* canvas, void* context) { | static void lock_icon_callback(Canvas* canvas, void* context) { | ||||||
|     assert(context); |     furi_assert(context); | ||||||
|     Dolphin* dolphin = context; |     Dolphin* dolphin = context; | ||||||
|     canvas_draw_icon(canvas, 0, 0, dolphin->lock_icon); |     canvas_draw_icon(canvas, 0, 0, dolphin->lock_icon); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| static void draw_passport_callback(Canvas* canvas, void* context) { | static void draw_passport_callback(Canvas* canvas, void* context) { | ||||||
|     assert(context); |     furi_assert(context); | ||||||
|     Dolphin* dolphin = context; |     Dolphin* dolphin = context; | ||||||
| 
 | 
 | ||||||
|     char level[20]; |     char level[20]; | ||||||
|  | |||||||
| @ -20,22 +20,22 @@ void view_port_free(ViewPort* view_port) { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void view_port_set_width(ViewPort* view_port, uint8_t width) { | void view_port_set_width(ViewPort* view_port, uint8_t width) { | ||||||
|     assert(view_port); |     furi_assert(view_port); | ||||||
|     view_port->width = width; |     view_port->width = width; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| uint8_t view_port_get_width(ViewPort* view_port) { | uint8_t view_port_get_width(ViewPort* view_port) { | ||||||
|     assert(view_port); |     furi_assert(view_port); | ||||||
|     return view_port->width; |     return view_port->width; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void view_port_set_height(ViewPort* view_port, uint8_t height) { | void view_port_set_height(ViewPort* view_port, uint8_t height) { | ||||||
|     assert(view_port); |     furi_assert(view_port); | ||||||
|     view_port->height = height; |     view_port->height = height; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| uint8_t view_port_get_height(ViewPort* view_port) { | uint8_t view_port_get_height(ViewPort* view_port) { | ||||||
|     assert(view_port); |     furi_assert(view_port); | ||||||
|     return view_port->height; |     return view_port->height; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -124,7 +124,7 @@ void menu_view_port_callback(Canvas* canvas, void* context) { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void menu_set_icon(Menu* menu, Icon* icon) { | void menu_set_icon(Menu* menu, Icon* icon) { | ||||||
|     assert(menu); |     furi_assert(menu); | ||||||
| 
 | 
 | ||||||
|     if(menu->icon) { |     if(menu->icon) { | ||||||
|         icon_stop_animation(menu->icon); |         icon_stop_animation(menu->icon); | ||||||
|  | |||||||
| @ -34,13 +34,13 @@ struct Power { | |||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| void power_draw_usb_callback(Canvas* canvas, void* context) { | void power_draw_usb_callback(Canvas* canvas, void* context) { | ||||||
|     assert(context); |     furi_assert(context); | ||||||
|     Power* power = context; |     Power* power = context; | ||||||
|     canvas_draw_icon(canvas, 0, 0, power->usb_icon); |     canvas_draw_icon(canvas, 0, 0, power->usb_icon); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void power_draw_battery_callback(Canvas* canvas, void* context) { | void power_draw_battery_callback(Canvas* canvas, void* context) { | ||||||
|     assert(context); |     furi_assert(context); | ||||||
|     Power* power = context; |     Power* power = context; | ||||||
|     canvas_draw_icon(canvas, 0, 0, power->battery_icon); |     canvas_draw_icon(canvas, 0, 0, power->battery_icon); | ||||||
|     with_view_model( |     with_view_model( | ||||||
| @ -138,7 +138,7 @@ Power* power_alloc() { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void power_free(Power* power) { | void power_free(Power* power) { | ||||||
|     assert(power); |     furi_assert(power); | ||||||
|     free(power); |     free(power); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -28,14 +28,12 @@ extern "C" { | |||||||
| // We have two levels of assertion
 | // We have two levels of assertion
 | ||||||
| // One - furi_check, which always runs, the only difference is in the level of debug information
 | // 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
 | // The second is furi_assert, which doesn't compile in release mode
 | ||||||
| #ifdef NDEBUG |  | ||||||
| #define furi_check(__e) ((__e) ? (void)0 : __furi_check()) | #define furi_check(__e) ((__e) ? (void)0 : __furi_check()) | ||||||
|  | 
 | ||||||
|  | #ifdef NDEBUG | ||||||
| #define furi_assert(__e) ((void)0) | #define furi_assert(__e) ((void)0) | ||||||
| #else | #else | ||||||
| #define furi_check(__e) \ | #define furi_assert(__e) ((__e) ? (void)0 : __furi_check()) | ||||||
|     ((__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)) |  | ||||||
| #endif | #endif | ||||||
| // !NDEBUG
 | // !NDEBUG
 | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -33,7 +33,7 @@ void furi_record_init() { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| FuriRecord* furi_record_get_or_create(string_t name_str) { | 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); |     FuriRecord* record = FuriRecordDict_get(furi_record_data->records, name_str); | ||||||
|     if(!record) { |     if(!record) { | ||||||
|         FuriRecord new_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) { | void furi_record_create(const char* name, void* data) { | ||||||
|     assert(furi_record_data); |     furi_assert(furi_record_data); | ||||||
|     osThreadId_t thread_id = osThreadGetId(); |     osThreadId_t thread_id = osThreadGetId(); | ||||||
| 
 | 
 | ||||||
|     string_t name_str; |     string_t name_str; | ||||||
| @ -71,7 +71,7 @@ void furi_record_create(const char* name, void* data) { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool furi_record_destroy(const char* name) { | bool furi_record_destroy(const char* name) { | ||||||
|     assert(furi_record_data); |     furi_assert(furi_record_data); | ||||||
|     osThreadId_t thread_id = osThreadGetId(); |     osThreadId_t thread_id = osThreadGetId(); | ||||||
| 
 | 
 | ||||||
|     string_t name_str; |     string_t name_str; | ||||||
| @ -92,7 +92,7 @@ bool furi_record_destroy(const char* name) { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void* furi_record_open(const char* name) { | void* furi_record_open(const char* name) { | ||||||
|     assert(furi_record_data); |     furi_assert(furi_record_data); | ||||||
|     osThreadId_t thread_id = osThreadGetId(); |     osThreadId_t thread_id = osThreadGetId(); | ||||||
| 
 | 
 | ||||||
|     string_t name_str; |     string_t name_str; | ||||||
| @ -117,7 +117,7 @@ void* furi_record_open(const char* name) { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void furi_record_close(const char* name) { | void furi_record_close(const char* name) { | ||||||
|     assert(furi_record_data); |     furi_assert(furi_record_data); | ||||||
|     osThreadId_t thread_id = osThreadGetId(); |     osThreadId_t thread_id = osThreadGetId(); | ||||||
| 
 | 
 | ||||||
|     string_t name_str; |     string_t name_str; | ||||||
|  | |||||||
| @ -26,7 +26,7 @@ typedef struct { | |||||||
| static FuriStdglue* furi_stdglue = NULL; | static FuriStdglue* furi_stdglue = NULL; | ||||||
| 
 | 
 | ||||||
| static ssize_t stdout_write(void* _cookie, const char* data, size_t size) { | static ssize_t stdout_write(void* _cookie, const char* data, size_t size) { | ||||||
|     assert(furi_stdglue); |     furi_assert(furi_stdglue); | ||||||
|     osKernelState_t state = osKernelGetState(); |     osKernelState_t state = osKernelGetState(); | ||||||
|     osThreadId_t thread_id = osThreadGetId(); |     osThreadId_t thread_id = osThreadGetId(); | ||||||
|     if(state == osKernelRunning && thread_id && |     if(state == osKernelRunning && thread_id && | ||||||
| @ -88,7 +88,7 @@ void furi_stdglue_init() { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool furi_stdglue_set_global_stdout_callback(FuriStdglueWriteCallback callback) { | bool furi_stdglue_set_global_stdout_callback(FuriStdglueWriteCallback callback) { | ||||||
|     assert(furi_stdglue); |     furi_assert(furi_stdglue); | ||||||
|     osThreadId_t thread_id = osThreadGetId(); |     osThreadId_t thread_id = osThreadGetId(); | ||||||
|     if(thread_id) { |     if(thread_id) { | ||||||
|         furi_check(osMutexAcquire(furi_stdglue->mutex, osWaitForever) == osOK); |         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) { | bool furi_stdglue_set_thread_stdout_callback(FuriStdglueWriteCallback callback) { | ||||||
|     assert(furi_stdglue); |     furi_assert(furi_stdglue); | ||||||
|     osThreadId_t thread_id = osThreadGetId(); |     osThreadId_t thread_id = osThreadGetId(); | ||||||
|     if(thread_id) { |     if(thread_id) { | ||||||
|         furi_check(osMutexAcquire(furi_stdglue->mutex, osWaitForever) == osOK); |         furi_check(osMutexAcquire(furi_stdglue->mutex, osWaitForever) == osOK); | ||||||
|  | |||||||
| @ -1,6 +1,7 @@ | |||||||
| #include "api-hal-delay.h" | #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; | static uint32_t clk_per_microsecond; | ||||||
| 
 | 
 | ||||||
| @ -24,5 +25,5 @@ void delay(float milliseconds) { | |||||||
|     uint32_t ticks = milliseconds / (1000.0f / osKernelGetTickFreq()); |     uint32_t ticks = milliseconds / (1000.0f / osKernelGetTickFreq()); | ||||||
|     osStatus_t result = osDelay(ticks); |     osStatus_t result = osDelay(ticks); | ||||||
|     (void)result; |     (void)result; | ||||||
|     assert(result == osOK); |     furi_assert(result == osOK); | ||||||
| } | } | ||||||
|  | |||||||
| @ -1,6 +1,7 @@ | |||||||
| #include "api-hal-delay.h" | #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; | static uint32_t clk_per_microsecond; | ||||||
| 
 | 
 | ||||||
| @ -24,5 +25,5 @@ void delay(float milliseconds) { | |||||||
|     uint32_t ticks = milliseconds / (1000.0f / osKernelGetTickFreq()); |     uint32_t ticks = milliseconds / (1000.0f / osKernelGetTickFreq()); | ||||||
|     osStatus_t result = osDelay(ticks); |     osStatus_t result = osDelay(ticks); | ||||||
|     (void)result; |     (void)result; | ||||||
|     assert(result == osOK); |     furi_assert(result == osOK); | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 あく
						あく