diff --git a/.pvsconfig b/.pvsconfig index 49c63ad73..b6001ca5c 100644 --- a/.pvsconfig +++ b/.pvsconfig @@ -1,10 +1,10 @@ # MLib macros we can't do much about. //-V:M_LET:1048,1044 //-V:M_EACH:1048,1044 -//-V:ARRAY_DEF:760,747,568,776,729,712,654 -//-V:LIST_DEF:760,747,568,712,729,654,776 +//-V:ARRAY_DEF:760,747,568,776,729,712,654,1103 +//-V:LIST_DEF:760,747,568,712,729,654,776,1103 //-V:BPTREE_DEF2:779,1086,557,773,512 -//-V:DICT_DEF2:779,524,776,760,1044,1001,729,590,568,747,685 +//-V:DICT_DEF2:779,524,776,760,1044,1001,729,590,568,747,685,1103 //-V:ALGO_DEF:1048,747,1044 //-V:TUPLE_DEF2:524,590,1001,760 @@ -42,8 +42,5 @@ # Model-related warnings //-V:with_view_model:1044,1048 -# Functions that always return the same error code -//-V:picopass_device_decrypt:1048 - # Examples //V_EXCLUDE_PATH applications/examples/ \ No newline at end of file diff --git a/applications/debug/accessor/accessor_app.h b/applications/debug/accessor/accessor_app.h index 2afd796d5..bfd5c06e1 100644 --- a/applications/debug/accessor/accessor_app.h +++ b/applications/debug/accessor/accessor_app.h @@ -11,29 +11,29 @@ class AccessorApp { public: void run(void); - AccessorApp(); - ~AccessorApp(); + AccessorApp(void); + ~AccessorApp(void); enum class Scene : uint8_t { Exit, Start, }; - AccessorAppViewManager* get_view_manager(); + AccessorAppViewManager* get_view_manager(void); void switch_to_next_scene(Scene index); void search_and_switch_to_previous_scene(std::initializer_list scenes_list); bool switch_to_previous_scene(uint8_t count = 1); - Scene get_previous_scene(); + Scene get_previous_scene(void); - void notify_green_blink(); - void notify_success(); + void notify_green_blink(void); + void notify_success(void); - char* get_text_store(); - uint8_t get_text_store_size(); + char* get_text_store(void); + uint8_t get_text_store_size(void); void set_text_store(const char* text...); - WIEGAND* get_wiegand(); - OneWireHost* get_one_wire(); + WIEGAND* get_wiegand(void); + OneWireHost* get_one_wire(void); private: std::list previous_scenes_list = {Scene::Exit}; diff --git a/applications/debug/accessor/accessor_view_manager.h b/applications/debug/accessor/accessor_view_manager.h index 8cd437797..66e54e41c 100644 --- a/applications/debug/accessor/accessor_view_manager.h +++ b/applications/debug/accessor/accessor_view_manager.h @@ -15,16 +15,16 @@ public: FuriMessageQueue* event_queue; - AccessorAppViewManager(); - ~AccessorAppViewManager(); + AccessorAppViewManager(void); + ~AccessorAppViewManager(void); void switch_to(ViewType type); void receive_event(AccessorEvent* event); void send_event(AccessorEvent* event); - Submenu* get_submenu(); - Popup* get_popup(); + Submenu* get_submenu(void); + Popup* get_popup(void); private: ViewDispatcher* view_dispatcher; diff --git a/applications/debug/accessor/helpers/wiegand.h b/applications/debug/accessor/helpers/wiegand.h index be80f94cd..1e1ab6bc8 100644 --- a/applications/debug/accessor/helpers/wiegand.h +++ b/applications/debug/accessor/helpers/wiegand.h @@ -2,19 +2,19 @@ class WIEGAND { public: - WIEGAND(); - void begin(); - void end(); - bool available(); - unsigned long getCode(); - unsigned long getCodeHigh(); - int getWiegandType(); + WIEGAND(void); + void begin(void); + void end(void); + bool available(void); + unsigned long getCode(void); + unsigned long getCodeHigh(void); + int getWiegandType(void); - static void ReadD0(); - static void ReadD1(); + static void ReadD0(void); + static void ReadD1(void); private: - static bool DoWiegandConversion(); + static bool DoWiegandConversion(void); static unsigned long GetCardId(unsigned long* codehigh, unsigned long* codelow, char bitlength); diff --git a/applications/debug/battery_test_app/battery_test_app.c b/applications/debug/battery_test_app/battery_test_app.c index 82c814ef4..5f9934e77 100644 --- a/applications/debug/battery_test_app/battery_test_app.c +++ b/applications/debug/battery_test_app/battery_test_app.c @@ -32,7 +32,7 @@ static void battery_test_battery_info_update_model(void* context) { notification_message(app->notifications, &sequence_display_backlight_on); } -BatteryTestApp* battery_test_alloc() { +BatteryTestApp* battery_test_alloc(void) { BatteryTestApp* app = malloc(sizeof(BatteryTestApp)); // Records diff --git a/applications/debug/battery_test_app/views/battery_info.c b/applications/debug/battery_test_app/views/battery_info.c index 5353a2e2a..4b5dcd627 100644 --- a/applications/debug/battery_test_app/views/battery_info.c +++ b/applications/debug/battery_test_app/views/battery_info.c @@ -116,7 +116,7 @@ static void battery_info_draw_callback(Canvas* canvas, void* context) { draw_stat(canvas, 104, 42, &I_Health_16x16, health); } -BatteryInfo* battery_info_alloc() { +BatteryInfo* battery_info_alloc(void) { BatteryInfo* battery_info = malloc(sizeof(BatteryInfo)); battery_info->view = view_alloc(); view_set_context(battery_info->view, battery_info); diff --git a/applications/debug/battery_test_app/views/battery_info.h b/applications/debug/battery_test_app/views/battery_info.h index 7bfacf69e..403caac4b 100644 --- a/applications/debug/battery_test_app/views/battery_info.h +++ b/applications/debug/battery_test_app/views/battery_info.h @@ -14,7 +14,7 @@ typedef struct { uint8_t health; } BatteryInfoModel; -BatteryInfo* battery_info_alloc(); +BatteryInfo* battery_info_alloc(void); void battery_info_free(BatteryInfo* battery_info); diff --git a/applications/debug/bt_debug_app/bt_debug_app.c b/applications/debug/bt_debug_app/bt_debug_app.c index bf13f6570..109feee60 100644 --- a/applications/debug/bt_debug_app/bt_debug_app.c +++ b/applications/debug/bt_debug_app/bt_debug_app.c @@ -28,7 +28,7 @@ uint32_t bt_debug_start_view(void* context) { return BtDebugAppViewSubmenu; } -BtDebugApp* bt_debug_app_alloc() { +BtDebugApp* bt_debug_app_alloc(void) { BtDebugApp* app = malloc(sizeof(BtDebugApp)); // Gui diff --git a/applications/debug/bt_debug_app/views/bt_carrier_test.c b/applications/debug/bt_debug_app/views/bt_carrier_test.c index 8e2240495..23066434b 100644 --- a/applications/debug/bt_debug_app/views/bt_carrier_test.c +++ b/applications/debug/bt_debug_app/views/bt_carrier_test.c @@ -129,7 +129,7 @@ static void bt_test_carrier_timer_callback(void* context) { } } -BtCarrierTest* bt_carrier_test_alloc() { +BtCarrierTest* bt_carrier_test_alloc(void) { BtCarrierTest* bt_carrier_test = malloc(sizeof(BtCarrierTest)); bt_carrier_test->bt_test = bt_test_alloc(); bt_test_set_context(bt_carrier_test->bt_test, bt_carrier_test); diff --git a/applications/debug/bt_debug_app/views/bt_carrier_test.h b/applications/debug/bt_debug_app/views/bt_carrier_test.h index 51a400890..07fedccc1 100644 --- a/applications/debug/bt_debug_app/views/bt_carrier_test.h +++ b/applications/debug/bt_debug_app/views/bt_carrier_test.h @@ -3,7 +3,7 @@ typedef struct BtCarrierTest BtCarrierTest; -BtCarrierTest* bt_carrier_test_alloc(); +BtCarrierTest* bt_carrier_test_alloc(void); void bt_carrier_test_free(BtCarrierTest* bt_carrier_test); diff --git a/applications/debug/bt_debug_app/views/bt_packet_test.c b/applications/debug/bt_debug_app/views/bt_packet_test.c index 8a56a3003..c30c6b5d2 100644 --- a/applications/debug/bt_debug_app/views/bt_packet_test.c +++ b/applications/debug/bt_debug_app/views/bt_packet_test.c @@ -97,7 +97,7 @@ static void bt_test_packet_timer_callback(void* context) { } } -BtPacketTest* bt_packet_test_alloc() { +BtPacketTest* bt_packet_test_alloc(void) { BtPacketTest* bt_packet_test = malloc(sizeof(BtPacketTest)); bt_packet_test->bt_test = bt_test_alloc(); bt_test_set_context(bt_packet_test->bt_test, bt_packet_test); diff --git a/applications/debug/bt_debug_app/views/bt_packet_test.h b/applications/debug/bt_debug_app/views/bt_packet_test.h index 8ea449b21..e31af3218 100644 --- a/applications/debug/bt_debug_app/views/bt_packet_test.h +++ b/applications/debug/bt_debug_app/views/bt_packet_test.h @@ -3,7 +3,7 @@ typedef struct BtPacketTest BtPacketTest; -BtPacketTest* bt_packet_test_alloc(); +BtPacketTest* bt_packet_test_alloc(void); void bt_packet_test_free(BtPacketTest* bt_packet_test); diff --git a/applications/debug/bt_debug_app/views/bt_test.c b/applications/debug/bt_debug_app/views/bt_test.c index cd52b8650..792ebfd8f 100644 --- a/applications/debug/bt_debug_app/views/bt_test.c +++ b/applications/debug/bt_debug_app/views/bt_test.c @@ -305,7 +305,7 @@ void bt_test_process_back(BtTest* bt_test) { } } -BtTest* bt_test_alloc() { +BtTest* bt_test_alloc(void) { BtTest* bt_test = malloc(sizeof(BtTest)); bt_test->view = view_alloc(); view_set_context(bt_test->view, bt_test); diff --git a/applications/debug/bt_debug_app/views/bt_test.h b/applications/debug/bt_debug_app/views/bt_test.h index 2d738cbd0..9d5ea26ec 100644 --- a/applications/debug/bt_debug_app/views/bt_test.h +++ b/applications/debug/bt_debug_app/views/bt_test.h @@ -12,7 +12,7 @@ typedef void (*BtTestBackCallback)(void* context); typedef struct BtTestParam BtTestParam; typedef void (*BtTestParamChangeCallback)(BtTestParam* param); -BtTest* bt_test_alloc(); +BtTest* bt_test_alloc(void); void bt_test_free(BtTest* bt_test); diff --git a/applications/debug/ccid_test/ccid_test_app.c b/applications/debug/ccid_test/ccid_test_app.c index 3d7fba39d..50b356696 100644 --- a/applications/debug/ccid_test/ccid_test_app.c +++ b/applications/debug/ccid_test/ccid_test_app.c @@ -90,7 +90,7 @@ uint32_t ccid_test_exit(void* context) { return VIEW_NONE; } -CcidTestApp* ccid_test_app_alloc() { +CcidTestApp* ccid_test_app_alloc(void) { CcidTestApp* app = malloc(sizeof(CcidTestApp)); // Gui diff --git a/applications/debug/crash_test/crash_test.c b/applications/debug/crash_test/crash_test.c index 92f1668be..ae0074fe1 100644 --- a/applications/debug/crash_test/crash_test.c +++ b/applications/debug/crash_test/crash_test.c @@ -50,7 +50,7 @@ static void crash_test_submenu_callback(void* context, uint32_t index) { furi_halt("Crash test: furi_halt"); break; default: - furi_crash("Programming error"); + furi_crash(); } } @@ -59,7 +59,7 @@ static uint32_t crash_test_exit_callback(void* context) { return VIEW_NONE; } -CrashTest* crash_test_alloc() { +CrashTest* crash_test_alloc(void) { CrashTest* instance = malloc(sizeof(CrashTest)); View* view = NULL; diff --git a/applications/debug/direct_draw/direct_draw.c b/applications/debug/direct_draw/direct_draw.c index 63e03530a..bc1e55459 100644 --- a/applications/debug/direct_draw/direct_draw.c +++ b/applications/debug/direct_draw/direct_draw.c @@ -26,7 +26,7 @@ static void gui_input_events_callback(const void* value, void* ctx) { } } -static DirectDraw* direct_draw_alloc() { +static DirectDraw* direct_draw_alloc(void) { DirectDraw* instance = malloc(sizeof(DirectDraw)); instance->input = furi_record_open(RECORD_INPUT_EVENTS); diff --git a/applications/debug/display_test/display_test.c b/applications/debug/display_test/display_test.c index 8065a23a1..ac1b6c65d 100644 --- a/applications/debug/display_test/display_test.c +++ b/applications/debug/display_test/display_test.c @@ -121,7 +121,7 @@ static void display_config_set_contrast(VariableItem* item) { display_test_reload_config(instance); } -DisplayTest* display_test_alloc() { +DisplayTest* display_test_alloc(void) { DisplayTest* instance = malloc(sizeof(DisplayTest)); View* view = NULL; diff --git a/applications/debug/display_test/view_display_test.c b/applications/debug/display_test/view_display_test.c index b47c74c6c..d4fe433ef 100644 --- a/applications/debug/display_test/view_display_test.c +++ b/applications/debug/display_test/view_display_test.c @@ -154,7 +154,7 @@ static void view_display_test_timer_callback(void* context) { instance->view, ViewDisplayTestModel * model, { model->counter++; }, true); } -ViewDisplayTest* view_display_test_alloc() { +ViewDisplayTest* view_display_test_alloc(void) { ViewDisplayTest* instance = malloc(sizeof(ViewDisplayTest)); instance->view = view_alloc(); diff --git a/applications/debug/display_test/view_display_test.h b/applications/debug/display_test/view_display_test.h index cafa142a8..ca78e5ffe 100644 --- a/applications/debug/display_test/view_display_test.h +++ b/applications/debug/display_test/view_display_test.h @@ -5,7 +5,7 @@ typedef struct ViewDisplayTest ViewDisplayTest; -ViewDisplayTest* view_display_test_alloc(); +ViewDisplayTest* view_display_test_alloc(void); void view_display_test_free(ViewDisplayTest* instance); diff --git a/applications/debug/expansion_test/expansion_test.c b/applications/debug/expansion_test/expansion_test.c index a0b8b42e8..fc7fb1894 100644 --- a/applications/debug/expansion_test/expansion_test.c +++ b/applications/debug/expansion_test/expansion_test.c @@ -81,7 +81,7 @@ static void expansion_test_app_serial_rx_callback( } } -static ExpansionTestApp* expansion_test_app_alloc() { +static ExpansionTestApp* expansion_test_app_alloc(void) { ExpansionTestApp* instance = malloc(sizeof(ExpansionTestApp)); instance->buf = furi_stream_buffer_alloc(RECEIVE_BUFFER_SIZE, 1); return instance; diff --git a/applications/debug/lfrfid_debug/lfrfid_debug.c b/applications/debug/lfrfid_debug/lfrfid_debug.c index 63d66b68b..8776f8b7a 100644 --- a/applications/debug/lfrfid_debug/lfrfid_debug.c +++ b/applications/debug/lfrfid_debug/lfrfid_debug.c @@ -12,7 +12,7 @@ static bool lfrfid_debug_back_event_callback(void* context) { return scene_manager_handle_back_event(app->scene_manager); } -static LfRfidDebug* lfrfid_debug_alloc() { +static LfRfidDebug* lfrfid_debug_alloc(void) { LfRfidDebug* app = malloc(sizeof(LfRfidDebug)); app->view_dispatcher = view_dispatcher_alloc(); diff --git a/applications/debug/lfrfid_debug/views/lfrfid_debug_view_tune.c b/applications/debug/lfrfid_debug/views/lfrfid_debug_view_tune.c index 9e48a7e27..6b9501e5b 100644 --- a/applications/debug/lfrfid_debug/views/lfrfid_debug_view_tune.c +++ b/applications/debug/lfrfid_debug/views/lfrfid_debug_view_tune.c @@ -170,7 +170,7 @@ static bool lfrfid_debug_view_tune_input_callback(InputEvent* event, void* conte return consumed; } -LfRfidTuneView* lfrfid_debug_view_tune_alloc() { +LfRfidTuneView* lfrfid_debug_view_tune_alloc(void) { LfRfidTuneView* tune_view = malloc(sizeof(LfRfidTuneView)); tune_view->view = view_alloc(); view_set_context(tune_view->view, tune_view); diff --git a/applications/debug/lfrfid_debug/views/lfrfid_debug_view_tune.h b/applications/debug/lfrfid_debug/views/lfrfid_debug_view_tune.h index be54b63f9..a0ee4cbf5 100644 --- a/applications/debug/lfrfid_debug/views/lfrfid_debug_view_tune.h +++ b/applications/debug/lfrfid_debug/views/lfrfid_debug_view_tune.h @@ -3,7 +3,7 @@ typedef struct LfRfidTuneView LfRfidTuneView; -LfRfidTuneView* lfrfid_debug_view_tune_alloc(); +LfRfidTuneView* lfrfid_debug_view_tune_alloc(void); void lfrfid_debug_view_tune_free(LfRfidTuneView* tune_view); diff --git a/applications/debug/locale_test/locale_test.c b/applications/debug/locale_test/locale_test.c index a7cbd52f8..1ca077db1 100644 --- a/applications/debug/locale_test/locale_test.c +++ b/applications/debug/locale_test/locale_test.c @@ -53,7 +53,7 @@ static uint32_t locale_test_exit(void* context) { return VIEW_NONE; } -static LocaleTestApp* locale_test_alloc() { +static LocaleTestApp* locale_test_alloc(void) { LocaleTestApp* app = malloc(sizeof(LocaleTestApp)); // Gui diff --git a/applications/debug/rpc_debug_app/rpc_debug_app.c b/applications/debug/rpc_debug_app/rpc_debug_app.c index 2a0756383..5e53c221e 100644 --- a/applications/debug/rpc_debug_app/rpc_debug_app.c +++ b/applications/debug/rpc_debug_app/rpc_debug_app.c @@ -83,7 +83,7 @@ static bool rpc_debug_app_rpc_init_rpc(RpcDebugApp* app, const char* args) { return ret; } -static RpcDebugApp* rpc_debug_app_alloc() { +static RpcDebugApp* rpc_debug_app_alloc(void) { RpcDebugApp* app = malloc(sizeof(RpcDebugApp)); app->gui = furi_record_open(RECORD_GUI); diff --git a/applications/debug/speaker_debug/speaker_debug.c b/applications/debug/speaker_debug/speaker_debug.c index e01d5b8ec..82a6fbc77 100644 --- a/applications/debug/speaker_debug/speaker_debug.c +++ b/applications/debug/speaker_debug/speaker_debug.c @@ -21,7 +21,7 @@ typedef struct { Cli* cli; } SpeakerDebugApp; -static SpeakerDebugApp* speaker_app_alloc() { +static SpeakerDebugApp* speaker_app_alloc(void) { SpeakerDebugApp* app = (SpeakerDebugApp*)malloc(sizeof(SpeakerDebugApp)); app->music_worker = music_worker_alloc(); app->message_queue = furi_message_queue_alloc(8, sizeof(SpeakerDebugAppMessage)); diff --git a/applications/debug/subghz_test/protocol/princeton_for_testing.c b/applications/debug/subghz_test/protocol/princeton_for_testing.c index 334a8241b..70f323937 100644 --- a/applications/debug/subghz_test/protocol/princeton_for_testing.c +++ b/applications/debug/subghz_test/protocol/princeton_for_testing.c @@ -38,7 +38,7 @@ typedef enum { PrincetonDecoderStepCheckDuration, } PrincetonDecoderStep; -SubGhzEncoderPrinceton* subghz_encoder_princeton_for_testing_alloc() { +SubGhzEncoderPrinceton* subghz_encoder_princeton_for_testing_alloc(void) { SubGhzEncoderPrinceton* instance = malloc(sizeof(SubGhzEncoderPrinceton)); return instance; } diff --git a/applications/debug/subghz_test/protocol/princeton_for_testing.h b/applications/debug/subghz_test/protocol/princeton_for_testing.h index 7b4201d38..281cb148b 100644 --- a/applications/debug/subghz_test/protocol/princeton_for_testing.h +++ b/applications/debug/subghz_test/protocol/princeton_for_testing.h @@ -15,7 +15,7 @@ typedef void (*SubGhzDecoderPrincetonCallback)(SubGhzDecoderPrinceton* parser, v * Allocate SubGhzEncoderPrinceton * @return pointer to SubGhzEncoderPrinceton instance */ -SubGhzEncoderPrinceton* subghz_encoder_princeton_for_testing_alloc(); +SubGhzEncoderPrinceton* subghz_encoder_princeton_for_testing_alloc(void); /** * Free SubGhzEncoderPrinceton instance @@ -69,7 +69,7 @@ LevelDuration subghz_encoder_princeton_for_testing_yield(void* context); * Allocate SubGhzDecoderPrinceton * @return SubGhzDecoderPrinceton* */ -SubGhzDecoderPrinceton* subghz_decoder_princeton_for_testing_alloc(); +SubGhzDecoderPrinceton* subghz_decoder_princeton_for_testing_alloc(void); /** * Free SubGhzDecoderPrinceton diff --git a/applications/debug/subghz_test/subghz_test_app.c b/applications/debug/subghz_test/subghz_test_app.c index 704941fb2..6eba864f6 100644 --- a/applications/debug/subghz_test/subghz_test_app.c +++ b/applications/debug/subghz_test/subghz_test_app.c @@ -21,7 +21,7 @@ static void subghz_test_app_tick_event_callback(void* context) { scene_manager_handle_tick_event(app->scene_manager); } -SubGhzTestApp* subghz_test_app_alloc() { +SubGhzTestApp* subghz_test_app_alloc(void) { SubGhzTestApp* app = malloc(sizeof(SubGhzTestApp)); // GUI diff --git a/applications/debug/subghz_test/views/subghz_test_carrier.c b/applications/debug/subghz_test/views/subghz_test_carrier.c index ec64e2d9b..b6b4530ae 100644 --- a/applications/debug/subghz_test/views/subghz_test_carrier.c +++ b/applications/debug/subghz_test/views/subghz_test_carrier.c @@ -219,7 +219,7 @@ void subghz_test_carrier_rssi_timer_callback(void* context) { false); } -SubGhzTestCarrier* subghz_test_carrier_alloc() { +SubGhzTestCarrier* subghz_test_carrier_alloc(void) { SubGhzTestCarrier* subghz_test_carrier = malloc(sizeof(SubGhzTestCarrier)); // View allocation and configuration diff --git a/applications/debug/subghz_test/views/subghz_test_carrier.h b/applications/debug/subghz_test/views/subghz_test_carrier.h index d171d19f4..0ba8bc8a2 100644 --- a/applications/debug/subghz_test/views/subghz_test_carrier.h +++ b/applications/debug/subghz_test/views/subghz_test_carrier.h @@ -16,7 +16,7 @@ void subghz_test_carrier_set_callback( SubGhzTestCarrierCallback callback, void* context); -SubGhzTestCarrier* subghz_test_carrier_alloc(); +SubGhzTestCarrier* subghz_test_carrier_alloc(void); void subghz_test_carrier_free(SubGhzTestCarrier* subghz_test_carrier); diff --git a/applications/debug/subghz_test/views/subghz_test_packet.c b/applications/debug/subghz_test/views/subghz_test_packet.c index 1f3458296..d50f10ad4 100644 --- a/applications/debug/subghz_test/views/subghz_test_packet.c +++ b/applications/debug/subghz_test/views/subghz_test_packet.c @@ -236,7 +236,7 @@ void subghz_test_packet_exit(void* context) { furi_hal_subghz_sleep(); } -SubGhzTestPacket* subghz_test_packet_alloc() { +SubGhzTestPacket* subghz_test_packet_alloc(void) { SubGhzTestPacket* instance = malloc(sizeof(SubGhzTestPacket)); // View allocation and configuration diff --git a/applications/debug/subghz_test/views/subghz_test_packet.h b/applications/debug/subghz_test/views/subghz_test_packet.h index f384cf4fe..3a8204f1f 100644 --- a/applications/debug/subghz_test/views/subghz_test_packet.h +++ b/applications/debug/subghz_test/views/subghz_test_packet.h @@ -15,7 +15,7 @@ void subghz_test_packet_set_callback( SubGhzTestPacketCallback callback, void* context); -SubGhzTestPacket* subghz_test_packet_alloc(); +SubGhzTestPacket* subghz_test_packet_alloc(void); void subghz_test_packet_free(SubGhzTestPacket* subghz_test_packet); diff --git a/applications/debug/subghz_test/views/subghz_test_static.c b/applications/debug/subghz_test/views/subghz_test_static.c index 6764fd5ca..22ad662c5 100644 --- a/applications/debug/subghz_test/views/subghz_test_static.c +++ b/applications/debug/subghz_test/views/subghz_test_static.c @@ -164,7 +164,7 @@ void subghz_test_static_exit(void* context) { furi_hal_subghz_sleep(); } -SubGhzTestStatic* subghz_test_static_alloc() { +SubGhzTestStatic* subghz_test_static_alloc(void) { SubGhzTestStatic* instance = malloc(sizeof(SubGhzTestStatic)); // View allocation and configuration diff --git a/applications/debug/subghz_test/views/subghz_test_static.h b/applications/debug/subghz_test/views/subghz_test_static.h index 902036431..3bb6156f7 100644 --- a/applications/debug/subghz_test/views/subghz_test_static.h +++ b/applications/debug/subghz_test/views/subghz_test_static.h @@ -15,7 +15,7 @@ void subghz_test_static_set_callback( SubGhzTestStaticCallback callback, void* context); -SubGhzTestStatic* subghz_test_static_alloc(); +SubGhzTestStatic* subghz_test_static_alloc(void); void subghz_test_static_free(SubGhzTestStatic* subghz_static); diff --git a/applications/debug/unit_tests/bit_lib/bit_lib_test.c b/applications/debug/unit_tests/bit_lib/bit_lib_test.c index 42b494413..239a3b562 100644 --- a/applications/debug/unit_tests/bit_lib/bit_lib_test.c +++ b/applications/debug/unit_tests/bit_lib/bit_lib_test.c @@ -734,7 +734,7 @@ MU_TEST_SUITE(test_bit_lib) { MU_RUN_TEST(test_bit_lib_bytes_to_num_bcd); } -int run_minunit_test_bit_lib() { +int run_minunit_test_bit_lib(void) { MU_RUN_SUITE(test_bit_lib); return MU_EXIT_CODE; } \ No newline at end of file diff --git a/applications/debug/unit_tests/bt/bt_test.c b/applications/debug/unit_tests/bt/bt_test.c index 32cf6533f..a09b9894b 100644 --- a/applications/debug/unit_tests/bt/bt_test.c +++ b/applications/debug/unit_tests/bt/bt_test.c @@ -17,7 +17,7 @@ typedef struct { BtTest* bt_test = NULL; -void bt_test_alloc() { +void bt_test_alloc(void) { bt_test = malloc(sizeof(BtTest)); bt_test->storage = furi_record_open(RECORD_STORAGE); bt_test->nvm_ram_buff_dut = malloc(BT_TEST_NVM_RAM_BUFF_SIZE); @@ -27,7 +27,7 @@ void bt_test_alloc() { bt_test->bt_keys_storage, bt_test->nvm_ram_buff_dut, BT_TEST_NVM_RAM_BUFF_SIZE); } -void bt_test_free() { +void bt_test_free(void) { furi_check(bt_test); free(bt_test->nvm_ram_buff_ref); free(bt_test->nvm_ram_buff_dut); @@ -37,7 +37,7 @@ void bt_test_free() { bt_test = NULL; } -static void bt_test_keys_storage_profile() { +static void bt_test_keys_storage_profile(void) { // Emulate nvm change on initial connection const int nvm_change_size_on_connection = 88; for(size_t i = 0; i < nvm_change_size_on_connection; i++) { @@ -82,7 +82,7 @@ static void bt_test_keys_storage_profile() { "Wrong buffer loaded"); } -static void bt_test_keys_remove_test_file() { +static void bt_test_keys_remove_test_file(void) { mu_assert( storage_simply_remove(bt_test->storage, BT_TEST_KEY_STORAGE_FILE_PATH), "Can't remove test file"); @@ -104,7 +104,7 @@ MU_TEST_SUITE(test_bt) { bt_test_free(); } -int run_minunit_test_bt() { +int run_minunit_test_bt(void) { MU_RUN_SUITE(test_bt); return MU_EXIT_CODE; } diff --git a/applications/debug/unit_tests/datetimelib/datetimelib_test.c b/applications/debug/unit_tests/datetimelib/datetimelib_test.c index bf8e6fabd..c171a4413 100644 --- a/applications/debug/unit_tests/datetimelib/datetimelib_test.c +++ b/applications/debug/unit_tests/datetimelib/datetimelib_test.c @@ -182,7 +182,7 @@ MU_TEST_SUITE(test_datetime_datetime_to_timestamp_suite) { MU_RUN_TEST(test_datetime_datetime_to_timestamp_max); } -int run_minunit_test_datetime() { +int run_minunit_test_datetime(void) { MU_RUN_SUITE(test_datetime_timestamp_to_datetime_suite); MU_RUN_SUITE(test_datetime_datetime_to_timestamp_suite); MU_RUN_SUITE(test_datetime_validate_datetime); diff --git a/applications/debug/unit_tests/dialogs/dialogs_file_browser_options.c b/applications/debug/unit_tests/dialogs/dialogs_file_browser_options.c index 2d5bad4c8..657b933df 100644 --- a/applications/debug/unit_tests/dialogs/dialogs_file_browser_options.c +++ b/applications/debug/unit_tests/dialogs/dialogs_file_browser_options.c @@ -25,7 +25,7 @@ MU_TEST_SUITE(dialogs_file_browser_options) { MU_RUN_TEST(test_dialog_file_browser_set_basic_options_should_init_all_fields); } -int run_minunit_test_dialogs_file_browser_options() { +int run_minunit_test_dialogs_file_browser_options(void) { MU_RUN_SUITE(dialogs_file_browser_options); return MU_EXIT_CODE; diff --git a/applications/debug/unit_tests/expansion/expansion_test.c b/applications/debug/unit_tests/expansion/expansion_test.c index 50fe1b9f4..c6a143ed3 100644 --- a/applications/debug/unit_tests/expansion/expansion_test.c +++ b/applications/debug/unit_tests/expansion/expansion_test.c @@ -194,7 +194,7 @@ MU_TEST_SUITE(test_expansion_suite) { MU_RUN_TEST(test_expansion_garbage_input); } -int run_minunit_test_expansion() { +int run_minunit_test_expansion(void) { MU_RUN_SUITE(test_expansion_suite); return MU_EXIT_CODE; } diff --git a/applications/debug/unit_tests/flipper_format/flipper_format_string_test.c b/applications/debug/unit_tests/flipper_format/flipper_format_string_test.c index 920a22a43..99bb5dda5 100644 --- a/applications/debug/unit_tests/flipper_format/flipper_format_string_test.c +++ b/applications/debug/unit_tests/flipper_format/flipper_format_string_test.c @@ -331,7 +331,7 @@ MU_TEST_SUITE(flipper_format_string_suite) { MU_RUN_TEST(flipper_format_file_test); } -int run_minunit_test_flipper_format_string() { +int run_minunit_test_flipper_format_string(void) { MU_RUN_SUITE(flipper_format_string_suite); return MU_EXIT_CODE; } diff --git a/applications/debug/unit_tests/flipper_format/flipper_format_test.c b/applications/debug/unit_tests/flipper_format/flipper_format_test.c index 012e905b6..471055fb0 100644 --- a/applications/debug/unit_tests/flipper_format/flipper_format_test.c +++ b/applications/debug/unit_tests/flipper_format/flipper_format_test.c @@ -103,14 +103,14 @@ static bool storage_write_string(const char* path, const char* data) { return result; } -static void tests_setup() { +static void tests_setup(void) { Storage* storage = furi_record_open(RECORD_STORAGE); mu_assert(storage_simply_remove_recursive(storage, TEST_DIR_NAME), "Cannot clean data"); mu_assert(storage_simply_mkdir(storage, TEST_DIR_NAME), "Cannot create dir"); furi_record_close(RECORD_STORAGE); } -static void tests_teardown() { +static void tests_teardown(void) { Storage* storage = furi_record_open(RECORD_STORAGE); mu_assert(storage_simply_remove_recursive(storage, TEST_DIR_NAME), "Cannot clean data"); furi_record_close(RECORD_STORAGE); @@ -545,7 +545,7 @@ MU_TEST_SUITE(flipper_format) { tests_teardown(); } -int run_minunit_test_flipper_format() { +int run_minunit_test_flipper_format(void) { MU_RUN_SUITE(flipper_format); return MU_EXIT_CODE; } diff --git a/applications/debug/unit_tests/float_tools/float_tools_test.c b/applications/debug/unit_tests/float_tools/float_tools_test.c index fc5b4ecfd..91ac46937 100644 --- a/applications/debug/unit_tests/float_tools/float_tools_test.c +++ b/applications/debug/unit_tests/float_tools/float_tools_test.c @@ -54,7 +54,7 @@ MU_TEST_SUITE(float_tools_suite) { MU_RUN_TEST(float_tools_equal_test); } -int run_minunit_test_float_tools() { +int run_minunit_test_float_tools(void) { MU_RUN_SUITE(float_tools_suite); return MU_EXIT_CODE; } diff --git a/applications/debug/unit_tests/furi/furi_memmgr_test.c b/applications/debug/unit_tests/furi/furi_memmgr_test.c index 9012eed78..01e2c17f6 100644 --- a/applications/debug/unit_tests/furi/furi_memmgr_test.c +++ b/applications/debug/unit_tests/furi/furi_memmgr_test.c @@ -4,7 +4,7 @@ #include #include -void test_furi_memmgr() { +void test_furi_memmgr(void) { void* ptr; // allocate memory case diff --git a/applications/debug/unit_tests/furi/furi_pubsub_test.c b/applications/debug/unit_tests/furi/furi_pubsub_test.c index ddaeb746d..8925ff42e 100644 --- a/applications/debug/unit_tests/furi/furi_pubsub_test.c +++ b/applications/debug/unit_tests/furi/furi_pubsub_test.c @@ -15,7 +15,7 @@ void test_pubsub_handler(const void* arg, void* ctx) { pubsub_context_value = *(uint32_t*)ctx; } -void test_furi_pubsub() { +void test_furi_pubsub(void) { FuriPubSub* test_pubsub = NULL; FuriPubSubSubscription* test_pubsub_subscription = NULL; diff --git a/applications/debug/unit_tests/furi/furi_record_test.c b/applications/debug/unit_tests/furi/furi_record_test.c index 236e1efc5..10a5a8393 100644 --- a/applications/debug/unit_tests/furi/furi_record_test.c +++ b/applications/debug/unit_tests/furi/furi_record_test.c @@ -5,7 +5,7 @@ #define TEST_RECORD_NAME "test/holding" -void test_furi_create_open() { +void test_furi_create_open(void) { // Test that record does not exist mu_check(furi_record_exists(TEST_RECORD_NAME) == false); diff --git a/applications/debug/unit_tests/furi/furi_string_test.c b/applications/debug/unit_tests/furi/furi_string_test.c index 6cbcc0dcc..853076b67 100644 --- a/applications/debug/unit_tests/furi/furi_string_test.c +++ b/applications/debug/unit_tests/furi/furi_string_test.c @@ -462,7 +462,7 @@ MU_TEST_SUITE(test_suite) { MU_RUN_TEST(mu_test_furi_string_utf8); } -int run_minunit_test_furi_string() { +int run_minunit_test_furi_string(void) { MU_RUN_SUITE(test_suite); return MU_EXIT_CODE; diff --git a/applications/debug/unit_tests/furi/furi_test.c b/applications/debug/unit_tests/furi/furi_test.c index 33ec5fd01..2f271c305 100644 --- a/applications/debug/unit_tests/furi/furi_test.c +++ b/applications/debug/unit_tests/furi/furi_test.c @@ -50,7 +50,7 @@ MU_TEST_SUITE(test_suite) { MU_RUN_TEST(mu_test_furi_memmgr); } -int run_minunit_test_furi() { +int run_minunit_test_furi(void) { MU_RUN_SUITE(test_suite); return MU_EXIT_CODE; diff --git a/applications/debug/unit_tests/furi_hal/furi_hal_crypto_tests.c b/applications/debug/unit_tests/furi_hal/furi_hal_crypto_tests.c index b06d51130..c2bd6c5f8 100644 --- a/applications/debug/unit_tests/furi_hal/furi_hal_crypto_tests.c +++ b/applications/debug/unit_tests/furi_hal/furi_hal_crypto_tests.c @@ -409,16 +409,16 @@ static const uint8_t tv_gcm_tag_4[16] = { 0x1B, }; -static void furi_hal_crypto_ctr_setup() { +static void furi_hal_crypto_ctr_setup(void) { } -static void furi_hal_crypto_ctr_teardown() { +static void furi_hal_crypto_ctr_teardown(void) { } -static void furi_hal_crypto_gcm_setup() { +static void furi_hal_crypto_gcm_setup(void) { } -static void furi_hal_crypto_gcm_teardown() { +static void furi_hal_crypto_gcm_teardown(void) { } MU_TEST(furi_hal_crypto_ctr_1) { @@ -595,7 +595,7 @@ MU_TEST_SUITE(furi_hal_crypto_gcm_test) { MU_RUN_TEST(furi_hal_crypto_gcm_4); } -int run_minunit_test_furi_hal_crypto() { +int run_minunit_test_furi_hal_crypto(void) { MU_RUN_SUITE(furi_hal_crypto_ctr_test); MU_RUN_SUITE(furi_hal_crypto_gcm_test); return MU_EXIT_CODE; diff --git a/applications/debug/unit_tests/furi_hal/furi_hal_tests.c b/applications/debug/unit_tests/furi_hal/furi_hal_tests.c index a75615d0c..0c5cec8a6 100644 --- a/applications/debug/unit_tests/furi_hal/furi_hal_tests.c +++ b/applications/debug/unit_tests/furi_hal/furi_hal_tests.c @@ -14,19 +14,19 @@ #define EEPROM_PAGE_SIZE 16 #define EEPROM_WRITE_DELAY_MS 6 -static void furi_hal_i2c_int_setup() { +static void furi_hal_i2c_int_setup(void) { furi_hal_i2c_acquire(&furi_hal_i2c_handle_power); } -static void furi_hal_i2c_int_teardown() { +static void furi_hal_i2c_int_teardown(void) { furi_hal_i2c_release(&furi_hal_i2c_handle_power); } -static void furi_hal_i2c_ext_setup() { +static void furi_hal_i2c_ext_setup(void) { furi_hal_i2c_acquire(&furi_hal_i2c_handle_external); } -static void furi_hal_i2c_ext_teardown() { +static void furi_hal_i2c_ext_teardown(void) { furi_hal_i2c_release(&furi_hal_i2c_handle_external); } @@ -227,7 +227,7 @@ MU_TEST_SUITE(furi_hal_i2c_ext_suite) { MU_RUN_TEST(furi_hal_i2c_ext_eeprom); } -int run_minunit_test_furi_hal() { +int run_minunit_test_furi_hal(void) { MU_RUN_SUITE(furi_hal_i2c_int_suite); MU_RUN_SUITE(furi_hal_i2c_ext_suite); return MU_EXIT_CODE; diff --git a/applications/debug/unit_tests/infrared/infrared_test.c b/applications/debug/unit_tests/infrared/infrared_test.c index ba57b78aa..4442fedb3 100644 --- a/applications/debug/unit_tests/infrared/infrared_test.c +++ b/applications/debug/unit_tests/infrared/infrared_test.c @@ -17,7 +17,7 @@ typedef struct { static InfraredTest* test; -static void infrared_test_alloc() { +static void infrared_test_alloc(void) { Storage* storage = furi_record_open(RECORD_STORAGE); test = malloc(sizeof(InfraredTest)); test->decoder_handler = infrared_alloc_decoder(); @@ -26,7 +26,7 @@ static void infrared_test_alloc() { test->file_path = furi_string_alloc(); } -static void infrared_test_free() { +static void infrared_test_free(void) { furi_check(test); infrared_free_decoder(test->decoder_handler); infrared_free_encoder(test->encoder_handler); @@ -545,7 +545,7 @@ MU_TEST_SUITE(infrared_test) { MU_RUN_TEST(infrared_test_encoder_decoder_all); } -int run_minunit_test_infrared() { +int run_minunit_test_infrared(void) { MU_RUN_SUITE(infrared_test); return MU_EXIT_CODE; } diff --git a/applications/debug/unit_tests/lfrfid/lfrfid_protocols.c b/applications/debug/unit_tests/lfrfid/lfrfid_protocols.c index d5c2433ba..6a7dbab9c 100644 --- a/applications/debug/unit_tests/lfrfid/lfrfid_protocols.c +++ b/applications/debug/unit_tests/lfrfid/lfrfid_protocols.c @@ -547,7 +547,7 @@ MU_TEST_SUITE(test_lfrfid_protocols_suite) { MU_RUN_TEST(test_lfrfid_protocol_fdxb_emulate_simple); } -int run_minunit_test_lfrfid_protocols() { +int run_minunit_test_lfrfid_protocols(void) { MU_RUN_SUITE(test_lfrfid_protocols_suite); return MU_EXIT_CODE; } \ No newline at end of file diff --git a/applications/debug/unit_tests/manifest/manifest.c b/applications/debug/unit_tests/manifest/manifest.c index 19370b0e1..e8ac93d7c 100644 --- a/applications/debug/unit_tests/manifest/manifest.c +++ b/applications/debug/unit_tests/manifest/manifest.c @@ -69,7 +69,7 @@ MU_TEST_SUITE(manifest_suite) { MU_RUN_TEST(manifest_iteration_test); } -int run_minunit_test_manifest() { +int run_minunit_test_manifest(void) { MU_RUN_SUITE(manifest_suite); return MU_EXIT_CODE; } \ No newline at end of file diff --git a/applications/debug/unit_tests/nfc/nfc_test.c b/applications/debug/unit_tests/nfc/nfc_test.c index 29b9e80d9..4b6503b72 100644 --- a/applications/debug/unit_tests/nfc/nfc_test.c +++ b/applications/debug/unit_tests/nfc/nfc_test.c @@ -28,12 +28,12 @@ typedef struct { static NfcTest* nfc_test = NULL; -static void nfc_test_alloc() { +static void nfc_test_alloc(void) { nfc_test = malloc(sizeof(NfcTest)); nfc_test->storage = furi_record_open(RECORD_STORAGE); } -static void nfc_test_free() { +static void nfc_test_free(void) { furi_check(nfc_test); furi_record_close(RECORD_STORAGE); @@ -292,7 +292,7 @@ MU_TEST(ntag_213_locked_reader) { nfc_free(poller); } -static void mf_ultralight_write() { +static void mf_ultralight_write(void) { Nfc* poller = nfc_alloc(); Nfc* listener = nfc_alloc(); @@ -342,7 +342,7 @@ static void mf_ultralight_write() { nfc_free(poller); } -static void mf_classic_reader() { +static void mf_classic_reader(void) { Nfc* poller = nfc_alloc(); Nfc* listener = nfc_alloc(); @@ -368,7 +368,7 @@ static void mf_classic_reader() { nfc_free(poller); } -static void mf_classic_write() { +static void mf_classic_write(void) { Nfc* poller = nfc_alloc(); Nfc* listener = nfc_alloc(); @@ -396,7 +396,7 @@ static void mf_classic_write() { nfc_free(poller); } -static void mf_classic_value_block() { +static void mf_classic_value_block(void) { Nfc* poller = nfc_alloc(); Nfc* listener = nfc_alloc(); @@ -548,7 +548,7 @@ MU_TEST_SUITE(nfc) { nfc_test_free(); } -int run_minunit_test_nfc() { +int run_minunit_test_nfc(void) { MU_RUN_SUITE(nfc); return MU_EXIT_CODE; } diff --git a/applications/debug/unit_tests/nfc/nfc_transport.c b/applications/debug/unit_tests/nfc/nfc_transport.c index e9f4e2134..6886ef66d 100644 --- a/applications/debug/unit_tests/nfc/nfc_transport.c +++ b/applications/debug/unit_tests/nfc/nfc_transport.c @@ -115,7 +115,7 @@ static void nfc_prepare_col_res_data( } } -Nfc* nfc_alloc() { +Nfc* nfc_alloc(void) { Nfc* instance = malloc(sizeof(Nfc)); return instance; diff --git a/applications/debug/unit_tests/power/power_test.c b/applications/debug/unit_tests/power/power_test.c index a9b66b221..03e0ad269 100644 --- a/applications/debug/unit_tests/power/power_test.c +++ b/applications/debug/unit_tests/power/power_test.c @@ -63,7 +63,7 @@ MU_TEST_SUITE(test_power_suite) { power_test_deinit(); } -int run_minunit_test_power() { +int run_minunit_test_power(void) { MU_RUN_SUITE(test_power_suite); return MU_EXIT_CODE; } diff --git a/applications/debug/unit_tests/protocol_dict/protocol_dict_test.c b/applications/debug/unit_tests/protocol_dict/protocol_dict_test.c index 73e77ec90..6ecaa1a52 100644 --- a/applications/debug/unit_tests/protocol_dict/protocol_dict_test.c +++ b/applications/debug/unit_tests/protocol_dict/protocol_dict_test.c @@ -18,7 +18,7 @@ typedef struct { static const uint32_t protocol_0_decoder_result = 0xDEADBEEF; -static void* protocol_0_alloc() { +static void* protocol_0_alloc(void) { void* data = malloc(sizeof(Protocol0Data)); return data; } @@ -63,7 +63,7 @@ typedef struct { static const uint64_t protocol_1_decoder_result = 0x1234567890ABCDEF; -static void* protocol_1_alloc() { +static void* protocol_1_alloc(void) { void* data = malloc(sizeof(Protocol1Data)); return data; } @@ -216,7 +216,7 @@ MU_TEST_SUITE(test_protocol_dict_suite) { MU_RUN_TEST(test_protocol_dict); } -int run_minunit_test_protocol_dict() { +int run_minunit_test_protocol_dict(void) { MU_RUN_SUITE(test_protocol_dict_suite); return MU_EXIT_CODE; } \ No newline at end of file diff --git a/applications/debug/unit_tests/rpc/rpc_test.c b/applications/debug/unit_tests/rpc/rpc_test.c index 3faf61572..cd692d69d 100644 --- a/applications/debug/unit_tests/rpc/rpc_test.c +++ b/applications/debug/unit_tests/rpc/rpc_test.c @@ -1840,7 +1840,7 @@ MU_TEST_SUITE(test_rpc_session) { furi_record_close(RECORD_STORAGE); } -int run_minunit_test_rpc() { +int run_minunit_test_rpc(void) { Storage* storage = furi_record_open(RECORD_STORAGE); if(storage_sd_status(storage) != FSE_OK) { FURI_LOG_E(TAG, "SD card not mounted - skip storage tests"); diff --git a/applications/debug/unit_tests/storage/dirwalk_test.c b/applications/debug/unit_tests/storage/dirwalk_test.c index 19ac336ff..415ec7dd4 100644 --- a/applications/debug/unit_tests/storage/dirwalk_test.c +++ b/applications/debug/unit_tests/storage/dirwalk_test.c @@ -266,7 +266,7 @@ MU_TEST_SUITE(test_dirwalk_suite) { furi_record_close(RECORD_STORAGE); } -int run_minunit_test_dirwalk() { +int run_minunit_test_dirwalk(void) { MU_RUN_SUITE(test_dirwalk_suite); return MU_EXIT_CODE; } \ No newline at end of file diff --git a/applications/debug/unit_tests/storage/storage_test.c b/applications/debug/unit_tests/storage/storage_test.c index 5ea36935b..e4361f06c 100644 --- a/applications/debug/unit_tests/storage/storage_test.c +++ b/applications/debug/unit_tests/storage/storage_test.c @@ -36,7 +36,7 @@ static bool storage_file_create(Storage* storage, const char* path, const char* return result; } -static void storage_file_open_lock_setup() { +static void storage_file_open_lock_setup(void) { Storage* storage = furi_record_open(RECORD_STORAGE); File* file = storage_file_alloc(storage); storage_simply_remove(storage, STORAGE_LOCKED_FILE); @@ -47,7 +47,7 @@ static void storage_file_open_lock_setup() { furi_record_close(RECORD_STORAGE); } -static void storage_file_open_lock_teardown() { +static void storage_file_open_lock_teardown(void) { Storage* storage = furi_record_open(RECORD_STORAGE); mu_check(storage_simply_remove(storage, STORAGE_LOCKED_FILE)); furi_record_close(RECORD_STORAGE); @@ -702,7 +702,7 @@ MU_TEST_SUITE(test_md5_calc_suite) { MU_RUN_TEST(test_md5_calc); } -int run_minunit_test_storage() { +int run_minunit_test_storage(void) { MU_RUN_SUITE(storage_file); MU_RUN_SUITE(storage_file_64k); MU_RUN_SUITE(storage_dir); diff --git a/applications/debug/unit_tests/stream/stream_test.c b/applications/debug/unit_tests/stream/stream_test.c index 2fa3b21a2..3e31773b4 100644 --- a/applications/debug/unit_tests/stream/stream_test.c +++ b/applications/debug/unit_tests/stream/stream_test.c @@ -526,7 +526,7 @@ MU_TEST_SUITE(stream_suite) { MU_RUN_TEST(stream_buffered_large_file_test); } -int run_minunit_test_stream() { +int run_minunit_test_stream(void) { MU_RUN_SUITE(stream_suite); return MU_EXIT_CODE; } diff --git a/applications/debug/unit_tests/subghz/subghz_test.c b/applications/debug/unit_tests/subghz/subghz_test.c index 0e6509b62..adb8b4965 100644 --- a/applications/debug/unit_tests/subghz/subghz_test.c +++ b/applications/debug/unit_tests/subghz/subghz_test.c @@ -312,7 +312,7 @@ static LevelDuration subghz_hal_async_tx_test_yield(void* context) { furi_crash("Yield after reset"); } } else { - furi_crash("Programming error"); + furi_crash(); } } @@ -902,7 +902,7 @@ MU_TEST_SUITE(subghz) { subghz_test_deinit(); } -int run_minunit_test_subghz() { +int run_minunit_test_subghz(void) { MU_RUN_SUITE(subghz); return MU_EXIT_CODE; } diff --git a/applications/debug/unit_tests/test_index.c b/applications/debug/unit_tests/test_index.c index 60132a161..eb475fada 100644 --- a/applications/debug/unit_tests/test_index.c +++ b/applications/debug/unit_tests/test_index.c @@ -66,7 +66,7 @@ const UnitTest unit_tests[] = { {.name = "expansion", .entry = run_minunit_test_expansion}, }; -void minunit_print_progress() { +void minunit_print_progress(void) { static const char progress[] = {'\\', '|', '/', '-'}; static uint8_t progress_counter = 0; static uint32_t last_tick = 0; @@ -157,7 +157,7 @@ void unit_tests_cli(Cli* cli, FuriString* args, void* context) { furi_record_close(RECORD_LOADER); } -void unit_tests_on_system_start() { +void unit_tests_on_system_start(void) { #ifdef SRV_CLI Cli* cli = furi_record_open(RECORD_CLI); diff --git a/applications/debug/unit_tests/varint/varint_test.c b/applications/debug/unit_tests/varint/varint_test.c index 8faab1368..ac444013d 100644 --- a/applications/debug/unit_tests/varint/varint_test.c +++ b/applications/debug/unit_tests/varint/varint_test.c @@ -82,7 +82,7 @@ MU_TEST_SUITE(test_varint_suite) { MU_RUN_TEST(test_varint_rand_i); } -int run_minunit_test_varint() { +int run_minunit_test_varint(void) { MU_RUN_SUITE(test_varint_suite); return MU_EXIT_CODE; } \ No newline at end of file diff --git a/applications/debug/usb_test/usb_test.c b/applications/debug/usb_test/usb_test.c index ed86c37a8..ddec9d9b0 100644 --- a/applications/debug/usb_test/usb_test.c +++ b/applications/debug/usb_test/usb_test.c @@ -55,7 +55,7 @@ uint32_t usb_test_exit(void* context) { return VIEW_NONE; } -UsbTestApp* usb_test_app_alloc() { +UsbTestApp* usb_test_app_alloc(void) { UsbTestApp* app = malloc(sizeof(UsbTestApp)); // Gui diff --git a/applications/drivers/subghz/cc1101_ext/cc1101_ext.c b/applications/drivers/subghz/cc1101_ext/cc1101_ext.c index 5c67579cc..d27d11416 100644 --- a/applications/drivers/subghz/cc1101_ext/cc1101_ext.c +++ b/applications/drivers/subghz/cc1101_ext/cc1101_ext.c @@ -98,7 +98,7 @@ typedef struct { static SubGhzDeviceCC1101Ext* subghz_device_cc1101_ext = NULL; -static bool subghz_device_cc1101_ext_check_init() { +static bool subghz_device_cc1101_ext_check_init(void) { furi_assert(subghz_device_cc1101_ext->state == SubGhzDeviceCC1101ExtStateInit); subghz_device_cc1101_ext->state = SubGhzDeviceCC1101ExtStateIdle; @@ -232,7 +232,7 @@ bool subghz_device_cc1101_ext_alloc(SubGhzDeviceConf* conf) { return subghz_device_cc1101_ext_check_init(); } -void subghz_device_cc1101_ext_free() { +void subghz_device_cc1101_ext_free(void) { furi_assert(subghz_device_cc1101_ext != NULL); furi_hal_spi_bus_handle_deinit(subghz_device_cc1101_ext->spi_bus_handle); @@ -248,11 +248,11 @@ void subghz_device_cc1101_ext_set_async_mirror_pin(const GpioPin* pin) { subghz_device_cc1101_ext->async_mirror_pin = pin; } -const GpioPin* subghz_device_cc1101_ext_get_data_gpio() { +const GpioPin* subghz_device_cc1101_ext_get_data_gpio(void) { return subghz_device_cc1101_ext->g0_pin; } -bool subghz_device_cc1101_ext_is_connect() { +bool subghz_device_cc1101_ext_is_connect(void) { bool ret = false; if(subghz_device_cc1101_ext == NULL) { // not initialized @@ -268,7 +268,7 @@ bool subghz_device_cc1101_ext_is_connect() { return ret; } -void subghz_device_cc1101_ext_sleep() { +void subghz_device_cc1101_ext_sleep(void) { furi_assert(subghz_device_cc1101_ext->state == SubGhzDeviceCC1101ExtStateIdle); furi_hal_spi_acquire(subghz_device_cc1101_ext->spi_bus_handle); @@ -283,7 +283,7 @@ void subghz_device_cc1101_ext_sleep() { furi_hal_spi_release(subghz_device_cc1101_ext->spi_bus_handle); } -void subghz_device_cc1101_ext_dump_state() { +void subghz_device_cc1101_ext_dump_state(void) { furi_hal_spi_acquire(subghz_device_cc1101_ext->spi_bus_handle); printf( "[subghz_device_cc1101_ext] cc1101 chip %d, version %d\r\n", @@ -348,19 +348,19 @@ void subghz_device_cc1101_ext_write_packet(const uint8_t* data, uint8_t size) { furi_hal_spi_release(subghz_device_cc1101_ext->spi_bus_handle); } -void subghz_device_cc1101_ext_flush_rx() { +void subghz_device_cc1101_ext_flush_rx(void) { furi_hal_spi_acquire(subghz_device_cc1101_ext->spi_bus_handle); cc1101_flush_rx(subghz_device_cc1101_ext->spi_bus_handle); furi_hal_spi_release(subghz_device_cc1101_ext->spi_bus_handle); } -void subghz_device_cc1101_ext_flush_tx() { +void subghz_device_cc1101_ext_flush_tx(void) { furi_hal_spi_acquire(subghz_device_cc1101_ext->spi_bus_handle); cc1101_flush_tx(subghz_device_cc1101_ext->spi_bus_handle); furi_hal_spi_release(subghz_device_cc1101_ext->spi_bus_handle); } -bool subghz_device_cc1101_ext_rx_pipe_not_empty() { +bool subghz_device_cc1101_ext_rx_pipe_not_empty(void) { CC1101RxBytes status[1]; furi_hal_spi_acquire(subghz_device_cc1101_ext->spi_bus_handle); cc1101_read_reg( @@ -376,7 +376,7 @@ bool subghz_device_cc1101_ext_rx_pipe_not_empty() { } } -bool subghz_device_cc1101_ext_is_rx_data_crc_valid() { +bool subghz_device_cc1101_ext_is_rx_data_crc_valid(void) { furi_hal_spi_acquire(subghz_device_cc1101_ext->spi_bus_handle); uint8_t data[1]; cc1101_read_reg( @@ -395,14 +395,14 @@ void subghz_device_cc1101_ext_read_packet(uint8_t* data, uint8_t* size) { furi_hal_spi_release(subghz_device_cc1101_ext->spi_bus_handle); } -void subghz_device_cc1101_ext_shutdown() { +void subghz_device_cc1101_ext_shutdown(void) { furi_hal_spi_acquire(subghz_device_cc1101_ext->spi_bus_handle); // Reset and shutdown cc1101_shutdown(subghz_device_cc1101_ext->spi_bus_handle); furi_hal_spi_release(subghz_device_cc1101_ext->spi_bus_handle); } -void subghz_device_cc1101_ext_reset() { +void subghz_device_cc1101_ext_reset(void) { furi_hal_spi_acquire(subghz_device_cc1101_ext->spi_bus_handle); furi_hal_gpio_init(subghz_device_cc1101_ext->g0_pin, GpioModeAnalog, GpioPullNo, GpioSpeedLow); cc1101_switch_to_idle(subghz_device_cc1101_ext->spi_bus_handle); @@ -413,7 +413,7 @@ void subghz_device_cc1101_ext_reset() { furi_hal_spi_release(subghz_device_cc1101_ext->spi_bus_handle); } -void subghz_device_cc1101_ext_idle() { +void subghz_device_cc1101_ext_idle(void) { furi_hal_spi_acquire(subghz_device_cc1101_ext->spi_bus_handle); cc1101_switch_to_idle(subghz_device_cc1101_ext->spi_bus_handle); //waiting for the chip to switch to IDLE mode @@ -425,7 +425,7 @@ void subghz_device_cc1101_ext_idle() { } } -void subghz_device_cc1101_ext_rx() { +void subghz_device_cc1101_ext_rx(void) { furi_hal_spi_acquire(subghz_device_cc1101_ext->spi_bus_handle); cc1101_switch_to_rx(subghz_device_cc1101_ext->spi_bus_handle); //waiting for the chip to switch to Rx mode @@ -437,7 +437,7 @@ void subghz_device_cc1101_ext_rx() { } } -bool subghz_device_cc1101_ext_tx() { +bool subghz_device_cc1101_ext_tx(void) { if(subghz_device_cc1101_ext->regulation != SubGhzDeviceCC1101ExtRegulationTxRx) return false; furi_hal_spi_acquire(subghz_device_cc1101_ext->spi_bus_handle); cc1101_switch_to_tx(subghz_device_cc1101_ext->spi_bus_handle); @@ -451,7 +451,7 @@ bool subghz_device_cc1101_ext_tx() { return true; } -float subghz_device_cc1101_ext_get_rssi() { +float subghz_device_cc1101_ext_get_rssi(void) { furi_hal_spi_acquire(subghz_device_cc1101_ext->spi_bus_handle); int32_t rssi_dec = cc1101_get_rssi(subghz_device_cc1101_ext->spi_bus_handle); furi_hal_spi_release(subghz_device_cc1101_ext->spi_bus_handle); @@ -466,7 +466,7 @@ float subghz_device_cc1101_ext_get_rssi() { return rssi; } -uint8_t subghz_device_cc1101_ext_get_lqi() { +uint8_t subghz_device_cc1101_ext_get_lqi(void) { furi_hal_spi_acquire(subghz_device_cc1101_ext->spi_bus_handle); uint8_t data[1]; cc1101_read_reg( @@ -525,7 +525,7 @@ uint32_t subghz_device_cc1101_ext_set_frequency(uint32_t value) { return real_frequency; } -static bool subghz_device_cc1101_ext_start_debug() { +static bool subghz_device_cc1101_ext_start_debug(void) { bool ret = false; if(subghz_device_cc1101_ext->async_mirror_pin != NULL) { furi_hal_gpio_init( @@ -538,7 +538,7 @@ static bool subghz_device_cc1101_ext_start_debug() { return ret; } -static bool subghz_device_cc1101_ext_stop_debug() { +static bool subghz_device_cc1101_ext_stop_debug(void) { bool ret = false; if(subghz_device_cc1101_ext->async_mirror_pin != NULL) { furi_hal_gpio_init( @@ -620,7 +620,7 @@ void subghz_device_cc1101_ext_start_async_rx( subghz_device_cc1101_ext->async_rx.capture_delta_duration = 0; } -void subghz_device_cc1101_ext_stop_async_rx() { +void subghz_device_cc1101_ext_stop_async_rx(void) { furi_assert(subghz_device_cc1101_ext->state == SubGhzDeviceCC1101ExtStateAsyncRx); subghz_device_cc1101_ext->state = SubGhzDeviceCC1101ExtStateIdle; @@ -858,13 +858,13 @@ bool subghz_device_cc1101_ext_start_async_tx(SubGhzDeviceCC1101ExtCallback callb return true; } -bool subghz_device_cc1101_ext_is_async_tx_complete() { +bool subghz_device_cc1101_ext_is_async_tx_complete(void) { return ( (subghz_device_cc1101_ext->state == SubGhzDeviceCC1101ExtStateAsyncTx) && (LL_TIM_GetAutoReload(TIM17) == 0)); } -void subghz_device_cc1101_ext_stop_async_tx() { +void subghz_device_cc1101_ext_stop_async_tx(void) { furi_assert(subghz_device_cc1101_ext->state == SubGhzDeviceCC1101ExtStateAsyncTx); // Shutdown radio diff --git a/applications/drivers/subghz/cc1101_ext/cc1101_ext.h b/applications/drivers/subghz/cc1101_ext/cc1101_ext.h index 64b7d4cc1..0832de8ac 100644 --- a/applications/drivers/subghz/cc1101_ext/cc1101_ext.h +++ b/applications/drivers/subghz/cc1101_ext/cc1101_ext.h @@ -29,7 +29,7 @@ void subghz_device_cc1101_ext_set_async_mirror_pin(const GpioPin* pin); * * @return pointer to the gpio pin structure */ -const GpioPin* subghz_device_cc1101_ext_get_data_gpio(); +const GpioPin* subghz_device_cc1101_ext_get_data_gpio(void); /** Initialize device * @@ -39,21 +39,21 @@ bool subghz_device_cc1101_ext_alloc(SubGhzDeviceConf* conf); /** Deinitialize device */ -void subghz_device_cc1101_ext_free(); +void subghz_device_cc1101_ext_free(void); /** Check and switch to power save mode Used by internal API-HAL * initialization routine Can be used to reinitialize device to safe state and * send it to sleep */ -bool subghz_device_cc1101_ext_is_connect(); +bool subghz_device_cc1101_ext_is_connect(void); /** Send device to sleep mode */ -void subghz_device_cc1101_ext_sleep(); +void subghz_device_cc1101_ext_sleep(void); /** Dump info to stdout */ -void subghz_device_cc1101_ext_dump_state(); +void subghz_device_cc1101_ext_dump_state(void); /** Load custom registers from preset * @@ -84,13 +84,13 @@ void subghz_device_cc1101_ext_write_packet(const uint8_t* data, uint8_t size); * * @return true if not empty */ -bool subghz_device_cc1101_ext_rx_pipe_not_empty(); +bool subghz_device_cc1101_ext_rx_pipe_not_empty(void); /** Check if received data crc is valid * * @return true if valid */ -bool subghz_device_cc1101_ext_is_rx_data_crc_valid(); +bool subghz_device_cc1101_ext_is_rx_data_crc_valid(void); /** Read packet from FIFO * @@ -101,47 +101,47 @@ void subghz_device_cc1101_ext_read_packet(uint8_t* data, uint8_t* size); /** Flush rx FIFO buffer */ -void subghz_device_cc1101_ext_flush_rx(); +void subghz_device_cc1101_ext_flush_rx(void); /** Flush tx FIFO buffer */ -void subghz_device_cc1101_ext_flush_tx(); +void subghz_device_cc1101_ext_flush_tx(void); /** Shutdown Issue SPWD command * @warning registers content will be lost */ -void subghz_device_cc1101_ext_shutdown(); +void subghz_device_cc1101_ext_shutdown(void); /** Reset Issue reset command * @warning registers content will be lost */ -void subghz_device_cc1101_ext_reset(); +void subghz_device_cc1101_ext_reset(void); /** Switch to Idle */ -void subghz_device_cc1101_ext_idle(); +void subghz_device_cc1101_ext_idle(void); /** Switch to Receive */ -void subghz_device_cc1101_ext_rx(); +void subghz_device_cc1101_ext_rx(void); /** Switch to Transmit * * @return true if the transfer is allowed by belonging to the region */ -bool subghz_device_cc1101_ext_tx(); +bool subghz_device_cc1101_ext_tx(void); /** Get RSSI value in dBm * * @return RSSI value */ -float subghz_device_cc1101_ext_get_rssi(); +float subghz_device_cc1101_ext_get_rssi(void); /** Get LQI * * @return LQI value */ -uint8_t subghz_device_cc1101_ext_get_lqi(); +uint8_t subghz_device_cc1101_ext_get_lqi(void); /** Check if frequency is in valid range * @@ -175,7 +175,7 @@ void subghz_device_cc1101_ext_start_async_rx( /** Disable signal timings capture Resets GPIO and TIM2 */ -void subghz_device_cc1101_ext_stop_async_rx(); +void subghz_device_cc1101_ext_stop_async_rx(void); /** Async TX callback type * @param context callback context @@ -196,11 +196,11 @@ bool subghz_device_cc1101_ext_start_async_tx(SubGhzDeviceCC1101ExtCallback callb * * @return true if TX complete */ -bool subghz_device_cc1101_ext_is_async_tx_complete(); +bool subghz_device_cc1101_ext_is_async_tx_complete(void); /** Stop async transmission and cleanup resources Resets GPIO, TIM2, and DMA1 */ -void subghz_device_cc1101_ext_stop_async_tx(); +void subghz_device_cc1101_ext_stop_async_tx(void); #ifdef __cplusplus } diff --git a/applications/drivers/subghz/cc1101_ext/cc1101_ext_interconnect.c b/applications/drivers/subghz/cc1101_ext/cc1101_ext_interconnect.c index 1f1193154..68f2b8aff 100644 --- a/applications/drivers/subghz/cc1101_ext/cc1101_ext_interconnect.c +++ b/applications/drivers/subghz/cc1101_ext/cc1101_ext_interconnect.c @@ -105,6 +105,6 @@ static const FlipperAppPluginDescriptor subghz_device_cc1101_ext_descriptor = { .entry_point = &subghz_device_cc1101_ext, }; -const FlipperAppPluginDescriptor* subghz_device_cc1101_ext_ep() { +const FlipperAppPluginDescriptor* subghz_device_cc1101_ext_ep(void) { return &subghz_device_cc1101_ext_descriptor; } \ No newline at end of file diff --git a/applications/drivers/subghz/cc1101_ext/cc1101_ext_interconnect.h b/applications/drivers/subghz/cc1101_ext/cc1101_ext_interconnect.h index cf1ff3ee0..3fcee45d5 100644 --- a/applications/drivers/subghz/cc1101_ext/cc1101_ext_interconnect.h +++ b/applications/drivers/subghz/cc1101_ext/cc1101_ext_interconnect.h @@ -5,4 +5,4 @@ typedef struct SubGhzDeviceCC1101Ext SubGhzDeviceCC1101Ext; -const FlipperAppPluginDescriptor* subghz_device_cc1101_ext_ep(); +const FlipperAppPluginDescriptor* subghz_device_cc1101_ext_ep(void); diff --git a/applications/examples/example_ble_beacon/ble_beacon_app.c b/applications/examples/example_ble_beacon/ble_beacon_app.c index 20e3e307a..af2133602 100644 --- a/applications/examples/example_ble_beacon/ble_beacon_app.c +++ b/applications/examples/example_ble_beacon/ble_beacon_app.c @@ -57,7 +57,7 @@ static void ble_beacon_app_restore_beacon_state(BleBeaconApp* app) { app->beacon_data_len = furi_hal_bt_extra_beacon_get_data(app->beacon_data); } -static BleBeaconApp* ble_beacon_app_alloc() { +static BleBeaconApp* ble_beacon_app_alloc(void) { BleBeaconApp* app = malloc(sizeof(BleBeaconApp)); app->gui = furi_record_open(RECORD_GUI); diff --git a/applications/examples/example_plugins/plugin1.c b/applications/examples/example_plugins/plugin1.c index de8041f34..05036d252 100644 --- a/applications/examples/example_plugins/plugin1.c +++ b/applications/examples/example_plugins/plugin1.c @@ -9,7 +9,7 @@ #include -static int example_plugin1_method1() { +static int example_plugin1_method1(void) { return 42; } @@ -32,6 +32,6 @@ static const FlipperAppPluginDescriptor example_plugin1_descriptor = { }; /* Plugin entry point - must return a pointer to const descriptor */ -const FlipperAppPluginDescriptor* example_plugin1_ep() { +const FlipperAppPluginDescriptor* example_plugin1_ep(void) { return &example_plugin1_descriptor; } diff --git a/applications/examples/example_plugins/plugin2.c b/applications/examples/example_plugins/plugin2.c index a196437f4..bff170dde 100644 --- a/applications/examples/example_plugins/plugin2.c +++ b/applications/examples/example_plugins/plugin2.c @@ -9,7 +9,7 @@ #include -static int example_plugin2_method1() { +static int example_plugin2_method1(void) { return 1337; } @@ -32,6 +32,6 @@ static const FlipperAppPluginDescriptor example_plugin2_descriptor = { }; /* Plugin entry point - must return a pointer to const descriptor */ -const FlipperAppPluginDescriptor* example_plugin2_ep() { +const FlipperAppPluginDescriptor* example_plugin2_ep(void) { return &example_plugin2_descriptor; } diff --git a/applications/examples/example_plugins/plugin_interface.h b/applications/examples/example_plugins/plugin_interface.h index 85428429e..fadb9089f 100644 --- a/applications/examples/example_plugins/plugin_interface.h +++ b/applications/examples/example_plugins/plugin_interface.h @@ -11,6 +11,6 @@ typedef struct { const char* name; - int (*method1)(); + int (*method1)(void); int (*method2)(int, int); } ExamplePlugin; diff --git a/applications/examples/example_plugins_advanced/app_api.c b/applications/examples/example_plugins_advanced/app_api.c index 42b3a1860..4f314f4ce 100644 --- a/applications/examples/example_plugins_advanced/app_api.c +++ b/applications/examples/example_plugins_advanced/app_api.c @@ -8,7 +8,7 @@ void app_api_accumulator_set(uint32_t value) { accumulator = value; } -uint32_t app_api_accumulator_get() { +uint32_t app_api_accumulator_get(void) { return accumulator; } diff --git a/applications/examples/example_plugins_advanced/app_api.h b/applications/examples/example_plugins_advanced/app_api.h index 60a52e6f7..df80455d7 100644 --- a/applications/examples/example_plugins_advanced/app_api.h +++ b/applications/examples/example_plugins_advanced/app_api.h @@ -15,7 +15,7 @@ extern "C" { void app_api_accumulator_set(uint32_t value); -uint32_t app_api_accumulator_get(); +uint32_t app_api_accumulator_get(void); void app_api_accumulator_add(uint32_t value); diff --git a/applications/examples/example_plugins_advanced/plugin1.c b/applications/examples/example_plugins_advanced/plugin1.c index 913081007..e45122d95 100644 --- a/applications/examples/example_plugins_advanced/plugin1.c +++ b/applications/examples/example_plugins_advanced/plugin1.c @@ -18,7 +18,7 @@ static void advanced_plugin1_method1(int arg1) { app_api_accumulator_add(arg1); } -static void advanced_plugin1_method2() { +static void advanced_plugin1_method2(void) { /* Accumulator value is stored inside host application */ FURI_LOG_I("TEST", "Plugin 1, accumulator: %lu", app_api_accumulator_get()); } @@ -38,6 +38,6 @@ static const FlipperAppPluginDescriptor advanced_plugin1_descriptor = { }; /* Plugin entry point - must return a pointer to const descriptor */ -const FlipperAppPluginDescriptor* advanced_plugin1_ep() { +const FlipperAppPluginDescriptor* advanced_plugin1_ep(void) { return &advanced_plugin1_descriptor; } diff --git a/applications/examples/example_plugins_advanced/plugin2.c b/applications/examples/example_plugins_advanced/plugin2.c index 1ea5590b2..efc8db478 100644 --- a/applications/examples/example_plugins_advanced/plugin2.c +++ b/applications/examples/example_plugins_advanced/plugin2.c @@ -18,7 +18,7 @@ static void advanced_plugin2_method1(int arg1) { app_api_accumulator_mul(arg1); } -static void advanced_plugin2_method2() { +static void advanced_plugin2_method2(void) { /* Accumulator value is stored inside host application */ FURI_LOG_I("TEST", "Plugin 2, accumulator: %lu", app_api_accumulator_get()); } @@ -38,6 +38,6 @@ static const FlipperAppPluginDescriptor advanced_plugin2_descriptor = { }; /* Plugin entry point - must return a pointer to const descriptor */ -const FlipperAppPluginDescriptor* advanced_plugin2_ep() { +const FlipperAppPluginDescriptor* advanced_plugin2_ep(void) { return &advanced_plugin2_descriptor; } diff --git a/applications/examples/example_plugins_advanced/plugin_interface.h b/applications/examples/example_plugins_advanced/plugin_interface.h index d78dc9ecc..4cef7567b 100644 --- a/applications/examples/example_plugins_advanced/plugin_interface.h +++ b/applications/examples/example_plugins_advanced/plugin_interface.h @@ -12,5 +12,5 @@ typedef struct { const char* name; void (*method1)(int); - void (*method2)(); + void (*method2)(void); } AdvancedPlugin; diff --git a/applications/examples/example_thermo/example_thermo.c b/applications/examples/example_thermo/example_thermo.c index 576ece382..dafe56886 100644 --- a/applications/examples/example_thermo/example_thermo.c +++ b/applications/examples/example_thermo/example_thermo.c @@ -315,7 +315,7 @@ static void example_thermo_run(ExampleThermoContext* context) { /******************** Initialisation & startup *****************************/ /* Allocate the memory and initialise the variables */ -static ExampleThermoContext* example_thermo_context_alloc() { +static ExampleThermoContext* example_thermo_context_alloc(void) { ExampleThermoContext* context = malloc(sizeof(ExampleThermoContext)); context->view_port = view_port_alloc(); diff --git a/applications/main/archive/archive.c b/applications/main/archive/archive.c index 066fcab05..7f01b2f75 100644 --- a/applications/main/archive/archive.c +++ b/applications/main/archive/archive.c @@ -18,7 +18,7 @@ static void archive_tick_event_callback(void* context) { scene_manager_handle_tick_event(archive->scene_manager); } -static ArchiveApp* archive_alloc() { +ArchiveApp* archive_alloc(void) { ArchiveApp* archive = malloc(sizeof(ArchiveApp)); archive->fav_move_str = furi_string_alloc(); diff --git a/applications/main/archive/helpers/archive_favorites.c b/applications/main/archive/helpers/archive_favorites.c index 682aa6b38..351d68c1d 100644 --- a/applications/main/archive/helpers/archive_favorites.c +++ b/applications/main/archive/helpers/archive_favorites.c @@ -79,7 +79,7 @@ uint16_t archive_favorites_count(void* context) { return lines; } -static bool archive_favourites_rescan() { +static bool archive_favourites_rescan(void) { FuriString* buffer; buffer = furi_string_alloc(); Storage* storage = furi_record_open(RECORD_STORAGE); diff --git a/applications/main/archive/views/archive_browser_view.c b/applications/main/archive/views/archive_browser_view.c index 6e3e8c5ce..d1eed91a0 100644 --- a/applications/main/archive/views/archive_browser_view.c +++ b/applications/main/archive/views/archive_browser_view.c @@ -687,7 +687,7 @@ static void browser_view_exit(void* context) { furi_timer_stop(browser->scroll_timer); } -ArchiveBrowserView* browser_alloc() { +ArchiveBrowserView* browser_alloc(void) { ArchiveBrowserView* browser = malloc(sizeof(ArchiveBrowserView)); browser->view = view_alloc(); view_allocate_model(browser->view, ViewModelTypeLocking, sizeof(ArchiveBrowserViewModel)); diff --git a/applications/main/archive/views/archive_browser_view.h b/applications/main/archive/views/archive_browser_view.h index 5541ba9fe..87d029664 100644 --- a/applications/main/archive/views/archive_browser_view.h +++ b/applications/main/archive/views/archive_browser_view.h @@ -126,8 +126,7 @@ void archive_browser_set_callback( View* archive_browser_get_view(ArchiveBrowserView* browser); -ArchiveBrowserView* browser_alloc(); - +ArchiveBrowserView* browser_alloc(void); void browser_free(ArchiveBrowserView* browser); void archive_browser_clipboard_set_mode(ArchiveBrowserView* browser, uint8_t mode); diff --git a/applications/main/bad_usb/helpers/ducky_script.c b/applications/main/bad_usb/helpers/ducky_script.c index 2b3d998a4..d2d7dae51 100644 --- a/applications/main/bad_usb/helpers/ducky_script.c +++ b/applications/main/bad_usb/helpers/ducky_script.c @@ -71,7 +71,7 @@ bool ducky_get_number(const char* param, uint32_t* val) { return false; } -void ducky_numlock_on() { +void ducky_numlock_on(void) { if((furi_hal_hid_get_led_state() & HID_KB_LED_NUM) == 0) { furi_hal_hid_kb_press(HID_KEYBOARD_LOCK_NUM_LOCK); furi_hal_hid_kb_release(HID_KEYBOARD_LOCK_NUM_LOCK); diff --git a/applications/main/bad_usb/views/bad_usb_view.c b/applications/main/bad_usb/views/bad_usb_view.c index 588b260c4..6ffa0f3c6 100644 --- a/applications/main/bad_usb/views/bad_usb_view.c +++ b/applications/main/bad_usb/views/bad_usb_view.c @@ -193,7 +193,7 @@ static bool bad_usb_input_callback(InputEvent* event, void* context) { return consumed; } -BadUsb* bad_usb_alloc() { +BadUsb* bad_usb_alloc(void) { BadUsb* bad_usb = malloc(sizeof(BadUsb)); bad_usb->view = view_alloc(); diff --git a/applications/main/bad_usb/views/bad_usb_view.h b/applications/main/bad_usb/views/bad_usb_view.h index 6210835f0..ee58e7bd0 100644 --- a/applications/main/bad_usb/views/bad_usb_view.h +++ b/applications/main/bad_usb/views/bad_usb_view.h @@ -6,7 +6,7 @@ typedef struct BadUsb BadUsb; typedef void (*BadUsbButtonCallback)(InputKey key, void* context); -BadUsb* bad_usb_alloc(); +BadUsb* bad_usb_alloc(void); void bad_usb_free(BadUsb* bad_usb); diff --git a/applications/main/gpio/gpio_app.c b/applications/main/gpio/gpio_app.c index 06d377d39..217423ecc 100644 --- a/applications/main/gpio/gpio_app.c +++ b/applications/main/gpio/gpio_app.c @@ -21,7 +21,7 @@ static void gpio_app_tick_event_callback(void* context) { scene_manager_handle_tick_event(app->scene_manager); } -GpioApp* gpio_app_alloc() { +GpioApp* gpio_app_alloc(void) { GpioApp* app = malloc(sizeof(GpioApp)); app->expansion = furi_record_open(RECORD_EXPANSION); diff --git a/applications/main/gpio/gpio_items.c b/applications/main/gpio/gpio_items.c index 746abe032..f4267695b 100644 --- a/applications/main/gpio/gpio_items.c +++ b/applications/main/gpio/gpio_items.c @@ -7,7 +7,7 @@ struct GPIOItems { size_t count; }; -GPIOItems* gpio_items_alloc() { +GPIOItems* gpio_items_alloc(void) { GPIOItems* items = malloc(sizeof(GPIOItems)); items->count = 0; diff --git a/applications/main/gpio/gpio_items.h b/applications/main/gpio/gpio_items.h index 68afbe693..717b29915 100644 --- a/applications/main/gpio/gpio_items.h +++ b/applications/main/gpio/gpio_items.h @@ -8,7 +8,7 @@ extern "C" { typedef struct GPIOItems GPIOItems; -GPIOItems* gpio_items_alloc(); +GPIOItems* gpio_items_alloc(void); void gpio_items_free(GPIOItems* items); diff --git a/applications/main/gpio/views/gpio_usb_uart.c b/applications/main/gpio/views/gpio_usb_uart.c index 3234309a2..f3d047d67 100644 --- a/applications/main/gpio/views/gpio_usb_uart.c +++ b/applications/main/gpio/views/gpio_usb_uart.c @@ -101,7 +101,7 @@ static bool gpio_usb_uart_input_callback(InputEvent* event, void* context) { return consumed; } -GpioUsbUart* gpio_usb_uart_alloc() { +GpioUsbUart* gpio_usb_uart_alloc(void) { GpioUsbUart* usb_uart = malloc(sizeof(GpioUsbUart)); usb_uart->view = view_alloc(); diff --git a/applications/main/gpio/views/gpio_usb_uart.h b/applications/main/gpio/views/gpio_usb_uart.h index 854b51f8d..531121f2b 100644 --- a/applications/main/gpio/views/gpio_usb_uart.h +++ b/applications/main/gpio/views/gpio_usb_uart.h @@ -7,7 +7,7 @@ typedef struct GpioUsbUart GpioUsbUart; typedef void (*GpioUsbUartCallback)(GpioCustomEvent event, void* context); -GpioUsbUart* gpio_usb_uart_alloc(); +GpioUsbUart* gpio_usb_uart_alloc(void); void gpio_usb_uart_free(GpioUsbUart* usb_uart); diff --git a/applications/main/ibutton/ibutton.c b/applications/main/ibutton/ibutton.c index afd51f7c9..b6e8a20cf 100644 --- a/applications/main/ibutton/ibutton.c +++ b/applications/main/ibutton/ibutton.c @@ -77,7 +77,7 @@ void ibutton_tick_event_callback(void* context) { scene_manager_handle_tick_event(ibutton->scene_manager); } -iButton* ibutton_alloc() { +iButton* ibutton_alloc(void) { iButton* ibutton = malloc(sizeof(iButton)); ibutton->file_path = furi_string_alloc(); diff --git a/applications/main/ibutton/ibutton_cli.c b/applications/main/ibutton/ibutton_cli.c index 54bc808b5..98ef30801 100644 --- a/applications/main/ibutton/ibutton_cli.c +++ b/applications/main/ibutton/ibutton_cli.c @@ -11,7 +11,7 @@ static void ibutton_cli(Cli* cli, FuriString* args, void* context); // app cli function -void ibutton_on_system_start() { +void ibutton_on_system_start(void) { #ifdef SRV_CLI Cli* cli = furi_record_open(RECORD_CLI); cli_add_command(cli, "ikey", CliCommandFlagDefault, ibutton_cli, cli); @@ -21,7 +21,7 @@ void ibutton_on_system_start() { #endif } -static void ibutton_cli_print_usage() { +static void ibutton_cli_print_usage(void) { printf("Usage:\r\n"); printf("ikey read\r\n"); printf("ikey emulate \r\n"); diff --git a/applications/main/infrared/infrared_app.c b/applications/main/infrared/infrared_app.c index 09827c9f8..15ee75d6c 100644 --- a/applications/main/infrared/infrared_app.c +++ b/applications/main/infrared/infrared_app.c @@ -126,7 +126,7 @@ static void infrared_find_vacant_remote_name(FuriString* name, const char* path) furi_record_close(RECORD_STORAGE); } -static InfraredApp* infrared_alloc() { +static InfraredApp* infrared_alloc(void) { InfraredApp* infrared = malloc(sizeof(InfraredApp)); infrared->task_thread = diff --git a/applications/main/infrared/infrared_brute_force.c b/applications/main/infrared/infrared_brute_force.c index b941a4760..b28918489 100644 --- a/applications/main/infrared/infrared_brute_force.c +++ b/applications/main/infrared/infrared_brute_force.c @@ -27,7 +27,7 @@ struct InfraredBruteForce { bool is_started; }; -InfraredBruteForce* infrared_brute_force_alloc() { +InfraredBruteForce* infrared_brute_force_alloc(void) { InfraredBruteForce* brute_force = malloc(sizeof(InfraredBruteForce)); brute_force->ff = NULL; brute_force->db_filename = NULL; diff --git a/applications/main/infrared/infrared_brute_force.h b/applications/main/infrared/infrared_brute_force.h index 33677d2ec..8eda08a63 100644 --- a/applications/main/infrared/infrared_brute_force.h +++ b/applications/main/infrared/infrared_brute_force.h @@ -21,7 +21,7 @@ typedef struct InfraredBruteForce InfraredBruteForce; * * @returns pointer to the created instance. */ -InfraredBruteForce* infrared_brute_force_alloc(); +InfraredBruteForce* infrared_brute_force_alloc(void); /** * @brief Delete an InfraredBruteForce instance. diff --git a/applications/main/infrared/infrared_cli.c b/applications/main/infrared/infrared_cli.c index 8ac3e65b6..123fe78d5 100644 --- a/applications/main/infrared/infrared_cli.c +++ b/applications/main/infrared/infrared_cli.c @@ -544,7 +544,7 @@ static void infrared_cli_start_ir(Cli* cli, FuriString* args, void* context) { furi_string_free(command); } -void infrared_on_system_start() { +void infrared_on_system_start(void) { #ifdef SRV_CLI Cli* cli = (Cli*)furi_record_open(RECORD_CLI); cli_add_command(cli, "ir", CliCommandFlagDefault, infrared_cli_start_ir, NULL); diff --git a/applications/main/infrared/infrared_remote.c b/applications/main/infrared/infrared_remote.c index cab241c12..c574d75c7 100644 --- a/applications/main/infrared/infrared_remote.c +++ b/applications/main/infrared/infrared_remote.c @@ -37,7 +37,7 @@ typedef struct { typedef bool ( *InfraredBatchCallback)(const InfraredBatch* batch, const InfraredBatchTarget* target); -InfraredRemote* infrared_remote_alloc() { +InfraredRemote* infrared_remote_alloc(void) { InfraredRemote* remote = malloc(sizeof(InfraredRemote)); StringArray_init(remote->signal_names); remote->name = furi_string_alloc(); diff --git a/applications/main/infrared/infrared_remote.h b/applications/main/infrared/infrared_remote.h index 7477cd3b5..4604a25ef 100644 --- a/applications/main/infrared/infrared_remote.h +++ b/applications/main/infrared/infrared_remote.h @@ -23,7 +23,7 @@ typedef struct InfraredRemote InfraredRemote; * * @returns pointer to the created instance. */ -InfraredRemote* infrared_remote_alloc(); +InfraredRemote* infrared_remote_alloc(void); /** * @brief Delete an InfraredRemote instance. diff --git a/applications/main/infrared/infrared_signal.c b/applications/main/infrared/infrared_signal.c index eac8bc7d6..c27afb027 100644 --- a/applications/main/infrared/infrared_signal.c +++ b/applications/main/infrared/infrared_signal.c @@ -201,7 +201,7 @@ bool infrared_signal_read_body(InfraredSignal* signal, FlipperFormat* ff) { return success; } -InfraredSignal* infrared_signal_alloc() { +InfraredSignal* infrared_signal_alloc(void) { InfraredSignal* signal = malloc(sizeof(InfraredSignal)); signal->is_raw = false; diff --git a/applications/main/infrared/infrared_signal.h b/applications/main/infrared/infrared_signal.h index 69b677f23..dcfde6e72 100644 --- a/applications/main/infrared/infrared_signal.h +++ b/applications/main/infrared/infrared_signal.h @@ -36,7 +36,7 @@ typedef struct { * * @returns pointer to the instance created. */ -InfraredSignal* infrared_signal_alloc(); +InfraredSignal* infrared_signal_alloc(void); /** * @brief Delete an InfraredSignal instance. diff --git a/applications/main/infrared/views/infrared_debug_view.c b/applications/main/infrared/views/infrared_debug_view.c index ec0896281..4eb58434c 100644 --- a/applications/main/infrared/views/infrared_debug_view.c +++ b/applications/main/infrared/views/infrared_debug_view.c @@ -30,7 +30,7 @@ static void infrared_debug_view_draw_callback(Canvas* canvas, void* model) { } } -InfraredDebugView* infrared_debug_view_alloc() { +InfraredDebugView* infrared_debug_view_alloc(void) { InfraredDebugView* debug_view = malloc(sizeof(InfraredDebugView)); debug_view->view = view_alloc(); view_allocate_model(debug_view->view, ViewModelTypeLocking, sizeof(InfraredDebugViewModel)); diff --git a/applications/main/infrared/views/infrared_debug_view.h b/applications/main/infrared/views/infrared_debug_view.h index 722850f8d..29cb0ff2d 100644 --- a/applications/main/infrared/views/infrared_debug_view.h +++ b/applications/main/infrared/views/infrared_debug_view.h @@ -4,7 +4,7 @@ typedef struct InfraredDebugView InfraredDebugView; -InfraredDebugView* infrared_debug_view_alloc(); +InfraredDebugView* infrared_debug_view_alloc(void); void infrared_debug_view_free(InfraredDebugView* debug_view); View* infrared_debug_view_get_view(InfraredDebugView* debug_view); diff --git a/applications/main/infrared/views/infrared_progress_view.h b/applications/main/infrared/views/infrared_progress_view.h index 4f3c3a875..9d1f70e91 100644 --- a/applications/main/infrared/views/infrared_progress_view.h +++ b/applications/main/infrared/views/infrared_progress_view.h @@ -20,7 +20,7 @@ typedef void (*InfraredProgressViewBackCallback)(void*); * * @retval new allocated instance */ -InfraredProgressView* infrared_progress_view_alloc(); +InfraredProgressView* infrared_progress_view_alloc(void); /** Free previously allocated Progress view module instance * diff --git a/applications/main/lfrfid/lfrfid.c b/applications/main/lfrfid/lfrfid.c index bd64c7906..7fc6cf6b0 100644 --- a/applications/main/lfrfid/lfrfid.c +++ b/applications/main/lfrfid/lfrfid.c @@ -57,7 +57,7 @@ static void rpc_command_callback(const RpcAppSystemEvent* event, void* context) } } -static LfRfid* lfrfid_alloc() { +static LfRfid* lfrfid_alloc(void) { LfRfid* lfrfid = malloc(sizeof(LfRfid)); lfrfid->storage = furi_record_open(RECORD_STORAGE); diff --git a/applications/main/lfrfid/lfrfid_cli.c b/applications/main/lfrfid/lfrfid_cli.c index af340008a..2101670fa 100644 --- a/applications/main/lfrfid/lfrfid_cli.c +++ b/applications/main/lfrfid/lfrfid_cli.c @@ -17,13 +17,13 @@ static void lfrfid_cli(Cli* cli, FuriString* args, void* context); // app cli function -void lfrfid_on_system_start() { +void lfrfid_on_system_start(void) { Cli* cli = furi_record_open(RECORD_CLI); cli_add_command(cli, "rfid", CliCommandFlagDefault, lfrfid_cli, NULL); furi_record_close(RECORD_CLI); } -static void lfrfid_cli_print_usage() { +static void lfrfid_cli_print_usage(void) { printf("Usage:\r\n"); printf("rfid read - read in ASK/PSK mode\r\n"); printf("rfid - write or emulate a card\r\n"); diff --git a/applications/main/lfrfid/views/lfrfid_view_read.c b/applications/main/lfrfid/views/lfrfid_view_read.c index 094afb617..a1c859af9 100644 --- a/applications/main/lfrfid/views/lfrfid_view_read.c +++ b/applications/main/lfrfid/views/lfrfid_view_read.c @@ -66,7 +66,7 @@ void lfrfid_view_read_exit(void* context) { read_view->view, LfRfidReadViewModel * model, { icon_animation_stop(model->icon); }, false); } -LfRfidReadView* lfrfid_view_read_alloc() { +LfRfidReadView* lfrfid_view_read_alloc(void) { LfRfidReadView* read_view = malloc(sizeof(LfRfidReadView)); read_view->view = view_alloc(); view_set_context(read_view->view, read_view); diff --git a/applications/main/lfrfid/views/lfrfid_view_read.h b/applications/main/lfrfid/views/lfrfid_view_read.h index 55bb1f230..f647ac354 100644 --- a/applications/main/lfrfid/views/lfrfid_view_read.h +++ b/applications/main/lfrfid/views/lfrfid_view_read.h @@ -10,7 +10,7 @@ typedef enum { typedef struct LfRfidReadView LfRfidReadView; -LfRfidReadView* lfrfid_view_read_alloc(); +LfRfidReadView* lfrfid_view_read_alloc(void); void lfrfid_view_read_free(LfRfidReadView* read_view); diff --git a/applications/main/nfc/helpers/mf_classic_key_cache.c b/applications/main/nfc/helpers/mf_classic_key_cache.c index 5127e6452..2c1141e9c 100644 --- a/applications/main/nfc/helpers/mf_classic_key_cache.c +++ b/applications/main/nfc/helpers/mf_classic_key_cache.c @@ -23,7 +23,7 @@ static void nfc_get_key_cache_file_path(const uint8_t* uid, size_t uid_len, Furi furi_string_cat_printf(path, "%s", NFC_APP_KEYS_EXTENSION); } -MfClassicKeyCache* mf_classic_key_cache_alloc() { +MfClassicKeyCache* mf_classic_key_cache_alloc(void) { MfClassicKeyCache* instance = malloc(sizeof(MfClassicKeyCache)); return instance; diff --git a/applications/main/nfc/helpers/mf_classic_key_cache.h b/applications/main/nfc/helpers/mf_classic_key_cache.h index 407c6e28b..b09f4526b 100644 --- a/applications/main/nfc/helpers/mf_classic_key_cache.h +++ b/applications/main/nfc/helpers/mf_classic_key_cache.h @@ -8,7 +8,7 @@ extern "C" { typedef struct MfClassicKeyCache MfClassicKeyCache; -MfClassicKeyCache* mf_classic_key_cache_alloc(); +MfClassicKeyCache* mf_classic_key_cache_alloc(void); void mf_classic_key_cache_free(MfClassicKeyCache* instance); diff --git a/applications/main/nfc/helpers/mf_ultralight_auth.c b/applications/main/nfc/helpers/mf_ultralight_auth.c index 5e0c67887..d954c1f7e 100644 --- a/applications/main/nfc/helpers/mf_ultralight_auth.c +++ b/applications/main/nfc/helpers/mf_ultralight_auth.c @@ -3,7 +3,7 @@ #include #include -MfUltralightAuth* mf_ultralight_auth_alloc() { +MfUltralightAuth* mf_ultralight_auth_alloc(void) { MfUltralightAuth* instance = malloc(sizeof(MfUltralightAuth)); return instance; diff --git a/applications/main/nfc/helpers/mf_ultralight_auth.h b/applications/main/nfc/helpers/mf_ultralight_auth.h index 2ddfcafe1..51267b3ea 100644 --- a/applications/main/nfc/helpers/mf_ultralight_auth.h +++ b/applications/main/nfc/helpers/mf_ultralight_auth.h @@ -20,7 +20,7 @@ typedef struct { MfUltralightAuthPack pack; } MfUltralightAuth; -MfUltralightAuth* mf_ultralight_auth_alloc(); +MfUltralightAuth* mf_ultralight_auth_alloc(void); void mf_ultralight_auth_free(MfUltralightAuth* instance); diff --git a/applications/main/nfc/helpers/nfc_supported_cards.c b/applications/main/nfc/helpers/nfc_supported_cards.c index f5668b506..1e0e7ba6b 100644 --- a/applications/main/nfc/helpers/nfc_supported_cards.c +++ b/applications/main/nfc/helpers/nfc_supported_cards.c @@ -53,7 +53,7 @@ struct NfcSupportedCards { NfcSupportedCardsLoadContext* load_context; }; -NfcSupportedCards* nfc_supported_cards_alloc() { +NfcSupportedCards* nfc_supported_cards_alloc(void) { NfcSupportedCards* instance = malloc(sizeof(NfcSupportedCards)); instance->api_resolver = composite_api_resolver_alloc(); @@ -81,7 +81,7 @@ void nfc_supported_cards_free(NfcSupportedCards* instance) { free(instance); } -static NfcSupportedCardsLoadContext* nfc_supported_cards_load_context_alloc() { +static NfcSupportedCardsLoadContext* nfc_supported_cards_load_context_alloc(void) { NfcSupportedCardsLoadContext* instance = malloc(sizeof(NfcSupportedCardsLoadContext)); instance->storage = furi_record_open(RECORD_STORAGE); diff --git a/applications/main/nfc/helpers/nfc_supported_cards.h b/applications/main/nfc/helpers/nfc_supported_cards.h index 7778c6f22..5eaee360a 100644 --- a/applications/main/nfc/helpers/nfc_supported_cards.h +++ b/applications/main/nfc/helpers/nfc_supported_cards.h @@ -25,7 +25,7 @@ typedef struct NfcSupportedCards NfcSupportedCards; * * @return pointer to allocated NfcSupportedCards instance. */ -NfcSupportedCards* nfc_supported_cards_alloc(); +NfcSupportedCards* nfc_supported_cards_alloc(void); /** * @brief Delete an NfcSupportedCards instance diff --git a/applications/main/nfc/helpers/slix_unlock.c b/applications/main/nfc/helpers/slix_unlock.c index 931ec1790..d2306777e 100644 --- a/applications/main/nfc/helpers/slix_unlock.c +++ b/applications/main/nfc/helpers/slix_unlock.c @@ -13,7 +13,7 @@ struct SlixUnlock { static const SlixPassword tonie_box_pass_arr[] = {0x5B6EFD7F, 0x0F0F0F0F}; -SlixUnlock* slix_unlock_alloc() { +SlixUnlock* slix_unlock_alloc(void) { SlixUnlock* instance = malloc(sizeof(SlixUnlock)); return instance; diff --git a/applications/main/nfc/helpers/slix_unlock.h b/applications/main/nfc/helpers/slix_unlock.h index c378891e4..b5cd30c62 100644 --- a/applications/main/nfc/helpers/slix_unlock.h +++ b/applications/main/nfc/helpers/slix_unlock.h @@ -13,7 +13,7 @@ typedef enum { typedef struct SlixUnlock SlixUnlock; -SlixUnlock* slix_unlock_alloc(); +SlixUnlock* slix_unlock_alloc(void); void slix_unlock_free(SlixUnlock* instance); diff --git a/applications/main/nfc/nfc_app.c b/applications/main/nfc/nfc_app.c index 8120268e0..26821c8f7 100644 --- a/applications/main/nfc/nfc_app.c +++ b/applications/main/nfc/nfc_app.c @@ -36,7 +36,7 @@ static void nfc_app_rpc_command_callback(const RpcAppSystemEvent* event, void* c } } -NfcApp* nfc_app_alloc() { +NfcApp* nfc_app_alloc(void) { NfcApp* instance = malloc(sizeof(NfcApp)); instance->view_dispatcher = view_dispatcher_alloc(); @@ -457,7 +457,7 @@ void nfc_append_filename_string_when_present(NfcApp* instance, FuriString* strin } } -static bool nfc_is_hal_ready() { +static bool nfc_is_hal_ready(void) { if(furi_hal_nfc_is_hal_ready() != FuriHalNfcErrorNone) { // No connection to the chip, show an error screen DialogsApp* dialogs = furi_record_open(RECORD_DIALOGS); diff --git a/applications/main/nfc/nfc_cli.c b/applications/main/nfc/nfc_cli.c index b5a40b122..90ac26d7c 100644 --- a/applications/main/nfc/nfc_cli.c +++ b/applications/main/nfc/nfc_cli.c @@ -8,7 +8,7 @@ #define FLAG_EVENT (1 << 10) -static void nfc_cli_print_usage() { +static void nfc_cli_print_usage(void) { printf("Usage:\r\n"); printf("nfc \r\n"); printf("Cmd list:\r\n"); @@ -63,7 +63,7 @@ static void nfc_cli(Cli* cli, FuriString* args, void* context) { furi_string_free(cmd); } -void nfc_on_system_start() { +void nfc_on_system_start(void) { #ifdef SRV_CLI Cli* cli = furi_record_open(RECORD_CLI); cli_add_command(cli, "nfc", CliCommandFlagDefault, nfc_cli, NULL); diff --git a/applications/main/nfc/plugins/supported_cards/aime.c b/applications/main/nfc/plugins/supported_cards/aime.c index c4cd6d8bc..a4a04b2db 100644 --- a/applications/main/nfc/plugins/supported_cards/aime.c +++ b/applications/main/nfc/plugins/supported_cards/aime.c @@ -163,6 +163,6 @@ static const FlipperAppPluginDescriptor aime_plugin_descriptor = { }; /* Plugin entry point - must return a pointer to const descriptor */ -const FlipperAppPluginDescriptor* aime_plugin_ep() { +const FlipperAppPluginDescriptor* aime_plugin_ep(void) { return &aime_plugin_descriptor; } diff --git a/applications/main/nfc/plugins/supported_cards/all_in_one.c b/applications/main/nfc/plugins/supported_cards/all_in_one.c index 1378629e2..9e20b92d1 100644 --- a/applications/main/nfc/plugins/supported_cards/all_in_one.c +++ b/applications/main/nfc/plugins/supported_cards/all_in_one.c @@ -102,6 +102,6 @@ static const FlipperAppPluginDescriptor all_in_one_plugin_descriptor = { }; /* Plugin entry point - must return a pointer to const descriptor */ -const FlipperAppPluginDescriptor* all_in_one_plugin_ep() { +const FlipperAppPluginDescriptor* all_in_one_plugin_ep(void) { return &all_in_one_plugin_descriptor; } diff --git a/applications/main/nfc/plugins/supported_cards/bip.c b/applications/main/nfc/plugins/supported_cards/bip.c index c3587fbd3..43acd0947 100644 --- a/applications/main/nfc/plugins/supported_cards/bip.c +++ b/applications/main/nfc/plugins/supported_cards/bip.c @@ -342,6 +342,6 @@ static const FlipperAppPluginDescriptor bip_plugin_descriptor = { }; /* Plugin entry point - must return a pointer to const descriptor */ -const FlipperAppPluginDescriptor* bip_plugin_ep() { +const FlipperAppPluginDescriptor* bip_plugin_ep(void) { return &bip_plugin_descriptor; } diff --git a/applications/main/nfc/plugins/supported_cards/clipper.c b/applications/main/nfc/plugins/supported_cards/clipper.c index 860c1c72e..739d714e9 100644 --- a/applications/main/nfc/plugins/supported_cards/clipper.c +++ b/applications/main/nfc/plugins/supported_cards/clipper.c @@ -565,6 +565,6 @@ static const FlipperAppPluginDescriptor clipper_plugin_descriptor = { }; /* Plugin entry point - must return a pointer to const descriptor */ -const FlipperAppPluginDescriptor* clipper_plugin_ep() { +const FlipperAppPluginDescriptor* clipper_plugin_ep(void) { return &clipper_plugin_descriptor; } diff --git a/applications/main/nfc/plugins/supported_cards/gallagher.c b/applications/main/nfc/plugins/supported_cards/gallagher.c index 869d74563..4a634296a 100644 --- a/applications/main/nfc/plugins/supported_cards/gallagher.c +++ b/applications/main/nfc/plugins/supported_cards/gallagher.c @@ -82,6 +82,6 @@ static const FlipperAppPluginDescriptor gallagher_plugin_descriptor = { }; /* Plugin entry point */ -const FlipperAppPluginDescriptor* gallagher_plugin_ep() { +const FlipperAppPluginDescriptor* gallagher_plugin_ep(void) { return &gallagher_plugin_descriptor; } \ No newline at end of file diff --git a/applications/main/nfc/plugins/supported_cards/hi.c b/applications/main/nfc/plugins/supported_cards/hi.c index 4ab66ddd2..da616c1e1 100644 --- a/applications/main/nfc/plugins/supported_cards/hi.c +++ b/applications/main/nfc/plugins/supported_cards/hi.c @@ -221,6 +221,6 @@ static const FlipperAppPluginDescriptor hi_plugin_descriptor = { }; /* Plugin entry point - must return a pointer to const descriptor */ -const FlipperAppPluginDescriptor* hi_plugin_ep() { +const FlipperAppPluginDescriptor* hi_plugin_ep(void) { return &hi_plugin_descriptor; } diff --git a/applications/main/nfc/plugins/supported_cards/hid.c b/applications/main/nfc/plugins/supported_cards/hid.c index 39ab66351..601351d2d 100644 --- a/applications/main/nfc/plugins/supported_cards/hid.c +++ b/applications/main/nfc/plugins/supported_cards/hid.c @@ -147,6 +147,6 @@ static const FlipperAppPluginDescriptor hid_plugin_descriptor = { }; /* Plugin entry point - must return a pointer to const descriptor */ -const FlipperAppPluginDescriptor* hid_plugin_ep() { +const FlipperAppPluginDescriptor* hid_plugin_ep(void) { return &hid_plugin_descriptor; } diff --git a/applications/main/nfc/plugins/supported_cards/itso.c b/applications/main/nfc/plugins/supported_cards/itso.c index a5b8b43ad..92dbbd7b6 100644 --- a/applications/main/nfc/plugins/supported_cards/itso.c +++ b/applications/main/nfc/plugins/supported_cards/itso.c @@ -120,6 +120,6 @@ static const FlipperAppPluginDescriptor itso_plugin_descriptor = { }; /* Plugin entry point - must return a pointer to const descriptor */ -const FlipperAppPluginDescriptor* itso_plugin_ep() { +const FlipperAppPluginDescriptor* itso_plugin_ep(void) { return &itso_plugin_descriptor; } diff --git a/applications/main/nfc/plugins/supported_cards/microel.c b/applications/main/nfc/plugins/supported_cards/microel.c index 91e5b2286..2dc8cd3eb 100644 --- a/applications/main/nfc/plugins/supported_cards/microel.c +++ b/applications/main/nfc/plugins/supported_cards/microel.c @@ -226,6 +226,6 @@ static const FlipperAppPluginDescriptor microel_plugin_descriptor = { }; /* Plugin entry point - must return a pointer to const descriptor */ -const FlipperAppPluginDescriptor* microel_plugin_ep() { +const FlipperAppPluginDescriptor* microel_plugin_ep(void) { return µel_plugin_descriptor; } \ No newline at end of file diff --git a/applications/main/nfc/plugins/supported_cards/mizip.c b/applications/main/nfc/plugins/supported_cards/mizip.c index dc5705059..d29901d2e 100644 --- a/applications/main/nfc/plugins/supported_cards/mizip.c +++ b/applications/main/nfc/plugins/supported_cards/mizip.c @@ -252,6 +252,6 @@ static const FlipperAppPluginDescriptor mizip_plugin_descriptor = { }; /* Plugin entry point - must return a pointer to const descriptor */ -const FlipperAppPluginDescriptor* mizip_plugin_ep() { +const FlipperAppPluginDescriptor* mizip_plugin_ep(void) { return &mizip_plugin_descriptor; } diff --git a/applications/main/nfc/plugins/supported_cards/mykey.c b/applications/main/nfc/plugins/supported_cards/mykey.c index 70b9fa6a9..662a9a189 100644 --- a/applications/main/nfc/plugins/supported_cards/mykey.c +++ b/applications/main/nfc/plugins/supported_cards/mykey.c @@ -153,6 +153,6 @@ static const FlipperAppPluginDescriptor mykey_plugin_descriptor = { }; /* Plugin entry point - must return a pointer to const descriptor */ -const FlipperAppPluginDescriptor* mykey_plugin_ep() { +const FlipperAppPluginDescriptor* mykey_plugin_ep(void) { return &mykey_plugin_descriptor; } \ No newline at end of file diff --git a/applications/main/nfc/plugins/supported_cards/myki.c b/applications/main/nfc/plugins/supported_cards/myki.c index b023a913a..ff886bc75 100644 --- a/applications/main/nfc/plugins/supported_cards/myki.c +++ b/applications/main/nfc/plugins/supported_cards/myki.c @@ -111,6 +111,6 @@ static const FlipperAppPluginDescriptor myki_plugin_descriptor = { }; /* Plugin entry point - must return a pointer to const descriptor */ -const FlipperAppPluginDescriptor* myki_plugin_ep() { +const FlipperAppPluginDescriptor* myki_plugin_ep(void) { return &myki_plugin_descriptor; } diff --git a/applications/main/nfc/plugins/supported_cards/opal.c b/applications/main/nfc/plugins/supported_cards/opal.c index 60db7ed1e..dc451e72c 100644 --- a/applications/main/nfc/plugins/supported_cards/opal.c +++ b/applications/main/nfc/plugins/supported_cards/opal.c @@ -228,6 +228,6 @@ static const FlipperAppPluginDescriptor opal_plugin_descriptor = { }; /* Plugin entry point - must return a pointer to const descriptor */ -const FlipperAppPluginDescriptor* opal_plugin_ep() { +const FlipperAppPluginDescriptor* opal_plugin_ep(void) { return &opal_plugin_descriptor; } diff --git a/applications/main/nfc/plugins/supported_cards/plantain.c b/applications/main/nfc/plugins/supported_cards/plantain.c index bba31b559..b1d2a5164 100644 --- a/applications/main/nfc/plugins/supported_cards/plantain.c +++ b/applications/main/nfc/plugins/supported_cards/plantain.c @@ -214,6 +214,6 @@ static const FlipperAppPluginDescriptor plantain_plugin_descriptor = { }; /* Plugin entry point - must return a pointer to const descriptor */ -const FlipperAppPluginDescriptor* plantain_plugin_ep() { +const FlipperAppPluginDescriptor* plantain_plugin_ep(void) { return &plantain_plugin_descriptor; } diff --git a/applications/main/nfc/plugins/supported_cards/troika.c b/applications/main/nfc/plugins/supported_cards/troika.c index 758f824b7..84e92d3e0 100644 --- a/applications/main/nfc/plugins/supported_cards/troika.c +++ b/applications/main/nfc/plugins/supported_cards/troika.c @@ -244,6 +244,6 @@ static const FlipperAppPluginDescriptor troika_plugin_descriptor = { }; /* Plugin entry point - must return a pointer to const descriptor */ -const FlipperAppPluginDescriptor* troika_plugin_ep() { +const FlipperAppPluginDescriptor* troika_plugin_ep(void) { return &troika_plugin_descriptor; } \ No newline at end of file diff --git a/applications/main/nfc/plugins/supported_cards/two_cities.c b/applications/main/nfc/plugins/supported_cards/two_cities.c index 81b45de6b..2f92030d9 100644 --- a/applications/main/nfc/plugins/supported_cards/two_cities.c +++ b/applications/main/nfc/plugins/supported_cards/two_cities.c @@ -185,6 +185,6 @@ static const FlipperAppPluginDescriptor two_cities_plugin_descriptor = { }; /* Plugin entry point - must return a pointer to const descriptor */ -const FlipperAppPluginDescriptor* two_cities_plugin_ep() { +const FlipperAppPluginDescriptor* two_cities_plugin_ep(void) { return &two_cities_plugin_descriptor; } diff --git a/applications/main/nfc/plugins/supported_cards/umarsh.c b/applications/main/nfc/plugins/supported_cards/umarsh.c index 7a84a835c..a6dc5450c 100644 --- a/applications/main/nfc/plugins/supported_cards/umarsh.c +++ b/applications/main/nfc/plugins/supported_cards/umarsh.c @@ -151,6 +151,6 @@ static const FlipperAppPluginDescriptor umarsh_plugin_descriptor = { }; /* Plugin entry point - must return a pointer to const descriptor */ -const FlipperAppPluginDescriptor* umarsh_plugin_ep() { +const FlipperAppPluginDescriptor* umarsh_plugin_ep(void) { return &umarsh_plugin_descriptor; } diff --git a/applications/main/nfc/plugins/supported_cards/washcity.c b/applications/main/nfc/plugins/supported_cards/washcity.c index 7b72c5fc9..fe7abd32d 100644 --- a/applications/main/nfc/plugins/supported_cards/washcity.c +++ b/applications/main/nfc/plugins/supported_cards/washcity.c @@ -190,6 +190,6 @@ static const FlipperAppPluginDescriptor washcity_plugin_descriptor = { }; /* Plugin entry point - must return a pointer to const descriptor */ -const FlipperAppPluginDescriptor* washcity_plugin_ep() { +const FlipperAppPluginDescriptor* washcity_plugin_ep(void) { return &washcity_plugin_descriptor; } \ No newline at end of file diff --git a/applications/main/nfc/views/detect_reader.c b/applications/main/nfc/views/detect_reader.c index 4d7b324e0..132416d9a 100644 --- a/applications/main/nfc/views/detect_reader.c +++ b/applications/main/nfc/views/detect_reader.c @@ -86,7 +86,7 @@ static bool detect_reader_input_callback(InputEvent* event, void* context) { return consumed; } -DetectReader* detect_reader_alloc() { +DetectReader* detect_reader_alloc(void) { DetectReader* detect_reader = malloc(sizeof(DetectReader)); detect_reader->view = view_alloc(); view_allocate_model(detect_reader->view, ViewModelTypeLocking, sizeof(DetectReaderViewModel)); diff --git a/applications/main/nfc/views/detect_reader.h b/applications/main/nfc/views/detect_reader.h index 6481216b4..eda3d4ca3 100644 --- a/applications/main/nfc/views/detect_reader.h +++ b/applications/main/nfc/views/detect_reader.h @@ -14,7 +14,7 @@ typedef enum { typedef void (*DetectReaderDoneCallback)(void* context); -DetectReader* detect_reader_alloc(); +DetectReader* detect_reader_alloc(void); void detect_reader_free(DetectReader* detect_reader); diff --git a/applications/main/nfc/views/dict_attack.c b/applications/main/nfc/views/dict_attack.c index ce8679088..14298a6aa 100644 --- a/applications/main/nfc/views/dict_attack.c +++ b/applications/main/nfc/views/dict_attack.c @@ -92,7 +92,7 @@ static bool dict_attack_input_callback(InputEvent* event, void* context) { return consumed; } -DictAttack* dict_attack_alloc() { +DictAttack* dict_attack_alloc(void) { DictAttack* instance = malloc(sizeof(DictAttack)); instance->view = view_alloc(); view_allocate_model(instance->view, ViewModelTypeLocking, sizeof(DictAttackViewModel)); diff --git a/applications/main/nfc/views/dict_attack.h b/applications/main/nfc/views/dict_attack.h index 54a0220fe..30f3b3c44 100644 --- a/applications/main/nfc/views/dict_attack.h +++ b/applications/main/nfc/views/dict_attack.h @@ -15,7 +15,7 @@ typedef enum { typedef void (*DictAttackCallback)(DictAttackEvent event, void* context); -DictAttack* dict_attack_alloc(); +DictAttack* dict_attack_alloc(void); void dict_attack_free(DictAttack* instance); diff --git a/applications/main/onewire/onewire_cli.c b/applications/main/onewire/onewire_cli.c index 5f6cdc670..19e584217 100644 --- a/applications/main/onewire/onewire_cli.c +++ b/applications/main/onewire/onewire_cli.c @@ -8,7 +8,7 @@ static void onewire_cli(Cli* cli, FuriString* args, void* context); -void onewire_on_system_start() { +void onewire_on_system_start(void) { #ifdef SRV_CLI Cli* cli = furi_record_open(RECORD_CLI); cli_add_command(cli, "onewire", CliCommandFlagDefault, onewire_cli, cli); @@ -18,7 +18,7 @@ void onewire_on_system_start() { #endif } -static void onewire_cli_print_usage() { +static void onewire_cli_print_usage(void) { printf("Usage:\r\n"); printf("onewire search\r\n"); }; diff --git a/applications/main/subghz/helpers/subghz_txrx.c b/applications/main/subghz/helpers/subghz_txrx.c index e173eab3c..bf63491c3 100644 --- a/applications/main/subghz/helpers/subghz_txrx.c +++ b/applications/main/subghz/helpers/subghz_txrx.c @@ -22,7 +22,7 @@ static void subghz_txrx_radio_device_power_off(SubGhzTxRx* instance) { if(furi_hal_power_is_otg_enabled()) furi_hal_power_disable_otg(); } -SubGhzTxRx* subghz_txrx_alloc() { +SubGhzTxRx* subghz_txrx_alloc(void) { SubGhzTxRx* instance = malloc(sizeof(SubGhzTxRx)); instance->setting = subghz_setting_alloc(); subghz_setting_load(instance->setting, EXT_PATH("subghz/assets/setting_user")); diff --git a/applications/main/subghz/helpers/subghz_txrx.h b/applications/main/subghz/helpers/subghz_txrx.h index a0f9f3055..a380e4875 100644 --- a/applications/main/subghz/helpers/subghz_txrx.h +++ b/applications/main/subghz/helpers/subghz_txrx.h @@ -24,7 +24,7 @@ typedef enum { * * @return SubGhzTxRx* pointer to SubGhzTxRx */ -SubGhzTxRx* subghz_txrx_alloc(); +SubGhzTxRx* subghz_txrx_alloc(void); /** * Free SubGhzTxRx diff --git a/applications/main/subghz/subghz_cli.c b/applications/main/subghz/subghz_cli.c index 23b9c7d4c..598db5146 100644 --- a/applications/main/subghz/subghz_cli.c +++ b/applications/main/subghz/subghz_cli.c @@ -32,7 +32,7 @@ #define TAG "SubGhzCli" -static void subghz_cli_radio_device_power_on() { +static void subghz_cli_radio_device_power_on(void) { uint8_t attempts = 5; while(--attempts > 0) { if(furi_hal_power_enable_otg()) break; @@ -47,7 +47,7 @@ static void subghz_cli_radio_device_power_on() { } } -static void subghz_cli_radio_device_power_off() { +static void subghz_cli_radio_device_power_off(void) { if(furi_hal_power_is_otg_enabled()) furi_hal_power_disable_otg(); } @@ -833,7 +833,7 @@ void subghz_cli_command_tx_from_file(Cli* cli, FuriString* args, void* context) subghz_environment_free(environment); } -static void subghz_cli_command_print_usage() { +static void subghz_cli_command_print_usage(void) { printf("Usage:\r\n"); printf("subghz \r\n"); printf("Cmd list:\r\n"); @@ -1196,7 +1196,7 @@ static void subghz_cli_command(Cli* cli, FuriString* args, void* context) { furi_string_free(cmd); } -void subghz_on_system_start() { +void subghz_on_system_start(void) { #ifdef SRV_CLI Cli* cli = furi_record_open(RECORD_CLI); diff --git a/applications/main/subghz/subghz_cli.h b/applications/main/subghz/subghz_cli.h index 14b97e1ed..f6388218f 100644 --- a/applications/main/subghz/subghz_cli.h +++ b/applications/main/subghz/subghz_cli.h @@ -2,4 +2,4 @@ #include -void subghz_on_system_start(); +void subghz_on_system_start(void); diff --git a/applications/main/subghz/views/receiver.c b/applications/main/subghz/views/receiver.c index 88e3c31e4..5f9119353 100644 --- a/applications/main/subghz/views/receiver.c +++ b/applications/main/subghz/views/receiver.c @@ -571,7 +571,7 @@ void subghz_view_receiver_exit(void* context) { furi_timer_stop(subghz_receiver->flip_time_timer); } -SubGhzViewReceiver* subghz_view_receiver_alloc() { +SubGhzViewReceiver* subghz_view_receiver_alloc(void) { SubGhzViewReceiver* subghz_receiver = malloc(sizeof(SubGhzViewReceiver)); // View allocation and configuration diff --git a/applications/main/subghz/views/receiver.h b/applications/main/subghz/views/receiver.h index f28ed1304..a2e23379e 100644 --- a/applications/main/subghz/views/receiver.h +++ b/applications/main/subghz/views/receiver.h @@ -21,7 +21,7 @@ void subghz_view_receiver_set_callback( SubGhzViewReceiverCallback callback, void* context); -SubGhzViewReceiver* subghz_view_receiver_alloc(); +SubGhzViewReceiver* subghz_view_receiver_alloc(void); void subghz_view_receiver_free(SubGhzViewReceiver* subghz_receiver); diff --git a/applications/main/subghz/views/transmitter.c b/applications/main/subghz/views/transmitter.c index f75bbc661..3b705beed 100644 --- a/applications/main/subghz/views/transmitter.c +++ b/applications/main/subghz/views/transmitter.c @@ -228,7 +228,7 @@ void subghz_view_transmitter_exit(void* context) { furi_assert(context); } -SubGhzViewTransmitter* subghz_view_transmitter_alloc() { +SubGhzViewTransmitter* subghz_view_transmitter_alloc(void) { SubGhzViewTransmitter* subghz_transmitter = malloc(sizeof(SubGhzViewTransmitter)); // View allocation and configuration diff --git a/applications/main/subghz/views/transmitter.h b/applications/main/subghz/views/transmitter.h index 19da3145c..7fa51a65d 100644 --- a/applications/main/subghz/views/transmitter.h +++ b/applications/main/subghz/views/transmitter.h @@ -17,7 +17,7 @@ void subghz_view_transmitter_set_radio_device_type( SubGhzViewTransmitter* subghz_transmitter, SubGhzRadioDeviceType device_type); -SubGhzViewTransmitter* subghz_view_transmitter_alloc(); +SubGhzViewTransmitter* subghz_view_transmitter_alloc(void); void subghz_view_transmitter_free(SubGhzViewTransmitter* subghz_transmitter); diff --git a/applications/main/u2f/u2f.c b/applications/main/u2f/u2f.c index 3bdafe918..2a2e91f21 100644 --- a/applications/main/u2f/u2f.c +++ b/applications/main/u2f/u2f.c @@ -108,7 +108,7 @@ static int u2f_uecc_random_cb(void* context, uint8_t* dest, unsigned size) { return 0; } -U2fData* u2f_alloc() { +U2fData* u2f_alloc(void) { return malloc(sizeof(U2fData)); } diff --git a/applications/main/u2f/u2f.h b/applications/main/u2f/u2f.h index dcd7c3ff2..8f28d5f67 100644 --- a/applications/main/u2f/u2f.h +++ b/applications/main/u2f/u2f.h @@ -20,7 +20,7 @@ typedef struct U2fData U2fData; typedef void (*U2fEvtCallback)(U2fNotifyEvent evt, void* context); -U2fData* u2f_alloc(); +U2fData* u2f_alloc(void); bool u2f_init(U2fData* instance); diff --git a/applications/main/u2f/u2f_app.c b/applications/main/u2f/u2f_app.c index 216481976..68966390a 100644 --- a/applications/main/u2f/u2f_app.c +++ b/applications/main/u2f/u2f_app.c @@ -21,7 +21,7 @@ static void u2f_app_tick_event_callback(void* context) { scene_manager_handle_tick_event(app->scene_manager); } -U2fApp* u2f_app_alloc() { +U2fApp* u2f_app_alloc(void) { U2fApp* app = malloc(sizeof(U2fApp)); app->gui = furi_record_open(RECORD_GUI); diff --git a/applications/main/u2f/u2f_data.c b/applications/main/u2f/u2f_data.c index cb9c4c294..c6451757b 100644 --- a/applications/main/u2f/u2f_data.c +++ b/applications/main/u2f/u2f_data.c @@ -67,7 +67,7 @@ bool u2f_data_check(bool cert_only) { return state; } -bool u2f_data_cert_check() { +bool u2f_data_cert_check(void) { bool state = false; Storage* fs_api = furi_record_open(RECORD_STORAGE); File* file = storage_file_alloc(fs_api); diff --git a/applications/main/u2f/u2f_data.h b/applications/main/u2f/u2f_data.h index 8d3923464..9c04bf386 100644 --- a/applications/main/u2f/u2f_data.h +++ b/applications/main/u2f/u2f_data.h @@ -8,7 +8,7 @@ extern "C" { bool u2f_data_check(bool cert_only); -bool u2f_data_cert_check(); +bool u2f_data_cert_check(void); uint32_t u2f_data_cert_load(uint8_t* cert); diff --git a/applications/main/u2f/views/u2f_view.c b/applications/main/u2f/views/u2f_view.c index bf220ca2c..bdbe8bcec 100644 --- a/applications/main/u2f/views/u2f_view.c +++ b/applications/main/u2f/views/u2f_view.c @@ -59,7 +59,7 @@ static bool u2f_view_input_callback(InputEvent* event, void* context) { return consumed; } -U2fView* u2f_view_alloc() { +U2fView* u2f_view_alloc(void) { U2fView* u2f = malloc(sizeof(U2fView)); u2f->view = view_alloc(); diff --git a/applications/main/u2f/views/u2f_view.h b/applications/main/u2f/views/u2f_view.h index 5da3279a4..b0ec1c5e3 100644 --- a/applications/main/u2f/views/u2f_view.h +++ b/applications/main/u2f/views/u2f_view.h @@ -14,7 +14,7 @@ typedef enum { U2fMsgError, } U2fViewMsg; -U2fView* u2f_view_alloc(); +U2fView* u2f_view_alloc(void); void u2f_view_free(U2fView* u2f); diff --git a/applications/services/bt/bt_cli.c b/applications/services/bt/bt_cli.c index e8ba215bf..7505c424d 100644 --- a/applications/services/bt/bt_cli.c +++ b/applications/services/bt/bt_cli.c @@ -165,7 +165,7 @@ static void bt_cli_command_packet_rx(Cli* cli, FuriString* args, void* context) } while(false); } -static void bt_cli_print_usage() { +static void bt_cli_print_usage(void) { printf("Usage:\r\n"); printf("bt \r\n"); printf("Cmd list:\r\n"); @@ -227,7 +227,7 @@ static void bt_cli(Cli* cli, FuriString* args, void* context) { furi_record_close(RECORD_BT); } -void bt_on_system_start() { +void bt_on_system_start(void) { #ifdef SRV_CLI Cli* cli = furi_record_open(RECORD_CLI); cli_add_command(cli, RECORD_BT, CliCommandFlagDefault, bt_cli, NULL); diff --git a/applications/services/bt/bt_service/bt.c b/applications/services/bt/bt_service/bt.c index 0315a4eaf..6d7a5c5f0 100644 --- a/applications/services/bt/bt_service/bt.c +++ b/applications/services/bt/bt_service/bt.c @@ -138,7 +138,7 @@ static void bt_battery_level_changed_callback(const void* _event, void* context) } } -Bt* bt_alloc() { +Bt* bt_alloc(void) { Bt* bt = malloc(sizeof(Bt)); // Init default maximum packet size bt->max_packet_size = BLE_PROFILE_SERIAL_PACKET_SIZE_MAX; diff --git a/applications/services/bt/bt_service/bt_api.c b/applications/services/bt/bt_service/bt_api.c index ab5d20128..f0e792d42 100644 --- a/applications/services/bt/bt_service/bt_api.c +++ b/applications/services/bt/bt_service/bt_api.c @@ -5,7 +5,7 @@ FuriHalBleProfileBase* bt_profile_start( Bt* bt, const FuriHalBleProfileTemplate* profile_template, FuriHalBleProfileParams params) { - furi_assert(bt); + furi_check(bt); // Send message FuriHalBleProfileBase* profile_instance = NULL; @@ -32,7 +32,7 @@ bool bt_profile_restore_default(Bt* bt) { } void bt_disconnect(Bt* bt) { - furi_assert(bt); + furi_check(bt); // Send message BtMessage message = {.lock = api_lock_alloc_locked(), .type = BtMessageTypeDisconnect}; @@ -43,23 +43,23 @@ void bt_disconnect(Bt* bt) { } void bt_set_status_changed_callback(Bt* bt, BtStatusChangedCallback callback, void* context) { - furi_assert(bt); + furi_check(bt); bt->status_changed_cb = callback; bt->status_changed_ctx = context; } void bt_forget_bonded_devices(Bt* bt) { - furi_assert(bt); + furi_check(bt); BtMessage message = {.type = BtMessageTypeForgetBondedDevices}; furi_check( furi_message_queue_put(bt->message_queue, &message, FuriWaitForever) == FuriStatusOk); } void bt_keys_storage_set_storage_path(Bt* bt, const char* keys_storage_path) { - furi_assert(bt); - furi_assert(bt->keys_storage); - furi_assert(keys_storage_path); + furi_check(bt); + furi_check(bt->keys_storage); + furi_check(keys_storage_path); Storage* storage = furi_record_open(RECORD_STORAGE); FuriString* path = furi_string_alloc_set(keys_storage_path); @@ -72,8 +72,8 @@ void bt_keys_storage_set_storage_path(Bt* bt, const char* keys_storage_path) { } void bt_keys_storage_set_default_path(Bt* bt) { - furi_assert(bt); - furi_assert(bt->keys_storage); + furi_check(bt); + furi_check(bt->keys_storage); bt_keys_storage_set_file_path(bt->keys_storage, BT_KEYS_STORAGE_PATH); } diff --git a/applications/services/cli/cli.c b/applications/services/cli/cli.c index 41e658df1..7ba704219 100644 --- a/applications/services/cli/cli.c +++ b/applications/services/cli/cli.c @@ -8,7 +8,7 @@ #define CLI_INPUT_LEN_LIMIT 256 -Cli* cli_alloc() { +Cli* cli_alloc(void) { Cli* cli = malloc(sizeof(Cli)); CliCommandTree_init(cli->commands); @@ -27,14 +27,14 @@ Cli* cli_alloc() { } void cli_putc(Cli* cli, char c) { - furi_assert(cli); + furi_check(cli); if(cli->session != NULL) { cli->session->tx((uint8_t*)&c, 1); } } char cli_getc(Cli* cli) { - furi_assert(cli); + furi_check(cli); char c = 0; if(cli->session != NULL) { if(cli->session->rx((uint8_t*)&c, 1, FuriWaitForever) == 0) { @@ -49,14 +49,14 @@ char cli_getc(Cli* cli) { } void cli_write(Cli* cli, const uint8_t* buffer, size_t size) { - furi_assert(cli); + furi_check(cli); if(cli->session != NULL) { cli->session->tx(buffer, size); } } size_t cli_read(Cli* cli, uint8_t* buffer, size_t size) { - furi_assert(cli); + furi_check(cli); if(cli->session != NULL) { return cli->session->rx(buffer, size, FuriWaitForever); } else { @@ -65,7 +65,7 @@ size_t cli_read(Cli* cli, uint8_t* buffer, size_t size) { } size_t cli_read_timeout(Cli* cli, uint8_t* buffer, size_t size, uint32_t timeout) { - furi_assert(cli); + furi_check(cli); if(cli->session != NULL) { return cli->session->rx(buffer, size, timeout); } else { @@ -74,7 +74,7 @@ size_t cli_read_timeout(Cli* cli, uint8_t* buffer, size_t size, uint32_t timeout } bool cli_is_connected(Cli* cli) { - furi_assert(cli); + furi_check(cli); if(cli->session != NULL) { return (cli->session->is_connected()); } @@ -82,7 +82,7 @@ bool cli_is_connected(Cli* cli) { } bool cli_cmd_interrupt_received(Cli* cli) { - furi_assert(cli); + furi_check(cli); char c = '\0'; if(cli_is_connected(cli)) { if(cli->session->rx((uint8_t*)&c, 1, 0) == 1) { @@ -95,14 +95,14 @@ bool cli_cmd_interrupt_received(Cli* cli) { } void cli_print_usage(const char* cmd, const char* usage, const char* arg) { - furi_assert(cmd); - furi_assert(arg); - furi_assert(usage); + furi_check(cmd); + furi_check(arg); + furi_check(usage); printf("%s: illegal option -- %s\r\nusage: %s %s", cmd, arg, cmd, usage); } -void cli_motd() { +void cli_motd(void) { printf("\r\n" " _.-------.._ -,\r\n" " .-\"```\"--..,,_/ /`-, -, \\ \r\n" @@ -385,6 +385,7 @@ void cli_add_command( CliCommandFlag flags, CliCallback callback, void* context) { + furi_check(cli); FuriString* name_str; name_str = furi_string_alloc_set(name); furi_string_trim(name_str); @@ -407,6 +408,7 @@ void cli_add_command( } void cli_delete_command(Cli* cli, const char* name) { + furi_check(cli); FuriString* name_str; name_str = furi_string_alloc_set(name); furi_string_trim(name_str); @@ -424,7 +426,7 @@ void cli_delete_command(Cli* cli, const char* name) { } void cli_session_open(Cli* cli, void* session) { - furi_assert(cli); + furi_check(cli); furi_check(furi_mutex_acquire(cli->mutex, FuriWaitForever) == FuriStatusOk); cli->session = session; @@ -439,7 +441,7 @@ void cli_session_open(Cli* cli, void* session) { } void cli_session_close(Cli* cli) { - furi_assert(cli); + furi_check(cli); furi_check(furi_mutex_acquire(cli->mutex, FuriWaitForever) == FuriStatusOk); if(cli->session != NULL) { diff --git a/applications/services/cli/cli.h b/applications/services/cli/cli.h index 09f54f056..bb84670a7 100644 --- a/applications/services/cli/cli.h +++ b/applications/services/cli/cli.h @@ -121,7 +121,7 @@ char cli_getc(Cli* cli); /** New line Send new ine sequence */ -void cli_nl(); +void cli_nl(Cli* cli); void cli_session_open(Cli* cli, void* session); diff --git a/applications/services/cli/cli_command_gpio.c b/applications/services/cli/cli_command_gpio.c index 67511a194..010a7dfbe 100644 --- a/applications/services/cli/cli_command_gpio.c +++ b/applications/services/cli/cli_command_gpio.c @@ -4,7 +4,7 @@ #include #include -void cli_command_gpio_print_usage() { +void cli_command_gpio_print_usage(void) { printf("Usage:\r\n"); printf("gpio \r\n"); printf("Cmd list:\r\n"); diff --git a/applications/services/cli/cli_commands.c b/applications/services/cli/cli_commands.c index a01ce173a..b1dfa3b73 100644 --- a/applications/services/cli/cli_commands.c +++ b/applications/services/cli/cli_commands.c @@ -83,7 +83,7 @@ void cli_command_help(Cli* cli, FuriString* args, void* context) { }; if(furi_string_size(args) > 0) { - cli_nl(); + cli_nl(cli); printf("`"); printf("%s", furi_string_get_cstr(args)); printf("` command not found"); @@ -282,7 +282,7 @@ void cli_command_sysctl_heap_track(Cli* cli, FuriString* args, void* context) { } } -void cli_command_sysctl_print_usage() { +void cli_command_sysctl_print_usage(void) { printf("Usage:\r\n"); printf("sysctl \r\n"); printf("Cmd list:\r\n"); diff --git a/applications/services/cli/cli_i.h b/applications/services/cli/cli_i.h index 858cd0c8f..8a82d9619 100644 --- a/applications/services/cli/cli_i.h +++ b/applications/services/cli/cli_i.h @@ -54,7 +54,7 @@ struct Cli { size_t cursor_position; }; -Cli* cli_alloc(); +Cli* cli_alloc(void); void cli_reset(Cli* cli); diff --git a/applications/services/cli/cli_vcp.c b/applications/services/cli/cli_vcp.c index 454c99d7a..58c5c887f 100644 --- a/applications/services/cli/cli_vcp.c +++ b/applications/services/cli/cli_vcp.c @@ -64,7 +64,7 @@ static CliVcp* vcp = NULL; static const uint8_t ascii_soh = 0x01; static const uint8_t ascii_eot = 0x04; -static void cli_vcp_init() { +static void cli_vcp_init(void) { if(vcp == NULL) { vcp = malloc(sizeof(CliVcp)); vcp->tx_stream = furi_stream_buffer_alloc(VCP_TX_BUF_SIZE, 1); @@ -80,7 +80,7 @@ static void cli_vcp_init() { FURI_LOG_I(TAG, "Init OK"); } -static void cli_vcp_deinit() { +static void cli_vcp_deinit(void) { furi_thread_flags_set(furi_thread_get_id(vcp->thread), VcpEvtStop); furi_thread_join(vcp->thread); furi_thread_free(vcp->thread); diff --git a/applications/services/crypto/crypto_cli.c b/applications/services/crypto/crypto_cli.c index bfd2003e1..1fc19e48b 100644 --- a/applications/services/crypto/crypto_cli.c +++ b/applications/services/crypto/crypto_cli.c @@ -4,7 +4,7 @@ #include #include -void crypto_cli_print_usage() { +void crypto_cli_print_usage(void) { printf("Usage:\r\n"); printf("crypto \r\n"); printf("Cmd list:\r\n"); @@ -316,7 +316,7 @@ static void crypto_cli(Cli* cli, FuriString* args, void* context) { furi_string_free(cmd); } -void crypto_on_system_start() { +void crypto_on_system_start(void) { #ifdef SRV_CLI Cli* cli = furi_record_open(RECORD_CLI); cli_add_command(cli, "crypto", CliCommandFlagDefault, crypto_cli, NULL); diff --git a/applications/services/desktop/desktop.c b/applications/services/desktop/desktop.c index 9d26d473e..9803210a6 100644 --- a/applications/services/desktop/desktop.c +++ b/applications/services/desktop/desktop.c @@ -268,7 +268,7 @@ void desktop_set_stealth_mode_state(Desktop* desktop, bool enabled) { desktop->in_transition = false; } -Desktop* desktop_alloc() { +Desktop* desktop_alloc(void) { Desktop* desktop = malloc(sizeof(Desktop)); desktop->animation_manager = animation_manager_alloc(); diff --git a/applications/services/desktop/desktop_i.h b/applications/services/desktop/desktop_i.h index bb495c920..f6eeef6b1 100644 --- a/applications/services/desktop/desktop_i.h +++ b/applications/services/desktop/desktop_i.h @@ -82,7 +82,7 @@ struct Desktop { bool in_transition : 1; }; -Desktop* desktop_alloc(); +Desktop* desktop_alloc(void); void desktop_free(Desktop* desktop); void desktop_lock(Desktop* desktop); diff --git a/applications/services/desktop/helpers/pin.c b/applications/services/desktop/helpers/pin.c index 8a79a1fb8..374b569f0 100644 --- a/applications/services/desktop/helpers/pin.c +++ b/applications/services/desktop/helpers/pin.c @@ -42,13 +42,13 @@ static const uint8_t desktop_helpers_fails_timeout[] = { /* +60 for every next fail */ }; -void desktop_pin_lock_error_notify() { +void desktop_pin_lock_error_notify(void) { NotificationApp* notification = furi_record_open(RECORD_NOTIFICATION); notification_message(notification, &sequence_pin_fail); furi_record_close(RECORD_NOTIFICATION); } -uint32_t desktop_pin_lock_get_fail_timeout() { +uint32_t desktop_pin_lock_get_fail_timeout(void) { uint32_t pin_fails = furi_hal_rtc_get_pin_fails(); uint32_t pin_timeout = 0; uint32_t max_index = COUNT_OF(desktop_helpers_fails_timeout) - 1; diff --git a/applications/services/desktop/helpers/pin.h b/applications/services/desktop/helpers/pin.h index e5410723e..23d16b0aa 100644 --- a/applications/services/desktop/helpers/pin.h +++ b/applications/services/desktop/helpers/pin.h @@ -4,8 +4,8 @@ #include "../desktop.h" #include -void desktop_pin_lock_error_notify(); +void desktop_pin_lock_error_notify(void); -uint32_t desktop_pin_lock_get_fail_timeout(); +uint32_t desktop_pin_lock_get_fail_timeout(void); bool desktop_pin_compare(const PinCode* pin_code1, const PinCode* pin_code2); diff --git a/applications/services/desktop/helpers/slideshow.c b/applications/services/desktop/helpers/slideshow.c index a8e132779..efd02c4bc 100644 --- a/applications/services/desktop/helpers/slideshow.c +++ b/applications/services/desktop/helpers/slideshow.c @@ -33,7 +33,7 @@ _Static_assert(sizeof(SlideshowFrameHeader) == 2, "Incorrect SlideshowFrameHeade #pragma pack(pop) -Slideshow* slideshow_alloc() { +Slideshow* slideshow_alloc(void) { Slideshow* ret = malloc(sizeof(Slideshow)); ret->loaded = false; return ret; diff --git a/applications/services/desktop/helpers/slideshow.h b/applications/services/desktop/helpers/slideshow.h index 9083e0dcf..cd4d2334f 100644 --- a/applications/services/desktop/helpers/slideshow.h +++ b/applications/services/desktop/helpers/slideshow.h @@ -4,7 +4,7 @@ typedef struct Slideshow Slideshow; -Slideshow* slideshow_alloc(); +Slideshow* slideshow_alloc(void); void slideshow_free(Slideshow* slideshow); bool slideshow_load(Slideshow* slideshow, const char* fspath); diff --git a/applications/services/desktop/views/desktop_view_debug.c b/applications/services/desktop/views/desktop_view_debug.c index fef2356ba..fe9d9e161 100644 --- a/applications/services/desktop/views/desktop_view_debug.c +++ b/applications/services/desktop/views/desktop_view_debug.c @@ -117,7 +117,7 @@ void desktop_debug_timer(void* context) { view_commit_model(debug_view->view, true); } -DesktopDebugView* desktop_debug_alloc() { +DesktopDebugView* desktop_debug_alloc(void) { DesktopDebugView* debug_view = malloc(sizeof(DesktopDebugView)); debug_view->view = view_alloc(); debug_view->timer = furi_timer_alloc(desktop_debug_timer, FuriTimerTypePeriodic, debug_view); diff --git a/applications/services/desktop/views/desktop_view_debug.h b/applications/services/desktop/views/desktop_view_debug.h index fea0c22a0..c594002af 100644 --- a/applications/services/desktop/views/desktop_view_debug.h +++ b/applications/services/desktop/views/desktop_view_debug.h @@ -22,6 +22,6 @@ void desktop_debug_set_callback( View* desktop_debug_get_view(DesktopDebugView* debug_view); -DesktopDebugView* desktop_debug_alloc(); +DesktopDebugView* desktop_debug_alloc(void); void desktop_debug_free(DesktopDebugView* debug_view); diff --git a/applications/services/desktop/views/desktop_view_lock_menu.c b/applications/services/desktop/views/desktop_view_lock_menu.c index 4665e5e15..83f7ee501 100644 --- a/applications/services/desktop/views/desktop_view_lock_menu.c +++ b/applications/services/desktop/views/desktop_view_lock_menu.c @@ -149,7 +149,7 @@ bool desktop_lock_menu_input_callback(InputEvent* event, void* context) { return consumed; } -DesktopLockMenuView* desktop_lock_menu_alloc() { +DesktopLockMenuView* desktop_lock_menu_alloc(void) { DesktopLockMenuView* lock_menu = malloc(sizeof(DesktopLockMenuView)); lock_menu->view = view_alloc(); view_allocate_model(lock_menu->view, ViewModelTypeLocking, sizeof(DesktopLockMenuViewModel)); diff --git a/applications/services/desktop/views/desktop_view_lock_menu.h b/applications/services/desktop/views/desktop_view_lock_menu.h index 8ac3a7273..a44e6b132 100644 --- a/applications/services/desktop/views/desktop_view_lock_menu.h +++ b/applications/services/desktop/views/desktop_view_lock_menu.h @@ -30,5 +30,5 @@ View* desktop_lock_menu_get_view(DesktopLockMenuView* lock_menu); void desktop_lock_menu_set_dummy_mode_state(DesktopLockMenuView* lock_menu, bool dummy_mode); void desktop_lock_menu_set_stealth_mode_state(DesktopLockMenuView* lock_menu, bool stealth_mode); void desktop_lock_menu_set_idx(DesktopLockMenuView* lock_menu, uint8_t idx); -DesktopLockMenuView* desktop_lock_menu_alloc(); +DesktopLockMenuView* desktop_lock_menu_alloc(void); void desktop_lock_menu_free(DesktopLockMenuView* lock_menu); diff --git a/applications/services/desktop/views/desktop_view_locked.c b/applications/services/desktop/views/desktop_view_locked.c index 97feb3c12..3c3985c80 100644 --- a/applications/services/desktop/views/desktop_view_locked.c +++ b/applications/services/desktop/views/desktop_view_locked.c @@ -191,7 +191,7 @@ static bool desktop_view_locked_input(InputEvent* event, void* context) { return true; } -DesktopViewLocked* desktop_view_locked_alloc() { +DesktopViewLocked* desktop_view_locked_alloc(void) { DesktopViewLocked* locked_view = malloc(sizeof(DesktopViewLocked)); locked_view->view = view_alloc(); locked_view->timer = diff --git a/applications/services/desktop/views/desktop_view_locked.h b/applications/services/desktop/views/desktop_view_locked.h index ea065e398..233cc8d5d 100644 --- a/applications/services/desktop/views/desktop_view_locked.h +++ b/applications/services/desktop/views/desktop_view_locked.h @@ -14,7 +14,7 @@ void desktop_view_locked_set_callback( void* context); void desktop_view_locked_update(DesktopViewLocked* locked_view); View* desktop_view_locked_get_view(DesktopViewLocked* locked_view); -DesktopViewLocked* desktop_view_locked_alloc(); +DesktopViewLocked* desktop_view_locked_alloc(void); void desktop_view_locked_free(DesktopViewLocked* locked_view); void desktop_view_locked_lock(DesktopViewLocked* locked_view, bool pin_locked); void desktop_view_locked_unlock(DesktopViewLocked* locked_view); diff --git a/applications/services/desktop/views/desktop_view_main.c b/applications/services/desktop/views/desktop_view_main.c index ace0674e1..ac84cc5d9 100644 --- a/applications/services/desktop/views/desktop_view_main.c +++ b/applications/services/desktop/views/desktop_view_main.c @@ -119,7 +119,7 @@ bool desktop_main_input_callback(InputEvent* event, void* context) { return true; } -DesktopMainView* desktop_main_alloc() { +DesktopMainView* desktop_main_alloc(void) { DesktopMainView* main_view = malloc(sizeof(DesktopMainView)); main_view->view = view_alloc(); diff --git a/applications/services/desktop/views/desktop_view_main.h b/applications/services/desktop/views/desktop_view_main.h index b5492b1be..755d6b2af 100644 --- a/applications/services/desktop/views/desktop_view_main.h +++ b/applications/services/desktop/views/desktop_view_main.h @@ -14,5 +14,5 @@ void desktop_main_set_callback( View* desktop_main_get_view(DesktopMainView* main_view); void desktop_main_set_dummy_mode_state(DesktopMainView* main_view, bool dummy_mode); -DesktopMainView* desktop_main_alloc(); +DesktopMainView* desktop_main_alloc(void); void desktop_main_free(DesktopMainView* main_view); diff --git a/applications/services/desktop/views/desktop_view_slideshow.c b/applications/services/desktop/views/desktop_view_slideshow.c index e528d6878..db7c69811 100644 --- a/applications/services/desktop/views/desktop_view_slideshow.c +++ b/applications/services/desktop/views/desktop_view_slideshow.c @@ -105,7 +105,7 @@ static void desktop_view_slideshow_exit(void* context) { view_commit_model(instance->view, false); } -DesktopSlideshowView* desktop_view_slideshow_alloc() { +DesktopSlideshowView* desktop_view_slideshow_alloc(void) { DesktopSlideshowView* instance = malloc(sizeof(DesktopSlideshowView)); instance->view = view_alloc(); view_allocate_model(instance->view, ViewModelTypeLocking, sizeof(DesktopSlideshowViewModel)); diff --git a/applications/services/desktop/views/desktop_view_slideshow.h b/applications/services/desktop/views/desktop_view_slideshow.h index 624cbf007..b9e610c62 100644 --- a/applications/services/desktop/views/desktop_view_slideshow.h +++ b/applications/services/desktop/views/desktop_view_slideshow.h @@ -11,7 +11,7 @@ typedef struct DesktopSlideshowView DesktopSlideshowView; typedef void (*DesktopSlideshowViewCallback)(DesktopEvent event, void* context); -DesktopSlideshowView* desktop_view_slideshow_alloc(); +DesktopSlideshowView* desktop_view_slideshow_alloc(void); void desktop_view_slideshow_free(DesktopSlideshowView* main_view); diff --git a/applications/services/dialogs/dialogs.c b/applications/services/dialogs/dialogs.c index 10c08a991..ec1289d5b 100644 --- a/applications/services/dialogs/dialogs.c +++ b/applications/services/dialogs/dialogs.c @@ -8,6 +8,7 @@ void dialog_file_browser_set_basic_options( DialogsFileBrowserOptions* options, const char* extension, const Icon* icon) { + furi_check(options); options->extension = extension; options->base_path = NULL; options->skip_assets = true; @@ -18,7 +19,7 @@ void dialog_file_browser_set_basic_options( options->item_loader_context = NULL; } -static DialogsApp* dialogs_app_alloc() { +static DialogsApp* dialogs_app_alloc(void) { DialogsApp* app = malloc(sizeof(DialogsApp)); app->message_queue = furi_message_queue_alloc(8, sizeof(DialogsAppMessage)); diff --git a/applications/services/dialogs/dialogs.h b/applications/services/dialogs/dialogs.h index 39b15c67c..b8beddc5e 100644 --- a/applications/services/dialogs/dialogs.h +++ b/applications/services/dialogs/dialogs.h @@ -87,7 +87,7 @@ typedef struct DialogMessage DialogMessage; * Allocate and fill message * @return DialogMessage* */ -DialogMessage* dialog_message_alloc(); +DialogMessage* dialog_message_alloc(void); /** * Free message struct diff --git a/applications/services/dialogs/dialogs_api.c b/applications/services/dialogs/dialogs_api.c index 4723a1f91..73d1d876a 100644 --- a/applications/services/dialogs/dialogs_api.c +++ b/applications/services/dialogs/dialogs_api.c @@ -65,6 +65,8 @@ bool dialog_file_browser_show( /****************** Message ******************/ DialogMessageButton dialog_message_show(DialogsApp* context, const DialogMessage* dialog_message) { + furi_check(context); + FuriApiLock lock = api_lock_alloc_locked(); furi_check(lock != NULL); @@ -91,6 +93,8 @@ DialogMessageButton dialog_message_show(DialogsApp* context, const DialogMessage /****************** Storage error ******************/ void dialog_message_show_storage_error(DialogsApp* context, const char* error_text) { + furi_check(context); + DialogMessage* message = dialog_message_alloc(); dialog_message_set_text(message, error_text, 88, 32, AlignCenter, AlignCenter); dialog_message_set_icon(message, &I_SDQuestion_35x43, 5, 6); diff --git a/applications/services/dialogs/dialogs_module_message.c b/applications/services/dialogs/dialogs_module_message.c index 879ba9baa..69d28c405 100644 --- a/applications/services/dialogs/dialogs_module_message.c +++ b/applications/services/dialogs/dialogs_module_message.c @@ -101,12 +101,13 @@ DialogMessageButton dialogs_app_process_module_message(const DialogsAppMessageDa return ret; } -DialogMessage* dialog_message_alloc() { +DialogMessage* dialog_message_alloc(void) { DialogMessage* message = malloc(sizeof(DialogMessage)); return message; } void dialog_message_free(DialogMessage* message) { + furi_check(message); free(message); } @@ -117,6 +118,8 @@ void dialog_message_set_text( uint8_t y, Align horizontal, Align vertical) { + furi_check(message); + message->dialog_text = text; message->dialog_text_x = x; message->dialog_text_y = y; @@ -131,6 +134,8 @@ void dialog_message_set_header( uint8_t y, Align horizontal, Align vertical) { + furi_check(message); + message->header_text = text; message->header_text_x = x; message->header_text_y = y; @@ -139,6 +144,8 @@ void dialog_message_set_header( } void dialog_message_set_icon(DialogMessage* message, const Icon* icon, uint8_t x, uint8_t y) { + furi_check(message); + message->icon = icon; message->icon_x = x; message->icon_y = y; @@ -149,6 +156,8 @@ void dialog_message_set_buttons( const char* left, const char* center, const char* right) { + furi_check(message); + message->left_button_text = left; message->center_button_text = center; message->right_button_text = right; diff --git a/applications/services/dolphin/dolphin.c b/applications/services/dolphin/dolphin.c index e81101ba5..5f3d5cb28 100644 --- a/applications/services/dolphin/dolphin.c +++ b/applications/services/dolphin/dolphin.c @@ -22,7 +22,7 @@ void dolphin_deed(DolphinDeed deed) { } DolphinStats dolphin_stats(Dolphin* dolphin) { - furi_assert(dolphin); + furi_check(dolphin); DolphinStats stats; DolphinEvent event; @@ -36,7 +36,7 @@ DolphinStats dolphin_stats(Dolphin* dolphin) { } void dolphin_flush(Dolphin* dolphin) { - furi_assert(dolphin); + furi_check(dolphin); DolphinEvent event; event.type = DolphinEventTypeFlush; @@ -73,7 +73,7 @@ void dolphin_clear_limits_timer_callback(void* context) { dolphin_event_send_async(dolphin, &event); } -Dolphin* dolphin_alloc() { +Dolphin* dolphin_alloc(void) { Dolphin* dolphin = malloc(sizeof(Dolphin)); dolphin->state = dolphin_state_alloc(); @@ -119,6 +119,7 @@ void dolphin_event_release(Dolphin* dolphin, DolphinEvent* event) { } FuriPubSub* dolphin_get_pubsub(Dolphin* dolphin) { + furi_check(dolphin); return dolphin->pubsub; } @@ -201,6 +202,8 @@ int32_t dolphin_srv(void* p) { } void dolphin_upgrade_level(Dolphin* dolphin) { + furi_check(dolphin); + dolphin_state_increase_level(dolphin->state); dolphin_flush(dolphin); } diff --git a/applications/services/dolphin/dolphin_i.h b/applications/services/dolphin/dolphin_i.h index 2d716c181..666e03942 100644 --- a/applications/services/dolphin/dolphin_i.h +++ b/applications/services/dolphin/dolphin_i.h @@ -35,7 +35,7 @@ struct Dolphin { FuriTimer* clear_limits_timer; }; -Dolphin* dolphin_alloc(); +Dolphin* dolphin_alloc(void); void dolphin_event_send_async(Dolphin* dolphin, DolphinEvent* event); diff --git a/applications/services/dolphin/helpers/dolphin_state.c b/applications/services/dolphin/helpers/dolphin_state.c index 842d6b715..55c2286d9 100644 --- a/applications/services/dolphin/helpers/dolphin_state.c +++ b/applications/services/dolphin/helpers/dolphin_state.c @@ -19,7 +19,7 @@ #define BUTTHURT_MAX 14 #define BUTTHURT_MIN 0 -DolphinState* dolphin_state_alloc() { +DolphinState* dolphin_state_alloc(void) { return malloc(sizeof(DolphinState)); } @@ -73,7 +73,7 @@ bool dolphin_state_load(DolphinState* dolphin_state) { return success; } -uint64_t dolphin_state_timestamp() { +uint64_t dolphin_state_timestamp(void) { DateTime datetime; furi_hal_rtc_get_datetime(&datetime); return datetime_datetime_to_timestamp(&datetime); diff --git a/applications/services/dolphin/helpers/dolphin_state.h b/applications/services/dolphin/helpers/dolphin_state.h index 3e02fb872..a8d8406be 100644 --- a/applications/services/dolphin/helpers/dolphin_state.h +++ b/applications/services/dolphin/helpers/dolphin_state.h @@ -21,7 +21,7 @@ struct DolphinState { bool dirty; }; -DolphinState* dolphin_state_alloc(); +DolphinState* dolphin_state_alloc(void); void dolphin_state_free(DolphinState* dolphin_state); @@ -31,7 +31,7 @@ bool dolphin_state_load(DolphinState* dolphin_state); void dolphin_state_clear_limits(DolphinState* dolphin_state); -uint64_t dolphin_state_timestamp(); +uint64_t dolphin_state_timestamp(void); void dolphin_state_on_deed(DolphinState* dolphin_state, DolphinDeed deed); diff --git a/applications/services/expansion/expansion.c b/applications/services/expansion/expansion.c index 9c64d0b5a..9b0b31cf7 100644 --- a/applications/services/expansion/expansion.c +++ b/applications/services/expansion/expansion.c @@ -238,7 +238,7 @@ static int32_t expansion_control(void* context) { return 0; } -static Expansion* expansion_alloc() { +static Expansion* expansion_alloc(void) { Expansion* instance = malloc(sizeof(Expansion)); instance->queue = diff --git a/applications/services/gui/canvas.c b/applications/services/gui/canvas.c index 65a766543..cb890a7e6 100644 --- a/applications/services/gui/canvas.c +++ b/applications/services/gui/canvas.c @@ -14,7 +14,7 @@ const CanvasFontParameters canvas_font_params[FontTotalNumber] = { [FontBatteryPercent] = {.leading_default = 11, .leading_min = 9, .height = 6, .descender = 0}, }; -Canvas* canvas_init() { +Canvas* canvas_init(void) { Canvas* canvas = malloc(sizeof(Canvas)); canvas->compress_icon = compress_icon_alloc(); @@ -40,7 +40,7 @@ Canvas* canvas_init() { } void canvas_free(Canvas* canvas) { - furi_assert(canvas); + furi_check(canvas); compress_icon_free(canvas->compress_icon); CanvasCallbackPairArray_clear(canvas->canvas_callback_pair); furi_mutex_free(canvas->mutex); @@ -58,7 +58,7 @@ static void canvas_unlock(Canvas* canvas) { } void canvas_reset(Canvas* canvas) { - furi_assert(canvas); + furi_check(canvas); canvas_clear(canvas); @@ -68,7 +68,7 @@ void canvas_reset(Canvas* canvas) { } void canvas_commit(Canvas* canvas) { - furi_assert(canvas); + furi_check(canvas); u8g2_SendBuffer(&canvas->fb); // Iterate over callbacks @@ -85,12 +85,12 @@ void canvas_commit(Canvas* canvas) { } uint8_t* canvas_get_buffer(Canvas* canvas) { - furi_assert(canvas); + furi_check(canvas); return u8g2_GetBufferPtr(&canvas->fb); } size_t canvas_get_buffer_size(const Canvas* canvas) { - furi_assert(canvas); + furi_check(canvas); return u8g2_GetBufferTileWidth(&canvas->fb) * u8g2_GetBufferTileHeight(&canvas->fb) * 8; } @@ -100,7 +100,7 @@ void canvas_frame_set( uint8_t offset_y, uint8_t width, uint8_t height) { - furi_assert(canvas); + furi_check(canvas); canvas->offset_x = offset_x; canvas->offset_y = offset_y; canvas->width = width; @@ -108,17 +108,17 @@ void canvas_frame_set( } uint8_t canvas_width(const Canvas* canvas) { - furi_assert(canvas); + furi_check(canvas); return canvas->width; } uint8_t canvas_height(const Canvas* canvas) { - furi_assert(canvas); + furi_check(canvas); return canvas->height; } uint8_t canvas_current_font_height(const Canvas* canvas) { - furi_assert(canvas); + furi_check(canvas); uint8_t font_height = u8g2_GetMaxCharHeight(&canvas->fb); if(canvas->fb.font == u8g2_font_haxrcorp4089_tr) { @@ -134,23 +134,23 @@ uint8_t canvas_current_font_width(const Canvas* canvas) { } const CanvasFontParameters* canvas_get_font_params(const Canvas* canvas, Font font) { - furi_assert(canvas); - furi_assert(font < FontTotalNumber); + furi_check(canvas); + furi_check(font < FontTotalNumber); return &canvas_font_params[font]; } void canvas_clear(Canvas* canvas) { - furi_assert(canvas); + furi_check(canvas); u8g2_ClearBuffer(&canvas->fb); } void canvas_set_color(Canvas* canvas, Color color) { - furi_assert(canvas); + furi_check(canvas); u8g2_SetDrawColor(&canvas->fb, color); } void canvas_set_font_direction(Canvas* canvas, CanvasDirection dir) { - furi_assert(canvas); + furi_check(canvas); u8g2_SetFontDirection(&canvas->fb, dir); } @@ -159,7 +159,7 @@ void canvas_invert_color(Canvas* canvas) { } void canvas_set_font(Canvas* canvas, Font font) { - furi_assert(canvas); + furi_check(canvas); u8g2_SetFontMode(&canvas->fb, 1); if(font == FontPrimary) { u8g2_SetFont(&canvas->fb, u8g2_font_helvB08_tr); @@ -177,13 +177,13 @@ void canvas_set_font(Canvas* canvas, Font font) { } void canvas_set_custom_u8g2_font(Canvas* canvas, const uint8_t* font) { - furi_assert(canvas); + furi_check(canvas); u8g2_SetFontMode(&canvas->fb, 1); u8g2_SetFont(&canvas->fb, font); } void canvas_draw_str(Canvas* canvas, uint8_t x, uint8_t y, const char* str) { - furi_assert(canvas); + furi_check(canvas); if(!str) return; x += canvas->offset_x; y += canvas->offset_y; @@ -197,7 +197,7 @@ void canvas_draw_str_aligned( Align horizontal, Align vertical, const char* str) { - furi_assert(canvas); + furi_check(canvas); if(!str) return; x += canvas->offset_x; y += canvas->offset_y; @@ -234,13 +234,13 @@ void canvas_draw_str_aligned( } uint16_t canvas_string_width(Canvas* canvas, const char* str) { - furi_assert(canvas); + furi_check(canvas); if(!str) return 0; return u8g2_GetStrWidth(&canvas->fb, str); } uint8_t canvas_glyph_width(Canvas* canvas, uint16_t symbol) { - furi_assert(canvas); + furi_check(canvas); return u8g2_GetGlyphWidth(&canvas->fb, symbol); } @@ -251,7 +251,7 @@ void canvas_draw_bitmap( uint8_t width, uint8_t height, const uint8_t* compressed_bitmap_data) { - furi_assert(canvas); + furi_check(canvas); x += canvas->offset_x; y += canvas->offset_y; @@ -265,8 +265,8 @@ void canvas_draw_icon_animation( uint8_t x, uint8_t y, IconAnimation* icon_animation) { - furi_assert(canvas); - furi_assert(icon_animation); + furi_check(canvas); + furi_check(icon_animation); x += canvas->offset_x; y += canvas->offset_y; @@ -364,10 +364,6 @@ void canvas_draw_u8g2_bitmap( u8g2_uint_t h, const uint8_t* bitmap, IconRotation rotation) { - u8g2_uint_t blen; - blen = w; - blen += 7; - blen >>= 3; #ifdef U8G2_WITH_INTERSECTION if(u8g2_IsIntersection(u8g2, x, y, x + w, y + h) == 0) return; #endif /* U8G2_WITH_INTERSECTION */ @@ -396,8 +392,8 @@ void canvas_draw_icon_ex( uint8_t y, const Icon* icon, IconRotation rotation) { - furi_assert(canvas); - furi_assert(icon); + furi_check(canvas); + furi_check(icon); x += canvas->offset_x; y += canvas->offset_y; @@ -408,8 +404,8 @@ void canvas_draw_icon_ex( } void canvas_draw_icon(Canvas* canvas, uint8_t x, uint8_t y, const Icon* icon) { - furi_assert(canvas); - furi_assert(icon); + furi_check(canvas); + furi_check(icon); x += canvas->offset_x; y += canvas->offset_y; @@ -420,14 +416,14 @@ void canvas_draw_icon(Canvas* canvas, uint8_t x, uint8_t y, const Icon* icon) { } void canvas_draw_dot(Canvas* canvas, uint8_t x, uint8_t y) { - furi_assert(canvas); + furi_check(canvas); x += canvas->offset_x; y += canvas->offset_y; u8g2_DrawPixel(&canvas->fb, x, y); } void canvas_draw_box(Canvas* canvas, uint8_t x, uint8_t y, uint8_t width, uint8_t height) { - furi_assert(canvas); + furi_check(canvas); x += canvas->offset_x; y += canvas->offset_y; u8g2_DrawBox(&canvas->fb, x, y, width, height); @@ -440,14 +436,14 @@ void canvas_draw_rbox( uint8_t width, uint8_t height, uint8_t radius) { - furi_assert(canvas); + furi_check(canvas); x += canvas->offset_x; y += canvas->offset_y; u8g2_DrawRBox(&canvas->fb, x, y, width, height, radius); } void canvas_draw_frame(Canvas* canvas, uint8_t x, uint8_t y, uint8_t width, uint8_t height) { - furi_assert(canvas); + furi_check(canvas); x += canvas->offset_x; y += canvas->offset_y; u8g2_DrawFrame(&canvas->fb, x, y, width, height); @@ -460,14 +456,14 @@ void canvas_draw_rframe( uint8_t width, uint8_t height, uint8_t radius) { - furi_assert(canvas); + furi_check(canvas); x += canvas->offset_x; y += canvas->offset_y; u8g2_DrawRFrame(&canvas->fb, x, y, width, height, radius); } void canvas_draw_line(Canvas* canvas, uint8_t x1, uint8_t y1, uint8_t x2, uint8_t y2) { - furi_assert(canvas); + furi_check(canvas); x1 += canvas->offset_x; y1 += canvas->offset_y; x2 += canvas->offset_x; @@ -476,14 +472,14 @@ void canvas_draw_line(Canvas* canvas, uint8_t x1, uint8_t y1, uint8_t x2, uint8_ } void canvas_draw_circle(Canvas* canvas, uint8_t x, uint8_t y, uint8_t radius) { - furi_assert(canvas); + furi_check(canvas); x += canvas->offset_x; y += canvas->offset_y; u8g2_DrawCircle(&canvas->fb, x, y, radius, U8G2_DRAW_ALL); } void canvas_draw_disc(Canvas* canvas, uint8_t x, uint8_t y, uint8_t radius) { - furi_assert(canvas); + furi_check(canvas); x += canvas->offset_x; y += canvas->offset_y; u8g2_DrawDisc(&canvas->fb, x, y, radius, U8G2_DRAW_ALL); @@ -496,7 +492,7 @@ void canvas_draw_triangle( uint8_t base, uint8_t height, CanvasDirection dir) { - furi_assert(canvas); + furi_check(canvas); if(dir == CanvasDirectionBottomToTop) { canvas_draw_line(canvas, x - base / 2, y, x + base / 2, y); canvas_draw_line(canvas, x - base / 2, y, x, y - height + 1); @@ -523,14 +519,14 @@ void canvas_draw_xbm( uint8_t w, uint8_t h, const uint8_t* bitmap) { - furi_assert(canvas); + furi_check(canvas); x += canvas->offset_x; y += canvas->offset_y; canvas_draw_u8g2_bitmap(&canvas->fb, x, y, w, h, bitmap, IconRotation0); } void canvas_draw_glyph(Canvas* canvas, uint8_t x, uint8_t y, uint16_t ch) { - furi_assert(canvas); + furi_check(canvas); x += canvas->offset_x; y += canvas->offset_y; u8g2_DrawGlyph(&canvas->fb, x, y, ch); @@ -558,7 +554,7 @@ void canvas_set_bitmap_mode(Canvas* canvas, bool alpha) { } void canvas_set_orientation(Canvas* canvas, CanvasOrientation orientation) { - furi_assert(canvas); + furi_check(canvas); const u8g2_cb_t* rotate_cb = NULL; bool need_swap = false; if(canvas->orientation != orientation) { @@ -598,12 +594,12 @@ CanvasOrientation canvas_get_orientation(const Canvas* canvas) { } void canvas_add_framebuffer_callback(Canvas* canvas, CanvasCommitCallback callback, void* context) { - furi_assert(canvas); + furi_check(canvas); const CanvasCallbackPair p = {callback, context}; canvas_lock(canvas); - furi_assert(!CanvasCallbackPairArray_count(canvas->canvas_callback_pair, p)); + furi_check(!CanvasCallbackPairArray_count(canvas->canvas_callback_pair, p)); CanvasCallbackPairArray_push_back(canvas->canvas_callback_pair, p); canvas_unlock(canvas); } @@ -612,12 +608,12 @@ void canvas_remove_framebuffer_callback( Canvas* canvas, CanvasCommitCallback callback, void* context) { - furi_assert(canvas); + furi_check(canvas); const CanvasCallbackPair p = {callback, context}; canvas_lock(canvas); - furi_assert(CanvasCallbackPairArray_count(canvas->canvas_callback_pair, p) == 1); + furi_check(CanvasCallbackPairArray_count(canvas->canvas_callback_pair, p) == 1); CanvasCallbackPairArray_remove_val(canvas->canvas_callback_pair, p); canvas_unlock(canvas); } \ No newline at end of file diff --git a/applications/services/gui/canvas_i.h b/applications/services/gui/canvas_i.h index 5d2a38ddf..c31bdd3bb 100644 --- a/applications/services/gui/canvas_i.h +++ b/applications/services/gui/canvas_i.h @@ -51,7 +51,7 @@ struct Canvas { * * @return Canvas instance */ -Canvas* canvas_init(); +Canvas* canvas_init(void); /** Free canvas memory * diff --git a/applications/services/gui/elements.c b/applications/services/gui/elements.c index f35c36aed..2285c32f2 100644 --- a/applications/services/gui/elements.c +++ b/applications/services/gui/elements.c @@ -28,8 +28,8 @@ typedef struct { } ElementTextBoxLine; void elements_progress_bar(Canvas* canvas, uint8_t x, uint8_t y, uint8_t width, float progress) { - furi_assert(canvas); - furi_assert((progress >= 0) && (progress <= 1.0)); + furi_check(canvas); + furi_check((progress >= 0.0f) && (progress <= 1.0f)); uint8_t height = 9; uint8_t progress_length = roundf(progress * (width - 2)); @@ -49,8 +49,8 @@ void elements_progress_bar_with_text( uint8_t width, float progress, const char* text) { - furi_assert(canvas); - furi_assert((progress >= 0.0f) && (progress <= 1.0f)); + furi_check(canvas); + furi_check((progress >= 0.0f) && (progress <= 1.0f)); uint8_t height = 11; uint8_t progress_length = roundf(progress * (width - 2)); @@ -74,7 +74,7 @@ void elements_scrollbar_pos( uint8_t height, uint16_t pos, uint16_t total) { - furi_assert(canvas); + furi_check(canvas); // prevent overflows canvas_set_color(canvas, ColorWhite); canvas_draw_box(canvas, x - 3, y, 3, height); @@ -91,7 +91,7 @@ void elements_scrollbar_pos( } void elements_scrollbar(Canvas* canvas, uint16_t pos, uint16_t total) { - furi_assert(canvas); + furi_check(canvas); uint8_t width = canvas_width(canvas); uint8_t height = canvas_height(canvas); @@ -111,7 +111,7 @@ void elements_scrollbar(Canvas* canvas, uint16_t pos, uint16_t total) { } void elements_frame(Canvas* canvas, uint8_t x, uint8_t y, uint8_t width, uint8_t height) { - furi_assert(canvas); + furi_check(canvas); canvas_draw_line(canvas, x + 2, y, x + width - 2, y); canvas_draw_line(canvas, x + 1, y + height - 1, x + width, y + height - 1); @@ -125,6 +125,8 @@ void elements_frame(Canvas* canvas, uint8_t x, uint8_t y, uint8_t width, uint8_t } void elements_button_left(Canvas* canvas, const char* str) { + furi_check(canvas); + const uint8_t button_height = 12; const uint8_t vertical_offset = 3; const uint8_t horizontal_offset = 3; @@ -151,6 +153,8 @@ void elements_button_left(Canvas* canvas, const char* str) { } void elements_button_right(Canvas* canvas, const char* str) { + furi_check(canvas); + const uint8_t button_height = 12; const uint8_t vertical_offset = 3; const uint8_t horizontal_offset = 3; @@ -177,6 +181,8 @@ void elements_button_right(Canvas* canvas, const char* str) { } void elements_button_center(Canvas* canvas, const char* str) { + furi_check(canvas); + const uint8_t button_height = 12; const uint8_t vertical_offset = 3; const uint8_t horizontal_offset = 1; @@ -260,8 +266,8 @@ void elements_multiline_text_aligned( Align horizontal, Align vertical, const char* text) { - furi_assert(canvas); - furi_assert(text); + furi_check(canvas); + furi_check(text); uint8_t lines_count = 0; uint8_t font_height = canvas_current_font_height(canvas); @@ -306,8 +312,8 @@ void elements_multiline_text_aligned( } void elements_multiline_text(Canvas* canvas, uint8_t x, uint8_t y, const char* text) { - furi_assert(canvas); - furi_assert(text); + furi_check(canvas); + furi_check(text); uint8_t font_height = canvas_current_font_height(canvas); FuriString* str; @@ -329,8 +335,8 @@ void elements_multiline_text(Canvas* canvas, uint8_t x, uint8_t y, const char* t } void elements_multiline_text_framed(Canvas* canvas, uint8_t x, uint8_t y, const char* text) { - furi_assert(canvas); - furi_assert(text); + furi_check(canvas); + furi_check(text); uint8_t font_y = canvas_current_font_height(canvas); uint16_t str_width = canvas_string_width(canvas, text); @@ -359,7 +365,7 @@ void elements_slightly_rounded_frame( uint8_t y, uint8_t width, uint8_t height) { - furi_assert(canvas); + furi_check(canvas); canvas_draw_rframe(canvas, x, y, width, height, 1); } @@ -369,7 +375,7 @@ void elements_slightly_rounded_box( uint8_t y, uint8_t width, uint8_t height) { - furi_assert(canvas); + furi_check(canvas); canvas_draw_rbox(canvas, x, y, width, height, 1); } @@ -379,7 +385,7 @@ void elements_bold_rounded_frame( uint8_t y, uint8_t width, uint8_t height) { - furi_assert(canvas); + furi_check(canvas); canvas_set_color(canvas, ColorWhite); canvas_draw_box(canvas, x + 2, y + 2, width - 3, height - 3); @@ -415,7 +421,7 @@ void elements_bold_rounded_frame( } void elements_bubble(Canvas* canvas, uint8_t x, uint8_t y, uint8_t width, uint8_t height) { - furi_assert(canvas); + furi_check(canvas); canvas_draw_rframe(canvas, x + 4, y, width, height, 3); uint8_t y_corner = y + height * 2 / 3; canvas_draw_line(canvas, x, y_corner, x + 4, y_corner - 4); @@ -432,8 +438,8 @@ void elements_bubble_str( const char* text, Align horizontal, Align vertical) { - furi_assert(canvas); - furi_assert(text); + furi_check(canvas); + furi_check(text); uint8_t font_y = canvas_current_font_height(canvas); uint16_t str_width = canvas_string_width(canvas, text); @@ -560,8 +566,8 @@ void elements_bubble_str( } void elements_string_fit_width(Canvas* canvas, FuriString* string, uint8_t width) { - furi_assert(canvas); - furi_assert(string); + furi_check(canvas); + furi_check(string); uint16_t len_px = canvas_string_width(canvas, furi_string_get_cstr(string)); if(len_px > width) { @@ -640,6 +646,9 @@ void elements_scrollable_text_line( FuriString* string, size_t scroll, bool ellipsis) { + furi_check(canvas); + furi_check(string); + FuriString* line = furi_string_alloc_set(string); size_t len_px = canvas_string_width(canvas, furi_string_get_cstr(line)); @@ -689,7 +698,7 @@ void elements_text_box( Align vertical, const char* text, bool strip_to_dots) { - furi_assert(canvas); + furi_check(canvas); ElementTextBoxLine line[ELEMENTS_MAX_LINES_NUM]; bool bold = false; diff --git a/applications/services/gui/gui.c b/applications/services/gui/gui.c index 0e29a5a01..24ea57bc0 100644 --- a/applications/services/gui/gui.c +++ b/applications/services/gui/gui.c @@ -349,9 +349,10 @@ void gui_unlock(Gui* gui) { } void gui_add_view_port(Gui* gui, ViewPort* view_port, GuiLayer layer) { - furi_assert(gui); - furi_assert(view_port); + furi_check(gui); + furi_check(view_port); furi_check(layer < GuiLayerMAX); + // Only fullscreen supports Vertical orientation for now ViewPortOrientation view_port_orientation = view_port_get_orientation(view_port); furi_check( @@ -379,8 +380,8 @@ void gui_add_view_port(Gui* gui, ViewPort* view_port, GuiLayer layer) { } void gui_remove_view_port(Gui* gui, ViewPort* view_port) { - furi_assert(gui); - furi_assert(view_port); + furi_check(gui); + furi_check(view_port); gui_lock(gui); view_port_gui_set(view_port, NULL); @@ -405,8 +406,8 @@ void gui_remove_view_port(Gui* gui, ViewPort* view_port) { } void gui_view_port_send_to_front(Gui* gui, ViewPort* view_port) { - furi_assert(gui); - furi_assert(view_port); + furi_check(gui); + furi_check(view_port); gui_lock(gui); // Remove @@ -417,14 +418,14 @@ void gui_view_port_send_to_front(Gui* gui, ViewPort* view_port) { while(!ViewPortArray_end_p(it)) { if(*ViewPortArray_ref(it) == view_port) { ViewPortArray_remove(gui->layers[i], it); - furi_assert(layer == GuiLayerMAX); + furi_check(layer == GuiLayerMAX); layer = i; } else { ViewPortArray_next(it); } } } - furi_assert(layer != GuiLayerMAX); + furi_check(layer != GuiLayerMAX); // Return to the top ViewPortArray_push_back(gui->layers[layer], view_port); gui_unlock(gui); @@ -463,7 +464,7 @@ void gui_view_port_send_to_back(Gui* gui, ViewPort* view_port) { } void gui_add_framebuffer_callback(Gui* gui, GuiCanvasCommitCallback callback, void* context) { - furi_assert(gui); + furi_check(gui); canvas_add_framebuffer_callback(gui->canvas, callback, context); @@ -472,18 +473,19 @@ void gui_add_framebuffer_callback(Gui* gui, GuiCanvasCommitCallback callback, vo } void gui_remove_framebuffer_callback(Gui* gui, GuiCanvasCommitCallback callback, void* context) { - furi_assert(gui); + furi_check(gui); canvas_remove_framebuffer_callback(gui->canvas, callback, context); } size_t gui_get_framebuffer_size(const Gui* gui) { - furi_assert(gui); + furi_check(gui); + return canvas_get_buffer_size(gui->canvas); } void gui_set_lockdown(Gui* gui, bool lockdown) { - furi_assert(gui); + furi_check(gui); gui_lock(gui); gui->lockdown = lockdown; @@ -494,7 +496,8 @@ void gui_set_lockdown(Gui* gui, bool lockdown) { } Canvas* gui_direct_draw_acquire(Gui* gui) { - furi_assert(gui); + furi_check(gui); + gui_lock(gui); gui->direct_draw = true; gui_unlock(gui); @@ -508,7 +511,7 @@ Canvas* gui_direct_draw_acquire(Gui* gui) { } void gui_direct_draw_release(Gui* gui) { - furi_assert(gui); + furi_check(gui); canvas_reset(gui->canvas); canvas_commit(gui->canvas); @@ -520,7 +523,7 @@ void gui_direct_draw_release(Gui* gui) { gui_update(gui); } -Gui* gui_alloc() { +Gui* gui_alloc(void) { Gui* gui = malloc(sizeof(Gui)); // Thread ID gui->thread_id = furi_thread_get_current_id(); diff --git a/applications/services/gui/icon.c b/applications/services/gui/icon.c index 98f35b12a..e216b9255 100644 --- a/applications/services/gui/icon.c +++ b/applications/services/gui/icon.c @@ -1,13 +1,20 @@ #include "icon_i.h" +#include uint8_t icon_get_width(const Icon* instance) { + furi_check(instance); + return instance->width; } uint8_t icon_get_height(const Icon* instance) { + furi_check(instance); + return instance->height; } const uint8_t* icon_get_data(const Icon* instance) { + furi_check(instance); + return instance->frames[0]; } diff --git a/applications/services/gui/icon_animation.c b/applications/services/gui/icon_animation.c index a39ef2e25..f887b90ac 100644 --- a/applications/services/gui/icon_animation.c +++ b/applications/services/gui/icon_animation.c @@ -4,18 +4,22 @@ #include IconAnimation* icon_animation_alloc(const Icon* icon) { - furi_assert(icon); + furi_check(icon); + IconAnimation* instance = malloc(sizeof(IconAnimation)); instance->icon = icon; instance->timer = furi_timer_alloc(icon_animation_timer_callback, FuriTimerTypePeriodic, instance); + return instance; } void icon_animation_free(IconAnimation* instance) { - furi_assert(instance); + furi_check(instance); + icon_animation_stop(instance); furi_timer_free(instance->timer); + free(instance); } @@ -23,7 +27,8 @@ void icon_animation_set_update_callback( IconAnimation* instance, IconAnimationCallback callback, void* context) { - furi_assert(instance); + furi_check(instance); + instance->callback = callback; instance->callback_context = context; } @@ -51,17 +56,20 @@ void icon_animation_timer_callback(void* context) { } uint8_t icon_animation_get_width(const IconAnimation* instance) { - furi_assert(instance); + furi_check(instance); + return instance->icon->width; } uint8_t icon_animation_get_height(const IconAnimation* instance) { - furi_assert(instance); + furi_check(instance); + return instance->icon->height; } void icon_animation_start(IconAnimation* instance) { - furi_assert(instance); + furi_check(instance); + if(!instance->animating) { instance->animating = true; furi_assert(instance->icon->frame_rate); @@ -73,7 +81,8 @@ void icon_animation_start(IconAnimation* instance) { } void icon_animation_stop(IconAnimation* instance) { - furi_assert(instance); + furi_check(instance); + if(instance->animating) { instance->animating = false; furi_timer_stop(instance->timer); @@ -82,6 +91,7 @@ void icon_animation_stop(IconAnimation* instance) { } bool icon_animation_is_last_frame(const IconAnimation* instance) { - furi_assert(instance); + furi_check(instance); + return instance->icon->frame_count - instance->frame <= 1; } diff --git a/applications/services/gui/modules/button_menu.c b/applications/services/gui/modules/button_menu.c index 6ac786c92..ed76bd2b3 100644 --- a/applications/services/gui/modules/button_menu.c +++ b/applications/services/gui/modules/button_menu.c @@ -300,12 +300,12 @@ static bool button_menu_view_input_callback(InputEvent* event, void* context) { } View* button_menu_get_view(ButtonMenu* button_menu) { - furi_assert(button_menu); + furi_check(button_menu); return button_menu->view; } void button_menu_reset(ButtonMenu* button_menu) { - furi_assert(button_menu); + furi_check(button_menu); with_view_model( button_menu->view, @@ -319,7 +319,7 @@ void button_menu_reset(ButtonMenu* button_menu) { } void button_menu_set_header(ButtonMenu* button_menu, const char* header) { - furi_assert(button_menu); + furi_check(button_menu); with_view_model( button_menu->view, ButtonMenuModel * model, { model->header = header; }, true); @@ -333,8 +333,8 @@ ButtonMenuItem* button_menu_add_item( ButtonMenuItemType type, void* callback_context) { ButtonMenuItem* item = NULL; - furi_assert(label); - furi_assert(button_menu); + furi_check(label); + furi_check(button_menu); with_view_model( button_menu->view, @@ -376,7 +376,7 @@ ButtonMenu* button_menu_alloc(void) { } void button_menu_free(ButtonMenu* button_menu) { - furi_assert(button_menu); + furi_check(button_menu); with_view_model( button_menu->view, @@ -388,7 +388,7 @@ void button_menu_free(ButtonMenu* button_menu) { } void button_menu_set_selected_item(ButtonMenu* button_menu, uint32_t index) { - furi_assert(button_menu); + furi_check(button_menu); with_view_model( button_menu->view, diff --git a/applications/services/gui/modules/button_panel.c b/applications/services/gui/modules/button_panel.c index a6900dee3..9f39095cb 100644 --- a/applications/services/gui/modules/button_panel.c +++ b/applications/services/gui/modules/button_panel.c @@ -67,7 +67,7 @@ static void button_panel_process_ok(ButtonPanel* button_panel); static void button_panel_view_draw_callback(Canvas* canvas, void* _model); static bool button_panel_view_input_callback(InputEvent* event, void* context); -ButtonPanel* button_panel_alloc() { +ButtonPanel* button_panel_alloc(void) { ButtonPanel* button_panel = malloc(sizeof(ButtonPanel)); button_panel->view = view_alloc(); view_set_orientation(button_panel->view, ViewOrientationVertical); @@ -125,7 +125,7 @@ void button_panel_reserve(ButtonPanel* button_panel, size_t reserve_x, size_t re } void button_panel_free(ButtonPanel* button_panel) { - furi_assert(button_panel); + furi_check(button_panel); button_panel_reset(button_panel); @@ -143,7 +143,7 @@ void button_panel_free(ButtonPanel* button_panel) { } void button_panel_reset(ButtonPanel* button_panel) { - furi_assert(button_panel); + furi_check(button_panel); with_view_model( button_panel->view, @@ -188,7 +188,7 @@ void button_panel_add_item( const Icon* icon_name_selected, ButtonItemCallback callback, void* callback_context) { - furi_assert(button_panel); + furi_check(button_panel); with_view_model( //-V773 button_panel->view, @@ -211,7 +211,7 @@ void button_panel_add_item( } View* button_panel_get_view(ButtonPanel* button_panel) { - furi_assert(button_panel); + furi_check(button_panel); return button_panel->view; } @@ -416,7 +416,7 @@ void button_panel_add_label( uint16_t y, Font font, const char* label_str) { - furi_assert(button_panel); + furi_check(button_panel); with_view_model( button_panel->view, @@ -437,7 +437,7 @@ void button_panel_add_icon( uint16_t x, uint16_t y, const Icon* icon_name) { - furi_assert(button_panel); + furi_check(button_panel); with_view_model( //-V773 button_panel->view, diff --git a/applications/services/gui/modules/byte_input.c b/applications/services/gui/modules/byte_input.c index dd13e3aad..4c3da820b 100644 --- a/applications/services/gui/modules/byte_input.c +++ b/applications/services/gui/modules/byte_input.c @@ -808,7 +808,7 @@ static void byte_input_reset_model_input_data(ByteInputModel* model) { model->first_visible_byte = 0; } -ByteInput* byte_input_alloc() { +ByteInput* byte_input_alloc(void) { ByteInput* byte_input = malloc(sizeof(ByteInput)); byte_input->view = view_alloc(); view_set_context(byte_input->view, byte_input); @@ -832,13 +832,13 @@ ByteInput* byte_input_alloc() { } void byte_input_free(ByteInput* byte_input) { - furi_assert(byte_input); + furi_check(byte_input); view_free(byte_input->view); free(byte_input); } View* byte_input_get_view(ByteInput* byte_input) { - furi_assert(byte_input); + furi_check(byte_input); return byte_input->view; } @@ -849,6 +849,8 @@ void byte_input_set_result_callback( void* callback_context, uint8_t* bytes, uint8_t bytes_count) { + furi_check(byte_input); + with_view_model( byte_input->view, ByteInputModel * model, @@ -864,6 +866,8 @@ void byte_input_set_result_callback( } void byte_input_set_header_text(ByteInput* byte_input, const char* text) { + furi_check(byte_input); + with_view_model( byte_input->view, ByteInputModel * model, { model->header = text; }, true); } diff --git a/applications/services/gui/modules/byte_input.h b/applications/services/gui/modules/byte_input.h index 42c4b5d65..9cca7575e 100644 --- a/applications/services/gui/modules/byte_input.h +++ b/applications/services/gui/modules/byte_input.h @@ -24,7 +24,7 @@ typedef void (*ByteChangedCallback)(void* context); * * @return ByteInput instance pointer */ -ByteInput* byte_input_alloc(); +ByteInput* byte_input_alloc(void); /** Deinitialize and free byte input * diff --git a/applications/services/gui/modules/dialog_ex.c b/applications/services/gui/modules/dialog_ex.c index 7c3ef9b45..5fd42be6c 100644 --- a/applications/services/gui/modules/dialog_ex.c +++ b/applications/services/gui/modules/dialog_ex.c @@ -143,7 +143,7 @@ static bool dialog_ex_view_input_callback(InputEvent* event, void* context) { return consumed; } -DialogEx* dialog_ex_alloc() { +DialogEx* dialog_ex_alloc(void) { DialogEx* dialog_ex = malloc(sizeof(DialogEx)); dialog_ex->view = view_alloc(); view_set_context(dialog_ex->view, dialog_ex); @@ -180,23 +180,23 @@ DialogEx* dialog_ex_alloc() { } void dialog_ex_free(DialogEx* dialog_ex) { - furi_assert(dialog_ex); + furi_check(dialog_ex); view_free(dialog_ex->view); free(dialog_ex); } View* dialog_ex_get_view(DialogEx* dialog_ex) { - furi_assert(dialog_ex); + furi_check(dialog_ex); return dialog_ex->view; } void dialog_ex_set_result_callback(DialogEx* dialog_ex, DialogExResultCallback callback) { - furi_assert(dialog_ex); + furi_check(dialog_ex); dialog_ex->callback = callback; } void dialog_ex_set_context(DialogEx* dialog_ex, void* context) { - furi_assert(dialog_ex); + furi_check(dialog_ex); dialog_ex->context = context; } @@ -207,7 +207,7 @@ void dialog_ex_set_header( uint8_t y, Align horizontal, Align vertical) { - furi_assert(dialog_ex); + furi_check(dialog_ex); with_view_model( dialog_ex->view, DialogExModel * model, @@ -228,7 +228,7 @@ void dialog_ex_set_text( uint8_t y, Align horizontal, Align vertical) { - furi_assert(dialog_ex); + furi_check(dialog_ex); with_view_model( dialog_ex->view, DialogExModel * model, @@ -243,7 +243,7 @@ void dialog_ex_set_text( } void dialog_ex_set_icon(DialogEx* dialog_ex, uint8_t x, uint8_t y, const Icon* icon) { - furi_assert(dialog_ex); + furi_check(dialog_ex); with_view_model( dialog_ex->view, DialogExModel * model, @@ -256,25 +256,25 @@ void dialog_ex_set_icon(DialogEx* dialog_ex, uint8_t x, uint8_t y, const Icon* i } void dialog_ex_set_left_button_text(DialogEx* dialog_ex, const char* text) { - furi_assert(dialog_ex); + furi_check(dialog_ex); with_view_model( dialog_ex->view, DialogExModel * model, { model->left_text = text; }, true); } void dialog_ex_set_center_button_text(DialogEx* dialog_ex, const char* text) { - furi_assert(dialog_ex); + furi_check(dialog_ex); with_view_model( dialog_ex->view, DialogExModel * model, { model->center_text = text; }, true); } void dialog_ex_set_right_button_text(DialogEx* dialog_ex, const char* text) { - furi_assert(dialog_ex); + furi_check(dialog_ex); with_view_model( dialog_ex->view, DialogExModel * model, { model->right_text = text; }, true); } void dialog_ex_reset(DialogEx* dialog_ex) { - furi_assert(dialog_ex); + furi_check(dialog_ex); TextElement clean_text_el = { .text = NULL, .x = 0, .y = 0, .horizontal = AlignLeft, .vertical = AlignLeft}; IconElement clean_icon_el = {.icon = NULL, .x = 0, .y = 0}; @@ -295,11 +295,11 @@ void dialog_ex_reset(DialogEx* dialog_ex) { } void dialog_ex_enable_extended_events(DialogEx* dialog_ex) { - furi_assert(dialog_ex); + furi_check(dialog_ex); dialog_ex->enable_extended_events = true; } void dialog_ex_disable_extended_events(DialogEx* dialog_ex) { - furi_assert(dialog_ex); + furi_check(dialog_ex); dialog_ex->enable_extended_events = false; } diff --git a/applications/services/gui/modules/dialog_ex.h b/applications/services/gui/modules/dialog_ex.h index 91424f78c..aa87097f7 100644 --- a/applications/services/gui/modules/dialog_ex.h +++ b/applications/services/gui/modules/dialog_ex.h @@ -38,7 +38,7 @@ typedef void (*DialogExResultCallback)(DialogExResult result, void* context); * * @return DialogEx instance */ -DialogEx* dialog_ex_alloc(); +DialogEx* dialog_ex_alloc(void); /** Deinitialize and free dialog * diff --git a/applications/services/gui/modules/empty_screen.c b/applications/services/gui/modules/empty_screen.c index 0a51bc71c..1efb1d910 100644 --- a/applications/services/gui/modules/empty_screen.c +++ b/applications/services/gui/modules/empty_screen.c @@ -16,7 +16,7 @@ static bool empty_screen_view_input_callback(InputEvent* event, void* context) { return false; } -EmptyScreen* empty_screen_alloc() { +EmptyScreen* empty_screen_alloc(void) { EmptyScreen* empty_screen = malloc(sizeof(EmptyScreen)); empty_screen->view = view_alloc(); view_set_context(empty_screen->view, empty_screen); @@ -26,12 +26,12 @@ EmptyScreen* empty_screen_alloc() { } void empty_screen_free(EmptyScreen* empty_screen) { - furi_assert(empty_screen); + furi_check(empty_screen); view_free(empty_screen->view); free(empty_screen); } View* empty_screen_get_view(EmptyScreen* empty_screen) { - furi_assert(empty_screen); + furi_check(empty_screen); return empty_screen->view; } diff --git a/applications/services/gui/modules/empty_screen.h b/applications/services/gui/modules/empty_screen.h index 23ebeb3a0..5ca99bda2 100644 --- a/applications/services/gui/modules/empty_screen.h +++ b/applications/services/gui/modules/empty_screen.h @@ -20,7 +20,7 @@ typedef struct EmptyScreen EmptyScreen; * * @return EmptyScreen instance */ -EmptyScreen* empty_screen_alloc(); +EmptyScreen* empty_screen_alloc(void); /** Deinitialize and free empty screen * diff --git a/applications/services/gui/modules/file_browser.c b/applications/services/gui/modules/file_browser.c index bfca1f91c..70c432afe 100644 --- a/applications/services/gui/modules/file_browser.c +++ b/applications/services/gui/modules/file_browser.c @@ -172,14 +172,14 @@ static void browser_list_item_cb( static void browser_long_load_cb(void* context); static void file_browser_scroll_timer_callback(void* context) { - furi_assert(context); + furi_check(context); FileBrowser* browser = context; with_view_model( browser->view, FileBrowserModel * model, { model->scroll_counter++; }, true); } static void file_browser_view_enter_callback(void* context) { - furi_assert(context); + furi_check(context); FileBrowser* browser = context; with_view_model( browser->view, FileBrowserModel * model, { model->scroll_counter = 0; }, true); @@ -187,13 +187,14 @@ static void file_browser_view_enter_callback(void* context) { } static void file_browser_view_exit_callback(void* context) { - furi_assert(context); + furi_check(context); FileBrowser* browser = context; furi_timer_stop(browser->scroll_timer); } FileBrowser* file_browser_alloc(FuriString* result_path) { - furi_assert(result_path); + furi_check(result_path); + FileBrowser* browser = malloc(sizeof(FileBrowser)); browser->view = view_alloc(); view_allocate_model(browser->view, ViewModelTypeLocking, sizeof(FileBrowserModel)); @@ -215,7 +216,7 @@ FileBrowser* file_browser_alloc(FuriString* result_path) { } void file_browser_free(FileBrowser* browser) { - furi_assert(browser); + furi_check(browser); furi_timer_free(browser->scroll_timer); @@ -227,7 +228,7 @@ void file_browser_free(FileBrowser* browser) { } View* file_browser_get_view(FileBrowser* browser) { - furi_assert(browser); + furi_check(browser); return browser->view; } @@ -239,7 +240,7 @@ void file_browser_configure( bool hide_dot_files, const Icon* file_icon, bool hide_ext) { - furi_assert(browser); + furi_check(browser); browser->ext_filter = extension; browser->skip_assets = skip_assets; @@ -258,7 +259,7 @@ void file_browser_configure( } void file_browser_start(FileBrowser* browser, FuriString* path) { - furi_assert(browser); + furi_check(browser); browser->worker = file_browser_worker_alloc( path, browser->base_path, @@ -273,7 +274,7 @@ void file_browser_start(FileBrowser* browser, FuriString* path) { } void file_browser_stop(FileBrowser* browser) { - furi_assert(browser); + furi_check(browser); file_browser_worker_free(browser->worker); with_view_model( browser->view, @@ -289,6 +290,7 @@ void file_browser_stop(FileBrowser* browser) { } void file_browser_set_callback(FileBrowser* browser, FileBrowserCallback callback, void* context) { + furi_check(browser); browser->context = context; browser->callback = callback; } @@ -297,6 +299,8 @@ void file_browser_set_item_callback( FileBrowser* browser, FileBrowserLoadItemCallback callback, void* context) { + furi_check(browser); + browser->item_context = context; browser->item_callback = callback; } @@ -336,7 +340,7 @@ static bool browser_is_list_load_required(FileBrowserModel* model) { } static void browser_update_offset(FileBrowser* browser) { - furi_assert(browser); + furi_check(browser); with_view_model( browser->view, @@ -362,7 +366,7 @@ static void browser_update_offset(FileBrowser* browser) { static void browser_folder_open_cb(void* context, uint32_t item_cnt, int32_t file_idx, bool is_root) { - furi_assert(context); + furi_check(context); FileBrowser* browser = (FileBrowser*)context; int32_t load_offset = 0; @@ -396,7 +400,7 @@ static void } static void browser_list_load_cb(void* context, uint32_t list_load_offset) { - furi_assert(context); + furi_check(context); FileBrowser* browser = (FileBrowser*)context; BrowserItem_t back_item; @@ -506,7 +510,7 @@ static void browser_list_item_cb( } static void browser_long_load_cb(void* context) { - furi_assert(context); + furi_check(context); FileBrowser* browser = (FileBrowser*)context; with_view_model( @@ -643,7 +647,7 @@ static void file_browser_view_draw_callback(Canvas* canvas, void* _model) { static bool file_browser_view_input_callback(InputEvent* event, void* context) { FileBrowser* browser = context; - furi_assert(browser); + furi_check(browser); bool consumed = false; bool is_loading = false; diff --git a/applications/services/gui/modules/file_browser_worker.c b/applications/services/gui/modules/file_browser_worker.c index c33288765..08e194325 100644 --- a/applications/services/gui/modules/file_browser_worker.c +++ b/applications/services/gui/modules/file_browser_worker.c @@ -357,7 +357,7 @@ static bool browser_folder_load_full(BrowserWorker* browser, FuriString* path) { static int32_t browser_worker(void* context) { BrowserWorker* browser = (BrowserWorker*)context; - furi_assert(browser); + furi_check(browser); FURI_LOG_D(TAG, "Start"); uint32_t items_cnt = 0; @@ -373,7 +373,7 @@ static int32_t browser_worker(void* context) { while(1) { uint32_t flags = furi_thread_flags_wait(WORKER_FLAGS_ALL, FuriFlagWaitAny, FuriWaitForever); - furi_assert((flags & FuriFlagError) == 0); + furi_check((flags & FuriFlagError) == 0); if(flags & WorkerEvtConfigChange) { // If start path is a path to the file - try finding index of this file in a folder @@ -499,7 +499,7 @@ BrowserWorker* file_browser_worker_alloc( } //-V773 void file_browser_worker_free(BrowserWorker* browser) { - furi_assert(browser); + furi_check(browser); furi_thread_flags_set(furi_thread_get_id(browser->thread), WorkerEvtStop); furi_thread_join(browser->thread); @@ -516,35 +516,35 @@ void file_browser_worker_free(BrowserWorker* browser) { } void file_browser_worker_set_callback_context(BrowserWorker* browser, void* context) { - furi_assert(browser); + furi_check(browser); browser->cb_ctx = context; } void file_browser_worker_set_folder_callback( BrowserWorker* browser, BrowserWorkerFolderOpenCallback cb) { - furi_assert(browser); + furi_check(browser); browser->folder_cb = cb; } void file_browser_worker_set_list_callback( BrowserWorker* browser, BrowserWorkerListLoadCallback cb) { - furi_assert(browser); + furi_check(browser); browser->list_load_cb = cb; } void file_browser_worker_set_item_callback( BrowserWorker* browser, BrowserWorkerListItemCallback cb) { - furi_assert(browser); + furi_check(browser); browser->list_item_cb = cb; } void file_browser_worker_set_long_load_callback( BrowserWorker* browser, BrowserWorkerLongLoadCallback cb) { - furi_assert(browser); + furi_check(browser); browser->long_load_cb = cb; } @@ -554,7 +554,7 @@ void file_browser_worker_set_config( const char* ext_filter, bool skip_assets, bool hide_dot_files) { - furi_assert(browser); + furi_check(browser); furi_string_set(browser->path_next, path); browser_parse_ext_filter(browser->ext_filter, ext_filter); browser->skip_assets = skip_assets; @@ -563,30 +563,30 @@ void file_browser_worker_set_config( } void file_browser_worker_folder_enter(BrowserWorker* browser, FuriString* path, int32_t item_idx) { - furi_assert(browser); + furi_check(browser); furi_string_set(browser->path_next, path); browser->item_sel_idx = item_idx; furi_thread_flags_set(furi_thread_get_id(browser->thread), WorkerEvtFolderEnter); } bool file_browser_worker_is_in_start_folder(BrowserWorker* browser) { - furi_assert(browser); + furi_check(browser); return (furi_string_cmp(browser->path_start, browser->path_current) == 0); } void file_browser_worker_folder_exit(BrowserWorker* browser) { - furi_assert(browser); + furi_check(browser); furi_thread_flags_set(furi_thread_get_id(browser->thread), WorkerEvtFolderExit); } void file_browser_worker_folder_refresh(BrowserWorker* browser, int32_t item_idx) { - furi_assert(browser); + furi_check(browser); browser->item_sel_idx = item_idx; furi_thread_flags_set(furi_thread_get_id(browser->thread), WorkerEvtFolderRefresh); } void file_browser_worker_load(BrowserWorker* browser, uint32_t offset, uint32_t count) { - furi_assert(browser); + furi_check(browser); browser->load_offset = offset; browser->load_count = count; furi_thread_flags_set(furi_thread_get_id(browser->thread), WorkerEvtLoad); diff --git a/applications/services/gui/modules/loading.c b/applications/services/gui/modules/loading.c index e64aeb78f..7ef4ba8f3 100644 --- a/applications/services/gui/modules/loading.c +++ b/applications/services/gui/modules/loading.c @@ -79,6 +79,8 @@ Loading* loading_alloc(void) { } void loading_free(Loading* instance) { + furi_check(instance); + LoadingModel* model = view_get_model(instance->view); icon_animation_free(model->icon); view_commit_model(instance->view, false); @@ -89,7 +91,6 @@ void loading_free(Loading* instance) { } View* loading_get_view(Loading* instance) { - furi_assert(instance); - furi_assert(instance->view); + furi_check(instance); return instance->view; } diff --git a/applications/services/gui/modules/loading.h b/applications/services/gui/modules/loading.h index 1e071c10a..12eac00d5 100644 --- a/applications/services/gui/modules/loading.h +++ b/applications/services/gui/modules/loading.h @@ -14,7 +14,7 @@ typedef struct Loading Loading; * * @return Loading View instance */ -Loading* loading_alloc(); +Loading* loading_alloc(void); /** Deinitialize and free Loading View * diff --git a/applications/services/gui/modules/menu.c b/applications/services/gui/modules/menu.c index afae8b8fa..f0a3b82b5 100644 --- a/applications/services/gui/modules/menu.c +++ b/applications/services/gui/modules/menu.c @@ -129,9 +129,9 @@ static void menu_exit(void* context) { false); } -Menu* menu_alloc() { +Menu* menu_alloc(void) { Menu* menu = malloc(sizeof(Menu)); - menu->view = view_alloc(menu->view); + menu->view = view_alloc(); view_set_context(menu->view, menu); view_allocate_model(menu->view, ViewModelTypeLocking, sizeof(MenuModel)); view_set_draw_callback(menu->view, menu_draw_callback); @@ -152,16 +152,18 @@ Menu* menu_alloc() { } void menu_free(Menu* menu) { - furi_assert(menu); + furi_check(menu); + menu_reset(menu); with_view_model( menu->view, MenuModel * model, { MenuItemArray_clear(model->items); }, false); view_free(menu->view); + free(menu); } View* menu_get_view(Menu* menu) { - furi_assert(menu); + furi_check(menu); return (menu->view); } @@ -172,8 +174,8 @@ void menu_add_item( uint32_t index, MenuItemCallback callback, void* context) { - furi_assert(menu); - furi_assert(label); + furi_check(menu); + furi_check(label); MenuItem* item = NULL; with_view_model( @@ -192,7 +194,7 @@ void menu_add_item( } void menu_reset(Menu* menu) { - furi_assert(menu); + furi_check(menu); with_view_model( menu->view, MenuModel * model, @@ -210,6 +212,8 @@ void menu_reset(Menu* menu) { } void menu_set_selected_item(Menu* menu, uint32_t index) { + furi_check(menu); + with_view_model( menu->view, MenuModel * model, diff --git a/applications/services/gui/modules/menu.h b/applications/services/gui/modules/menu.h index f66514a71..616bfcebe 100644 --- a/applications/services/gui/modules/menu.h +++ b/applications/services/gui/modules/menu.h @@ -21,7 +21,7 @@ typedef void (*MenuItemCallback)(void* context, uint32_t index); * * @return Menu instance */ -Menu* menu_alloc(); +Menu* menu_alloc(void); /** Free menu * diff --git a/applications/services/gui/modules/popup.c b/applications/services/gui/modules/popup.c index 520efceef..45014f6f4 100644 --- a/applications/services/gui/modules/popup.c +++ b/applications/services/gui/modules/popup.c @@ -108,7 +108,7 @@ void popup_stop_timer(void* context) { furi_timer_stop(popup->timer); } -Popup* popup_alloc() { +Popup* popup_alloc(void) { Popup* popup = malloc(sizeof(Popup)); popup->view = view_alloc(); popup->timer = furi_timer_alloc(popup_timer_callback, FuriTimerTypeOnce, popup); @@ -148,24 +148,25 @@ Popup* popup_alloc() { } void popup_free(Popup* popup) { - furi_assert(popup); + furi_check(popup); furi_timer_free(popup->timer); view_free(popup->view); free(popup); } View* popup_get_view(Popup* popup) { - furi_assert(popup); + furi_check(popup); + return popup->view; } void popup_set_callback(Popup* popup, PopupCallback callback) { - furi_assert(popup); + furi_check(popup); popup->callback = callback; } void popup_set_context(Popup* popup, void* context) { - furi_assert(popup); + furi_check(popup); popup->context = context; } @@ -176,7 +177,8 @@ void popup_set_header( uint8_t y, Align horizontal, Align vertical) { - furi_assert(popup); + furi_check(popup); + with_view_model( popup->view, PopupModel * model, @@ -197,7 +199,8 @@ void popup_set_text( uint8_t y, Align horizontal, Align vertical) { - furi_assert(popup); + furi_check(popup); + with_view_model( popup->view, PopupModel * model, @@ -212,7 +215,8 @@ void popup_set_text( } void popup_set_icon(Popup* popup, uint8_t x, uint8_t y, const Icon* icon) { - furi_assert(popup); + furi_check(popup); + with_view_model( popup->view, PopupModel * model, @@ -225,20 +229,24 @@ void popup_set_icon(Popup* popup, uint8_t x, uint8_t y, const Icon* icon) { } void popup_set_timeout(Popup* popup, uint32_t timeout_in_ms) { - furi_assert(popup); + furi_check(popup); popup->timer_period_in_ms = timeout_in_ms; } void popup_enable_timeout(Popup* popup) { + furi_check(popup); + popup->timer_enabled = true; } void popup_disable_timeout(Popup* popup) { + furi_check(popup); + popup->timer_enabled = false; } void popup_reset(Popup* popup) { - furi_assert(popup); + furi_check(popup); with_view_model( popup->view, diff --git a/applications/services/gui/modules/popup.h b/applications/services/gui/modules/popup.h index ca783fdb7..6bf6a9d50 100644 --- a/applications/services/gui/modules/popup.h +++ b/applications/services/gui/modules/popup.h @@ -25,7 +25,7 @@ typedef void (*PopupCallback)(void* context); * * @return Popup instance */ -Popup* popup_alloc(); +Popup* popup_alloc(void); /** Deinitialize and free popup * diff --git a/applications/services/gui/modules/submenu.c b/applications/services/gui/modules/submenu.c index 368f5be28..a4250c2e1 100644 --- a/applications/services/gui/modules/submenu.c +++ b/applications/services/gui/modules/submenu.c @@ -234,7 +234,7 @@ void submenu_timer_callback(void* context) { submenu->view, SubmenuModel * model, { model->locked_message_visible = false; }, true); } -Submenu* submenu_alloc() { +Submenu* submenu_alloc(void) { Submenu* submenu = malloc(sizeof(Submenu)); submenu->view = view_alloc(); view_set_context(submenu->view, submenu); @@ -259,7 +259,7 @@ Submenu* submenu_alloc() { } void submenu_free(Submenu* submenu) { - furi_assert(submenu); + furi_check(submenu); with_view_model( submenu->view, @@ -276,7 +276,7 @@ void submenu_free(Submenu* submenu) { } View* submenu_get_view(Submenu* submenu) { - furi_assert(submenu); + furi_check(submenu); return submenu->view; } @@ -298,11 +298,8 @@ void submenu_add_lockable_item( bool locked, const char* locked_message) { SubmenuItem* item = NULL; - furi_assert(label); - furi_assert(submenu); - if(locked) { - furi_assert(locked_message); - } + furi_check(label); + furi_check(submenu); with_view_model( submenu->view, @@ -322,7 +319,7 @@ void submenu_add_lockable_item( } void submenu_reset(Submenu* submenu) { - furi_assert(submenu); + furi_check(submenu); view_set_orientation(submenu->view, ViewOrientationHorizontal); with_view_model( @@ -339,6 +336,7 @@ void submenu_reset(Submenu* submenu) { } void submenu_set_selected_item(Submenu* submenu, uint32_t index) { + furi_check(submenu); with_view_model( submenu->view, SubmenuModel * model, @@ -452,7 +450,7 @@ void submenu_process_ok(Submenu* submenu) { } void submenu_set_header(Submenu* submenu, const char* header) { - furi_assert(submenu); + furi_check(submenu); with_view_model( submenu->view, diff --git a/applications/services/gui/modules/submenu.h b/applications/services/gui/modules/submenu.h index 03337d777..676e99d29 100644 --- a/applications/services/gui/modules/submenu.h +++ b/applications/services/gui/modules/submenu.h @@ -21,7 +21,7 @@ typedef void (*SubmenuItemCallback)(void* context, uint32_t index); * * @return Submenu instance */ -Submenu* submenu_alloc(); +Submenu* submenu_alloc(void); /** Deinitialize and free submenu * diff --git a/applications/services/gui/modules/text_box.c b/applications/services/gui/modules/text_box.c index 55649c5f6..7059d356a 100644 --- a/applications/services/gui/modules/text_box.c +++ b/applications/services/gui/modules/text_box.c @@ -172,7 +172,7 @@ static bool text_box_view_input_callback(InputEvent* event, void* context) { return consumed; } -TextBox* text_box_alloc() { +TextBox* text_box_alloc(void) { TextBox* text_box = malloc(sizeof(TextBox)); text_box->view = view_alloc(); view_set_context(text_box->view, text_box); @@ -195,7 +195,7 @@ TextBox* text_box_alloc() { } void text_box_free(TextBox* text_box) { - furi_assert(text_box); + furi_check(text_box); with_view_model( text_box->view, TextBoxModel * model, { furi_string_free(model->text_formatted); }, true); @@ -204,12 +204,12 @@ void text_box_free(TextBox* text_box) { } View* text_box_get_view(TextBox* text_box) { - furi_assert(text_box); + furi_check(text_box); return text_box->view; } void text_box_reset(TextBox* text_box) { - furi_assert(text_box); + furi_check(text_box); with_view_model( text_box->view, @@ -225,8 +225,8 @@ void text_box_reset(TextBox* text_box) { } void text_box_set_text(TextBox* text_box, const char* text) { - furi_assert(text_box); - furi_assert(text); + furi_check(text_box); + furi_check(text); size_t str_length = strlen(text); size_t formating_margin = str_length * TEXT_BOX_MAX_SYMBOL_WIDTH / TEXT_BOX_LINE_WIDTH; @@ -243,14 +243,14 @@ void text_box_set_text(TextBox* text_box, const char* text) { } void text_box_set_font(TextBox* text_box, TextBoxFont font) { - furi_assert(text_box); + furi_check(text_box); with_view_model( text_box->view, TextBoxModel * model, { model->font = font; }, true); } void text_box_set_focus(TextBox* text_box, TextBoxFocus focus) { - furi_assert(text_box); + furi_check(text_box); with_view_model( text_box->view, TextBoxModel * model, { model->focus = focus; }, true); diff --git a/applications/services/gui/modules/text_box.h b/applications/services/gui/modules/text_box.h index 2a0548f2e..0e30f6370 100644 --- a/applications/services/gui/modules/text_box.h +++ b/applications/services/gui/modules/text_box.h @@ -28,7 +28,7 @@ typedef enum { * * @return TextBox instance */ -TextBox* text_box_alloc(); +TextBox* text_box_alloc(void); /** Deinitialize and free text_box * diff --git a/applications/services/gui/modules/text_input.c b/applications/services/gui/modules/text_input.c index 926a74910..c96510bcc 100644 --- a/applications/services/gui/modules/text_input.c +++ b/applications/services/gui/modules/text_input.c @@ -498,7 +498,7 @@ void text_input_timer_callback(void* context) { true); } -TextInput* text_input_alloc() { +TextInput* text_input_alloc(void) { TextInput* text_input = malloc(sizeof(TextInput)); text_input->view = view_alloc(); view_set_context(text_input->view, text_input); @@ -525,7 +525,7 @@ TextInput* text_input_alloc() { } void text_input_free(TextInput* text_input) { - furi_assert(text_input); + furi_check(text_input); with_view_model( text_input->view, TextInputModel * model, @@ -543,7 +543,7 @@ void text_input_free(TextInput* text_input) { } void text_input_reset(TextInput* text_input) { - furi_assert(text_input); + furi_check(text_input); with_view_model( text_input->view, TextInputModel * model, @@ -568,7 +568,7 @@ void text_input_reset(TextInput* text_input) { } View* text_input_get_view(TextInput* text_input) { - furi_assert(text_input); + furi_check(text_input); return text_input->view; } @@ -579,6 +579,7 @@ void text_input_set_result_callback( char* text_buffer, size_t text_buffer_size, bool clear_default_text) { + furi_check(text_input); with_view_model( text_input->view, TextInputModel * model, @@ -613,6 +614,7 @@ void text_input_set_validator( TextInput* text_input, TextInputValidatorCallback callback, void* callback_context) { + furi_check(text_input); with_view_model( text_input->view, TextInputModel * model, @@ -624,6 +626,7 @@ void text_input_set_validator( } TextInputValidatorCallback text_input_get_validator_callback(TextInput* text_input) { + furi_check(text_input); TextInputValidatorCallback validator_callback = NULL; with_view_model( text_input->view, @@ -634,6 +637,7 @@ TextInputValidatorCallback text_input_get_validator_callback(TextInput* text_inp } void* text_input_get_validator_callback_context(TextInput* text_input) { + furi_check(text_input); void* validator_callback_context = NULL; with_view_model( text_input->view, @@ -644,6 +648,7 @@ void* text_input_get_validator_callback_context(TextInput* text_input) { } void text_input_set_header_text(TextInput* text_input, const char* text) { + furi_check(text_input); with_view_model( text_input->view, TextInputModel * model, { model->header = text; }, true); } diff --git a/applications/services/gui/modules/text_input.h b/applications/services/gui/modules/text_input.h index 65207532e..6733c01cc 100644 --- a/applications/services/gui/modules/text_input.h +++ b/applications/services/gui/modules/text_input.h @@ -23,7 +23,7 @@ typedef bool (*TextInputValidatorCallback)(const char* text, FuriString* error, * * @return TextInput instance */ -TextInput* text_input_alloc(); +TextInput* text_input_alloc(void); /** Deinitialize and free text input * diff --git a/applications/services/gui/modules/validators.c b/applications/services/gui/modules/validators.c index a18cb925f..407a3aa1e 100644 --- a/applications/services/gui/modules/validators.c +++ b/applications/services/gui/modules/validators.c @@ -9,7 +9,7 @@ struct ValidatorIsFile { }; bool validator_is_file_callback(const char* text, FuriString* error, void* context) { - furi_assert(context); + furi_check(context); ValidatorIsFile* instance = context; if(instance->current_name != NULL) { @@ -47,7 +47,7 @@ ValidatorIsFile* validator_is_file_alloc_init( } void validator_is_file_free(ValidatorIsFile* instance) { - furi_assert(instance); + furi_check(instance); free(instance->app_path_folder); free(instance->current_name); free(instance); diff --git a/applications/services/gui/modules/variable_item_list.c b/applications/services/gui/modules/variable_item_list.c index 9aefcfd0e..3fe26b569 100644 --- a/applications/services/gui/modules/variable_item_list.c +++ b/applications/services/gui/modules/variable_item_list.c @@ -147,6 +147,7 @@ static void variable_item_list_draw_callback(Canvas* canvas, void* _model) { } void variable_item_list_set_selected_item(VariableItemList* variable_item_list, uint8_t index) { + furi_check(variable_item_list); with_view_model( variable_item_list->view, VariableItemListModel * model, @@ -175,6 +176,7 @@ void variable_item_list_set_selected_item(VariableItemList* variable_item_list, } uint8_t variable_item_list_get_selected_item_index(VariableItemList* variable_item_list) { + furi_check(variable_item_list); VariableItemListModel* model = view_get_model(variable_item_list->view); uint8_t idx = model->position; view_commit_model(variable_item_list->view, false); @@ -394,7 +396,7 @@ void variable_item_list_locked_timer_callback(void* context) { true); } -VariableItemList* variable_item_list_alloc() { +VariableItemList* variable_item_list_alloc(void) { VariableItemList* variable_item_list = malloc(sizeof(VariableItemList)); variable_item_list->view = view_alloc(); view_set_context(variable_item_list->view, variable_item_list); @@ -424,7 +426,7 @@ VariableItemList* variable_item_list_alloc() { } void variable_item_list_free(VariableItemList* variable_item_list) { - furi_assert(variable_item_list); + furi_check(variable_item_list); with_view_model( variable_item_list->view, @@ -448,7 +450,7 @@ void variable_item_list_free(VariableItemList* variable_item_list) { } void variable_item_list_reset(VariableItemList* variable_item_list) { - furi_assert(variable_item_list); + furi_check(variable_item_list); with_view_model( variable_item_list->view, @@ -466,7 +468,7 @@ void variable_item_list_reset(VariableItemList* variable_item_list) { } View* variable_item_list_get_view(VariableItemList* variable_item_list) { - furi_assert(variable_item_list); + furi_check(variable_item_list); return variable_item_list->view; } @@ -477,8 +479,8 @@ VariableItem* variable_item_list_add( VariableItemChangeCallback change_callback, void* context) { VariableItem* item = NULL; - furi_assert(label); - furi_assert(variable_item_list); + furi_check(label); + furi_check(variable_item_list); with_view_model( variable_item_list->view, @@ -520,7 +522,7 @@ void variable_item_list_set_enter_callback( VariableItemList* variable_item_list, VariableItemListEnterCallback callback, void* context) { - furi_assert(callback); + furi_check(callback); with_view_model( variable_item_list->view, VariableItemListModel * model, @@ -533,14 +535,17 @@ void variable_item_list_set_enter_callback( } void variable_item_set_current_value_index(VariableItem* item, uint8_t current_value_index) { + furi_check(item); item->current_value_index = current_value_index; } void variable_item_set_values_count(VariableItem* item, uint8_t values_count) { + furi_check(item); item->values_count = values_count; } void variable_item_set_current_value_text(VariableItem* item, const char* current_value_text) { + furi_check(item); furi_string_set(item->current_value_text, current_value_text); } @@ -553,9 +558,11 @@ void variable_item_set_locked(VariableItem* item, bool locked, const char* locke } uint8_t variable_item_get_current_value_index(VariableItem* item) { + furi_check(item); return item->current_value_index; } void* variable_item_get_context(VariableItem* item) { + furi_check(item); return item->context; } diff --git a/applications/services/gui/modules/variable_item_list.h b/applications/services/gui/modules/variable_item_list.h index 59a3b0830..aec2239f7 100644 --- a/applications/services/gui/modules/variable_item_list.h +++ b/applications/services/gui/modules/variable_item_list.h @@ -20,7 +20,7 @@ typedef void (*VariableItemListEnterCallback)(void* context, uint32_t index); * * @return VariableItemList* */ -VariableItemList* variable_item_list_alloc(); +VariableItemList* variable_item_list_alloc(void); /** Deinitialize and free VariableItemList * diff --git a/applications/services/gui/modules/widget.c b/applications/services/gui/modules/widget.c index 21b8e5616..50171e0cc 100644 --- a/applications/services/gui/modules/widget.c +++ b/applications/services/gui/modules/widget.c @@ -54,7 +54,7 @@ static bool gui_widget_view_input_callback(InputEvent* event, void* context) { return consumed; } -Widget* widget_alloc() { +Widget* widget_alloc(void) { Widget* widget = malloc(sizeof(Widget)); widget->view = view_alloc(); view_set_context(widget->view, widget); @@ -69,7 +69,7 @@ Widget* widget_alloc() { } void widget_reset(Widget* widget) { - furi_assert(widget); + furi_check(widget); with_view_model( widget->view, @@ -89,7 +89,7 @@ void widget_reset(Widget* widget) { } void widget_free(Widget* widget) { - furi_assert(widget); + furi_check(widget); // Free all elements widget_reset(widget); // Free elements container @@ -101,7 +101,7 @@ void widget_free(Widget* widget) { } View* widget_get_view(Widget* widget) { - furi_assert(widget); + furi_check(widget); return widget->view; } @@ -127,7 +127,7 @@ void widget_add_string_multiline_element( Align vertical, Font font, const char* text) { - furi_assert(widget); + furi_check(widget); WidgetElement* string_multiline_element = widget_element_string_multiline_create(x, y, horizontal, vertical, font, text); widget_add_element(widget, string_multiline_element); @@ -141,7 +141,7 @@ void widget_add_string_element( Align vertical, Font font, const char* text) { - furi_assert(widget); + furi_check(widget); WidgetElement* string_element = widget_element_string_create(x, y, horizontal, vertical, font, text); widget_add_element(widget, string_element); @@ -157,7 +157,7 @@ void widget_add_text_box_element( Align vertical, const char* text, bool strip_to_dots) { - furi_assert(widget); + furi_check(widget); WidgetElement* text_box_element = widget_element_text_box_create( x, y, width, height, horizontal, vertical, text, strip_to_dots); widget_add_element(widget, text_box_element); @@ -170,7 +170,7 @@ void widget_add_text_scroll_element( uint8_t width, uint8_t height, const char* text) { - furi_assert(widget); + furi_check(widget); WidgetElement* text_scroll_element = widget_element_text_scroll_create(x, y, width, height, text); widget_add_element(widget, text_scroll_element); @@ -182,15 +182,15 @@ void widget_add_button_element( const char* text, ButtonCallback callback, void* context) { - furi_assert(widget); + furi_check(widget); WidgetElement* button_element = widget_element_button_create(button_type, text, callback, context); widget_add_element(widget, button_element); } void widget_add_icon_element(Widget* widget, uint8_t x, uint8_t y, const Icon* icon) { - furi_assert(widget); - furi_assert(icon); + furi_check(widget); + furi_check(icon); WidgetElement* icon_element = widget_element_icon_create(x, y, icon); widget_add_element(widget, icon_element); } @@ -202,7 +202,7 @@ void widget_add_frame_element( uint8_t width, uint8_t height, uint8_t radius) { - furi_assert(widget); + furi_check(widget); WidgetElement* frame_element = widget_element_frame_create(x, y, width, height, radius); widget_add_element(widget, frame_element); } diff --git a/applications/services/gui/modules/widget.h b/applications/services/gui/modules/widget.h index f86b14cc9..21a939c13 100644 --- a/applications/services/gui/modules/widget.h +++ b/applications/services/gui/modules/widget.h @@ -18,7 +18,7 @@ typedef struct WidgetElement WidgetElement; * * @return Widget instance */ -Widget* widget_alloc(); +Widget* widget_alloc(void); /** Free Widget * @note this function free allocated Widget Elements diff --git a/applications/services/gui/scene_manager.c b/applications/services/gui/scene_manager.c index 4122b3bc3..3cdcbf071 100644 --- a/applications/services/gui/scene_manager.c +++ b/applications/services/gui/scene_manager.c @@ -2,7 +2,7 @@ #include SceneManager* scene_manager_alloc(const SceneManagerHandlers* app_scene_handlers, void* context) { - furi_assert(context); + furi_check(context); SceneManager* scene_manager = malloc(sizeof(SceneManager)); // Set SceneManager context and scene handlers @@ -17,7 +17,7 @@ SceneManager* scene_manager_alloc(const SceneManagerHandlers* app_scene_handlers } void scene_manager_free(SceneManager* scene_manager) { - furi_assert(scene_manager); + furi_check(scene_manager); // Clear SceneManager array SceneManagerIdStack_clear(scene_manager->scene_id_stack); @@ -28,21 +28,21 @@ void scene_manager_free(SceneManager* scene_manager) { } void scene_manager_set_scene_state(SceneManager* scene_manager, uint32_t scene_id, uint32_t state) { - furi_assert(scene_manager); - furi_assert(scene_id < scene_manager->scene_handlers->scene_num); + furi_check(scene_manager); + furi_check(scene_id < scene_manager->scene_handlers->scene_num); scene_manager->scene[scene_id].state = state; } uint32_t scene_manager_get_scene_state(const SceneManager* scene_manager, uint32_t scene_id) { - furi_assert(scene_manager); - furi_assert(scene_id < scene_manager->scene_handlers->scene_num); + furi_check(scene_manager); + furi_check(scene_id < scene_manager->scene_handlers->scene_num); return scene_manager->scene[scene_id].state; } bool scene_manager_handle_custom_event(SceneManager* scene_manager, uint32_t custom_event) { - furi_assert(scene_manager); + furi_check(scene_manager); SceneManagerEvent event = { .type = SceneManagerEventTypeCustom, @@ -61,7 +61,7 @@ bool scene_manager_handle_custom_event(SceneManager* scene_manager, uint32_t cus } bool scene_manager_handle_back_event(SceneManager* scene_manager) { - furi_assert(scene_manager); + furi_check(scene_manager); SceneManagerEvent event = { .type = SceneManagerEventTypeBack, @@ -82,7 +82,7 @@ bool scene_manager_handle_back_event(SceneManager* scene_manager) { } void scene_manager_handle_tick_event(SceneManager* scene_manager) { - furi_assert(scene_manager); + furi_check(scene_manager); SceneManagerEvent event = { .type = SceneManagerEventTypeTick, @@ -96,8 +96,8 @@ void scene_manager_handle_tick_event(SceneManager* scene_manager) { } void scene_manager_next_scene(SceneManager* scene_manager, uint32_t next_scene_id) { - furi_assert(scene_manager); - furi_assert(next_scene_id < scene_manager->scene_handlers->scene_num); + furi_check(scene_manager); + furi_check(next_scene_id < scene_manager->scene_handlers->scene_num); // Check if it is not the first scene if(SceneManagerIdStack_size(scene_manager->scene_id_stack) > 0) { @@ -110,7 +110,7 @@ void scene_manager_next_scene(SceneManager* scene_manager, uint32_t next_scene_i } bool scene_manager_previous_scene(SceneManager* scene_manager) { - furi_assert(scene_manager); + furi_check(scene_manager); if(SceneManagerIdStack_size(scene_manager->scene_id_stack) > 0) { uint32_t cur_scene_id = 0; @@ -133,7 +133,7 @@ bool scene_manager_previous_scene(SceneManager* scene_manager) { bool scene_manager_search_and_switch_to_previous_scene( SceneManager* scene_manager, uint32_t scene_id) { - furi_assert(scene_manager); + furi_check(scene_manager); if(SceneManagerIdStack_size(scene_manager->scene_id_stack) > 0) { uint32_t prev_scene_id = 0; @@ -169,8 +169,8 @@ bool scene_manager_search_and_switch_to_previous_scene_one_of( SceneManager* scene_manager, const uint32_t* scene_ids, size_t scene_ids_size) { - furi_assert(scene_manager); - furi_assert(scene_ids); + furi_check(scene_manager); + furi_check(scene_ids); bool scene_found = false; for(size_t i = 0; i < scene_ids_size; ++i) { @@ -185,7 +185,7 @@ bool scene_manager_search_and_switch_to_previous_scene_one_of( } bool scene_manager_has_previous_scene(const SceneManager* scene_manager, uint32_t scene_id) { - furi_assert(scene_manager); + furi_check(scene_manager); bool scene_found = false; if(SceneManagerIdStack_size(scene_manager->scene_id_stack) > 0) { @@ -211,8 +211,8 @@ bool scene_manager_has_previous_scene(const SceneManager* scene_manager, uint32_ bool scene_manager_search_and_switch_to_another_scene( SceneManager* scene_manager, uint32_t scene_id) { - furi_assert(scene_manager); - furi_assert(scene_id < scene_manager->scene_handlers->scene_num); + furi_check(scene_manager); + furi_check(scene_id < scene_manager->scene_handlers->scene_num); if(SceneManagerIdStack_size(scene_manager->scene_id_stack) > 0) { uint32_t cur_scene_id = *SceneManagerIdStack_back(scene_manager->scene_id_stack); @@ -234,7 +234,7 @@ bool scene_manager_search_and_switch_to_another_scene( } void scene_manager_stop(SceneManager* scene_manager) { - furi_assert(scene_manager); + furi_check(scene_manager); if(SceneManagerIdStack_size(scene_manager->scene_id_stack) > 0) { uint32_t cur_scene_id = *SceneManagerIdStack_back(scene_manager->scene_id_stack); diff --git a/applications/services/gui/view.c b/applications/services/gui/view.c index 316f5c612..8fc5c2699 100644 --- a/applications/services/gui/view.c +++ b/applications/services/gui/view.c @@ -1,77 +1,77 @@ #include "view_i.h" -View* view_alloc() { +View* view_alloc(void) { View* view = malloc(sizeof(View)); view->orientation = ViewOrientationHorizontal; return view; } void view_free(View* view) { - furi_assert(view); + furi_check(view); view_free_model(view); free(view); } void view_tie_icon_animation(View* view, IconAnimation* icon_animation) { - furi_assert(view); + furi_check(view); icon_animation_set_update_callback(icon_animation, view_icon_animation_callback, view); } void view_set_draw_callback(View* view, ViewDrawCallback callback) { - furi_assert(view); + furi_check(view); view->draw_callback = callback; } void view_set_input_callback(View* view, ViewInputCallback callback) { - furi_assert(view); + furi_check(view); view->input_callback = callback; } void view_set_custom_callback(View* view, ViewCustomCallback callback) { - furi_assert(view); + furi_check(view); view->custom_callback = callback; } void view_set_previous_callback(View* view, ViewNavigationCallback callback) { - furi_assert(view); + furi_check(view); view->previous_callback = callback; } void view_set_enter_callback(View* view, ViewCallback callback) { - furi_assert(view); + furi_check(view); view->enter_callback = callback; } void view_set_exit_callback(View* view, ViewCallback callback) { - furi_assert(view); + furi_check(view); view->exit_callback = callback; } void view_set_update_callback(View* view, ViewUpdateCallback callback) { - furi_assert(view); + furi_check(view); view->update_callback = callback; } void view_set_update_callback_context(View* view, void* context) { - furi_assert(view); + furi_check(view); view->update_callback_context = context; } void view_set_context(View* view, void* context) { - furi_assert(view); + furi_check(view); view->context = context; } void view_set_orientation(View* view, ViewOrientation orientation) { - furi_assert(view); + furi_check(view); view->orientation = orientation; } void view_allocate_model(View* view, ViewModelType type, size_t size) { - furi_assert(view); - furi_assert(size > 0); - furi_assert(view->model_type == ViewModelTypeNone); - furi_assert(view->model == NULL); + furi_check(view); + furi_check(size > 0); + furi_check(view->model_type == ViewModelTypeNone); + furi_check(view->model == NULL); view->model_type = type; if(view->model_type == ViewModelTypeLockFree) { view->model = malloc(size); @@ -87,7 +87,7 @@ void view_allocate_model(View* view, ViewModelType type, size_t size) { } void view_free_model(View* view) { - furi_assert(view); + furi_check(view); if(view->model_type == ViewModelTypeNone) { return; } else if(view->model_type == ViewModelTypeLockFree) { @@ -104,7 +104,7 @@ void view_free_model(View* view) { } void* view_get_model(View* view) { - furi_assert(view); + furi_check(view); if(view->model_type == ViewModelTypeLocking) { ViewModelLocking* model = (ViewModelLocking*)(view->model); furi_check(furi_mutex_acquire(model->mutex, FuriWaitForever) == FuriStatusOk); @@ -114,7 +114,7 @@ void* view_get_model(View* view) { } void view_commit_model(View* view, bool update) { - furi_assert(view); + furi_check(view); view_unlock_model(view); if(update && view->update_callback) { view->update_callback(view, view->update_callback_context); @@ -123,7 +123,7 @@ void view_commit_model(View* view, bool update) { void view_icon_animation_callback(IconAnimation* instance, void* context) { UNUSED(instance); - furi_assert(context); + furi_check(context); View* view = context; if(view->update_callback) { view->update_callback(view, view->update_callback_context); @@ -131,7 +131,7 @@ void view_icon_animation_callback(IconAnimation* instance, void* context) { } void view_unlock_model(View* view) { - furi_assert(view); + furi_check(view); if(view->model_type == ViewModelTypeLocking) { ViewModelLocking* model = (ViewModelLocking*)(view->model); furi_check(furi_mutex_release(model->mutex) == FuriStatusOk); @@ -139,7 +139,7 @@ void view_unlock_model(View* view) { } void view_draw(View* view, Canvas* canvas) { - furi_assert(view); + furi_check(view); if(view->draw_callback) { void* data = view_get_model(view); view->draw_callback(canvas, data); @@ -148,7 +148,7 @@ void view_draw(View* view, Canvas* canvas) { } bool view_input(View* view, InputEvent* event) { - furi_assert(view); + furi_check(view); if(view->input_callback) { return view->input_callback(event, view->context); } else { @@ -157,7 +157,7 @@ bool view_input(View* view, InputEvent* event) { } bool view_custom(View* view, uint32_t event) { - furi_assert(view); + furi_check(view); if(view->custom_callback) { return view->custom_callback(event, view->context); } else { @@ -166,7 +166,7 @@ bool view_custom(View* view, uint32_t event) { } uint32_t view_previous(View* view) { - furi_assert(view); + furi_check(view); if(view->previous_callback) { return view->previous_callback(view->context); } else { @@ -175,11 +175,11 @@ uint32_t view_previous(View* view) { } void view_enter(View* view) { - furi_assert(view); + furi_check(view); if(view->enter_callback) view->enter_callback(view->context); } void view_exit(View* view) { - furi_assert(view); + furi_check(view); if(view->exit_callback) view->exit_callback(view->context); } diff --git a/applications/services/gui/view.h b/applications/services/gui/view.h index eafe445fa..1cae4cd6c 100644 --- a/applications/services/gui/view.h +++ b/applications/services/gui/view.h @@ -93,7 +93,7 @@ typedef enum { /** Allocate and init View * @return View instance */ -View* view_alloc(); +View* view_alloc(void); /** Free View * diff --git a/applications/services/gui/view_dispatcher.c b/applications/services/gui/view_dispatcher.c index 87b07a87c..222ba817f 100644 --- a/applications/services/gui/view_dispatcher.c +++ b/applications/services/gui/view_dispatcher.c @@ -2,7 +2,7 @@ #define TAG "ViewDispatcher" -ViewDispatcher* view_dispatcher_alloc() { +ViewDispatcher* view_dispatcher_alloc(void) { ViewDispatcher* view_dispatcher = malloc(sizeof(ViewDispatcher)); view_dispatcher->view_port = view_port_alloc(); @@ -23,7 +23,7 @@ void view_dispatcher_free(ViewDispatcher* view_dispatcher) { gui_remove_view_port(view_dispatcher->gui, view_dispatcher->view_port); } // Crash if not all views were freed - furi_assert(!ViewDict_size(view_dispatcher->views)); + furi_check(!ViewDict_size(view_dispatcher->views)); ViewDict_clear(view_dispatcher->views); // Free ViewPort @@ -37,29 +37,29 @@ void view_dispatcher_free(ViewDispatcher* view_dispatcher) { } void view_dispatcher_enable_queue(ViewDispatcher* view_dispatcher) { - furi_assert(view_dispatcher); - furi_assert(view_dispatcher->queue == NULL); + furi_check(view_dispatcher); + furi_check(view_dispatcher->queue == NULL); view_dispatcher->queue = furi_message_queue_alloc(16, sizeof(ViewDispatcherMessage)); } void view_dispatcher_set_event_callback_context(ViewDispatcher* view_dispatcher, void* context) { - furi_assert(view_dispatcher); + furi_check(view_dispatcher); view_dispatcher->event_context = context; } void view_dispatcher_set_navigation_event_callback( ViewDispatcher* view_dispatcher, ViewDispatcherNavigationEventCallback callback) { - furi_assert(view_dispatcher); - furi_assert(callback); + furi_check(view_dispatcher); + furi_check(callback); view_dispatcher->navigation_event_callback = callback; } void view_dispatcher_set_custom_event_callback( ViewDispatcher* view_dispatcher, ViewDispatcherCustomEventCallback callback) { - furi_assert(view_dispatcher); - furi_assert(callback); + furi_check(view_dispatcher); + furi_check(callback); view_dispatcher->custom_event_callback = callback; } @@ -67,15 +67,15 @@ void view_dispatcher_set_tick_event_callback( ViewDispatcher* view_dispatcher, ViewDispatcherTickEventCallback callback, uint32_t tick_period) { - furi_assert(view_dispatcher); - furi_assert(callback); + furi_check(view_dispatcher); + furi_check(callback); view_dispatcher->tick_event_callback = callback; view_dispatcher->tick_period = tick_period; } void view_dispatcher_run(ViewDispatcher* view_dispatcher) { - furi_assert(view_dispatcher); - furi_assert(view_dispatcher->queue); + furi_check(view_dispatcher); + furi_check(view_dispatcher->queue); uint32_t tick_period = view_dispatcher->tick_period == 0 ? FuriWaitForever : view_dispatcher->tick_period; @@ -109,8 +109,8 @@ void view_dispatcher_run(ViewDispatcher* view_dispatcher) { } void view_dispatcher_stop(ViewDispatcher* view_dispatcher) { - furi_assert(view_dispatcher); - furi_assert(view_dispatcher->queue); + furi_check(view_dispatcher); + furi_check(view_dispatcher->queue); ViewDispatcherMessage message; message.type = ViewDispatcherMessageTypeStop; furi_check( @@ -118,8 +118,8 @@ void view_dispatcher_stop(ViewDispatcher* view_dispatcher) { } void view_dispatcher_add_view(ViewDispatcher* view_dispatcher, uint32_t view_id, View* view) { - furi_assert(view_dispatcher); - furi_assert(view); + furi_check(view_dispatcher); + furi_check(view); // Check if view id is not used and register view furi_check(ViewDict_get(view_dispatcher->views, view_id) == NULL); @@ -139,7 +139,7 @@ void view_dispatcher_add_view(ViewDispatcher* view_dispatcher, uint32_t view_id, } void view_dispatcher_remove_view(ViewDispatcher* view_dispatcher, uint32_t view_id) { - furi_assert(view_dispatcher); + furi_check(view_dispatcher); // Lock gui if(view_dispatcher->gui) { @@ -169,7 +169,7 @@ void view_dispatcher_remove_view(ViewDispatcher* view_dispatcher, uint32_t view_ } void view_dispatcher_switch_to_view(ViewDispatcher* view_dispatcher, uint32_t view_id) { - furi_assert(view_dispatcher); + furi_check(view_dispatcher); if(view_id == VIEW_NONE) { view_dispatcher_set_current_view(view_dispatcher, NULL); } else if(view_id == VIEW_IGNORE) { @@ -181,14 +181,14 @@ void view_dispatcher_switch_to_view(ViewDispatcher* view_dispatcher, uint32_t vi } void view_dispatcher_send_to_front(ViewDispatcher* view_dispatcher) { - furi_assert(view_dispatcher); - furi_assert(view_dispatcher->gui); + furi_check(view_dispatcher); + furi_check(view_dispatcher->gui); gui_view_port_send_to_front(view_dispatcher->gui, view_dispatcher->view_port); } void view_dispatcher_send_to_back(ViewDispatcher* view_dispatcher) { - furi_assert(view_dispatcher); - furi_assert(view_dispatcher->gui); + furi_check(view_dispatcher); + furi_check(view_dispatcher->gui); gui_view_port_send_to_back(view_dispatcher->gui, view_dispatcher->view_port); } @@ -196,9 +196,9 @@ void view_dispatcher_attach_to_gui( ViewDispatcher* view_dispatcher, Gui* gui, ViewDispatcherType type) { - furi_assert(view_dispatcher); - furi_assert(view_dispatcher->gui == NULL); - furi_assert(gui); + furi_check(view_dispatcher); + furi_check(view_dispatcher->gui == NULL); + furi_check(gui); if(type == ViewDispatcherTypeDesktop) { gui_add_view_port(gui, view_dispatcher->view_port, GuiLayerDesktop); @@ -308,8 +308,8 @@ void view_dispatcher_handle_custom_event(ViewDispatcher* view_dispatcher, uint32 } void view_dispatcher_send_custom_event(ViewDispatcher* view_dispatcher, uint32_t event) { - furi_assert(view_dispatcher); - furi_assert(view_dispatcher->queue); + furi_check(view_dispatcher); + furi_check(view_dispatcher->queue); ViewDispatcherMessage message; message.type = ViewDispatcherMessageTypeCustomEvent; @@ -327,7 +327,7 @@ static const ViewPortOrientation view_dispatcher_view_port_orientation_table[] = }; void view_dispatcher_set_current_view(ViewDispatcher* view_dispatcher, View* view) { - furi_assert(view_dispatcher); + furi_check(view_dispatcher); // Dispatch view exit event if(view_dispatcher->current_view) { view_exit(view_dispatcher->current_view); @@ -355,8 +355,8 @@ void view_dispatcher_set_current_view(ViewDispatcher* view_dispatcher, View* vie } void view_dispatcher_update(View* view, void* context) { - furi_assert(view); - furi_assert(context); + furi_check(view); + furi_check(context); ViewDispatcher* view_dispatcher = context; diff --git a/applications/services/gui/view_dispatcher.h b/applications/services/gui/view_dispatcher.h index bec15f6e3..f8567ea1a 100644 --- a/applications/services/gui/view_dispatcher.h +++ b/applications/services/gui/view_dispatcher.h @@ -37,7 +37,7 @@ typedef void (*ViewDispatcherTickEventCallback)(void* context); * * @return pointer to ViewDispatcher instance */ -ViewDispatcher* view_dispatcher_alloc(); +ViewDispatcher* view_dispatcher_alloc(void); /** Free ViewDispatcher instance * diff --git a/applications/services/gui/view_holder.c b/applications/services/gui/view_holder.c index 7ab0a8e1a..d9b382c17 100644 --- a/applications/services/gui/view_holder.c +++ b/applications/services/gui/view_holder.c @@ -20,7 +20,7 @@ struct ViewHolder { static void view_holder_draw_callback(Canvas* canvas, void* context); static void view_holder_input_callback(InputEvent* event, void* context); -ViewHolder* view_holder_alloc() { +ViewHolder* view_holder_alloc(void) { ViewHolder* view_holder = malloc(sizeof(ViewHolder)); view_holder->view_port = view_port_alloc(); diff --git a/applications/services/gui/view_holder.h b/applications/services/gui/view_holder.h index 0bd29652c..bc313a926 100644 --- a/applications/services/gui/view_holder.h +++ b/applications/services/gui/view_holder.h @@ -30,7 +30,7 @@ typedef void (*BackCallback)(void* back_context); * @brief Allocate ViewHolder * @return pointer to ViewHolder instance */ -ViewHolder* view_holder_alloc(); +ViewHolder* view_holder_alloc(void); /** * @brief Free ViewHolder and call Free callback diff --git a/applications/services/gui/view_port.c b/applications/services/gui/view_port.c index 25f670a7c..7f1da3b70 100644 --- a/applications/services/gui/view_port.c +++ b/applications/services/gui/view_port.c @@ -61,7 +61,7 @@ static const CanvasOrientation view_port_orientation_mapping[ViewPortOrientation // Remaps directional pad buttons on Flipper based on ViewPort orientation static void view_port_map_input(InputEvent* event, ViewPortOrientation orientation) { - furi_assert(orientation < ViewPortOrientationMAX && event->key < InputKeyMAX); + furi_check(orientation < ViewPortOrientationMAX && event->key < InputKeyMAX); if(event->sequence_source != INPUT_SEQUENCE_SOURCE_HARDWARE) { return; @@ -90,7 +90,7 @@ static void view_port_setup_canvas_orientation(const ViewPort* view_port, Canvas canvas_set_orientation(canvas, orientation); } -ViewPort* view_port_alloc() { +ViewPort* view_port_alloc(void) { ViewPort* view_port = malloc(sizeof(ViewPort)); view_port->orientation = ViewPortOrientationHorizontal; view_port->is_enabled = true; @@ -99,7 +99,7 @@ ViewPort* view_port_alloc() { } void view_port_free(ViewPort* view_port) { - furi_assert(view_port); + furi_check(view_port); furi_check(furi_mutex_acquire(view_port->mutex, FuriWaitForever) == FuriStatusOk); furi_check(view_port->gui == NULL); furi_check(furi_mutex_release(view_port->mutex) == FuriStatusOk); @@ -108,14 +108,14 @@ void view_port_free(ViewPort* view_port) { } void view_port_set_width(ViewPort* view_port, uint8_t width) { - furi_assert(view_port); + furi_check(view_port); furi_check(furi_mutex_acquire(view_port->mutex, FuriWaitForever) == FuriStatusOk); view_port->width = width; furi_check(furi_mutex_release(view_port->mutex) == FuriStatusOk); } uint8_t view_port_get_width(const ViewPort* view_port) { - furi_assert(view_port); + furi_check(view_port); furi_check(furi_mutex_acquire(view_port->mutex, FuriWaitForever) == FuriStatusOk); uint8_t width = view_port->width; furi_check(furi_mutex_release(view_port->mutex) == FuriStatusOk); @@ -123,14 +123,14 @@ uint8_t view_port_get_width(const ViewPort* view_port) { } void view_port_set_height(ViewPort* view_port, uint8_t height) { - furi_assert(view_port); + furi_check(view_port); furi_check(furi_mutex_acquire(view_port->mutex, FuriWaitForever) == FuriStatusOk); view_port->height = height; furi_check(furi_mutex_release(view_port->mutex) == FuriStatusOk); } uint8_t view_port_get_height(const ViewPort* view_port) { - furi_assert(view_port); + furi_check(view_port); furi_check(furi_mutex_acquire(view_port->mutex, FuriWaitForever) == FuriStatusOk); uint8_t height = view_port->height; furi_check(furi_mutex_release(view_port->mutex) == FuriStatusOk); @@ -138,7 +138,7 @@ uint8_t view_port_get_height(const ViewPort* view_port) { } void view_port_enabled_set(ViewPort* view_port, bool enabled) { - furi_assert(view_port); + furi_check(view_port); furi_check(furi_mutex_acquire(view_port->mutex, FuriWaitForever) == FuriStatusOk); if(view_port->is_enabled != enabled) { view_port->is_enabled = enabled; @@ -148,7 +148,7 @@ void view_port_enabled_set(ViewPort* view_port, bool enabled) { } bool view_port_is_enabled(const ViewPort* view_port) { - furi_assert(view_port); + furi_check(view_port); furi_check(furi_mutex_acquire(view_port->mutex, FuriWaitForever) == FuriStatusOk); bool is_enabled = view_port->is_enabled; furi_check(furi_mutex_release(view_port->mutex) == FuriStatusOk); @@ -156,7 +156,7 @@ bool view_port_is_enabled(const ViewPort* view_port) { } void view_port_draw_callback_set(ViewPort* view_port, ViewPortDrawCallback callback, void* context) { - furi_assert(view_port); + furi_check(view_port); furi_check(furi_mutex_acquire(view_port->mutex, FuriWaitForever) == FuriStatusOk); view_port->draw_callback = callback; view_port->draw_callback_context = context; @@ -167,7 +167,7 @@ void view_port_input_callback_set( ViewPort* view_port, ViewPortInputCallback callback, void* context) { - furi_assert(view_port); + furi_check(view_port); furi_check(furi_mutex_acquire(view_port->mutex, FuriWaitForever) == FuriStatusOk); view_port->input_callback = callback; view_port->input_callback_context = context; @@ -175,7 +175,7 @@ void view_port_input_callback_set( } void view_port_update(ViewPort* view_port) { - furi_assert(view_port); + furi_check(view_port); // We are not going to lockup system, but will notify you instead // Make sure that you don't call viewport methods inside of another mutex, especially one that is used in draw call @@ -188,15 +188,15 @@ void view_port_update(ViewPort* view_port) { } void view_port_gui_set(ViewPort* view_port, Gui* gui) { - furi_assert(view_port); + furi_check(view_port); furi_check(furi_mutex_acquire(view_port->mutex, FuriWaitForever) == FuriStatusOk); view_port->gui = gui; furi_check(furi_mutex_release(view_port->mutex) == FuriStatusOk); } void view_port_draw(ViewPort* view_port, Canvas* canvas) { - furi_assert(view_port); - furi_assert(canvas); + furi_check(view_port); + furi_check(canvas); // We are not going to lockup system, but will notify you instead // Make sure that you don't call viewport methods inside of another mutex, especially one that is used in draw call @@ -215,8 +215,8 @@ void view_port_draw(ViewPort* view_port, Canvas* canvas) { } void view_port_input(ViewPort* view_port, InputEvent* event) { - furi_assert(view_port); - furi_assert(event); + furi_check(view_port); + furi_check(event); furi_check(furi_mutex_acquire(view_port->mutex, FuriWaitForever) == FuriStatusOk); furi_check(view_port->gui); @@ -229,7 +229,7 @@ void view_port_input(ViewPort* view_port, InputEvent* event) { } void view_port_set_orientation(ViewPort* view_port, ViewPortOrientation orientation) { - furi_assert(view_port); + furi_check(view_port); furi_check(furi_mutex_acquire(view_port->mutex, FuriWaitForever) == FuriStatusOk); view_port->orientation = orientation; furi_check(furi_mutex_release(view_port->mutex) == FuriStatusOk); diff --git a/applications/services/gui/view_port.h b/applications/services/gui/view_port.h index 752fc46ba..bdc8b2633 100644 --- a/applications/services/gui/view_port.h +++ b/applications/services/gui/view_port.h @@ -38,7 +38,7 @@ typedef void (*ViewPortInputCallback)(InputEvent* event, void* context); * * @return ViewPort instance */ -ViewPort* view_port_alloc(); +ViewPort* view_port_alloc(void); /** ViewPort deallocator * diff --git a/applications/services/input/input_cli.c b/applications/services/input/input_cli.c index f7e904b17..8aa04d6bd 100644 --- a/applications/services/input/input_cli.c +++ b/applications/services/input/input_cli.c @@ -4,7 +4,7 @@ #include #include -static void input_cli_usage() { +static void input_cli_usage(void) { printf("Usage:\r\n"); printf("input \r\n"); printf("Cmd list:\r\n"); @@ -40,7 +40,7 @@ static void input_cli_dump(Cli* cli, FuriString* args, Input* input) { furi_message_queue_free(input_queue); } -static void input_cli_send_print_usage() { +static void input_cli_send_print_usage(void) { printf("Invalid arguments. Usage:\r\n"); printf("\tinput send \r\n"); printf("\t\t \t - one of 'up', 'down', 'left', 'right', 'back', 'ok'\r\n"); diff --git a/applications/services/loader/loader.c b/applications/services/loader/loader.c index 11261a86c..c701041c3 100644 --- a/applications/services/loader/loader.c +++ b/applications/services/loader/loader.c @@ -29,6 +29,9 @@ static const char* loader_find_external_application_by_name(const char* app_name LoaderStatus loader_start(Loader* loader, const char* name, const char* args, FuriString* error_message) { + furi_check(loader); + furi_check(name); + LoaderMessage message; LoaderMessageLoaderStatusResult result; @@ -40,10 +43,14 @@ LoaderStatus message.status_value = &result; furi_message_queue_put(loader->queue, &message, FuriWaitForever); api_lock_wait_unlock_and_free(message.api_lock); + return result.value; } LoaderStatus loader_start_with_gui_error(Loader* loader, const char* name, const char* args) { + furi_check(loader); + furi_check(name); + FuriString* error_message = furi_string_alloc(); LoaderStatus status = loader_start(loader, name, args, error_message); @@ -85,6 +92,8 @@ LoaderStatus loader_start_with_gui_error(Loader* loader, const char* name, const } bool loader_lock(Loader* loader) { + furi_check(loader); + LoaderMessage message; LoaderMessageBoolResult result; message.type = LoaderMessageTypeLock; @@ -92,16 +101,22 @@ bool loader_lock(Loader* loader) { message.bool_value = &result; furi_message_queue_put(loader->queue, &message, FuriWaitForever); api_lock_wait_unlock_and_free(message.api_lock); + return result.value; } void loader_unlock(Loader* loader) { + furi_check(loader); + LoaderMessage message; message.type = LoaderMessageTypeUnlock; + furi_message_queue_put(loader->queue, &message, FuriWaitForever); } bool loader_is_locked(Loader* loader) { + furi_check(loader); + LoaderMessage message; LoaderMessageBoolResult result; message.type = LoaderMessageTypeIsLocked; @@ -109,17 +124,21 @@ bool loader_is_locked(Loader* loader) { message.bool_value = &result; furi_message_queue_put(loader->queue, &message, FuriWaitForever); api_lock_wait_unlock_and_free(message.api_lock); + return result.value; } void loader_show_menu(Loader* loader) { + furi_check(loader); + LoaderMessage message; message.type = LoaderMessageTypeShowMenu; + furi_message_queue_put(loader->queue, &message, FuriWaitForever); } FuriPubSub* loader_get_pubsub(Loader* loader) { - furi_assert(loader); + furi_check(loader); // it's safe to return pubsub without locking // because it's never freed and loader is never exited // also the loader instance cannot be obtained until the pubsub is created @@ -160,7 +179,7 @@ static void loader_thread_state_callback(FuriThreadState thread_state, void* con // implementation -static Loader* loader_alloc() { +static Loader* loader_alloc(void) { Loader* loader = malloc(sizeof(Loader)); loader->pubsub = furi_pubsub_alloc(); loader->queue = furi_message_queue_alloc(1, sizeof(LoaderMessage)); diff --git a/applications/services/loader/loader_applications.c b/applications/services/loader/loader_applications.c index 235cf20ec..d52aec097 100644 --- a/applications/services/loader/loader_applications.c +++ b/applications/services/loader/loader_applications.c @@ -49,7 +49,7 @@ typedef struct { Loading* loading; } LoaderApplicationsApp; -static LoaderApplicationsApp* loader_applications_app_alloc() { +static LoaderApplicationsApp* loader_applications_app_alloc(void) { LoaderApplicationsApp* app = malloc(sizeof(LoaderApplicationsApp)); //-V799 app->file_path = furi_string_alloc_set(EXT_PATH("apps")); app->dialogs = furi_record_open(RECORD_DIALOGS); diff --git a/applications/services/loader/loader_cli.c b/applications/services/loader/loader_cli.c index 489a576e5..1fbd0035e 100644 --- a/applications/services/loader/loader_cli.c +++ b/applications/services/loader/loader_cli.c @@ -4,7 +4,7 @@ #include #include "loader.h" -static void loader_cli_print_usage() { +static void loader_cli_print_usage(void) { printf("Usage:\r\n"); printf("loader \r\n"); printf("Cmd list:\r\n"); @@ -13,7 +13,7 @@ static void loader_cli_print_usage() { printf("\tinfo\t - Show loader state\r\n"); } -static void loader_cli_list() { +static void loader_cli_list(void) { printf("Apps:\r\n"); for(size_t i = 0; i < FLIPPER_APPS_COUNT; i++) { printf("\t%s\r\n", FLIPPER_APPS[i].name); @@ -96,7 +96,7 @@ static void loader_cli(Cli* cli, FuriString* args, void* context) { furi_record_close(RECORD_LOADER); } -void loader_on_system_start() { +void loader_on_system_start(void) { #ifdef SRV_CLI Cli* cli = furi_record_open(RECORD_CLI); cli_add_command(cli, RECORD_LOADER, CliCommandFlagParallelSafe, loader_cli, NULL); diff --git a/applications/services/locale/locale.c b/applications/services/locale/locale.c index 4f7eb90ec..f4ee9c634 100644 --- a/applications/services/locale/locale.c +++ b/applications/services/locale/locale.c @@ -39,8 +39,8 @@ void locale_format_time( const DateTime* datetime, const LocaleTimeFormat format, const bool show_seconds) { - furi_assert(out_str); - furi_assert(datetime); + furi_check(out_str); + furi_check(datetime); uint8_t hours = datetime->hour; uint8_t am_pm = 0; @@ -72,9 +72,9 @@ void locale_format_date( const DateTime* datetime, const LocaleDateFormat format, const char* separator) { - furi_assert(out_str); - furi_assert(datetime); - furi_assert(separator); + furi_check(out_str); + furi_check(datetime); + furi_check(separator); if(format == LocaleDateFormatDMY) { furi_string_printf( diff --git a/applications/services/locale/locale.h b/applications/services/locale/locale.h index c4f8e78e5..0046302df 100644 --- a/applications/services/locale/locale.h +++ b/applications/services/locale/locale.h @@ -28,7 +28,7 @@ typedef enum { * * @return The locale measurement units. */ -LocaleMeasurementUnits locale_get_measurement_unit(); +LocaleMeasurementUnits locale_get_measurement_unit(void); /** Set locale measurement units * @@ -56,7 +56,7 @@ float locale_celsius_to_fahrenheit(float temp_c); * * @return The locale time format. */ -LocaleTimeFormat locale_get_time_format(); +LocaleTimeFormat locale_get_time_format(void); /** Set Locale Time Format * diff --git a/applications/services/notification/notification_app.c b/applications/services/notification/notification_app.c index 9baa738b7..514a37f00 100644 --- a/applications/services/notification/notification_app.c +++ b/applications/services/notification/notification_app.c @@ -163,7 +163,7 @@ static void notification_vibro_on(bool force) { } } -static void notification_vibro_off() { +static void notification_vibro_off(void) { furi_hal_vibro_on(false); } @@ -175,7 +175,7 @@ static void notification_sound_on(float freq, float volume, bool force) { } } -static void notification_sound_off() { +static void notification_sound_off(void) { if(furi_hal_speaker_is_mine()) { furi_hal_speaker_stop(); furi_hal_speaker_release(); @@ -516,7 +516,7 @@ static void input_event_callback(const void* value, void* context) { } // App alloc -static NotificationApp* notification_app_alloc() { +static NotificationApp* notification_app_alloc(void) { NotificationApp* app = malloc(sizeof(NotificationApp)); app->queue = furi_message_queue_alloc(8, sizeof(NotificationAppMessage)); app->display_timer = furi_timer_alloc(notification_display_timer, FuriTimerTypeOnce, app); diff --git a/applications/services/notification/notification_app_api.c b/applications/services/notification/notification_app_api.c index 9bc06b013..9c9a2680e 100644 --- a/applications/services/notification/notification_app_api.c +++ b/applications/services/notification/notification_app_api.c @@ -5,18 +5,27 @@ #include "notification_app.h" void notification_message(NotificationApp* app, const NotificationSequence* sequence) { + furi_check(app); + furi_check(sequence); + NotificationAppMessage m = { .type = NotificationLayerMessage, .sequence = sequence, .back_event = NULL}; furi_check(furi_message_queue_put(app->queue, &m, FuriWaitForever) == FuriStatusOk); }; void notification_internal_message(NotificationApp* app, const NotificationSequence* sequence) { + furi_check(app); + furi_check(sequence); + NotificationAppMessage m = { .type = InternalLayerMessage, .sequence = sequence, .back_event = NULL}; furi_check(furi_message_queue_put(app->queue, &m, FuriWaitForever) == FuriStatusOk); }; void notification_message_block(NotificationApp* app, const NotificationSequence* sequence) { + furi_check(app); + furi_check(sequence); + NotificationAppMessage m = { .type = NotificationLayerMessage, .sequence = sequence, @@ -30,6 +39,9 @@ void notification_message_block(NotificationApp* app, const NotificationSequence void notification_internal_message_block( NotificationApp* app, const NotificationSequence* sequence) { + furi_check(app); + furi_check(sequence); + NotificationAppMessage m = { .type = InternalLayerMessage, .sequence = sequence, .back_event = furi_event_flag_alloc()}; furi_check(furi_message_queue_put(app->queue, &m, FuriWaitForever) == FuriStatusOk); diff --git a/applications/services/power/power_cli.c b/applications/services/power/power_cli.c index 021ce3553..6e1e34e67 100644 --- a/applications/services/power/power_cli.c +++ b/applications/services/power/power_cli.c @@ -48,7 +48,7 @@ void power_cli_3v3(Cli* cli, FuriString* args) { } } -static void power_cli_command_print_usage() { +static void power_cli_command_print_usage(void) { printf("Usage:\r\n"); printf("power \r\n"); printf("Cmd list:\r\n"); @@ -106,7 +106,7 @@ void power_cli(Cli* cli, FuriString* args, void* context) { furi_string_free(cmd); } -void power_on_system_start() { +void power_on_system_start(void) { #ifdef SRV_CLI Cli* cli = furi_record_open(RECORD_CLI); diff --git a/applications/services/power/power_cli.h b/applications/services/power/power_cli.h index 1517c6140..4056c8300 100644 --- a/applications/services/power/power_cli.h +++ b/applications/services/power/power_cli.h @@ -4,7 +4,7 @@ extern "C" { #endif -void power_on_system_start(); +void power_on_system_start(void); #ifdef __cplusplus } diff --git a/applications/services/power/power_service/power.c b/applications/services/power/power_service/power.c index 5ee60d949..29ce529be 100644 --- a/applications/services/power/power_service/power.c +++ b/applications/services/power/power_service/power.c @@ -232,7 +232,7 @@ static ViewPort* power_battery_view_port_alloc(Power* power) { return battery_view_port; } -Power* power_alloc() { +Power* power_alloc(void) { Power* power = malloc(sizeof(Power)); // Records diff --git a/applications/services/power/power_service/power_api.c b/applications/services/power/power_service/power_api.c index 8185b7cd5..1bb482bf5 100644 --- a/applications/services/power/power_service/power_api.c +++ b/applications/services/power/power_service/power_api.c @@ -5,6 +5,8 @@ #include void power_off(Power* power) { + furi_check(power); + furi_hal_power_off(); // Notify user if USB is plugged view_dispatcher_send_to_front(power->view_dispatcher); @@ -20,13 +22,16 @@ void power_reboot(PowerBootMode mode) { furi_hal_rtc_set_boot_mode(FuriHalRtcBootModeDfu); } else if(mode == PowerBootModeUpdateStart) { furi_hal_rtc_set_boot_mode(FuriHalRtcBootModePreUpdate); + } else { + furi_crash(); } + furi_hal_power_reset(); } void power_get_info(Power* power, PowerInfo* info) { - furi_assert(power); - furi_assert(info); + furi_check(power); + furi_check(info); furi_mutex_acquire(power->api_mtx, FuriWaitForever); memcpy(info, &power->info, sizeof(power->info)); @@ -34,12 +39,12 @@ void power_get_info(Power* power, PowerInfo* info) { } FuriPubSub* power_get_pubsub(Power* power) { - furi_assert(power); + furi_check(power); return power->event_pubsub; } bool power_is_battery_healthy(Power* power) { - furi_assert(power); + furi_check(power); bool is_healthy = false; furi_mutex_acquire(power->api_mtx, FuriWaitForever); is_healthy = power->info.health > POWER_BATTERY_HEALTHY_LEVEL; @@ -48,7 +53,7 @@ bool power_is_battery_healthy(Power* power) { } void power_enable_low_battery_level_notification(Power* power, bool enable) { - furi_assert(power); + furi_check(power); furi_mutex_acquire(power->api_mtx, FuriWaitForever); power->show_low_bat_level_message = enable; furi_mutex_release(power->api_mtx); diff --git a/applications/services/power/power_service/views/power_off.c b/applications/services/power/power_service/views/power_off.c index 3a1addbac..4da374b31 100644 --- a/applications/services/power/power_service/views/power_off.c +++ b/applications/services/power/power_service/views/power_off.c @@ -62,7 +62,7 @@ static bool power_off_input_callback(InputEvent* event, void* context) { return true; } -PowerOff* power_off_alloc() { +PowerOff* power_off_alloc(void) { PowerOff* power_off = malloc(sizeof(PowerOff)); power_off->view = view_alloc(); diff --git a/applications/services/power/power_service/views/power_off.h b/applications/services/power/power_service/views/power_off.h index 5137c2e99..df021fad8 100644 --- a/applications/services/power/power_service/views/power_off.h +++ b/applications/services/power/power_service/views/power_off.h @@ -11,7 +11,7 @@ typedef enum { #include -PowerOff* power_off_alloc(); +PowerOff* power_off_alloc(void); void power_off_free(PowerOff* power_off); diff --git a/applications/services/power/power_service/views/power_unplug_usb.c b/applications/services/power/power_service/views/power_unplug_usb.c index c2d61139e..da230d892 100644 --- a/applications/services/power/power_service/views/power_unplug_usb.c +++ b/applications/services/power/power_service/views/power_unplug_usb.c @@ -21,7 +21,7 @@ static void power_unplug_usb_draw_callback(Canvas* canvas, void* _model) { canvas, 64, 32, AlignCenter, AlignCenter, "It's now safe to unplug\nthe USB cable"); } -PowerUnplugUsb* power_unplug_usb_alloc() { +PowerUnplugUsb* power_unplug_usb_alloc(void) { PowerUnplugUsb* power_unplug_usb = malloc(sizeof(PowerUnplugUsb)); power_unplug_usb->view = view_alloc(); diff --git a/applications/services/power/power_service/views/power_unplug_usb.h b/applications/services/power/power_service/views/power_unplug_usb.h index e85c6d03b..a763cf87c 100644 --- a/applications/services/power/power_service/views/power_unplug_usb.h +++ b/applications/services/power/power_service/views/power_unplug_usb.h @@ -4,7 +4,7 @@ typedef struct PowerUnplugUsb PowerUnplugUsb; #include -PowerUnplugUsb* power_unplug_usb_alloc(); +PowerUnplugUsb* power_unplug_usb_alloc(void); void power_unplug_usb_free(PowerUnplugUsb* power_unplug_usb); diff --git a/applications/services/rpc/rpc.c b/applications/services/rpc/rpc.c index 052184d8a..d2f4d2c24 100644 --- a/applications/services/rpc/rpc.c +++ b/applications/services/rpc/rpc.c @@ -91,7 +91,7 @@ struct Rpc { }; RpcOwner rpc_session_get_owner(RpcSession* session) { - furi_assert(session); + furi_check(session); return session->owner; } @@ -112,7 +112,7 @@ static void rpc_close_session_process(const PB_Main* request, void* context) { } void rpc_session_set_context(RpcSession* session, void* context) { - furi_assert(session); + furi_check(session); furi_mutex_acquire(session->callbacks_mutex, FuriWaitForever); session->context = context; @@ -120,7 +120,7 @@ void rpc_session_set_context(RpcSession* session, void* context) { } void rpc_session_set_close_callback(RpcSession* session, RpcSessionClosedCallback callback) { - furi_assert(session); + furi_check(session); furi_mutex_acquire(session->callbacks_mutex, FuriWaitForever); session->closed_callback = callback; @@ -128,7 +128,7 @@ void rpc_session_set_close_callback(RpcSession* session, RpcSessionClosedCallbac } void rpc_session_set_send_bytes_callback(RpcSession* session, RpcSendBytesCallback callback) { - furi_assert(session); + furi_check(session); furi_mutex_acquire(session->callbacks_mutex, FuriWaitForever); session->send_bytes_callback = callback; @@ -138,7 +138,7 @@ void rpc_session_set_send_bytes_callback(RpcSession* session, RpcSendBytesCallba void rpc_session_set_buffer_is_empty_callback( RpcSession* session, RpcBufferIsEmptyCallback callback) { - furi_assert(session); + furi_check(session); furi_mutex_acquire(session->callbacks_mutex, FuriWaitForever); session->buffer_is_empty_callback = callback; @@ -148,7 +148,7 @@ void rpc_session_set_buffer_is_empty_callback( void rpc_session_set_terminated_callback( RpcSession* session, RpcSessionTerminatedCallback callback) { - furi_assert(session); + furi_check(session); furi_mutex_acquire(session->callbacks_mutex, FuriWaitForever); session->terminated_callback = callback; @@ -166,8 +166,8 @@ size_t rpc_session_feed( const uint8_t* encoded_bytes, size_t size, uint32_t timeout) { - furi_assert(session); - furi_assert(encoded_bytes); + furi_check(session); + furi_check(encoded_bytes); if(!size) return 0; @@ -179,7 +179,7 @@ size_t rpc_session_feed( } size_t rpc_session_get_available_size(RpcSession* session) { - furi_assert(session); + furi_check(session); return furi_stream_buffer_spaces_available(session->stream); } @@ -381,7 +381,7 @@ static void rpc_session_thread_state_callback(FuriThreadState thread_state, void } RpcSession* rpc_session_open(Rpc* rpc, RpcOwner owner) { - furi_assert(rpc); + furi_check(rpc); RpcSession* session = malloc(sizeof(RpcSession)); session->callbacks_mutex = furi_mutex_alloc(FuriMutexTypeNormal); @@ -419,8 +419,8 @@ RpcSession* rpc_session_open(Rpc* rpc, RpcOwner owner) { } void rpc_session_close(RpcSession* session) { - furi_assert(session); - furi_assert(session->rpc); + furi_check(session); + furi_check(session->rpc); rpc_session_set_send_bytes_callback(session, NULL); rpc_session_set_close_callback(session, NULL); diff --git a/applications/services/rpc/rpc_app.c b/applications/services/rpc/rpc_app.c index 9af652dae..aa2a3f64f 100644 --- a/applications/services/rpc/rpc_app.c +++ b/applications/services/rpc/rpc_app.c @@ -314,20 +314,20 @@ static void rpc_system_app_data_exchange_process(const PB_Main* request, void* c } void rpc_system_app_send_started(RpcAppSystem* rpc_app) { - furi_assert(rpc_app); + furi_check(rpc_app); rpc_system_app_send_state_response(rpc_app, PB_App_AppState_APP_STARTED, "SendStarted"); } void rpc_system_app_send_exited(RpcAppSystem* rpc_app) { - furi_assert(rpc_app); + furi_check(rpc_app); rpc_system_app_send_state_response(rpc_app, PB_App_AppState_APP_CLOSED, "SendExit"); } void rpc_system_app_confirm(RpcAppSystem* rpc_app, bool result) { - furi_assert(rpc_app); - furi_assert(rpc_app->last_command_id != 0); + furi_check(rpc_app); + furi_check(rpc_app->last_command_id != 0); /* Ensure that only commands of these types can be confirmed */ - furi_assert( + furi_check( rpc_app->last_event_type == RpcAppEventTypeAppExit || rpc_app->last_event_type == RpcAppEventTypeLoadFile || rpc_app->last_event_type == RpcAppEventTypeButtonPress || @@ -353,19 +353,19 @@ void rpc_system_app_confirm(RpcAppSystem* rpc_app, bool result) { } void rpc_system_app_set_callback(RpcAppSystem* rpc_app, RpcAppSystemCallback callback, void* ctx) { - furi_assert(rpc_app); + furi_check(rpc_app); rpc_app->callback = callback; rpc_app->callback_context = ctx; } void rpc_system_app_set_error_code(RpcAppSystem* rpc_app, uint32_t error_code) { - furi_assert(rpc_app); + furi_check(rpc_app); rpc_app->error_code = error_code; } void rpc_system_app_set_error_text(RpcAppSystem* rpc_app, const char* error_text) { - furi_assert(rpc_app); + furi_check(rpc_app); if(rpc_app->error_text) { free(rpc_app->error_text); @@ -375,14 +375,14 @@ void rpc_system_app_set_error_text(RpcAppSystem* rpc_app, const char* error_text } void rpc_system_app_error_reset(RpcAppSystem* rpc_app) { - furi_assert(rpc_app); + furi_check(rpc_app); rpc_system_app_set_error_code(rpc_app, 0); rpc_system_app_set_error_text(rpc_app, NULL); } void rpc_system_app_exchange_data(RpcAppSystem* rpc_app, const uint8_t* data, size_t data_size) { - furi_assert(rpc_app); + furi_check(rpc_app); PB_Main* request = malloc(sizeof(PB_Main)); diff --git a/applications/services/storage/filesystem_api.c b/applications/services/storage/filesystem_api.c index 30b20ede4..e6012864d 100644 --- a/applications/services/storage/filesystem_api.c +++ b/applications/services/storage/filesystem_api.c @@ -1,4 +1,5 @@ #include "filesystem_api_defines.h" +#include const char* filesystem_api_error_get_desc(FS_Error error_id) { const char* result = "unknown error"; @@ -38,5 +39,6 @@ const char* filesystem_api_error_get_desc(FS_Error error_id) { } bool file_info_is_dir(const FileInfo* file_info) { + furi_check(file_info); return (file_info->flags & FSF_DIRECTORY); } \ No newline at end of file diff --git a/applications/services/storage/storage.c b/applications/services/storage/storage.c index a6229af81..f43c6e815 100644 --- a/applications/services/storage/storage.c +++ b/applications/services/storage/storage.c @@ -32,7 +32,7 @@ static void storage_app_sd_icon_draw_callback(Canvas* canvas, void* context) { } } -Storage* storage_app_alloc() { +Storage* storage_app_alloc(void) { Storage* app = malloc(sizeof(Storage)); app->message_queue = furi_message_queue_alloc(8, sizeof(StorageMessage)); app->pubsub = furi_pubsub_alloc(); diff --git a/applications/services/storage/storage_cli.c b/applications/services/storage/storage_cli.c index 52c911c57..67a7e288b 100644 --- a/applications/services/storage/storage_cli.c +++ b/applications/services/storage/storage_cli.c @@ -11,7 +11,7 @@ #define MAX_NAME_LENGTH 255 -static void storage_cli_print_usage() { +static void storage_cli_print_usage(void) { printf("Usage:\r\n"); printf("storage \r\n"); printf("The path must start with /int or /ext\r\n"); @@ -611,7 +611,7 @@ static void storage_cli_factory_reset(Cli* cli, FuriString* args, void* context) } } -void storage_on_system_start() { +void storage_on_system_start(void) { #ifdef SRV_CLI Cli* cli = furi_record_open(RECORD_CLI); cli_add_command(cli, RECORD_STORAGE, CliCommandFlagParallelSafe, storage_cli, NULL); diff --git a/applications/services/storage/storage_external_api.c b/applications/services/storage/storage_external_api.c index 666090346..a377751ea 100644 --- a/applications/services/storage/storage_external_api.c +++ b/applications/services/storage/storage_external_api.c @@ -16,8 +16,9 @@ #define S_API_PROLOGUE FuriApiLock lock = api_lock_alloc_locked(); #define S_FILE_API_PROLOGUE \ + furi_check(file); \ Storage* storage = file->storage; \ - furi_assert(storage); + furi_check(storage); #define S_API_EPILOGUE \ furi_check( \ @@ -92,6 +93,8 @@ bool storage_file_open( const char* path, FS_AccessMode access_mode, FS_OpenMode open_mode) { + furi_check(file); + bool result; FuriEventFlag* event = furi_event_flag_alloc(); FuriPubSubSubscription* subscription = furi_pubsub_subscribe( @@ -198,6 +201,8 @@ size_t storage_file_read(File* file, void* buff, size_t to_read) { } size_t storage_file_write(File* file, const void* buff, size_t to_write) { + furi_check(file); + size_t total = 0; const size_t max_chunk = UINT16_MAX; @@ -276,6 +281,8 @@ bool storage_file_eof(File* file) { } bool storage_file_exists(Storage* storage, const char* path) { + furi_check(storage); + bool exist = false; FileInfo fileinfo; FS_Error error = storage_common_stat(storage, path, &fileinfo); @@ -288,6 +295,9 @@ bool storage_file_exists(Storage* storage, const char* path) { } bool storage_file_copy_to_file(File* source, File* destination, size_t size) { + furi_check(source); + furi_check(destination); + uint8_t* buffer = malloc(FILE_BUFFER_SIZE); while(size) { @@ -328,6 +338,8 @@ static bool storage_dir_open_internal(File* file, const char* path) { } bool storage_dir_open(File* file, const char* path) { + furi_check(file); + bool result; FuriEventFlag* event = furi_event_flag_alloc(); FuriPubSubSubscription* subscription = furi_pubsub_subscribe( @@ -402,6 +414,8 @@ bool storage_dir_rewind(File* file) { } bool storage_dir_exists(Storage* storage, const char* path) { + furi_check(storage); + bool exist = false; FileInfo fileinfo; FS_Error error = storage_common_stat(storage, path, &fileinfo); @@ -415,6 +429,7 @@ bool storage_dir_exists(Storage* storage, const char* path) { /****************** COMMON ******************/ FS_Error storage_common_timestamp(Storage* storage, const char* path, uint32_t* timestamp) { + furi_check(storage); S_API_PROLOGUE; SAData data = { @@ -430,6 +445,8 @@ FS_Error storage_common_timestamp(Storage* storage, const char* path, uint32_t* } FS_Error storage_common_stat(Storage* storage, const char* path, FileInfo* fileinfo) { + furi_check(storage); + S_API_PROLOGUE; SAData data = { .cstat = { @@ -444,6 +461,8 @@ FS_Error storage_common_stat(Storage* storage, const char* path, FileInfo* filei } FS_Error storage_common_remove(Storage* storage, const char* path) { + furi_check(storage); + S_API_PROLOGUE; SAData data = { .path = { @@ -457,6 +476,7 @@ FS_Error storage_common_remove(Storage* storage, const char* path) { } FS_Error storage_common_rename(Storage* storage, const char* old_path, const char* new_path) { + furi_check(storage); FS_Error error; do { @@ -557,6 +577,8 @@ static FS_Error } FS_Error storage_common_copy(Storage* storage, const char* old_path, const char* new_path) { + furi_check(storage); + FS_Error error; FileInfo fileinfo; @@ -650,6 +672,8 @@ static FS_Error } FS_Error storage_common_merge(Storage* storage, const char* old_path, const char* new_path) { + furi_check(storage); + FS_Error error; const char* new_path_tmp = NULL; FuriString* new_path_next = NULL; @@ -718,6 +742,8 @@ FS_Error storage_common_merge(Storage* storage, const char* old_path, const char } FS_Error storage_common_mkdir(Storage* storage, const char* path) { + furi_check(storage); + S_API_PROLOGUE; SAData data = { .path = { @@ -735,6 +761,8 @@ FS_Error storage_common_fs_info( const char* fs_path, uint64_t* total_space, uint64_t* free_space) { + furi_check(storage); + S_API_PROLOGUE; SAData data = { @@ -751,6 +779,8 @@ FS_Error storage_common_fs_info( } void storage_common_resolve_path_and_ensure_app_directory(Storage* storage, FuriString* path) { + furi_check(storage); + S_API_PROLOGUE; SAData data = { @@ -764,6 +794,8 @@ void storage_common_resolve_path_and_ensure_app_directory(Storage* storage, Furi } FS_Error storage_common_migrate(Storage* storage, const char* source, const char* dest) { + furi_check(storage); + if(!storage_common_exists(storage, source)) { return FSE_OK; } @@ -778,6 +810,8 @@ FS_Error storage_common_migrate(Storage* storage, const char* source, const char } bool storage_common_exists(Storage* storage, const char* path) { + furi_check(storage); + FileInfo file_info; return storage_common_stat(storage, path, &file_info) == FSE_OK; } @@ -787,6 +821,8 @@ bool storage_common_equivalent_path( const char* path1, const char* path2, bool truncate) { + furi_check(storage); + S_API_PROLOGUE; SAData data = { @@ -810,23 +846,25 @@ const char* storage_error_get_desc(FS_Error error_id) { } FS_Error storage_file_get_error(File* file) { - furi_check(file != NULL); + furi_check(file); return file->error_id; } int32_t storage_file_get_internal_error(File* file) { - furi_check(file != NULL); + furi_check(file); return file->internal_error_id; } const char* storage_file_get_error_desc(File* file) { - furi_check(file != NULL); + furi_check(file); return filesystem_api_error_get_desc(file->error_id); } /****************** Raw SD API ******************/ FS_Error storage_sd_format(Storage* storage) { + furi_check(storage); + S_API_PROLOGUE; SAData data = {}; S_API_MESSAGE(StorageCommandSDFormat); @@ -835,6 +873,8 @@ FS_Error storage_sd_format(Storage* storage) { } FS_Error storage_sd_unmount(Storage* storage) { + furi_check(storage); + S_API_PROLOGUE; SAData data = {}; S_API_MESSAGE(StorageCommandSDUnmount); @@ -843,6 +883,8 @@ FS_Error storage_sd_unmount(Storage* storage) { } FS_Error storage_sd_mount(Storage* storage) { + furi_check(storage); + S_API_PROLOGUE; SAData data = {}; S_API_MESSAGE(StorageCommandSDMount); @@ -851,6 +893,8 @@ FS_Error storage_sd_mount(Storage* storage) { } FS_Error storage_sd_info(Storage* storage, SDInfo* info) { + furi_check(storage); + S_API_PROLOGUE; SAData data = { .sdinfo = { @@ -862,6 +906,8 @@ FS_Error storage_sd_info(Storage* storage, SDInfo* info) { } FS_Error storage_sd_status(Storage* storage) { + furi_check(storage); + S_API_PROLOGUE; SAData data = {}; S_API_MESSAGE(StorageCommandSDStatus); @@ -870,6 +916,8 @@ FS_Error storage_sd_status(Storage* storage) { } File* storage_file_alloc(Storage* storage) { + furi_check(storage); + File* file = malloc(sizeof(File)); file->type = FileTypeClosed; file->storage = storage; @@ -880,14 +928,18 @@ File* storage_file_alloc(Storage* storage) { } bool storage_file_is_open(File* file) { + furi_check(file); return (file->type != FileTypeClosed); } bool storage_file_is_dir(File* file) { + furi_check(file); return (file->type == FileTypeOpenDir); } void storage_file_free(File* file) { + furi_check(file); + if(storage_file_is_open(file)) { if(storage_file_is_dir(file)) { storage_dir_close(file); @@ -901,13 +953,13 @@ void storage_file_free(File* file) { } FuriPubSub* storage_get_pubsub(Storage* storage) { - furi_assert(storage); + furi_check(storage); return storage->pubsub; } bool storage_simply_remove_recursive(Storage* storage, const char* path) { - furi_assert(storage); - furi_assert(path); + furi_check(storage); + furi_check(path); FileInfo fileinfo; bool result = false; FuriString* fullname; @@ -967,12 +1019,16 @@ bool storage_simply_remove_recursive(Storage* storage, const char* path) { } //-V773 bool storage_simply_remove(Storage* storage, const char* path) { + furi_check(storage); + FS_Error result; result = storage_common_remove(storage, path); return result == FSE_OK || result == FSE_NOT_EXIST; } bool storage_simply_mkdir(Storage* storage, const char* path) { + furi_check(storage); + FS_Error result; result = storage_common_mkdir(storage, path); return result == FSE_OK || result == FSE_EXIST; @@ -985,6 +1041,8 @@ void storage_get_next_filename( const char* fileextension, FuriString* nextfilename, uint8_t max_len) { + furi_check(storage); + FuriString* temp_str; uint16_t num = 0; diff --git a/applications/services/storage/storage_internal_api.c b/applications/services/storage/storage_internal_api.c index d91c71c0e..37ea4a2a5 100644 --- a/applications/services/storage/storage_internal_api.c +++ b/applications/services/storage/storage_internal_api.c @@ -3,6 +3,8 @@ #include FS_Error storage_int_backup(Storage* storage, const char* dstname) { + furi_check(storage); + TarArchive* archive = tar_archive_alloc(storage); bool success = tar_archive_open(archive, dstname, TAR_OPEN_MODE_WRITE) && tar_archive_add_dir(archive, STORAGE_INT_PATH_PREFIX, "") && @@ -13,6 +15,8 @@ FS_Error storage_int_backup(Storage* storage, const char* dstname) { FS_Error storage_int_restore(Storage* storage, const char* srcname, Storage_name_converter converter) { + furi_check(storage); + TarArchive* archive = tar_archive_alloc(storage); bool success = tar_archive_open(archive, srcname, TAR_OPEN_MODE_READ) && tar_archive_unpack_to(archive, STORAGE_INT_PATH_PREFIX, converter); diff --git a/applications/services/storage/storages/storage_int.c b/applications/services/storage/storages/storage_int.c index ea6fa68ef..8c3827fe5 100644 --- a/applications/services/storage/storages/storage_int.c +++ b/applications/services/storage/storages/storage_int.c @@ -23,13 +23,13 @@ typedef struct { bool open; } LFSHandle; -static LFSHandle* lfs_handle_alloc_file() { +static LFSHandle* lfs_handle_alloc_file(void) { LFSHandle* handle = malloc(sizeof(LFSHandle)); handle->data = malloc(sizeof(lfs_file_t)); return handle; } -static LFSHandle* lfs_handle_alloc_dir() { +static LFSHandle* lfs_handle_alloc_dir(void) { LFSHandle* handle = malloc(sizeof(LFSHandle)); handle->data = malloc(sizeof(lfs_dir_t)); return handle; @@ -134,7 +134,7 @@ static int storage_int_device_sync(const struct lfs_config* c) { return 0; } -static LFSData* storage_int_lfs_data_alloc() { +static LFSData* storage_int_lfs_data_alloc(void) { LFSData* lfs_data = malloc(sizeof(LFSData)); // Internal storage start address diff --git a/applications/settings/bt_settings_app/bt_settings_app.c b/applications/settings/bt_settings_app/bt_settings_app.c index f211c7128..d86c9df64 100644 --- a/applications/settings/bt_settings_app/bt_settings_app.c +++ b/applications/settings/bt_settings_app/bt_settings_app.c @@ -12,7 +12,7 @@ static bool bt_settings_back_event_callback(void* context) { return scene_manager_handle_back_event(app->scene_manager); } -BtSettingsApp* bt_settings_app_alloc() { +BtSettingsApp* bt_settings_app_alloc(void) { BtSettingsApp* app = malloc(sizeof(BtSettingsApp)); // Load settings diff --git a/applications/settings/desktop_settings/desktop_settings_app.c b/applications/settings/desktop_settings/desktop_settings_app.c index 7e04271f2..15936bcb8 100644 --- a/applications/settings/desktop_settings/desktop_settings_app.c +++ b/applications/settings/desktop_settings/desktop_settings_app.c @@ -21,7 +21,7 @@ static bool desktop_settings_back_event_callback(void* context) { return scene_manager_handle_back_event(app->scene_manager); } -DesktopSettingsApp* desktop_settings_app_alloc() { +DesktopSettingsApp* desktop_settings_app_alloc(void) { DesktopSettingsApp* app = malloc(sizeof(DesktopSettingsApp)); app->gui = furi_record_open(RECORD_GUI); diff --git a/applications/settings/desktop_settings/views/desktop_settings_view_pin_setup_howto.c b/applications/settings/desktop_settings/views/desktop_settings_view_pin_setup_howto.c index 26aa7c3e1..537acb8d5 100644 --- a/applications/settings/desktop_settings/views/desktop_settings_view_pin_setup_howto.c +++ b/applications/settings/desktop_settings/views/desktop_settings_view_pin_setup_howto.c @@ -54,7 +54,7 @@ void desktop_settings_view_pin_setup_howto_set_callback( instance->context = context; } -DesktopSettingsViewPinSetupHowto* desktop_settings_view_pin_setup_howto_alloc() { +DesktopSettingsViewPinSetupHowto* desktop_settings_view_pin_setup_howto_alloc(void) { DesktopSettingsViewPinSetupHowto* view = malloc(sizeof(DesktopSettingsViewPinSetupHowto)); view->view = view_alloc(); view_set_context(view->view, view); diff --git a/applications/settings/desktop_settings/views/desktop_settings_view_pin_setup_howto.h b/applications/settings/desktop_settings/views/desktop_settings_view_pin_setup_howto.h index 0f62cb433..8a62018de 100644 --- a/applications/settings/desktop_settings/views/desktop_settings_view_pin_setup_howto.h +++ b/applications/settings/desktop_settings/views/desktop_settings_view_pin_setup_howto.h @@ -10,6 +10,6 @@ void desktop_settings_view_pin_setup_howto_set_callback( DesktopSettingsViewPinSetupHowto* instance, DesktopSettingsViewPinSetupHowtoDoneCallback callback, void* context); -DesktopSettingsViewPinSetupHowto* desktop_settings_view_pin_setup_howto_alloc(); +DesktopSettingsViewPinSetupHowto* desktop_settings_view_pin_setup_howto_alloc(void); void desktop_settings_view_pin_setup_howto_free(DesktopSettingsViewPinSetupHowto* instance); View* desktop_settings_view_pin_setup_howto_get_view(DesktopSettingsViewPinSetupHowto* instance); diff --git a/applications/settings/desktop_settings/views/desktop_settings_view_pin_setup_howto2.c b/applications/settings/desktop_settings/views/desktop_settings_view_pin_setup_howto2.c index c28826e62..b09b0b95f 100644 --- a/applications/settings/desktop_settings/views/desktop_settings_view_pin_setup_howto2.c +++ b/applications/settings/desktop_settings/views/desktop_settings_view_pin_setup_howto2.c @@ -76,7 +76,7 @@ void desktop_settings_view_pin_setup_howto2_set_ok_callback( instance->ok_callback = callback; } -DesktopSettingsViewPinSetupHowto2* desktop_settings_view_pin_setup_howto2_alloc() { +DesktopSettingsViewPinSetupHowto2* desktop_settings_view_pin_setup_howto2_alloc(void) { DesktopSettingsViewPinSetupHowto2* view = malloc(sizeof(DesktopSettingsViewPinSetupHowto2)); view->view = view_alloc(); view_set_context(view->view, view); diff --git a/applications/settings/desktop_settings/views/desktop_settings_view_pin_setup_howto2.h b/applications/settings/desktop_settings/views/desktop_settings_view_pin_setup_howto2.h index 8e3018d98..760e7bae1 100644 --- a/applications/settings/desktop_settings/views/desktop_settings_view_pin_setup_howto2.h +++ b/applications/settings/desktop_settings/views/desktop_settings_view_pin_setup_howto2.h @@ -6,7 +6,7 @@ typedef struct DesktopSettingsViewPinSetupHowto2 DesktopSettingsViewPinSetupHowt typedef void (*DesktopSettingsViewPinSetupHowto2Callback)(void*); -DesktopSettingsViewPinSetupHowto2* desktop_settings_view_pin_setup_howto2_alloc(); +DesktopSettingsViewPinSetupHowto2* desktop_settings_view_pin_setup_howto2_alloc(void); void desktop_settings_view_pin_setup_howto2_free(DesktopSettingsViewPinSetupHowto2* instance); View* desktop_settings_view_pin_setup_howto2_get_view(DesktopSettingsViewPinSetupHowto2* instance); void desktop_settings_view_pin_setup_howto2_set_context( diff --git a/applications/settings/expansion_settings_app/expansion_settings_app.c b/applications/settings/expansion_settings_app/expansion_settings_app.c index 12ead2160..fe0e3ca2c 100644 --- a/applications/settings/expansion_settings_app/expansion_settings_app.c +++ b/applications/settings/expansion_settings_app/expansion_settings_app.c @@ -24,7 +24,7 @@ static uint32_t expansion_settings_app_exit(void* context) { return VIEW_NONE; } -static ExpansionSettingsApp* expansion_settings_app_alloc() { +static ExpansionSettingsApp* expansion_settings_app_alloc(void) { ExpansionSettingsApp* app = malloc(sizeof(ExpansionSettingsApp)); app->gui = furi_record_open(RECORD_GUI); diff --git a/applications/settings/notification_settings/notification_settings_app.c b/applications/settings/notification_settings/notification_settings_app.c index 2a1d988ac..7576dcf3c 100644 --- a/applications/settings/notification_settings/notification_settings_app.c +++ b/applications/settings/notification_settings/notification_settings_app.c @@ -173,7 +173,7 @@ static uint32_t notification_app_settings_exit(void* context) { return VIEW_NONE; } -static NotificationAppSettings* alloc_settings() { +static NotificationAppSettings* alloc_settings(void) { NotificationAppSettings* app = malloc(sizeof(NotificationAppSettings)); app->notification = furi_record_open(RECORD_NOTIFICATION); app->gui = furi_record_open(RECORD_GUI); diff --git a/applications/settings/power_settings_app/views/battery_info.c b/applications/settings/power_settings_app/views/battery_info.c index 8add60db5..dd2ec2dbc 100644 --- a/applications/settings/power_settings_app/views/battery_info.c +++ b/applications/settings/power_settings_app/views/battery_info.c @@ -127,7 +127,7 @@ static void battery_info_draw_callback(Canvas* canvas, void* context) { draw_stat(canvas, 104, 42, &I_Health_16x16, health); } -BatteryInfo* battery_info_alloc() { +BatteryInfo* battery_info_alloc(void) { BatteryInfo* battery_info = malloc(sizeof(BatteryInfo)); battery_info->view = view_alloc(); view_set_context(battery_info->view, battery_info); diff --git a/applications/settings/power_settings_app/views/battery_info.h b/applications/settings/power_settings_app/views/battery_info.h index e52d1844c..97130cb46 100644 --- a/applications/settings/power_settings_app/views/battery_info.h +++ b/applications/settings/power_settings_app/views/battery_info.h @@ -14,7 +14,7 @@ typedef struct { uint8_t health; } BatteryInfoModel; -BatteryInfo* battery_info_alloc(); +BatteryInfo* battery_info_alloc(void); void battery_info_free(BatteryInfo* battery_info); diff --git a/applications/settings/storage_settings/storage_settings.c b/applications/settings/storage_settings/storage_settings.c index 77a8f0f22..0508e8e0f 100644 --- a/applications/settings/storage_settings/storage_settings.c +++ b/applications/settings/storage_settings/storage_settings.c @@ -12,7 +12,7 @@ static bool storage_settings_back_event_callback(void* context) { return scene_manager_handle_back_event(app->scene_manager); } -static StorageSettings* storage_settings_alloc() { +static StorageSettings* storage_settings_alloc(void) { StorageSettings* app = malloc(sizeof(StorageSettings)); app->gui = furi_record_open(RECORD_GUI); diff --git a/applications/settings/system/system_settings.c b/applications/settings/system/system_settings.c index 5d7f3193d..29fe0cd48 100644 --- a/applications/settings/system/system_settings.c +++ b/applications/settings/system/system_settings.c @@ -213,7 +213,7 @@ static uint32_t system_settings_exit(void* context) { return VIEW_NONE; } -SystemSettings* system_settings_alloc() { +SystemSettings* system_settings_alloc(void) { SystemSettings* app = malloc(sizeof(SystemSettings)); // Load settings diff --git a/applications/system/hid_app/hid.c b/applications/system/hid_app/hid.c index cd4f75d2e..1b0667bbf 100644 --- a/applications/system/hid_app/hid.c +++ b/applications/system/hid_app/hid.c @@ -133,7 +133,7 @@ static uint32_t hid_ptt_menu_view(void* context) { return HidViewPushToTalkMenu; } -Hid* hid_alloc() { +Hid* hid_alloc(void) { Hid* app = malloc(sizeof(Hid)); // Gui diff --git a/applications/system/hid_app/views/hid_media.h b/applications/system/hid_app/views/hid_media.h index 4aa51dc17..2356734b3 100644 --- a/applications/system/hid_app/views/hid_media.h +++ b/applications/system/hid_app/views/hid_media.h @@ -2,9 +2,11 @@ #include +typedef struct Hid Hid; + typedef struct HidMedia HidMedia; -HidMedia* hid_media_alloc(); +HidMedia* hid_media_alloc(Hid* hid); void hid_media_free(HidMedia* hid_media); diff --git a/applications/system/storage_move_to_sd/storage_move_to_sd.c b/applications/system/storage_move_to_sd/storage_move_to_sd.c index 949f889b2..bc587f3eb 100644 --- a/applications/system/storage_move_to_sd/storage_move_to_sd.c +++ b/applications/system/storage_move_to_sd/storage_move_to_sd.c @@ -113,7 +113,7 @@ static void storage_move_to_sd_unmount_callback(const void* message, void* conte } } -static StorageMoveToSd* storage_move_to_sd_alloc() { +static StorageMoveToSd* storage_move_to_sd_alloc(void) { StorageMoveToSd* app = malloc(sizeof(StorageMoveToSd)); app->gui = furi_record_open(RECORD_GUI); diff --git a/applications/system/updater/cli/updater_cli.c b/applications/system/updater/cli/updater_cli.c index cebdc4d7c..0b734c0f4 100644 --- a/applications/system/updater/cli/updater_cli.c +++ b/applications/system/updater/cli/updater_cli.c @@ -103,7 +103,7 @@ static void updater_start_app(void* context, uint32_t arg) { furi_record_close(RECORD_LOADER); } -void updater_on_system_start() { +void updater_on_system_start(void) { #ifdef SRV_CLI Cli* cli = (Cli*)furi_record_open(RECORD_CLI); cli_add_command(cli, "update", CliCommandFlagDefault, updater_cli_ep, NULL); diff --git a/applications/system/updater/scenes/updater_scene_main.c b/applications/system/updater/scenes/updater_scene_main.c index 9fd68161f..3f55b7c33 100644 --- a/applications/system/updater/scenes/updater_scene_main.c +++ b/applications/system/updater/scenes/updater_scene_main.c @@ -45,7 +45,7 @@ void updater_scene_main_on_enter(void* context) { view_dispatcher_switch_to_view(updater->view_dispatcher, UpdaterViewMain); } -static void updater_scene_cancel_update() { +static void updater_scene_cancel_update(void) { update_operation_disarm(); furi_hal_power_reset(); } diff --git a/applications/system/updater/util/update_task.c b/applications/system/updater/util/update_task.c index df1793a80..c0ea6421c 100644 --- a/applications/system/updater/util/update_task.c +++ b/applications/system/updater/util/update_task.c @@ -387,7 +387,7 @@ static void update_task_worker_thread_cb(FuriThreadState state, void* context) { } } -UpdateTask* update_task_alloc() { +UpdateTask* update_task_alloc(void) { UpdateTask* update_task = malloc(sizeof(UpdateTask)); update_task->state.stage = UpdateTaskStageProgress; diff --git a/applications/system/updater/util/update_task.h b/applications/system/updater/util/update_task.h index b3ac3f2f8..a3c47429e 100644 --- a/applications/system/updater/util/update_task.h +++ b/applications/system/updater/util/update_task.h @@ -69,7 +69,7 @@ typedef struct UpdateTask UpdateTask; typedef void ( *updateProgressCb)(const char* status, const uint8_t stage_pct, bool failed, void* state); -UpdateTask* update_task_alloc(); +UpdateTask* update_task_alloc(void); void update_task_free(UpdateTask* update_task); diff --git a/applications/system/updater/views/updater_main.c b/applications/system/updater/views/updater_main.c index d32d51b7c..4e018d419 100644 --- a/applications/system/updater/views/updater_main.c +++ b/applications/system/updater/views/updater_main.c @@ -102,7 +102,7 @@ static void updater_main_draw_callback(Canvas* canvas, void* _model) { } } -UpdaterMainView* updater_main_alloc() { +UpdaterMainView* updater_main_alloc(void) { UpdaterMainView* main_view = malloc(sizeof(UpdaterMainView)); main_view->view = view_alloc(); diff --git a/applications/system/updater/views/updater_main.h b/applications/system/updater/views/updater_main.h index 81a0e86c9..4d2b9b03c 100644 --- a/applications/system/updater/views/updater_main.h +++ b/applications/system/updater/views/updater_main.h @@ -9,7 +9,7 @@ typedef void (*UpdaterMainInputCallback)(InputType type, void* context); View* updater_main_get_view(UpdaterMainView* main_view); -UpdaterMainView* updater_main_alloc(); +UpdaterMainView* updater_main_alloc(void); void updater_main_free(UpdaterMainView* main_view); diff --git a/furi/core/check.c b/furi/core/check.c index 802596169..90989474a 100644 --- a/furi/core/check.c +++ b/furi/core/check.c @@ -67,7 +67,7 @@ static void __furi_put_uint32_as_hex(uint32_t data) { furi_log_puts(tmp_str); } -static void __furi_print_register_info() { +static void __furi_print_register_info(void) { // Print registers for(uint8_t i = 0; i < 12; i++) { furi_log_puts("\r\n\tr"); @@ -80,12 +80,12 @@ static void __furi_print_register_info() { __furi_put_uint32_as_hex(__furi_check_registers[12]); } -static void __furi_print_stack_info() { +static void __furi_print_stack_info(void) { furi_log_puts("\r\n\tstack watermark: "); __furi_put_uint32_as_text(uxTaskGetStackHighWaterMark(NULL) * 4); } -static void __furi_print_bt_stack_info() { +static void __furi_print_bt_stack_info(void) { const BleGlueHardfaultInfo* fault_info = ble_glue_get_hardfault_info(); if(fault_info == NULL) { furi_log_puts("\r\n\tcore2: not faulted"); @@ -99,7 +99,7 @@ static void __furi_print_bt_stack_info() { } } -static void __furi_print_heap_info() { +static void __furi_print_heap_info(void) { furi_log_puts("\r\n\t heap total: "); __furi_put_uint32_as_text(xPortGetTotalHeapSize()); furi_log_puts("\r\n\t heap free: "); @@ -125,7 +125,7 @@ static void __furi_print_name(bool isr) { } } -FURI_NORETURN void __furi_crash_implementation() { +FURI_NORETURN void __furi_crash_implementation(void) { __disable_irq(); GET_MESSAGE_AND_STORE_REGISTERS(); @@ -176,7 +176,7 @@ FURI_NORETURN void __furi_crash_implementation() { __builtin_unreachable(); } -FURI_NORETURN void __furi_halt_implementation() { +FURI_NORETURN void __furi_halt_implementation(void) { __disable_irq(); GET_MESSAGE_AND_STORE_REGISTERS(); diff --git a/furi/core/check.h b/furi/core/check.h index e782380fd..13b3fd51b 100644 --- a/furi/core/check.h +++ b/furi/core/check.h @@ -14,13 +14,10 @@ #pragma once #include +#include "common_defines.h" #ifdef __cplusplus extern "C" { -#define FURI_NORETURN [[noreturn]] -#else -#include -#define FURI_NORETURN noreturn #endif // Flags instead of pointers will save ~4 bytes on furi_assert and furi_check calls. @@ -28,10 +25,10 @@ extern "C" { #define __FURI_CHECK_MESSAGE_FLAG (0x02) /** Crash system */ -FURI_NORETURN void __furi_crash_implementation(); +FURI_NORETURN void __furi_crash_implementation(void); /** Halt system */ -FURI_NORETURN void __furi_halt_implementation(); +FURI_NORETURN void __furi_halt_implementation(void); /** Crash system with message. Show message after reboot. */ #define __furi_crash(message) \ diff --git a/furi/core/common_defines.h b/furi/core/common_defines.h index 820297863..beb9f6519 100644 --- a/furi/core/common_defines.h +++ b/furi/core/common_defines.h @@ -5,6 +5,10 @@ #ifdef __cplusplus extern "C" { +#define FURI_NORETURN [[noreturn]] +#else +#include +#define FURI_NORETURN noreturn #endif #include diff --git a/furi/core/event_flag.c b/furi/core/event_flag.c index 96b959187..ccbee93d6 100644 --- a/furi/core/event_flag.c +++ b/furi/core/event_flag.c @@ -8,8 +8,8 @@ #define FURI_EVENT_FLAG_MAX_BITS_EVENT_GROUPS 24U #define FURI_EVENT_FLAG_INVALID_BITS (~((1UL << FURI_EVENT_FLAG_MAX_BITS_EVENT_GROUPS) - 1U)) -FuriEventFlag* furi_event_flag_alloc() { - furi_assert(!FURI_IS_IRQ_MODE()); +FuriEventFlag* furi_event_flag_alloc(void) { + furi_check(!FURI_IS_IRQ_MODE()); EventGroupHandle_t handle = xEventGroupCreate(); furi_check(handle); @@ -18,13 +18,13 @@ FuriEventFlag* furi_event_flag_alloc() { } void furi_event_flag_free(FuriEventFlag* instance) { - furi_assert(!FURI_IS_IRQ_MODE()); + furi_check(!FURI_IS_IRQ_MODE()); vEventGroupDelete((EventGroupHandle_t)instance); } uint32_t furi_event_flag_set(FuriEventFlag* instance, uint32_t flags) { - furi_assert(instance); - furi_assert((flags & FURI_EVENT_FLAG_INVALID_BITS) == 0U); + furi_check(instance); + furi_check((flags & FURI_EVENT_FLAG_INVALID_BITS) == 0U); EventGroupHandle_t hEventGroup = (EventGroupHandle_t)instance; uint32_t rflags; @@ -47,8 +47,8 @@ uint32_t furi_event_flag_set(FuriEventFlag* instance, uint32_t flags) { } uint32_t furi_event_flag_clear(FuriEventFlag* instance, uint32_t flags) { - furi_assert(instance); - furi_assert((flags & FURI_EVENT_FLAG_INVALID_BITS) == 0U); + furi_check(instance); + furi_check((flags & FURI_EVENT_FLAG_INVALID_BITS) == 0U); EventGroupHandle_t hEventGroup = (EventGroupHandle_t)instance; uint32_t rflags; @@ -73,7 +73,7 @@ uint32_t furi_event_flag_clear(FuriEventFlag* instance, uint32_t flags) { } uint32_t furi_event_flag_get(FuriEventFlag* instance) { - furi_assert(instance); + furi_check(instance); EventGroupHandle_t hEventGroup = (EventGroupHandle_t)instance; uint32_t rflags; @@ -93,9 +93,9 @@ uint32_t furi_event_flag_wait( uint32_t flags, uint32_t options, uint32_t timeout) { - furi_assert(!FURI_IS_IRQ_MODE()); - furi_assert(instance); - furi_assert((flags & FURI_EVENT_FLAG_INVALID_BITS) == 0U); + furi_check(!FURI_IS_IRQ_MODE()); + furi_check(instance); + furi_check((flags & FURI_EVENT_FLAG_INVALID_BITS) == 0U); EventGroupHandle_t hEventGroup = (EventGroupHandle_t)instance; BaseType_t wait_all; diff --git a/furi/core/event_flag.h b/furi/core/event_flag.h index 133c95e7b..7200144cd 100644 --- a/furi/core/event_flag.h +++ b/furi/core/event_flag.h @@ -16,7 +16,7 @@ typedef void FuriEventFlag; * * @return pointer to FuriEventFlag */ -FuriEventFlag* furi_event_flag_alloc(); +FuriEventFlag* furi_event_flag_alloc(void); /** Deallocate FuriEventFlag * diff --git a/furi/core/kernel.c b/furi/core/kernel.c index 89a50a9b5..db3d6a716 100644 --- a/furi/core/kernel.c +++ b/furi/core/kernel.c @@ -10,7 +10,7 @@ #include CMSIS_device_header -bool furi_kernel_is_irq_or_masked() { +bool furi_kernel_is_irq_or_masked(void) { bool irq = false; BaseType_t state; @@ -34,12 +34,12 @@ bool furi_kernel_is_irq_or_masked() { return (irq); } -bool furi_kernel_is_running() { +bool furi_kernel_is_running(void) { return xTaskGetSchedulerState() != taskSCHEDULER_RUNNING; } -int32_t furi_kernel_lock() { - furi_assert(!furi_kernel_is_irq_or_masked()); +int32_t furi_kernel_lock(void) { + furi_check(!furi_kernel_is_irq_or_masked()); int32_t lock; @@ -63,8 +63,8 @@ int32_t furi_kernel_lock() { return (lock); } -int32_t furi_kernel_unlock() { - furi_assert(!furi_kernel_is_irq_or_masked()); +int32_t furi_kernel_unlock(void) { + furi_check(!furi_kernel_is_irq_or_masked()); int32_t lock; @@ -94,7 +94,7 @@ int32_t furi_kernel_unlock() { } int32_t furi_kernel_restore_lock(int32_t lock) { - furi_assert(!furi_kernel_is_irq_or_masked()); + furi_check(!furi_kernel_is_irq_or_masked()); switch(xTaskGetSchedulerState()) { case taskSCHEDULER_SUSPENDED: @@ -124,13 +124,13 @@ int32_t furi_kernel_restore_lock(int32_t lock) { return (lock); } -uint32_t furi_kernel_get_tick_frequency() { +uint32_t furi_kernel_get_tick_frequency(void) { /* Return frequency in hertz */ return (configTICK_RATE_HZ_RAW); } void furi_delay_tick(uint32_t ticks) { - furi_assert(!furi_kernel_is_irq_or_masked()); + furi_check(!furi_kernel_is_irq_or_masked()); if(ticks == 0U) { taskYIELD(); } else { @@ -139,7 +139,7 @@ void furi_delay_tick(uint32_t ticks) { } FuriStatus furi_delay_until_tick(uint32_t tick) { - furi_assert(!furi_kernel_is_irq_or_masked()); + furi_check(!furi_kernel_is_irq_or_masked()); TickType_t tcnt, delay; FuriStatus stat; @@ -165,7 +165,7 @@ FuriStatus furi_delay_until_tick(uint32_t tick) { return (stat); } -uint32_t furi_get_tick() { +uint32_t furi_get_tick(void) { TickType_t ticks; if(furi_kernel_is_irq_or_masked() != 0U) { diff --git a/furi/core/kernel.h b/furi/core/kernel.h index 592f01d57..2973a90e5 100644 --- a/furi/core/kernel.h +++ b/furi/core/kernel.h @@ -25,13 +25,13 @@ extern "C" { * * @return true if CPU is in IRQ or kernel running and IRQ is masked */ -bool furi_kernel_is_irq_or_masked(); +bool furi_kernel_is_irq_or_masked(void); /** Check if kernel is running * * @return true if running, false otherwise */ -bool furi_kernel_is_running(); +bool furi_kernel_is_running(void); /** Lock kernel, pause process scheduling * @@ -39,7 +39,7 @@ bool furi_kernel_is_running(); * * @return previous lock state(0 - unlocked, 1 - locked) */ -int32_t furi_kernel_lock(); +int32_t furi_kernel_lock(void); /** Unlock kernel, resume process scheduling * @@ -47,7 +47,7 @@ int32_t furi_kernel_lock(); * * @return previous lock state(0 - unlocked, 1 - locked) */ -int32_t furi_kernel_unlock(); +int32_t furi_kernel_unlock(void); /** Restore kernel lock state * @@ -63,7 +63,7 @@ int32_t furi_kernel_restore_lock(int32_t lock); * * @return systick counts per second */ -uint32_t furi_kernel_get_tick_frequency(); +uint32_t furi_kernel_get_tick_frequency(void); /** Delay execution * diff --git a/furi/core/log.c b/furi/core/log.c index 3d270816c..f8110b46a 100644 --- a/furi/core/log.c +++ b/furi/core/log.c @@ -31,7 +31,7 @@ static const FuriLogLevelDescription FURI_LOG_LEVEL_DESCRIPTIONS[] = { {"trace", FuriLogLevelTrace}, }; -void furi_log_init() { +void furi_log_init(void) { // Set default logging parameters furi_log.log_level = FURI_LOG_LEVEL_DEFAULT; furi_log.mutex = furi_mutex_alloc(FuriMutexTypeRecursive); @@ -178,6 +178,8 @@ void furi_log_print_raw_format(FuriLogLevel level, const char* format, ...) { } void furi_log_set_level(FuriLogLevel level) { + furi_check(level <= FuriLogLevelTrace); + if(level == FuriLogLevelDefault) { level = FURI_LOG_LEVEL_DEFAULT; } diff --git a/furi/core/memmgr_heap.c b/furi/core/memmgr_heap.c index b83b4212f..d915a61d7 100644 --- a/furi/core/memmgr_heap.c +++ b/furi/core/memmgr_heap.c @@ -133,7 +133,7 @@ static MemmgrHeapThreadDict_t memmgr_heap_thread_dict = {0}; static volatile uint32_t memmgr_heap_thread_trace_depth = 0; /* Initialize tracing storage on start */ -void memmgr_heap_init() { +void memmgr_heap_init(void) { MemmgrHeapThreadDict_init(memmgr_heap_thread_dict); } @@ -224,7 +224,7 @@ static inline void traceFREE(void* pointer, size_t size) { } } -size_t memmgr_heap_get_max_free_block() { +size_t memmgr_heap_get_max_free_block(void) { size_t max_free_size = 0; BlockLink_t* pxBlock; vTaskSuspendAll(); @@ -241,7 +241,7 @@ size_t memmgr_heap_get_max_free_block() { return max_free_size; } -void memmgr_heap_printf_free_blocks() { +void memmgr_heap_printf_free_blocks(void) { BlockLink_t* pxBlock; //TODO enable when we can do printf with a locked scheduler //vTaskSuspendAll(); @@ -283,7 +283,7 @@ char* ultoa(unsigned long num, char* str, int radix) { return str; } -static void print_heap_init() { +static void print_heap_init(void) { char tmp_str[33]; size_t heap_start = (size_t)&__heap_start__; size_t heap_end = (size_t)&__heap_end__; diff --git a/furi/core/memmgr_heap.h b/furi/core/memmgr_heap.h index 660c5c6bf..7d889f152 100644 --- a/furi/core/memmgr_heap.h +++ b/furi/core/memmgr_heap.h @@ -38,11 +38,11 @@ size_t memmgr_heap_get_thread_memory(FuriThreadId thread_id); * * @return size_t max contiguous block size */ -size_t memmgr_heap_get_max_free_block(); +size_t memmgr_heap_get_max_free_block(void); /** Print the address and size of all free blocks to stdout */ -void memmgr_heap_printf_free_blocks(); +void memmgr_heap_printf_free_blocks(void); #ifdef __cplusplus } diff --git a/furi/core/message_queue.c b/furi/core/message_queue.c index e20fa420a..6e8ab1869 100644 --- a/furi/core/message_queue.c +++ b/furi/core/message_queue.c @@ -6,7 +6,7 @@ #include FuriMessageQueue* furi_message_queue_alloc(uint32_t msg_count, uint32_t msg_size) { - furi_assert((furi_kernel_is_irq_or_masked() == 0U) && (msg_count > 0U) && (msg_size > 0U)); + furi_check((furi_kernel_is_irq_or_masked() == 0U) && (msg_count > 0U) && (msg_size > 0U)); QueueHandle_t handle = xQueueCreate(msg_count, msg_size); furi_check(handle); @@ -15,14 +15,16 @@ FuriMessageQueue* furi_message_queue_alloc(uint32_t msg_count, uint32_t msg_size } void furi_message_queue_free(FuriMessageQueue* instance) { - furi_assert(furi_kernel_is_irq_or_masked() == 0U); - furi_assert(instance); + furi_check(furi_kernel_is_irq_or_masked() == 0U); + furi_check(instance); vQueueDelete((QueueHandle_t)instance); } FuriStatus furi_message_queue_put(FuriMessageQueue* instance, const void* msg_ptr, uint32_t timeout) { + furi_check(instance); + QueueHandle_t hQueue = (QueueHandle_t)instance; FuriStatus stat; BaseType_t yield; @@ -30,7 +32,7 @@ FuriStatus stat = FuriStatusOk; if(furi_kernel_is_irq_or_masked() != 0U) { - if((hQueue == NULL) || (msg_ptr == NULL) || (timeout != 0U)) { + if((msg_ptr == NULL) || (timeout != 0U)) { stat = FuriStatusErrorParameter; } else { yield = pdFALSE; @@ -42,7 +44,7 @@ FuriStatus } } } else { - if((hQueue == NULL) || (msg_ptr == NULL)) { + if(msg_ptr == NULL) { stat = FuriStatusErrorParameter; } else { if(xQueueSendToBack(hQueue, msg_ptr, (TickType_t)timeout) != pdPASS) { @@ -60,6 +62,8 @@ FuriStatus } FuriStatus furi_message_queue_get(FuriMessageQueue* instance, void* msg_ptr, uint32_t timeout) { + furi_check(instance); + QueueHandle_t hQueue = (QueueHandle_t)instance; FuriStatus stat; BaseType_t yield; @@ -67,7 +71,7 @@ FuriStatus furi_message_queue_get(FuriMessageQueue* instance, void* msg_ptr, uin stat = FuriStatusOk; if(furi_kernel_is_irq_or_masked() != 0U) { - if((hQueue == NULL) || (msg_ptr == NULL) || (timeout != 0U)) { + if((msg_ptr == NULL) || (timeout != 0U)) { stat = FuriStatusErrorParameter; } else { yield = pdFALSE; @@ -79,7 +83,7 @@ FuriStatus furi_message_queue_get(FuriMessageQueue* instance, void* msg_ptr, uin } } } else { - if((hQueue == NULL) || (msg_ptr == NULL)) { + if(msg_ptr == NULL) { stat = FuriStatusErrorParameter; } else { if(xQueueReceive(hQueue, msg_ptr, (TickType_t)timeout) != pdPASS) { @@ -92,47 +96,42 @@ FuriStatus furi_message_queue_get(FuriMessageQueue* instance, void* msg_ptr, uin } } - /* Return execution status */ return (stat); } uint32_t furi_message_queue_get_capacity(FuriMessageQueue* instance) { + furi_check(instance); + StaticQueue_t* mq = (StaticQueue_t*)instance; uint32_t capacity; - if(mq == NULL) { - capacity = 0U; - } else { - /* capacity = pxQueue->uxLength */ - capacity = mq->uxDummy4[1]; - } + /* capacity = pxQueue->uxLength */ + capacity = mq->uxDummy4[1]; /* Return maximum number of messages */ return (capacity); } uint32_t furi_message_queue_get_message_size(FuriMessageQueue* instance) { + furi_check(instance); + StaticQueue_t* mq = (StaticQueue_t*)instance; uint32_t size; - if(mq == NULL) { - size = 0U; - } else { - /* size = pxQueue->uxItemSize */ - size = mq->uxDummy4[2]; - } + /* size = pxQueue->uxItemSize */ + size = mq->uxDummy4[2]; /* Return maximum message size */ return (size); } uint32_t furi_message_queue_get_count(FuriMessageQueue* instance) { + furi_check(instance); + QueueHandle_t hQueue = (QueueHandle_t)instance; UBaseType_t count; - if(hQueue == NULL) { - count = 0U; - } else if(furi_kernel_is_irq_or_masked() != 0U) { + if(furi_kernel_is_irq_or_masked() != 0U) { count = uxQueueMessagesWaitingFromISR(hQueue); } else { count = uxQueueMessagesWaiting(hQueue); @@ -143,13 +142,13 @@ uint32_t furi_message_queue_get_count(FuriMessageQueue* instance) { } uint32_t furi_message_queue_get_space(FuriMessageQueue* instance) { + furi_check(instance); + StaticQueue_t* mq = (StaticQueue_t*)instance; uint32_t space; uint32_t isrm; - if(mq == NULL) { - space = 0U; - } else if(furi_kernel_is_irq_or_masked() != 0U) { + if(furi_kernel_is_irq_or_masked() != 0U) { isrm = taskENTER_CRITICAL_FROM_ISR(); /* space = pxQueue->uxLength - pxQueue->uxMessagesWaiting; */ @@ -165,13 +164,13 @@ uint32_t furi_message_queue_get_space(FuriMessageQueue* instance) { } FuriStatus furi_message_queue_reset(FuriMessageQueue* instance) { + furi_check(instance); + QueueHandle_t hQueue = (QueueHandle_t)instance; FuriStatus stat; if(furi_kernel_is_irq_or_masked() != 0U) { stat = FuriStatusErrorISR; - } else if(hQueue == NULL) { - stat = FuriStatusErrorParameter; } else { stat = FuriStatusOk; (void)xQueueReset(hQueue); diff --git a/furi/core/mutex.c b/furi/core/mutex.c index f18fb1681..e32be1a39 100644 --- a/furi/core/mutex.c +++ b/furi/core/mutex.c @@ -6,7 +6,7 @@ #include FuriMutex* furi_mutex_alloc(FuriMutexType type) { - furi_assert(!FURI_IS_IRQ_MODE()); + furi_check(!FURI_IS_IRQ_MODE()); SemaphoreHandle_t hMutex = NULL; @@ -15,7 +15,7 @@ FuriMutex* furi_mutex_alloc(FuriMutexType type) { } else if(type == FuriMutexTypeRecursive) { hMutex = xSemaphoreCreateRecursiveMutex(); } else { - furi_crash("Programming error"); + furi_crash(); } furi_check(hMutex != NULL); @@ -30,13 +30,15 @@ FuriMutex* furi_mutex_alloc(FuriMutexType type) { } void furi_mutex_free(FuriMutex* instance) { - furi_assert(!FURI_IS_IRQ_MODE()); - furi_assert(instance); + furi_check(!FURI_IS_IRQ_MODE()); + furi_check(instance); vSemaphoreDelete((SemaphoreHandle_t)((uint32_t)instance & ~1U)); } FuriStatus furi_mutex_acquire(FuriMutex* instance, uint32_t timeout) { + furi_check(instance); + SemaphoreHandle_t hMutex; FuriStatus stat; uint32_t rmtx; @@ -77,6 +79,8 @@ FuriStatus furi_mutex_acquire(FuriMutex* instance, uint32_t timeout) { } FuriStatus furi_mutex_release(FuriMutex* instance) { + furi_check(instance); + SemaphoreHandle_t hMutex; FuriStatus stat; uint32_t rmtx; @@ -109,6 +113,8 @@ FuriStatus furi_mutex_release(FuriMutex* instance) { } FuriThreadId furi_mutex_get_owner(FuriMutex* instance) { + furi_check(instance); + SemaphoreHandle_t hMutex; FuriThreadId owner; diff --git a/furi/core/pubsub.c b/furi/core/pubsub.c index 44ef20c71..bcabc74a7 100644 --- a/furi/core/pubsub.c +++ b/furi/core/pubsub.c @@ -17,7 +17,7 @@ struct FuriPubSub { FuriMutex* mutex; }; -FuriPubSub* furi_pubsub_alloc() { +FuriPubSub* furi_pubsub_alloc(void) { FuriPubSub* pubsub = malloc(sizeof(FuriPubSub)); pubsub->mutex = furi_mutex_alloc(FuriMutexTypeNormal); @@ -42,6 +42,9 @@ void furi_pubsub_free(FuriPubSub* pubsub) { FuriPubSubSubscription* furi_pubsub_subscribe(FuriPubSub* pubsub, FuriPubSubCallback callback, void* callback_context) { + furi_check(pubsub); + furi_check(callback); + furi_check(furi_mutex_acquire(pubsub->mutex, FuriWaitForever) == FuriStatusOk); // put uninitialized item to the list FuriPubSubSubscription* item = FuriPubSubSubscriptionList_push_raw(pubsub->items); @@ -81,6 +84,8 @@ void furi_pubsub_unsubscribe(FuriPubSub* pubsub, FuriPubSubSubscription* pubsub_ } void furi_pubsub_publish(FuriPubSub* pubsub, void* message) { + furi_check(pubsub); + furi_check(furi_mutex_acquire(pubsub->mutex, FuriWaitForever) == FuriStatusOk); // iterate over subscribers diff --git a/furi/core/pubsub.h b/furi/core/pubsub.h index 69ca574ac..097ff0190 100644 --- a/furi/core/pubsub.h +++ b/furi/core/pubsub.h @@ -23,7 +23,7 @@ typedef struct FuriPubSubSubscription FuriPubSubSubscription; * * @return pointer to FuriPubSub instance */ -FuriPubSub* furi_pubsub_alloc(); +FuriPubSub* furi_pubsub_alloc(void); /** Free FuriPubSub * diff --git a/furi/core/record.c b/furi/core/record.c index 773585e7e..e9bd8edcd 100644 --- a/furi/core/record.c +++ b/furi/core/record.c @@ -37,7 +37,7 @@ static void furi_record_erase(const char* name, FuriRecordData* record_data) { FuriRecordDataDict_erase(furi_record->records, name); } -void furi_record_init() { +void furi_record_init(void) { furi_record = malloc(sizeof(FuriRecord)); furi_record->mutex = furi_mutex_alloc(FuriMutexTypeNormal); furi_check(furi_record->mutex); @@ -45,7 +45,7 @@ void furi_record_init() { } static FuriRecordData* furi_record_data_get_or_create(const char* name) { - furi_assert(furi_record); + furi_check(furi_record); FuriRecordData* record_data = furi_record_get(name); if(!record_data) { FuriRecordData new_record; @@ -58,17 +58,17 @@ static FuriRecordData* furi_record_data_get_or_create(const char* name) { return record_data; } -static void furi_record_lock() { +static void furi_record_lock(void) { furi_check(furi_mutex_acquire(furi_record->mutex, FuriWaitForever) == FuriStatusOk); } -static void furi_record_unlock() { +static void furi_record_unlock(void) { furi_check(furi_mutex_release(furi_record->mutex) == FuriStatusOk); } bool furi_record_exists(const char* name) { - furi_assert(furi_record); - furi_assert(name); + furi_check(furi_record); + furi_check(name); bool ret = false; @@ -80,13 +80,14 @@ bool furi_record_exists(const char* name) { } void furi_record_create(const char* name, void* data) { - furi_assert(furi_record); + furi_check(furi_record); + furi_check(name); furi_record_lock(); // Get record data and fill it FuriRecordData* record_data = furi_record_data_get_or_create(name); - furi_assert(record_data->data == NULL); + furi_check(record_data->data == NULL); record_data->data = data; furi_event_flag_set(record_data->flags, FURI_RECORD_FLAG_READY); @@ -94,14 +95,15 @@ void furi_record_create(const char* name, void* data) { } bool furi_record_destroy(const char* name) { - furi_assert(furi_record); + furi_check(furi_record); + furi_check(name); bool ret = false; furi_record_lock(); FuriRecordData* record_data = furi_record_get(name); - furi_assert(record_data); + furi_check(record_data); if(record_data->holders_count == 0) { furi_record_erase(name, record_data); ret = true; @@ -113,7 +115,8 @@ bool furi_record_destroy(const char* name) { } void* furi_record_open(const char* name) { - furi_assert(furi_record); + furi_check(furi_record); + furi_check(name); furi_record_lock(); @@ -134,12 +137,13 @@ void* furi_record_open(const char* name) { } void furi_record_close(const char* name) { - furi_assert(furi_record); + furi_check(furi_record); + furi_check(name); furi_record_lock(); FuriRecordData* record_data = furi_record_get(name); - furi_assert(record_data); + furi_check(record_data); record_data->holders_count--; furi_record_unlock(); diff --git a/furi/core/record.h b/furi/core/record.h index 4819123e2..a269484f0 100644 --- a/furi/core/record.h +++ b/furi/core/record.h @@ -14,7 +14,7 @@ extern "C" { /** Initialize record storage For internal use only. */ -void furi_record_init(); +void furi_record_init(void); /** Check if record exists * diff --git a/furi/core/semaphore.c b/furi/core/semaphore.c index 1f1a07780..503eec472 100644 --- a/furi/core/semaphore.c +++ b/furi/core/semaphore.c @@ -6,8 +6,8 @@ #include FuriSemaphore* furi_semaphore_alloc(uint32_t max_count, uint32_t initial_count) { - furi_assert(!FURI_IS_IRQ_MODE()); - furi_assert((max_count > 0U) && (initial_count <= max_count)); + furi_check(!FURI_IS_IRQ_MODE()); + furi_check((max_count > 0U) && (initial_count <= max_count)); SemaphoreHandle_t hSemaphore = NULL; if(max_count == 1U) { @@ -29,8 +29,8 @@ FuriSemaphore* furi_semaphore_alloc(uint32_t max_count, uint32_t initial_count) } void furi_semaphore_free(FuriSemaphore* instance) { - furi_assert(instance); - furi_assert(!FURI_IS_IRQ_MODE()); + furi_check(instance); + furi_check(!FURI_IS_IRQ_MODE()); SemaphoreHandle_t hSemaphore = (SemaphoreHandle_t)instance; @@ -38,7 +38,7 @@ void furi_semaphore_free(FuriSemaphore* instance) { } FuriStatus furi_semaphore_acquire(FuriSemaphore* instance, uint32_t timeout) { - furi_assert(instance); + furi_check(instance); SemaphoreHandle_t hSemaphore = (SemaphoreHandle_t)instance; FuriStatus stat; @@ -73,7 +73,7 @@ FuriStatus furi_semaphore_acquire(FuriSemaphore* instance, uint32_t timeout) { } FuriStatus furi_semaphore_release(FuriSemaphore* instance) { - furi_assert(instance); + furi_check(instance); SemaphoreHandle_t hSemaphore = (SemaphoreHandle_t)instance; FuriStatus stat; @@ -100,7 +100,7 @@ FuriStatus furi_semaphore_release(FuriSemaphore* instance) { } uint32_t furi_semaphore_get_count(FuriSemaphore* instance) { - furi_assert(instance); + furi_check(instance); SemaphoreHandle_t hSemaphore = (SemaphoreHandle_t)instance; uint32_t count; diff --git a/furi/core/stream_buffer.c b/furi/core/stream_buffer.c index a13d256b1..8bd00d91c 100644 --- a/furi/core/stream_buffer.c +++ b/furi/core/stream_buffer.c @@ -7,7 +7,7 @@ #include FuriStreamBuffer* furi_stream_buffer_alloc(size_t size, size_t trigger_level) { - furi_assert(size != 0); + furi_check(size != 0); StreamBufferHandle_t handle = xStreamBufferCreate(size, trigger_level); furi_check(handle); @@ -16,12 +16,13 @@ FuriStreamBuffer* furi_stream_buffer_alloc(size_t size, size_t trigger_level) { }; void furi_stream_buffer_free(FuriStreamBuffer* stream_buffer) { - furi_assert(stream_buffer); + furi_check(stream_buffer); + vStreamBufferDelete(stream_buffer); }; bool furi_stream_set_trigger_level(FuriStreamBuffer* stream_buffer, size_t trigger_level) { - furi_assert(stream_buffer); + furi_check(stream_buffer); return xStreamBufferSetTriggerLevel(stream_buffer, trigger_level) == pdTRUE; }; @@ -30,6 +31,8 @@ size_t furi_stream_buffer_send( const void* data, size_t length, uint32_t timeout) { + furi_check(stream_buffer); + size_t ret; if(FURI_IS_IRQ_MODE()) { @@ -48,6 +51,8 @@ size_t furi_stream_buffer_receive( void* data, size_t length, uint32_t timeout) { + furi_check(stream_buffer); + size_t ret; if(FURI_IS_IRQ_MODE()) { @@ -62,22 +67,32 @@ size_t furi_stream_buffer_receive( } size_t furi_stream_buffer_bytes_available(FuriStreamBuffer* stream_buffer) { + furi_check(stream_buffer); + return xStreamBufferBytesAvailable(stream_buffer); }; size_t furi_stream_buffer_spaces_available(FuriStreamBuffer* stream_buffer) { + furi_check(stream_buffer); + return xStreamBufferSpacesAvailable(stream_buffer); }; bool furi_stream_buffer_is_full(FuriStreamBuffer* stream_buffer) { + furi_check(stream_buffer); + return xStreamBufferIsFull(stream_buffer) == pdTRUE; }; bool furi_stream_buffer_is_empty(FuriStreamBuffer* stream_buffer) { + furi_check(stream_buffer); + return (xStreamBufferIsEmpty(stream_buffer) == pdTRUE); }; FuriStatus furi_stream_buffer_reset(FuriStreamBuffer* stream_buffer) { + furi_check(stream_buffer); + if(xStreamBufferReset(stream_buffer) == pdPASS) { return FuriStatusOk; } else { diff --git a/furi/core/string.c b/furi/core/string.c index a09ff953f..f3e40fe5e 100644 --- a/furi/core/string.c +++ b/furi/core/string.c @@ -22,7 +22,7 @@ struct FuriString { #undef furi_string_trim #undef furi_string_cat -FuriString* furi_string_alloc() { +FuriString* furi_string_alloc(void) { FuriString* string = malloc(sizeof(FuriString)); string_init(string->string); return string; diff --git a/furi/core/string.h b/furi/core/string.h index 77ae9da6d..324135e96 100644 --- a/furi/core/string.h +++ b/furi/core/string.h @@ -32,7 +32,7 @@ typedef struct FuriString FuriString; * @brief Allocate new FuriString. * @return FuriString* */ -FuriString* furi_string_alloc(); +FuriString* furi_string_alloc(void); /** * @brief Allocate new FuriString and set it to string. diff --git a/furi/core/thread.c b/furi/core/thread.c index 3c1a17258..f9f73b4f7 100644 --- a/furi/core/thread.c +++ b/furi/core/thread.c @@ -4,7 +4,6 @@ #include "memmgr_heap.h" #include "check.h" #include "common_defines.h" -#include "mutex.h" #include "string.h" #include "log.h" @@ -57,7 +56,7 @@ static size_t __furi_thread_stdout_write(FuriThread* thread, const char* data, s static int32_t __furi_thread_stdout_flush(FuriThread* thread); /** Catch threads that are trying to exit wrong way */ -__attribute__((__noreturn__)) void furi_thread_catch() { //-V1082 +__attribute__((__noreturn__)) void furi_thread_catch(void) { //-V1082 // If you're here it means you're probably doing something wrong // with critical sections or with scheduler state asm volatile("nop"); // extra magic @@ -74,14 +73,14 @@ static void furi_thread_set_state(FuriThread* thread, FuriThreadState state) { } static void furi_thread_body(void* context) { - furi_assert(context); + furi_check(context); FuriThread* thread = context; // store thread instance to thread local storage - furi_assert(pvTaskGetThreadLocalStoragePointer(NULL, 0) == NULL); + furi_check(pvTaskGetThreadLocalStoragePointer(NULL, 0) == NULL); vTaskSetThreadLocalStoragePointer(NULL, 0, thread); - furi_assert(thread->state == FuriThreadStateStarting); + furi_check(thread->state == FuriThreadStateStarting); furi_thread_set_state(thread, FuriThreadStateRunning); TaskHandle_t task_handle = xTaskGetCurrentTaskHandle(); @@ -103,7 +102,7 @@ static void furi_thread_body(void* context) { memmgr_heap_disable_thread_trace((FuriThreadId)task_handle); } - furi_assert(thread->state == FuriThreadStateRunning); + furi_check(thread->state == FuriThreadStateRunning); if(thread->is_service) { FURI_LOG_W( @@ -121,7 +120,7 @@ static void furi_thread_body(void* context) { furi_thread_catch(); } -FuriThread* furi_thread_alloc() { +FuriThread* furi_thread_alloc(void) { FuriThread* thread = malloc(sizeof(FuriThread)); thread->output.buffer = furi_string_alloc(); thread->is_service = false; @@ -167,11 +166,11 @@ FuriThread* furi_thread_alloc_ex( } void furi_thread_free(FuriThread* thread) { - furi_assert(thread); + furi_check(thread); // Ensure that use join before free - furi_assert(thread->state == FuriThreadStateStopped); - furi_assert(thread->task_handle == NULL); + furi_check(thread->state == FuriThreadStateStopped); + furi_check(thread->task_handle == NULL); if(thread->name) free(thread->name); if(thread->appid) free(thread->appid); @@ -181,15 +180,17 @@ void furi_thread_free(FuriThread* thread) { } void furi_thread_set_name(FuriThread* thread, const char* name) { - furi_assert(thread); - furi_assert(thread->state == FuriThreadStateStopped); + furi_check(thread); + furi_check(thread->state == FuriThreadStateStopped); + if(thread->name) free(thread->name); + thread->name = name ? strdup(name) : NULL; } void furi_thread_set_appid(FuriThread* thread, const char* appid) { - furi_assert(thread); - furi_assert(thread->state == FuriThreadStateStopped); + furi_check(thread); + furi_check(thread->state == FuriThreadStateStopped); if(thread->appid) free(thread->appid); thread->appid = appid ? strdup(appid) : NULL; } @@ -199,68 +200,70 @@ void furi_thread_mark_as_service(FuriThread* thread) { } void furi_thread_set_stack_size(FuriThread* thread, size_t stack_size) { - furi_assert(thread); - furi_assert(thread->state == FuriThreadStateStopped); - furi_assert(stack_size % 4 == 0); + furi_check(thread); + furi_check(thread->state == FuriThreadStateStopped); + furi_check(stack_size % 4 == 0); thread->stack_size = stack_size; } void furi_thread_set_callback(FuriThread* thread, FuriThreadCallback callback) { - furi_assert(thread); - furi_assert(thread->state == FuriThreadStateStopped); + furi_check(thread); + furi_check(thread->state == FuriThreadStateStopped); thread->callback = callback; } void furi_thread_set_context(FuriThread* thread, void* context) { - furi_assert(thread); - furi_assert(thread->state == FuriThreadStateStopped); + furi_check(thread); + furi_check(thread->state == FuriThreadStateStopped); thread->context = context; } void furi_thread_set_priority(FuriThread* thread, FuriThreadPriority priority) { - furi_assert(thread); - furi_assert(thread->state == FuriThreadStateStopped); - furi_assert(priority >= FuriThreadPriorityIdle && priority <= FuriThreadPriorityIsr); + furi_check(thread); + furi_check(thread->state == FuriThreadStateStopped); + furi_check(priority >= FuriThreadPriorityIdle && priority <= FuriThreadPriorityIsr); thread->priority = priority; } FuriThreadPriority furi_thread_get_priority(FuriThread* thread) { - furi_assert(thread); + furi_check(thread); TaskHandle_t hTask = furi_thread_get_id(thread); return (FuriThreadPriority)uxTaskPriorityGet(hTask); } void furi_thread_set_current_priority(FuriThreadPriority priority) { + furi_check(priority <= FuriThreadPriorityIsr); + UBaseType_t new_priority = priority ? priority : FuriThreadPriorityNormal; vTaskPrioritySet(NULL, new_priority); } -FuriThreadPriority furi_thread_get_current_priority() { +FuriThreadPriority furi_thread_get_current_priority(void) { return (FuriThreadPriority)uxTaskPriorityGet(NULL); } void furi_thread_set_state_callback(FuriThread* thread, FuriThreadStateCallback callback) { - furi_assert(thread); - furi_assert(thread->state == FuriThreadStateStopped); + furi_check(thread); + furi_check(thread->state == FuriThreadStateStopped); thread->state_callback = callback; } void furi_thread_set_state_context(FuriThread* thread, void* context) { - furi_assert(thread); - furi_assert(thread->state == FuriThreadStateStopped); + furi_check(thread); + furi_check(thread->state == FuriThreadStateStopped); thread->state_context = context; } FuriThreadState furi_thread_get_state(FuriThread* thread) { - furi_assert(thread); + furi_check(thread); return thread->state; } void furi_thread_start(FuriThread* thread) { - furi_assert(thread); - furi_assert(thread->callback); - furi_assert(thread->state == FuriThreadStateStopped); - furi_assert(thread->stack_size > 0 && thread->stack_size < (UINT16_MAX * sizeof(StackType_t))); + furi_check(thread); + furi_check(thread->callback); + furi_check(thread->state == FuriThreadStateStopped); + furi_check(thread->stack_size > 0 && thread->stack_size < (UINT16_MAX * sizeof(StackType_t))); furi_thread_set_state(thread, FuriThreadStateStarting); @@ -289,13 +292,13 @@ void furi_thread_cleanup_tcb_event(TaskHandle_t task) { if(thread) { // clear thread local storage vTaskSetThreadLocalStoragePointer(task, 0, NULL); - furi_assert(thread->task_handle == task); + furi_check(thread->task_handle == task); thread->task_handle = NULL; } } bool furi_thread_join(FuriThread* thread) { - furi_assert(thread); + furi_check(thread); furi_check(furi_thread_get_current() != thread); @@ -311,45 +314,45 @@ bool furi_thread_join(FuriThread* thread) { } FuriThreadId furi_thread_get_id(FuriThread* thread) { - furi_assert(thread); + furi_check(thread); return thread->task_handle; } void furi_thread_enable_heap_trace(FuriThread* thread) { - furi_assert(thread); - furi_assert(thread->state == FuriThreadStateStopped); + furi_check(thread); + furi_check(thread->state == FuriThreadStateStopped); thread->heap_trace_enabled = true; } void furi_thread_disable_heap_trace(FuriThread* thread) { - furi_assert(thread); - furi_assert(thread->state == FuriThreadStateStopped); + furi_check(thread); + furi_check(thread->state == FuriThreadStateStopped); thread->heap_trace_enabled = false; } size_t furi_thread_get_heap_size(FuriThread* thread) { - furi_assert(thread); - furi_assert(thread->heap_trace_enabled == true); + furi_check(thread); + furi_check(thread->heap_trace_enabled == true); return thread->heap_size; } int32_t furi_thread_get_return_code(FuriThread* thread) { - furi_assert(thread); - furi_assert(thread->state == FuriThreadStateStopped); + furi_check(thread); + furi_check(thread->state == FuriThreadStateStopped); return thread->ret; } -FuriThreadId furi_thread_get_current_id() { +FuriThreadId furi_thread_get_current_id(void) { return xTaskGetCurrentTaskHandle(); } -FuriThread* furi_thread_get_current() { +FuriThread* furi_thread_get_current(void) { FuriThread* thread = pvTaskGetThreadLocalStoragePointer(NULL, 0); return thread; } -void furi_thread_yield() { - furi_assert(!FURI_IS_IRQ_MODE()); +void furi_thread_yield(void) { + furi_check(!FURI_IS_IRQ_MODE()); taskYIELD(); } @@ -594,20 +597,21 @@ static int32_t __furi_thread_stdout_flush(FuriThread* thread) { void furi_thread_set_stdout_callback(FuriThreadStdoutWriteCallback callback) { FuriThread* thread = furi_thread_get_current(); - furi_assert(thread); + furi_check(thread); __furi_thread_stdout_flush(thread); thread->output.write_callback = callback; } -FuriThreadStdoutWriteCallback furi_thread_get_stdout_callback() { +FuriThreadStdoutWriteCallback furi_thread_get_stdout_callback(void) { FuriThread* thread = furi_thread_get_current(); - furi_assert(thread); + furi_check(thread); return thread->output.write_callback; } size_t furi_thread_stdout_write(const char* data, size_t size) { FuriThread* thread = furi_thread_get_current(); - furi_assert(thread); + furi_check(thread); + if(size == 0 || data == NULL) { return __furi_thread_stdout_flush(thread); } else { @@ -629,19 +633,26 @@ size_t furi_thread_stdout_write(const char* data, size_t size) { return size; } -int32_t furi_thread_stdout_flush() { +int32_t furi_thread_stdout_flush(void) { FuriThread* thread = furi_thread_get_current(); - furi_assert(thread); + furi_check(thread); + return __furi_thread_stdout_flush(thread); } void furi_thread_suspend(FuriThreadId thread_id) { + furi_check(thread_id); + TaskHandle_t hTask = (TaskHandle_t)thread_id; + vTaskSuspend(hTask); } void furi_thread_resume(FuriThreadId thread_id) { + furi_check(thread_id); + TaskHandle_t hTask = (TaskHandle_t)thread_id; + if(FURI_IS_IRQ_MODE()) { xTaskResumeFromISR(hTask); } else { @@ -650,6 +661,9 @@ void furi_thread_resume(FuriThreadId thread_id) { } bool furi_thread_is_suspended(FuriThreadId thread_id) { + furi_check(thread_id); + TaskHandle_t hTask = (TaskHandle_t)thread_id; + return eTaskGetState(hTask) == eSuspended; } diff --git a/furi/core/thread.h b/furi/core/thread.h index 489a46844..f21ee9df3 100644 --- a/furi/core/thread.h +++ b/furi/core/thread.h @@ -62,7 +62,7 @@ typedef void (*FuriThreadStateCallback)(FuriThreadState state, void* context); * * @return FuriThread instance */ -FuriThread* furi_thread_alloc(); +FuriThread* furi_thread_alloc(void); /** Allocate FuriThread, shortcut version * @@ -155,7 +155,7 @@ void furi_thread_set_current_priority(FuriThreadPriority priority); * * @return FuriThreadPriority value */ -FuriThreadPriority furi_thread_get_current_priority(); +FuriThreadPriority furi_thread_get_current_priority(void); /** Set FuriThread state change callback * @@ -238,16 +238,16 @@ int32_t furi_thread_get_return_code(FuriThread* thread); * * @return FuriThreadId or NULL */ -FuriThreadId furi_thread_get_current_id(); +FuriThreadId furi_thread_get_current_id(void); /** Get FuriThread instance for current thread * * @return pointer to FuriThread or NULL if this thread doesn't belongs to Furi */ -FuriThread* furi_thread_get_current(); +FuriThread* furi_thread_get_current(void); /** Return control to scheduler */ -void furi_thread_yield(); +void furi_thread_yield(void); uint32_t furi_thread_flags_set(FuriThreadId thread_id, uint32_t flags); @@ -294,7 +294,7 @@ uint32_t furi_thread_get_stack_space(FuriThreadId thread_id); * * @return STDOUT callback */ -FuriThreadStdoutWriteCallback furi_thread_get_stdout_callback(); +FuriThreadStdoutWriteCallback furi_thread_get_stdout_callback(void); /** Set STDOUT callback for thread * @@ -315,7 +315,7 @@ size_t furi_thread_stdout_write(const char* data, size_t size); * * @return int32_t error code */ -int32_t furi_thread_stdout_flush(); +int32_t furi_thread_stdout_flush(void); /** Suspend thread * diff --git a/furi/core/timer.c b/furi/core/timer.c index f667aae96..2e688dcc3 100644 --- a/furi/core/timer.c +++ b/furi/core/timer.c @@ -26,7 +26,7 @@ static void TimerCallback(TimerHandle_t hTimer) { } FuriTimer* furi_timer_alloc(FuriTimerCallback func, FuriTimerType type, void* context) { - furi_assert((furi_kernel_is_irq_or_masked() == 0U) && (func != NULL)); + furi_check((furi_kernel_is_irq_or_masked() == 0U) && (func != NULL)); TimerHandle_t hTimer; TimerCallback_t* callb; @@ -59,8 +59,8 @@ FuriTimer* furi_timer_alloc(FuriTimerCallback func, FuriTimerType type, void* co } void furi_timer_free(FuriTimer* instance) { - furi_assert(!furi_kernel_is_irq_or_masked()); - furi_assert(instance); + furi_check(!furi_kernel_is_irq_or_masked()); + furi_check(instance); TimerHandle_t hTimer = (TimerHandle_t)instance; TimerCallback_t* callb; @@ -86,9 +86,9 @@ void furi_timer_free(FuriTimer* instance) { } FuriStatus furi_timer_start(FuriTimer* instance, uint32_t ticks) { - furi_assert(!furi_kernel_is_irq_or_masked()); - furi_assert(instance); - furi_assert(ticks < portMAX_DELAY); + furi_check(!furi_kernel_is_irq_or_masked()); + furi_check(instance); + furi_check(ticks < portMAX_DELAY); TimerHandle_t hTimer = (TimerHandle_t)instance; FuriStatus stat; @@ -104,9 +104,9 @@ FuriStatus furi_timer_start(FuriTimer* instance, uint32_t ticks) { } FuriStatus furi_timer_restart(FuriTimer* instance, uint32_t ticks) { - furi_assert(!furi_kernel_is_irq_or_masked()); - furi_assert(instance); - furi_assert(ticks < portMAX_DELAY); + furi_check(!furi_kernel_is_irq_or_masked()); + furi_check(instance); + furi_check(ticks < portMAX_DELAY); TimerHandle_t hTimer = (TimerHandle_t)instance; FuriStatus stat; @@ -123,8 +123,8 @@ FuriStatus furi_timer_restart(FuriTimer* instance, uint32_t ticks) { } FuriStatus furi_timer_stop(FuriTimer* instance) { - furi_assert(!furi_kernel_is_irq_or_masked()); - furi_assert(instance); + furi_check(!furi_kernel_is_irq_or_masked()); + furi_check(instance); TimerHandle_t hTimer = (TimerHandle_t)instance; @@ -134,8 +134,8 @@ FuriStatus furi_timer_stop(FuriTimer* instance) { } uint32_t furi_timer_is_running(FuriTimer* instance) { - furi_assert(!furi_kernel_is_irq_or_masked()); - furi_assert(instance); + furi_check(!furi_kernel_is_irq_or_masked()); + furi_check(instance); TimerHandle_t hTimer = (TimerHandle_t)instance; @@ -144,8 +144,8 @@ uint32_t furi_timer_is_running(FuriTimer* instance) { } uint32_t furi_timer_get_expire_time(FuriTimer* instance) { - furi_assert(!furi_kernel_is_irq_or_masked()); - furi_assert(instance); + furi_check(!furi_kernel_is_irq_or_masked()); + furi_check(instance); TimerHandle_t hTimer = (TimerHandle_t)instance; @@ -153,17 +153,20 @@ uint32_t furi_timer_get_expire_time(FuriTimer* instance) { } void furi_timer_pending_callback(FuriTimerPendigCallback callback, void* context, uint32_t arg) { + furi_check(callback); + BaseType_t ret = pdFAIL; if(furi_kernel_is_irq_or_masked()) { ret = xTimerPendFunctionCallFromISR(callback, context, arg, NULL); } else { ret = xTimerPendFunctionCall(callback, context, arg, FuriWaitForever); } + furi_check(ret == pdPASS); } void furi_timer_set_thread_priority(FuriTimerThreadPriority priority) { - furi_assert(!furi_kernel_is_irq_or_masked()); + furi_check(!furi_kernel_is_irq_or_masked()); TaskHandle_t task_handle = xTimerGetTimerDaemonTaskHandle(); furi_check(task_handle); // Don't call this method before timer task start diff --git a/furi/flipper.c b/furi/flipper.c index b29424a9f..c7ba3b4fb 100644 --- a/furi/flipper.c +++ b/furi/flipper.c @@ -29,7 +29,7 @@ static void flipper_print_version(const char* target, const Version* version) { } } -void flipper_init() { +void flipper_init(void) { flipper_print_version("Firmware", furi_hal_version_get_firmware_version()); FURI_LOG_I(TAG, "Boot mode %d, starting services", furi_hal_rtc_get_boot_mode()); diff --git a/furi/flipper.h b/furi/flipper.h index 5b277fac6..674cccf88 100644 --- a/furi/flipper.h +++ b/furi/flipper.h @@ -1,3 +1,3 @@ #pragma once -void flipper_init(); +void flipper_init(void); diff --git a/furi/furi.c b/furi/furi.c index 6247e259f..628c47ea2 100644 --- a/furi/furi.c +++ b/furi/furi.c @@ -4,17 +4,17 @@ #include #include -void furi_init() { - furi_assert(!furi_kernel_is_irq_or_masked()); - furi_assert(xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED); +void furi_init(void) { + furi_check(!furi_kernel_is_irq_or_masked()); + furi_check(xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED); furi_log_init(); furi_record_init(); } -void furi_run() { - furi_assert(!furi_kernel_is_irq_or_masked()); - furi_assert(xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED); +void furi_run(void) { + furi_check(!furi_kernel_is_irq_or_masked()); + furi_check(xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED); #if(__ARM_ARCH_7A__ == 0U) /* Service Call interrupt might be configured before kernel start */ diff --git a/furi/furi.h b/furi/furi.h index 422509055..d8aec91c0 100644 --- a/furi/furi.h +++ b/furi/furi.h @@ -28,9 +28,9 @@ extern "C" { #endif -void furi_init(); +void furi_init(void); -void furi_run(); +void furi_run(void); #ifdef __cplusplus } diff --git a/lib/app-scened-template/text_store.h b/lib/app-scened-template/text_store.h index a01784fde..3fe58ed1d 100644 --- a/lib/app-scened-template/text_store.h +++ b/lib/app-scened-template/text_store.h @@ -4,7 +4,7 @@ class TextStore { public: TextStore(uint8_t text_size); - ~TextStore(); + ~TextStore(void); void set(const char* text...); const uint8_t text_size; diff --git a/lib/app-scened-template/view_modules/byte_input_vm.h b/lib/app-scened-template/view_modules/byte_input_vm.h index 9a1610127..69031fbee 100644 --- a/lib/app-scened-template/view_modules/byte_input_vm.h +++ b/lib/app-scened-template/view_modules/byte_input_vm.h @@ -4,7 +4,7 @@ class ByteInputVM : public GenericViewModule { public: - ByteInputVM(); + ByteInputVM(void); ~ByteInputVM() final; View* get_view() final; void clean() final; diff --git a/lib/app-scened-template/view_modules/dialog_ex_vm.h b/lib/app-scened-template/view_modules/dialog_ex_vm.h index 66c2b760a..cb63ccdbc 100644 --- a/lib/app-scened-template/view_modules/dialog_ex_vm.h +++ b/lib/app-scened-template/view_modules/dialog_ex_vm.h @@ -4,7 +4,7 @@ class DialogExVM : public GenericViewModule { public: - DialogExVM(); + DialogExVM(void); ~DialogExVM() final; View* get_view() final; void clean() final; diff --git a/lib/app-scened-template/view_modules/popup_vm.h b/lib/app-scened-template/view_modules/popup_vm.h index 266505639..234f33774 100644 --- a/lib/app-scened-template/view_modules/popup_vm.h +++ b/lib/app-scened-template/view_modules/popup_vm.h @@ -4,7 +4,7 @@ class PopupVM : public GenericViewModule { public: - PopupVM(); + PopupVM(void); ~PopupVM() final; View* get_view() final; void clean() final; @@ -56,12 +56,12 @@ public: /** * Enable popup timeout */ - void enable_timeout(); + void enable_timeout(void); /** * Disable popup timeout */ - void disable_timeout(); + void disable_timeout(void); private: Popup* popup; diff --git a/lib/app-scened-template/view_modules/submenu_vm.h b/lib/app-scened-template/view_modules/submenu_vm.h index 06541527a..223fbd531 100644 --- a/lib/app-scened-template/view_modules/submenu_vm.h +++ b/lib/app-scened-template/view_modules/submenu_vm.h @@ -4,7 +4,7 @@ class SubmenuVM : public GenericViewModule { public: - SubmenuVM(); + SubmenuVM(void); ~SubmenuVM() final; View* get_view() final; void clean() final; diff --git a/lib/app-scened-template/view_modules/text_input_vm.h b/lib/app-scened-template/view_modules/text_input_vm.h index 81799e48c..5c71c4318 100644 --- a/lib/app-scened-template/view_modules/text_input_vm.h +++ b/lib/app-scened-template/view_modules/text_input_vm.h @@ -4,7 +4,7 @@ class TextInputVM : public GenericViewModule { public: - TextInputVM(); + TextInputVM(void); ~TextInputVM() final; View* get_view() final; void clean() final; @@ -34,7 +34,7 @@ public: void set_validator(TextInputValidatorCallback callback, void* callback_context); - void* get_validator_callback_context(); + void* get_validator_callback_context(void); private: TextInput* text_input; diff --git a/lib/bit_lib/bit_lib.c b/lib/bit_lib/bit_lib.c index e13ca95d4..8122b1cc4 100644 --- a/lib/bit_lib/bit_lib.c +++ b/lib/bit_lib/bit_lib.c @@ -418,8 +418,8 @@ uint16_t bit_lib_crc16( } void bit_lib_num_to_bytes_be(uint64_t src, uint8_t len, uint8_t* dest) { - furi_assert(dest); - furi_assert(len <= 8); + furi_check(dest); + furi_check(len <= 8); while(len--) { dest[len] = (uint8_t)src; @@ -428,8 +428,8 @@ void bit_lib_num_to_bytes_be(uint64_t src, uint8_t len, uint8_t* dest) { } void bit_lib_num_to_bytes_le(uint64_t src, uint8_t len, uint8_t* dest) { - furi_assert(dest); - furi_assert(len <= 8); + furi_check(dest); + furi_check(len <= 8); for(int i = 0; i < len; i++) { dest[i] = (uint8_t)(src >> (8 * i)); @@ -437,8 +437,8 @@ void bit_lib_num_to_bytes_le(uint64_t src, uint8_t len, uint8_t* dest) { } uint64_t bit_lib_bytes_to_num_be(const uint8_t* src, uint8_t len) { - furi_assert(src); - furi_assert(len <= 8); + furi_check(src); + furi_check(len <= 8); uint64_t res = 0; while(len--) { @@ -449,8 +449,8 @@ uint64_t bit_lib_bytes_to_num_be(const uint8_t* src, uint8_t len) { } uint64_t bit_lib_bytes_to_num_le(const uint8_t* src, uint8_t len) { - furi_assert(src); - furi_assert(len <= 8); + furi_check(src); + furi_check(len <= 8); uint64_t res = 0; uint8_t shift = 0; @@ -462,8 +462,8 @@ uint64_t bit_lib_bytes_to_num_le(const uint8_t* src, uint8_t len) { } uint64_t bit_lib_bytes_to_num_bcd(const uint8_t* src, uint8_t len, bool* is_bcd) { - furi_assert(src); - furi_assert(len <= 9); + furi_check(src); + furi_check(len <= 9); uint64_t res = 0; uint8_t nibble_1, nibble_2; diff --git a/lib/ble_profile/extra_services/hid_service.c b/lib/ble_profile/extra_services/hid_service.c index d9ea09c14..92422d5d5 100644 --- a/lib/ble_profile/extra_services/hid_service.c +++ b/lib/ble_profile/extra_services/hid_service.c @@ -169,7 +169,7 @@ static BleEventAckStatus ble_svc_hid_event_handler(void* event, void* context) { return ret; } -BleServiceHid* ble_svc_hid_start() { +BleServiceHid* ble_svc_hid_start(void) { BleServiceHid* hid_svc = malloc(sizeof(BleServiceHid)); // Register event handler diff --git a/lib/ble_profile/extra_services/hid_service.h b/lib/ble_profile/extra_services/hid_service.h index 8e9cc2975..9bbb83611 100644 --- a/lib/ble_profile/extra_services/hid_service.h +++ b/lib/ble_profile/extra_services/hid_service.h @@ -9,7 +9,7 @@ extern "C" { typedef struct BleServiceHid BleServiceHid; -BleServiceHid* ble_svc_hid_start(); +BleServiceHid* ble_svc_hid_start(void); void ble_svc_hid_stop(BleServiceHid* service); diff --git a/lib/datetime/datetime.c b/lib/datetime/datetime.c index 73044fae6..9c2194d96 100644 --- a/lib/datetime/datetime.c +++ b/lib/datetime/datetime.c @@ -1,4 +1,5 @@ #include "datetime.h" +#include #define TAG "DateTime" @@ -37,6 +38,8 @@ bool datetime_validate_datetime(DateTime* datetime) { } uint32_t datetime_datetime_to_timestamp(DateTime* datetime) { + furi_check(datetime); + uint32_t timestamp = 0; uint8_t years = 0; uint8_t leap_years = 0; @@ -67,6 +70,7 @@ uint32_t datetime_datetime_to_timestamp(DateTime* datetime) { } void datetime_timestamp_to_datetime(uint32_t timestamp, DateTime* datetime) { + furi_check(datetime); uint32_t days = timestamp / SECONDS_PER_DAY; uint32_t seconds_in_day = timestamp % SECONDS_PER_DAY; diff --git a/lib/digital_signal/digital_sequence.c b/lib/digital_signal/digital_sequence.c index c85aae8c0..24dddb77d 100644 --- a/lib/digital_signal/digital_sequence.c +++ b/lib/digital_signal/digital_sequence.c @@ -115,17 +115,17 @@ void digital_sequence_register_signal( DigitalSequence* sequence, uint8_t signal_index, const DigitalSignal* signal) { - furi_assert(sequence); - furi_assert(signal); - furi_assert(signal_index < DIGITAL_SEQUENCE_BANK_SIZE); + furi_check(sequence); + furi_check(signal); + furi_check(signal_index < DIGITAL_SEQUENCE_BANK_SIZE); sequence->signals[signal_index] = signal; } void digital_sequence_add_signal(DigitalSequence* sequence, uint8_t signal_index) { - furi_assert(sequence); - furi_assert(signal_index < DIGITAL_SEQUENCE_BANK_SIZE); - furi_assert(sequence->size < sequence->max_size); + furi_check(sequence); + furi_check(signal_index < DIGITAL_SEQUENCE_BANK_SIZE); + furi_check(sequence->size < sequence->max_size); sequence->data[sequence->size++] = signal_index; } @@ -140,14 +140,14 @@ static inline void digital_sequence_start_dma(DigitalSequence* sequence) { LL_DMA_EnableChannel(DMA1, LL_DMA_CHANNEL_2); } -static inline void digital_sequence_stop_dma() { +static inline void digital_sequence_stop_dma(void) { LL_DMA_DisableChannel(DMA1, LL_DMA_CHANNEL_1); LL_DMA_DisableChannel(DMA1, LL_DMA_CHANNEL_2); LL_DMA_ClearFlag_TC1(DMA1); LL_DMA_ClearFlag_TC2(DMA1); } -static inline void digital_sequence_start_timer() { +static inline void digital_sequence_start_timer(void) { furi_hal_bus_enable(FuriHalBusTIM2); LL_TIM_SetCounterMode(TIM2, LL_TIM_COUNTERMODE_UP); @@ -162,7 +162,7 @@ static inline void digital_sequence_start_timer() { LL_TIM_GenerateEvent_UPDATE(TIM2); } -static void digital_sequence_stop_timer() { +static void digital_sequence_stop_timer(void) { LL_TIM_DisableCounter(TIM2); LL_TIM_DisableUpdateEvent(TIM2); LL_TIM_DisableDMAReq_UPDATE(TIM2); @@ -280,9 +280,9 @@ static inline void digital_sequence_timer_buffer_reset(DigitalSequence* sequence } void digital_sequence_transmit(DigitalSequence* sequence) { - furi_assert(sequence); - furi_assert(sequence->size); - furi_assert(sequence->state == DigitalSequenceStateIdle); + furi_check(sequence); + furi_check(sequence->size); + furi_check(sequence->state == DigitalSequenceStateIdle); FURI_CRITICAL_ENTER(); diff --git a/lib/digital_signal/digital_signal.c b/lib/digital_signal/digital_signal.c index a0408900d..585250c26 100644 --- a/lib/digital_signal/digital_signal.c +++ b/lib/digital_signal/digital_signal.c @@ -15,33 +15,33 @@ DigitalSignal* digital_signal_alloc(uint32_t max_size) { } void digital_signal_free(DigitalSignal* signal) { - furi_assert(signal); + furi_check(signal); free(signal->data); free(signal); } bool digital_signal_get_start_level(const DigitalSignal* signal) { - furi_assert(signal); + furi_check(signal); return signal->start_level; } void digital_signal_set_start_level(DigitalSignal* signal, bool level) { - furi_assert(signal); + furi_check(signal); signal->start_level = level; } uint32_t digital_signal_get_size(const DigitalSignal* signal) { - furi_assert(signal); + furi_check(signal); return signal->size; } void digital_signal_add_period(DigitalSignal* signal, uint32_t ticks) { - furi_assert(signal); - furi_assert(signal->size < signal->max_size); + furi_check(signal); + furi_check(signal->size < signal->max_size); const uint32_t duration = ticks + signal->remainder; @@ -80,7 +80,7 @@ static void digital_signal_extend_last_period(DigitalSignal* signal, uint32_t ti } void digital_signal_add_period_with_level(DigitalSignal* signal, uint32_t ticks, bool level) { - furi_assert(signal); + furi_check(signal); if(signal->size == 0) { signal->start_level = level; diff --git a/lib/drivers/st25r3916_reg.c b/lib/drivers/st25r3916_reg.c index 8ac467238..76a882755 100644 --- a/lib/drivers/st25r3916_reg.c +++ b/lib/drivers/st25r3916_reg.c @@ -34,7 +34,7 @@ static void st25r3916_reg_tx_byte(FuriHalSpiBusHandle* handle, uint8_t byte) { } void st25r3916_read_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t* val) { - furi_assert(handle); + furi_check(handle); st25r3916_read_burst_regs(handle, reg, val, 1); } @@ -43,9 +43,9 @@ void st25r3916_read_burst_regs( uint8_t reg_start, uint8_t* values, uint8_t length) { - furi_assert(handle); - furi_assert(values); - furi_assert(length); + furi_check(handle); + furi_check(values); + furi_check(length); furi_hal_gpio_write(handle->cs, false); @@ -60,7 +60,7 @@ void st25r3916_read_burst_regs( } void st25r3916_write_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t val) { - furi_assert(handle); + furi_check(handle); uint8_t reg_val = val; st25r3916_write_burst_regs(handle, reg, ®_val, 1); } @@ -70,9 +70,9 @@ void st25r3916_write_burst_regs( uint8_t reg_start, const uint8_t* values, uint8_t length) { - furi_assert(handle); - furi_assert(values); - furi_assert(length); + furi_check(handle); + furi_check(values); + furi_check(length); furi_hal_gpio_write(handle->cs, false); @@ -87,10 +87,10 @@ void st25r3916_write_burst_regs( } void st25r3916_reg_write_fifo(FuriHalSpiBusHandle* handle, const uint8_t* buff, size_t length) { - furi_assert(handle); - furi_assert(buff); - furi_assert(length); - furi_assert(length <= ST25R3916_FIFO_DEPTH); + furi_check(handle); + furi_check(buff); + furi_check(length); + furi_check(length <= ST25R3916_FIFO_DEPTH); furi_hal_gpio_write(handle->cs, false); st25r3916_reg_tx_byte(handle, ST25R3916_FIFO_LOAD); @@ -99,10 +99,10 @@ void st25r3916_reg_write_fifo(FuriHalSpiBusHandle* handle, const uint8_t* buff, } void st25r3916_reg_read_fifo(FuriHalSpiBusHandle* handle, uint8_t* buff, size_t length) { - furi_assert(handle); - furi_assert(buff); - furi_assert(length); - furi_assert(length <= ST25R3916_FIFO_DEPTH); + furi_check(handle); + furi_check(buff); + furi_check(length); + furi_check(length <= ST25R3916_FIFO_DEPTH); furi_hal_gpio_write(handle->cs, false); st25r3916_reg_tx_byte(handle, ST25R3916_FIFO_READ); @@ -111,10 +111,10 @@ void st25r3916_reg_read_fifo(FuriHalSpiBusHandle* handle, uint8_t* buff, size_t } void st25r3916_write_pta_mem(FuriHalSpiBusHandle* handle, const uint8_t* values, size_t length) { - furi_assert(handle); - furi_assert(values); - furi_assert(length); - furi_assert(length <= ST25R3916_PTM_LEN); + furi_check(handle); + furi_check(values); + furi_check(length); + furi_check(length <= ST25R3916_PTM_LEN); furi_hal_gpio_write(handle->cs, false); st25r3916_reg_tx_byte(handle, ST25R3916_PT_A_CONFIG_LOAD); @@ -123,10 +123,10 @@ void st25r3916_write_pta_mem(FuriHalSpiBusHandle* handle, const uint8_t* values, } void st25r3916_read_pta_mem(FuriHalSpiBusHandle* handle, uint8_t* buff, size_t length) { - furi_assert(handle); - furi_assert(buff); - furi_assert(length); - furi_assert(length <= ST25R3916_PTM_LEN); + furi_check(handle); + furi_check(buff); + furi_check(length); + furi_check(length <= ST25R3916_PTM_LEN); uint8_t tmp_buff[ST25R3916_PTM_LEN + 1]; furi_hal_gpio_write(handle->cs, false); @@ -137,8 +137,8 @@ void st25r3916_read_pta_mem(FuriHalSpiBusHandle* handle, uint8_t* buff, size_t l } void st25r3916_write_ptf_mem(FuriHalSpiBusHandle* handle, const uint8_t* values, size_t length) { - furi_assert(handle); - furi_assert(values); + furi_check(handle); + furi_check(values); furi_hal_gpio_write(handle->cs, false); st25r3916_reg_tx_byte(handle, ST25R3916_PT_F_CONFIG_LOAD); @@ -147,8 +147,8 @@ void st25r3916_write_ptf_mem(FuriHalSpiBusHandle* handle, const uint8_t* values, } void st25r3916_write_pttsn_mem(FuriHalSpiBusHandle* handle, uint8_t* buff, size_t length) { - furi_assert(handle); - furi_assert(buff); + furi_check(handle); + furi_check(buff); furi_hal_gpio_write(handle->cs, false); st25r3916_reg_tx_byte(handle, ST25R3916_PT_TSN_DATA_LOAD); @@ -157,7 +157,7 @@ void st25r3916_write_pttsn_mem(FuriHalSpiBusHandle* handle, uint8_t* buff, size_ } void st25r3916_direct_cmd(FuriHalSpiBusHandle* handle, uint8_t cmd) { - furi_assert(handle); + furi_check(handle); furi_hal_gpio_write(handle->cs, false); st25r3916_reg_tx_byte(handle, cmd | ST25R3916_CMD_MODE); @@ -165,7 +165,7 @@ void st25r3916_direct_cmd(FuriHalSpiBusHandle* handle, uint8_t cmd) { } void st25r3916_read_test_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t* val) { - furi_assert(handle); + furi_check(handle); furi_hal_gpio_write(handle->cs, false); st25r3916_reg_tx_byte(handle, ST25R3916_CMD_TEST_ACCESS); @@ -175,7 +175,7 @@ void st25r3916_read_test_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t* } void st25r3916_write_test_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t val) { - furi_assert(handle); + furi_check(handle); furi_hal_gpio_write(handle->cs, false); st25r3916_reg_tx_byte(handle, ST25R3916_CMD_TEST_ACCESS); @@ -185,7 +185,7 @@ void st25r3916_write_test_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t } void st25r3916_clear_reg_bits(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t clr_mask) { - furi_assert(handle); + furi_check(handle); uint8_t reg_val = 0; st25r3916_read_reg(handle, reg, ®_val); @@ -196,7 +196,7 @@ void st25r3916_clear_reg_bits(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t } void st25r3916_set_reg_bits(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t set_mask) { - furi_assert(handle); + furi_check(handle); uint8_t reg_val = 0; st25r3916_read_reg(handle, reg, ®_val); @@ -211,7 +211,7 @@ void st25r3916_change_reg_bits( uint8_t reg, uint8_t mask, uint8_t value) { - furi_assert(handle); + furi_check(handle); st25r3916_modify_reg(handle, reg, mask, (mask & value)); } @@ -221,7 +221,7 @@ void st25r3916_modify_reg( uint8_t reg, uint8_t clr_mask, uint8_t set_mask) { - furi_assert(handle); + furi_check(handle); uint8_t reg_val = 0; uint8_t new_val = 0; @@ -237,7 +237,7 @@ void st25r3916_change_test_reg_bits( uint8_t reg, uint8_t mask, uint8_t value) { - furi_assert(handle); + furi_check(handle); uint8_t reg_val = 0; uint8_t new_val = 0; @@ -249,7 +249,7 @@ void st25r3916_change_test_reg_bits( } bool st25r3916_check_reg(FuriHalSpiBusHandle* handle, uint8_t reg, uint8_t mask, uint8_t val) { - furi_assert(handle); + furi_check(handle); uint8_t reg_val = 0; st25r3916_read_reg(handle, reg, ®_val); diff --git a/lib/flipper_application/api_hashtable/api_hashtable.cpp b/lib/flipper_application/api_hashtable/api_hashtable.cpp index 11f2d7ecf..861eece79 100644 --- a/lib/flipper_application/api_hashtable/api_hashtable.cpp +++ b/lib/flipper_application/api_hashtable/api_hashtable.cpp @@ -9,6 +9,10 @@ bool elf_resolve_from_hashtable( const ElfApiInterface* interface, uint32_t hash, Elf32_Addr* address) { + + furi_check(interface); + furi_check(address); + bool result = false; const HashtableApiInterface* hashtable_interface = static_cast(interface); @@ -33,5 +37,6 @@ bool elf_resolve_from_hashtable( } uint32_t elf_symbolname_hash(const char* s) { + furi_check(s); return elf_gnu_hash(s); } \ No newline at end of file diff --git a/lib/flipper_application/application_manifest.c b/lib/flipper_application/application_manifest.c index addbd5e4c..dfe18e249 100644 --- a/lib/flipper_application/application_manifest.c +++ b/lib/flipper_application/application_manifest.c @@ -1,8 +1,11 @@ #include "application_manifest.h" #include +#include bool flipper_application_manifest_is_valid(const FlipperApplicationManifest* manifest) { + furi_check(manifest); + if((manifest->base.manifest_magic != FAP_MANIFEST_MAGIC) || (manifest->base.manifest_version != FAP_MANIFEST_SUPPORTED_VERSION)) { return false; @@ -14,6 +17,9 @@ bool flipper_application_manifest_is_valid(const FlipperApplicationManifest* man bool flipper_application_manifest_is_too_old( const FlipperApplicationManifest* manifest, const ElfApiInterface* api_interface) { + furi_check(manifest); + furi_check(api_interface); + if(manifest->base.api_version.major < api_interface->api_version_major /* || manifest->base.api_version.minor > app->api_interface->api_version_minor */) { return false; @@ -25,6 +31,9 @@ bool flipper_application_manifest_is_too_old( bool flipper_application_manifest_is_too_new( const FlipperApplicationManifest* manifest, const ElfApiInterface* api_interface) { + furi_check(manifest); + furi_check(api_interface); + if(manifest->base.api_version.major > api_interface->api_version_major /* || manifest->base.api_version.minor > app->api_interface->api_version_minor */) { return false; @@ -34,6 +43,8 @@ bool flipper_application_manifest_is_too_new( } bool flipper_application_manifest_is_target_compatible(const FlipperApplicationManifest* manifest) { + furi_check(manifest); + const Version* version = furi_hal_version_get_firmware_version(); return version_get_target(version) == manifest->base.hardware_target_id; } \ No newline at end of file diff --git a/lib/flipper_application/flipper_application.c b/lib/flipper_application/flipper_application.c index d56a8a7ef..3c4a07f2f 100644 --- a/lib/flipper_application/flipper_application.c +++ b/lib/flipper_application/flipper_application.c @@ -24,7 +24,7 @@ FlipperApplicationList_t flipper_application_loaded_app_list = {0}; static bool flipper_application_loaded_app_list_initialized = false; static void flipper_application_list_add_app(const FlipperApplication* app) { - furi_assert(app); + furi_check(app); if(!flipper_application_loaded_app_list_initialized) { FlipperApplicationList_init(flipper_application_loaded_app_list); @@ -34,8 +34,8 @@ static void flipper_application_list_add_app(const FlipperApplication* app) { } static void flipper_application_list_remove_app(const FlipperApplication* app) { - furi_assert(flipper_application_loaded_app_list_initialized); - furi_assert(app); + furi_check(flipper_application_loaded_app_list_initialized); + furi_check(app); FlipperApplicationList_it_t it; for(FlipperApplicationList_it(it, flipper_application_loaded_app_list); @@ -52,19 +52,24 @@ static void flipper_application_list_remove_app(const FlipperApplication* app) { FlipperApplication* flipper_application_alloc(Storage* storage, const ElfApiInterface* api_interface) { + furi_check(storage); + furi_check(api_interface); + FlipperApplication* app = malloc(sizeof(FlipperApplication)); app->elf = elf_file_alloc(storage, api_interface); app->thread = NULL; app->ep_thread_args = NULL; + return app; } bool flipper_application_is_plugin(FlipperApplication* app) { + furi_check(app); return app->manifest.stack_size == 0; } void flipper_application_free(FlipperApplication* app) { - furi_assert(app); + furi_check(app); if(app->thread) { furi_thread_join(app->thread); @@ -184,20 +189,29 @@ static FlipperApplicationPreloadStatus /* Parse headers, load manifest */ FlipperApplicationPreloadStatus flipper_application_preload_manifest(FlipperApplication* app, const char* path) { + furi_check(app); + furi_check(path); + return flipper_application_load(app, path, false); } /* Parse headers, load full file */ FlipperApplicationPreloadStatus flipper_application_preload(FlipperApplication* app, const char* path) { + furi_check(app); + furi_check(path); + return flipper_application_load(app, path, true); } const FlipperApplicationManifest* flipper_application_get_manifest(FlipperApplication* app) { + furi_check(app); return &app->manifest; } FlipperApplicationLoadStatus flipper_application_map_to_memory(FlipperApplication* app) { + furi_check(app); + ELFFileLoadStatus status = elf_file_load_sections(app->elf); switch(status) { @@ -215,7 +229,7 @@ FlipperApplicationLoadStatus flipper_application_map_to_memory(FlipperApplicatio } static int32_t flipper_application_thread(void* context) { - furi_assert(context); + furi_check(context); FlipperApplication* app = (FlipperApplication*)context; elf_file_call_init(app->elf); @@ -237,6 +251,7 @@ static int32_t flipper_application_thread(void* context) { } FuriThread* flipper_application_alloc_thread(FlipperApplication* app, const char* args) { + furi_check(app); furi_check(app->thread == NULL); furi_check(!flipper_application_is_plugin(app)); @@ -290,6 +305,8 @@ const char* flipper_application_load_status_to_string(FlipperApplicationLoadStat const FlipperAppPluginDescriptor* flipper_application_plugin_get_descriptor(FlipperApplication* app) { + furi_check(app); + if(!flipper_application_is_plugin(app)) { return NULL; } @@ -318,6 +335,11 @@ bool flipper_application_load_name_and_icon( Storage* storage, uint8_t** icon_ptr, FuriString* item_name) { + furi_check(path); + furi_check(storage); + furi_check(icon_ptr); + furi_check(item_name); + FlipperApplication* app = flipper_application_alloc(storage, firmware_api_interface); FlipperApplicationPreloadStatus preload_res = diff --git a/lib/flipper_application/plugins/composite_resolver.c b/lib/flipper_application/plugins/composite_resolver.c index 7cc2b340a..03dcd95e7 100644 --- a/lib/flipper_application/plugins/composite_resolver.c +++ b/lib/flipper_application/plugins/composite_resolver.c @@ -1,5 +1,6 @@ #include "composite_resolver.h" +#include #include #include @@ -25,21 +26,28 @@ static bool composite_api_resolver_callback( return false; } -CompositeApiResolver* composite_api_resolver_alloc() { +CompositeApiResolver* composite_api_resolver_alloc(void) { CompositeApiResolver* resolver = malloc(sizeof(CompositeApiResolver)); + resolver->api_interface.api_version_major = 0; resolver->api_interface.api_version_minor = 0; resolver->api_interface.resolver_callback = &composite_api_resolver_callback; ElfApiInterfaceList_init(resolver->interfaces); + return resolver; } void composite_api_resolver_free(CompositeApiResolver* resolver) { + furi_check(resolver); + ElfApiInterfaceList_clear(resolver->interfaces); free(resolver); } void composite_api_resolver_add(CompositeApiResolver* resolver, const ElfApiInterface* interface) { + furi_check(resolver); + furi_check(interface); + if(ElfApiInterfaceList_empty_p(resolver->interfaces)) { resolver->api_interface.api_version_major = interface->api_version_major; resolver->api_interface.api_version_minor = interface->api_version_minor; @@ -48,5 +56,6 @@ void composite_api_resolver_add(CompositeApiResolver* resolver, const ElfApiInte } const ElfApiInterface* composite_api_resolver_get(CompositeApiResolver* resolver) { + furi_check(resolver); return &resolver->api_interface; } diff --git a/lib/flipper_application/plugins/composite_resolver.h b/lib/flipper_application/plugins/composite_resolver.h index a2d4bab25..d8a22887f 100644 --- a/lib/flipper_application/plugins/composite_resolver.h +++ b/lib/flipper_application/plugins/composite_resolver.h @@ -19,7 +19,7 @@ typedef struct CompositeApiResolver CompositeApiResolver; * @brief Allocate composite API resolver * @return CompositeApiResolver* instance */ -CompositeApiResolver* composite_api_resolver_alloc(); +CompositeApiResolver* composite_api_resolver_alloc(void); /** * @brief Free composite API resolver diff --git a/lib/flipper_application/plugins/plugin_manager.c b/lib/flipper_application/plugins/plugin_manager.c index 8f30ed13e..d0e294220 100644 --- a/lib/flipper_application/plugins/plugin_manager.c +++ b/lib/flipper_application/plugins/plugin_manager.c @@ -36,6 +36,8 @@ PluginManager* plugin_manager_alloc( } void plugin_manager_free(PluginManager* manager) { + furi_check(manager); + for M_EACH(loaded_lib, manager->libs, FlipperApplicationList_t) { flipper_application_free(*loaded_lib); @@ -46,6 +48,7 @@ void plugin_manager_free(PluginManager* manager) { } PluginManagerError plugin_manager_load_single(PluginManager* manager, const char* path) { + furi_check(manager); FlipperApplication* lib = flipper_application_alloc(manager->storage, manager->api_interface); PluginManagerError error = PluginManagerErrorNone; @@ -103,6 +106,7 @@ PluginManagerError plugin_manager_load_single(PluginManager* manager, const char } PluginManagerError plugin_manager_load_all(PluginManager* manager, const char* path) { + furi_check(manager); File* directory = storage_file_alloc(manager->storage); char file_name_buffer[256]; FuriString* file_name = furi_string_alloc(); @@ -139,15 +143,21 @@ PluginManagerError plugin_manager_load_all(PluginManager* manager, const char* p } uint32_t plugin_manager_get_count(PluginManager* manager) { + furi_check(manager); + return FlipperApplicationList_size(manager->libs); } const FlipperAppPluginDescriptor* plugin_manager_get(PluginManager* manager, uint32_t index) { + furi_check(manager); + FlipperApplication* app = *FlipperApplicationList_get(manager->libs, index); return flipper_application_plugin_get_descriptor(app); } const void* plugin_manager_get_ep(PluginManager* manager, uint32_t index) { + furi_check(manager); + const FlipperAppPluginDescriptor* lib_descr = plugin_manager_get(manager, index); furi_check(lib_descr); return lib_descr->entry_point; diff --git a/lib/flipper_format/flipper_format.c b/lib/flipper_format/flipper_format.c index bb1aa59f5..8992247d1 100644 --- a/lib/flipper_format/flipper_format.c +++ b/lib/flipper_format/flipper_format.c @@ -23,7 +23,7 @@ Stream* flipper_format_get_raw_stream(FlipperFormat* flipper_format) { /********************************** Public **********************************/ -FlipperFormat* flipper_format_string_alloc() { +FlipperFormat* flipper_format_string_alloc(void) { FlipperFormat* flipper_format = malloc(sizeof(FlipperFormat)); flipper_format->stream = string_stream_alloc(); flipper_format->strict_mode = false; @@ -45,18 +45,18 @@ FlipperFormat* flipper_format_buffered_file_alloc(Storage* storage) { } bool flipper_format_file_open_existing(FlipperFormat* flipper_format, const char* path) { - furi_assert(flipper_format); + furi_check(flipper_format); return file_stream_open(flipper_format->stream, path, FSAM_READ_WRITE, FSOM_OPEN_EXISTING); } bool flipper_format_buffered_file_open_existing(FlipperFormat* flipper_format, const char* path) { - furi_assert(flipper_format); + furi_check(flipper_format); return buffered_file_stream_open( flipper_format->stream, path, FSAM_READ_WRITE, FSOM_OPEN_EXISTING); } bool flipper_format_file_open_append(FlipperFormat* flipper_format, const char* path) { - furi_assert(flipper_format); + furi_check(flipper_format); bool result = file_stream_open(flipper_format->stream, path, FSAM_READ_WRITE, FSOM_OPEN_APPEND); @@ -87,33 +87,33 @@ bool flipper_format_file_open_append(FlipperFormat* flipper_format, const char* } bool flipper_format_file_open_always(FlipperFormat* flipper_format, const char* path) { - furi_assert(flipper_format); + furi_check(flipper_format); return file_stream_open(flipper_format->stream, path, FSAM_READ_WRITE, FSOM_CREATE_ALWAYS); } bool flipper_format_buffered_file_open_always(FlipperFormat* flipper_format, const char* path) { - furi_assert(flipper_format); + furi_check(flipper_format); return buffered_file_stream_open( flipper_format->stream, path, FSAM_READ_WRITE, FSOM_CREATE_ALWAYS); } bool flipper_format_file_open_new(FlipperFormat* flipper_format, const char* path) { - furi_assert(flipper_format); + furi_check(flipper_format); return file_stream_open(flipper_format->stream, path, FSAM_READ_WRITE, FSOM_CREATE_NEW); } bool flipper_format_file_close(FlipperFormat* flipper_format) { - furi_assert(flipper_format); + furi_check(flipper_format); return file_stream_close(flipper_format->stream); } bool flipper_format_buffered_file_close(FlipperFormat* flipper_format) { - furi_assert(flipper_format); + furi_check(flipper_format); return buffered_file_stream_close(flipper_format->stream); } void flipper_format_free(FlipperFormat* flipper_format) { - furi_assert(flipper_format); + furi_check(flipper_format); stream_free(flipper_format->stream); free(flipper_format); } @@ -123,12 +123,12 @@ void flipper_format_set_strict_mode(FlipperFormat* flipper_format, bool strict_m } bool flipper_format_rewind(FlipperFormat* flipper_format) { - furi_assert(flipper_format); + furi_check(flipper_format); return stream_rewind(flipper_format->stream); } bool flipper_format_seek_to_end(FlipperFormat* flipper_format) { - furi_assert(flipper_format); + furi_check(flipper_format); return stream_seek(flipper_format->stream, 0, StreamOffsetFromEnd); } @@ -145,7 +145,7 @@ bool flipper_format_read_header( FlipperFormat* flipper_format, FuriString* filetype, uint32_t* version) { - furi_assert(flipper_format); + furi_check(flipper_format); return flipper_format_read_string(flipper_format, flipper_format_filetype_key, filetype) && flipper_format_read_uint32(flipper_format, flipper_format_version_key, version, 1); } @@ -154,7 +154,7 @@ bool flipper_format_write_header( FlipperFormat* flipper_format, FuriString* filetype, const uint32_t version) { - furi_assert(flipper_format); + furi_check(flipper_format); return flipper_format_write_header_cstr( flipper_format, furi_string_get_cstr(filetype), version); } @@ -163,7 +163,7 @@ bool flipper_format_write_header_cstr( FlipperFormat* flipper_format, const char* filetype, const uint32_t version) { - furi_assert(flipper_format); + furi_check(flipper_format); return flipper_format_write_string_cstr( flipper_format, flipper_format_filetype_key, filetype) && flipper_format_write_uint32(flipper_format, flipper_format_version_key, &version, 1); @@ -173,19 +173,19 @@ bool flipper_format_get_value_count( FlipperFormat* flipper_format, const char* key, uint32_t* count) { - furi_assert(flipper_format); + furi_check(flipper_format); return flipper_format_stream_get_value_count( flipper_format->stream, key, count, flipper_format->strict_mode); } bool flipper_format_read_string(FlipperFormat* flipper_format, const char* key, FuriString* data) { - furi_assert(flipper_format); + furi_check(flipper_format); return flipper_format_stream_read_value_line( flipper_format->stream, key, FlipperStreamValueStr, data, 1, flipper_format->strict_mode); } bool flipper_format_write_string(FlipperFormat* flipper_format, const char* key, FuriString* data) { - furi_assert(flipper_format); + furi_check(flipper_format); FlipperStreamWriteData write_data = { .key = key, .type = FlipperStreamValueStr, @@ -200,7 +200,7 @@ bool flipper_format_write_string_cstr( FlipperFormat* flipper_format, const char* key, const char* data) { - furi_assert(flipper_format); + furi_check(flipper_format); FlipperStreamWriteData write_data = { .key = key, .type = FlipperStreamValueStr, @@ -216,7 +216,7 @@ bool flipper_format_read_hex_uint64( const char* key, uint64_t* data, const uint16_t data_size) { - furi_assert(flipper_format); + furi_check(flipper_format); return flipper_format_stream_read_value_line( flipper_format->stream, key, @@ -231,7 +231,7 @@ bool flipper_format_write_hex_uint64( const char* key, const uint64_t* data, const uint16_t data_size) { - furi_assert(flipper_format); + furi_check(flipper_format); FlipperStreamWriteData write_data = { .key = key, .type = FlipperStreamValueHexUint64, @@ -247,7 +247,7 @@ bool flipper_format_read_uint32( const char* key, uint32_t* data, const uint16_t data_size) { - furi_assert(flipper_format); + furi_check(flipper_format); return flipper_format_stream_read_value_line( flipper_format->stream, key, @@ -262,7 +262,7 @@ bool flipper_format_write_uint32( const char* key, const uint32_t* data, const uint16_t data_size) { - furi_assert(flipper_format); + furi_check(flipper_format); FlipperStreamWriteData write_data = { .key = key, .type = FlipperStreamValueUint32, @@ -292,7 +292,7 @@ bool flipper_format_write_int32( const char* key, const int32_t* data, const uint16_t data_size) { - furi_assert(flipper_format); + furi_check(flipper_format); FlipperStreamWriteData write_data = { .key = key, .type = FlipperStreamValueInt32, @@ -322,7 +322,7 @@ bool flipper_format_write_bool( const char* key, const bool* data, const uint16_t data_size) { - furi_assert(flipper_format); + furi_check(flipper_format); FlipperStreamWriteData write_data = { .key = key, .type = FlipperStreamValueBool, @@ -352,7 +352,7 @@ bool flipper_format_write_float( const char* key, const float* data, const uint16_t data_size) { - furi_assert(flipper_format); + furi_check(flipper_format); FlipperStreamWriteData write_data = { .key = key, .type = FlipperStreamValueFloat, @@ -382,7 +382,7 @@ bool flipper_format_write_hex( const char* key, const uint8_t* data, const uint16_t data_size) { - furi_assert(flipper_format); + furi_check(flipper_format); FlipperStreamWriteData write_data = { .key = key, .type = FlipperStreamValueHex, @@ -394,17 +394,17 @@ bool flipper_format_write_hex( } bool flipper_format_write_comment(FlipperFormat* flipper_format, FuriString* data) { - furi_assert(flipper_format); + furi_check(flipper_format); return flipper_format_write_comment_cstr(flipper_format, furi_string_get_cstr(data)); } bool flipper_format_write_comment_cstr(FlipperFormat* flipper_format, const char* data) { - furi_assert(flipper_format); + furi_check(flipper_format); return flipper_format_stream_write_comment_cstr(flipper_format->stream, data); } bool flipper_format_delete_key(FlipperFormat* flipper_format, const char* key) { - furi_assert(flipper_format); + furi_check(flipper_format); FlipperStreamWriteData write_data = { .key = key, .type = FlipperStreamValueIgnore, @@ -417,7 +417,7 @@ bool flipper_format_delete_key(FlipperFormat* flipper_format, const char* key) { } bool flipper_format_update_string(FlipperFormat* flipper_format, const char* key, FuriString* data) { - furi_assert(flipper_format); + furi_check(flipper_format); FlipperStreamWriteData write_data = { .key = key, .type = FlipperStreamValueStr, @@ -433,7 +433,7 @@ bool flipper_format_update_string_cstr( FlipperFormat* flipper_format, const char* key, const char* data) { - furi_assert(flipper_format); + furi_check(flipper_format); FlipperStreamWriteData write_data = { .key = key, .type = FlipperStreamValueStr, @@ -450,7 +450,7 @@ bool flipper_format_update_uint32( const char* key, const uint32_t* data, const uint16_t data_size) { - furi_assert(flipper_format); + furi_check(flipper_format); FlipperStreamWriteData write_data = { .key = key, .type = FlipperStreamValueUint32, diff --git a/lib/flipper_format/flipper_format.h b/lib/flipper_format/flipper_format.h index 671ff6fa0..c8f5278ed 100644 --- a/lib/flipper_format/flipper_format.h +++ b/lib/flipper_format/flipper_format.h @@ -106,7 +106,7 @@ typedef struct FlipperFormat FlipperFormat; * Allocate FlipperFormat as string. * @return FlipperFormat* pointer to a FlipperFormat instance */ -FlipperFormat* flipper_format_string_alloc(); +FlipperFormat* flipper_format_string_alloc(void); /** * Allocate FlipperFormat as file. diff --git a/lib/ibutton/ibutton_key.c b/lib/ibutton/ibutton_key.c index 926a826a2..cf98ea313 100644 --- a/lib/ibutton/ibutton_key.c +++ b/lib/ibutton/ibutton_key.c @@ -1,4 +1,5 @@ #include "ibutton_key_i.h" +#include struct iButtonKey { iButtonProtocolId protocol_id; @@ -17,20 +18,28 @@ iButtonKey* ibutton_key_alloc(size_t data_size) { } void ibutton_key_free(iButtonKey* key) { + furi_check(key); + free(key->protocol_data); free(key); } void ibutton_key_reset(iButtonKey* key) { + furi_check(key); + key->protocol_id = iButtonProtocolIdInvalid; + memset(key->protocol_data, 0, key->protocol_data_size); } iButtonProtocolId ibutton_key_get_protocol_id(const iButtonKey* key) { + furi_check(key); + return key->protocol_id; } void ibutton_key_set_protocol_id(iButtonKey* key, iButtonProtocolId protocol_id) { + furi_check(key); key->protocol_id = protocol_id; } diff --git a/lib/ibutton/ibutton_protocols.c b/lib/ibutton/ibutton_protocols.c index df7412670..ce4392475 100644 --- a/lib/ibutton/ibutton_protocols.c +++ b/lib/ibutton/ibutton_protocols.c @@ -51,7 +51,7 @@ static void ibutton_protocols_get_group_by_id( furi_crash(); } -iButtonProtocols* ibutton_protocols_alloc() { +iButtonProtocols* ibutton_protocols_alloc(void) { iButtonProtocols* protocols = malloc(sizeof(iButtonProtocols*)); protocols->group_datas = malloc(sizeof(iButtonProtocolGroupData*) * iButtonProtocolGroupMax); @@ -64,6 +64,8 @@ iButtonProtocols* ibutton_protocols_alloc() { } void ibutton_protocols_free(iButtonProtocols* protocols) { + furi_check(protocols); + for(iButtonProtocolGroupId i = 0; i < iButtonProtocolGroupMax; ++i) { ibutton_protocol_groups[i]->free(protocols->group_datas[i]); } @@ -72,7 +74,7 @@ void ibutton_protocols_free(iButtonProtocols* protocols) { free(protocols); } -uint32_t ibutton_protocols_get_protocol_count() { +uint32_t ibutton_protocols_get_protocol_count(void) { uint32_t count = 0; for(iButtonProtocolGroupId i = 0; i < iButtonProtocolGroupMax; ++i) { @@ -83,6 +85,9 @@ uint32_t ibutton_protocols_get_protocol_count() { } iButtonProtocolId ibutton_protocols_get_id_by_name(iButtonProtocols* protocols, const char* name) { + furi_check(protocols); + furi_check(name); + iButtonProtocolLocalId offset = 0; for(iButtonProtocolGroupId i = 0; i < iButtonProtocolGroupMax; ++i) { @@ -96,11 +101,16 @@ iButtonProtocolId ibutton_protocols_get_id_by_name(iButtonProtocols* protocols, } uint32_t ibutton_protocols_get_features(iButtonProtocols* protocols, iButtonProtocolId id) { + furi_check(protocols); + GET_PROTOCOL_GROUP(id); + return GROUP_BASE->get_features(GROUP_DATA, PROTOCOL_ID); } size_t ibutton_protocols_get_max_data_size(iButtonProtocols* protocols) { + furi_check(protocols); + size_t max_size = 0; for(iButtonProtocolGroupId i = 0; i < iButtonProtocolGroupMax; ++i) { @@ -115,16 +125,25 @@ size_t ibutton_protocols_get_max_data_size(iButtonProtocols* protocols) { } const char* ibutton_protocols_get_manufacturer(iButtonProtocols* protocols, iButtonProtocolId id) { + furi_check(protocols); + GET_PROTOCOL_GROUP(id); + return GROUP_BASE->get_manufacturer(GROUP_DATA, PROTOCOL_ID); } const char* ibutton_protocols_get_name(iButtonProtocols* protocols, iButtonProtocolId id) { + furi_check(protocols); + GET_PROTOCOL_GROUP(id); + return GROUP_BASE->get_name(GROUP_DATA, PROTOCOL_ID); } bool ibutton_protocols_read(iButtonProtocols* protocols, iButtonKey* key) { + furi_check(protocols); + furi_check(key); + iButtonProtocolLocalId id = iButtonProtocolIdInvalid; iButtonProtocolData* data = ibutton_key_get_protocol_data(key); @@ -142,6 +161,9 @@ bool ibutton_protocols_read(iButtonProtocols* protocols, iButtonKey* key) { } bool ibutton_protocols_write_blank(iButtonProtocols* protocols, iButtonKey* key) { + furi_check(protocols); + furi_check(key); + const iButtonProtocolId id = ibutton_key_get_protocol_id(key); iButtonProtocolData* data = ibutton_key_get_protocol_data(key); @@ -150,6 +172,9 @@ bool ibutton_protocols_write_blank(iButtonProtocols* protocols, iButtonKey* key) } bool ibutton_protocols_write_copy(iButtonProtocols* protocols, iButtonKey* key) { + furi_check(protocols); + furi_check(key); + const iButtonProtocolId id = ibutton_key_get_protocol_id(key); iButtonProtocolData* data = ibutton_key_get_protocol_data(key); @@ -158,6 +183,9 @@ bool ibutton_protocols_write_copy(iButtonProtocols* protocols, iButtonKey* key) } void ibutton_protocols_emulate_start(iButtonProtocols* protocols, iButtonKey* key) { + furi_check(protocols); + furi_check(key); + const iButtonProtocolId id = ibutton_key_get_protocol_id(key); iButtonProtocolData* data = ibutton_key_get_protocol_data(key); @@ -166,6 +194,9 @@ void ibutton_protocols_emulate_start(iButtonProtocols* protocols, iButtonKey* ke } void ibutton_protocols_emulate_stop(iButtonProtocols* protocols, iButtonKey* key) { + furi_check(protocols); + furi_check(key); + const iButtonProtocolId id = ibutton_key_get_protocol_id(key); iButtonProtocolData* data = ibutton_key_get_protocol_data(key); @@ -177,6 +208,10 @@ bool ibutton_protocols_save( iButtonProtocols* protocols, const iButtonKey* key, const char* file_name) { + furi_check(protocols); + furi_check(key); + furi_check(file_name); + const iButtonProtocolId id = ibutton_key_get_protocol_id(key); const iButtonProtocolData* data = ibutton_key_get_protocol_data(key); @@ -207,6 +242,10 @@ bool ibutton_protocols_save( } bool ibutton_protocols_load(iButtonProtocols* protocols, iButtonKey* key, const char* file_name) { + furi_check(protocols); + furi_check(key); + furi_check(file_name); + iButtonProtocolData* data = ibutton_key_get_protocol_data(key); bool success = false; @@ -252,6 +291,10 @@ void ibutton_protocols_render_data( iButtonProtocols* protocols, const iButtonKey* key, FuriString* result) { + furi_check(protocols); + furi_check(key); + furi_check(result); + const iButtonProtocolId id = ibutton_key_get_protocol_id(key); const iButtonProtocolData* data = ibutton_key_get_protocol_data(key); @@ -263,6 +306,10 @@ void ibutton_protocols_render_brief_data( iButtonProtocols* protocols, const iButtonKey* key, FuriString* result) { + furi_check(protocols); + furi_check(key); + furi_check(result); + const iButtonProtocolId id = ibutton_key_get_protocol_id(key); const iButtonProtocolData* data = ibutton_key_get_protocol_data(key); @@ -274,6 +321,10 @@ void ibutton_protocols_render_error( iButtonProtocols* protocols, const iButtonKey* key, FuriString* result) { + furi_check(protocols); + furi_check(key); + furi_check(result); + const iButtonProtocolId id = ibutton_key_get_protocol_id(key); const iButtonProtocolData* data = ibutton_key_get_protocol_data(key); @@ -282,6 +333,9 @@ void ibutton_protocols_render_error( } bool ibutton_protocols_is_valid(iButtonProtocols* protocols, const iButtonKey* key) { + furi_check(protocols); + furi_check(key); + const iButtonProtocolId id = ibutton_key_get_protocol_id(key); const iButtonProtocolData* data = ibutton_key_get_protocol_data(key); @@ -293,6 +347,10 @@ void ibutton_protocols_get_editable_data( iButtonProtocols* protocols, const iButtonKey* key, iButtonEditableData* editable) { + furi_check(protocols); + furi_check(key); + furi_check(editable); + const iButtonProtocolId id = ibutton_key_get_protocol_id(key); iButtonProtocolData* data = ibutton_key_get_protocol_data(key); @@ -301,6 +359,9 @@ void ibutton_protocols_get_editable_data( } void ibutton_protocols_apply_edits(iButtonProtocols* protocols, const iButtonKey* key) { + furi_check(protocols); + furi_check(key); + const iButtonProtocolId id = ibutton_key_get_protocol_id(key); iButtonProtocolData* data = ibutton_key_get_protocol_data(key); diff --git a/lib/ibutton/ibutton_protocols.h b/lib/ibutton/ibutton_protocols.h index 0e7ed0a80..ec4a9fc72 100644 --- a/lib/ibutton/ibutton_protocols.h +++ b/lib/ibutton/ibutton_protocols.h @@ -23,7 +23,7 @@ typedef struct iButtonProtocols iButtonProtocols; * Allocate an iButtonProtocols object * @return pointer to an iButtonProtocols object */ -iButtonProtocols* ibutton_protocols_alloc(); +iButtonProtocols* ibutton_protocols_alloc(void); /** * Destroy an iButtonProtocols object, free resources @@ -34,7 +34,7 @@ void ibutton_protocols_free(iButtonProtocols* protocols); /** * Get the total number of available protocols */ -uint32_t ibutton_protocols_get_protocol_count(); +uint32_t ibutton_protocols_get_protocol_count(void); /** * Get maximum data size out of all protocols available diff --git a/lib/ibutton/ibutton_worker.c b/lib/ibutton/ibutton_worker.c index d40dba71a..2874f120f 100644 --- a/lib/ibutton/ibutton_worker.c +++ b/lib/ibutton/ibutton_worker.c @@ -23,6 +23,8 @@ typedef struct { static int32_t ibutton_worker_thread(void* thread_context); iButtonWorker* ibutton_worker_alloc(iButtonProtocols* protocols) { + furi_check(protocols); + iButtonWorker* worker = malloc(sizeof(iButtonWorker)); worker->protocols = protocols; @@ -38,7 +40,9 @@ void ibutton_worker_read_set_callback( iButtonWorker* worker, iButtonWorkerReadCallback callback, void* context) { + furi_check(worker); furi_check(worker->mode_index == iButtonWorkerModeIdle); + worker->read_cb = callback; worker->cb_ctx = context; } @@ -47,7 +51,9 @@ void ibutton_worker_write_set_callback( iButtonWorker* worker, iButtonWorkerWriteCallback callback, void* context) { + furi_check(worker); furi_check(worker->mode_index == iButtonWorkerModeIdle); + worker->write_cb = callback; worker->cb_ctx = context; } @@ -56,55 +62,83 @@ void ibutton_worker_emulate_set_callback( iButtonWorker* worker, iButtonWorkerEmulateCallback callback, void* context) { + furi_check(worker); furi_check(worker->mode_index == iButtonWorkerModeIdle); + worker->emulate_cb = callback; worker->cb_ctx = context; } void ibutton_worker_read_start(iButtonWorker* worker, iButtonKey* key) { + furi_check(worker); + iButtonMessage message = {.type = iButtonMessageRead, .data.key = key}; + furi_check( furi_message_queue_put(worker->messages, &message, FuriWaitForever) == FuriStatusOk); } void ibutton_worker_write_blank_start(iButtonWorker* worker, iButtonKey* key) { + furi_check(worker); + furi_check(key); + iButtonMessage message = {.type = iButtonMessageWriteBlank, .data.key = key}; + furi_check( furi_message_queue_put(worker->messages, &message, FuriWaitForever) == FuriStatusOk); } void ibutton_worker_write_copy_start(iButtonWorker* worker, iButtonKey* key) { + furi_check(worker); + furi_check(key); + iButtonMessage message = {.type = iButtonMessageWriteCopy, .data.key = key}; + furi_check( furi_message_queue_put(worker->messages, &message, FuriWaitForever) == FuriStatusOk); } void ibutton_worker_emulate_start(iButtonWorker* worker, iButtonKey* key) { + furi_check(worker); + iButtonMessage message = {.type = iButtonMessageEmulate, .data.key = key}; + furi_check( furi_message_queue_put(worker->messages, &message, FuriWaitForever) == FuriStatusOk); } void ibutton_worker_stop(iButtonWorker* worker) { + furi_check(worker); + iButtonMessage message = {.type = iButtonMessageStop}; + furi_check( furi_message_queue_put(worker->messages, &message, FuriWaitForever) == FuriStatusOk); } void ibutton_worker_free(iButtonWorker* worker) { + furi_check(worker); + furi_message_queue_free(worker->messages); furi_thread_free(worker->thread); + free(worker); } void ibutton_worker_start_thread(iButtonWorker* worker) { + furi_check(worker); + furi_thread_start(worker->thread); } void ibutton_worker_stop_thread(iButtonWorker* worker) { + furi_check(worker); + iButtonMessage message = {.type = iButtonMessageEnd}; + furi_check( furi_message_queue_put(worker->messages, &message, FuriWaitForever) == FuriStatusOk); + furi_thread_join(worker->thread); } diff --git a/lib/ibutton/protocols/dallas/protocol_group_dallas.c b/lib/ibutton/protocols/dallas/protocol_group_dallas.c index 63ec97855..39cabbeb4 100644 --- a/lib/ibutton/protocols/dallas/protocol_group_dallas.c +++ b/lib/ibutton/protocols/dallas/protocol_group_dallas.c @@ -11,7 +11,7 @@ typedef struct { OneWireSlave* bus; } iButtonProtocolGroupDallas; -static iButtonProtocolGroupDallas* ibutton_protocol_group_dallas_alloc() { +static iButtonProtocolGroupDallas* ibutton_protocol_group_dallas_alloc(void) { iButtonProtocolGroupDallas* group = malloc(sizeof(iButtonProtocolGroupDallas)); group->host = onewire_host_alloc(&gpio_ibutton); diff --git a/lib/ibutton/protocols/misc/protocol_group_misc.c b/lib/ibutton/protocols/misc/protocol_group_misc.c index dad1ef3cf..20534602d 100644 --- a/lib/ibutton/protocols/misc/protocol_group_misc.c +++ b/lib/ibutton/protocols/misc/protocol_group_misc.c @@ -16,7 +16,7 @@ typedef struct { ProtocolId emulate_id; } iButtonProtocolGroupMisc; -static iButtonProtocolGroupMisc* ibutton_protocol_group_misc_alloc() { +static iButtonProtocolGroupMisc* ibutton_protocol_group_misc_alloc(void) { iButtonProtocolGroupMisc* group = malloc(sizeof(iButtonProtocolGroupMisc)); group->dict = protocol_dict_alloc(ibutton_protocols_misc, iButtonProtocolMiscMax); diff --git a/lib/infrared/encoder_decoder/infrared.c b/lib/infrared/encoder_decoder/infrared.c index c2e48ac32..8f4c0c872 100644 --- a/lib/infrared/encoder_decoder/infrared.c +++ b/lib/infrared/encoder_decoder/infrared.c @@ -164,7 +164,7 @@ static const InfraredProtocolVariant* infrared_get_variant_by_protocol(InfraredP const InfraredMessage* infrared_decode(InfraredDecoderHandler* handler, bool level, uint32_t duration) { - furi_assert(handler); + furi_check(handler); InfraredMessage* message = NULL; InfraredMessage* result = NULL; @@ -196,8 +196,8 @@ InfraredDecoderHandler* infrared_alloc_decoder(void) { } void infrared_free_decoder(InfraredDecoderHandler* handler) { - furi_assert(handler); - furi_assert(handler->ctx); + furi_check(handler); + furi_check(handler->ctx); for(size_t i = 0; i < COUNT_OF(infrared_encoder_decoder); ++i) { if(infrared_encoder_decoder[i].decoder.free) @@ -209,6 +209,8 @@ void infrared_free_decoder(InfraredDecoderHandler* handler) { } void infrared_reset_decoder(InfraredDecoderHandler* handler) { + furi_check(handler); + for(size_t i = 0; i < COUNT_OF(infrared_encoder_decoder); ++i) { if(infrared_encoder_decoder[i].decoder.reset) infrared_encoder_decoder[i].decoder.reset(handler->ctx[i]); @@ -216,7 +218,7 @@ void infrared_reset_decoder(InfraredDecoderHandler* handler) { } const InfraredMessage* infrared_check_decoder_ready(InfraredDecoderHandler* handler) { - furi_assert(handler); + furi_check(handler); InfraredMessage* message = NULL; InfraredMessage* result = NULL; @@ -241,13 +243,13 @@ InfraredEncoderHandler* infrared_alloc_encoder(void) { } void infrared_free_encoder(InfraredEncoderHandler* handler) { - furi_assert(handler); + furi_check(handler); const InfraredEncoders* encoder = handler->encoder; if(encoder || handler->handler) { - furi_assert(encoder); - furi_assert(handler->handler); - furi_assert(encoder->free); + furi_check(encoder); + furi_check(handler->handler); + furi_check(encoder->free); encoder->free(handler->handler); } @@ -265,20 +267,20 @@ static int infrared_find_index_by_protocol(InfraredProtocol protocol) { } void infrared_reset_encoder(InfraredEncoderHandler* handler, const InfraredMessage* message) { - furi_assert(handler); - furi_assert(message); + furi_check(handler); + furi_check(message); int index = infrared_find_index_by_protocol(message->protocol); furi_check(index >= 0); const InfraredEncoders* required_encoder = &infrared_encoder_decoder[index].encoder; - furi_assert(required_encoder); - furi_assert(required_encoder->reset); - furi_assert(required_encoder->alloc); + furi_check(required_encoder); + furi_check(required_encoder->reset); + furi_check(required_encoder->alloc); /* Realloc encoder if different protocol set */ if(required_encoder != handler->encoder) { if(handler->handler != NULL) { - furi_assert(handler->encoder->free); + furi_check(handler->encoder->free); handler->encoder->free(handler->handler); } handler->encoder = required_encoder; @@ -289,15 +291,16 @@ void infrared_reset_encoder(InfraredEncoderHandler* handler, const InfraredMessa } InfraredStatus infrared_encode(InfraredEncoderHandler* handler, uint32_t* duration, bool* level) { - furi_assert(handler); - furi_assert(duration); - furi_assert(level); + furi_check(handler); + furi_check(duration); + furi_check(level); + const InfraredEncoders* encoder = handler->encoder; - furi_assert(encoder); - furi_assert(encoder->encode); + furi_check(encoder); + furi_check(encoder->encode); InfraredStatus status = encoder->encode(handler->handler, duration, level); - furi_assert(status != InfraredStatusError); + furi_check(status != InfraredStatusError); return status; } @@ -307,6 +310,8 @@ bool infrared_is_protocol_valid(InfraredProtocol protocol) { } InfraredProtocol infrared_get_protocol_by_name(const char* protocol_name) { + furi_check(protocol_name); + for(InfraredProtocol protocol = 0; protocol < InfraredProtocolMAX; ++protocol) { const char* name = infrared_get_protocol_name(protocol); if(!strcmp(name, protocol_name)) return protocol; @@ -321,7 +326,7 @@ static const InfraredProtocolVariant* infrared_get_variant_by_protocol(InfraredP variant = infrared_encoder_decoder[index].get_protocol_variant(protocol); } - furi_assert(variant); + furi_check(variant); return variant; } diff --git a/lib/infrared/worker/infrared_transmit.c b/lib/infrared/worker/infrared_transmit.c index 8f99c0066..5756da651 100644 --- a/lib/infrared/worker/infrared_transmit.c +++ b/lib/infrared/worker/infrared_transmit.c @@ -42,7 +42,7 @@ void infrared_send_raw_ext( bool start_from_mark, uint32_t frequency, float duty_cycle) { - furi_assert(timings); + furi_check(timings); infrared_tx_raw_start_from_mark = start_from_mark; infrared_tx_raw_timings_index = 0; @@ -53,7 +53,7 @@ void infrared_send_raw_ext( furi_hal_infrared_async_tx_start(frequency, duty_cycle); furi_hal_infrared_async_tx_wait_termination(); - furi_assert(!furi_hal_infrared_is_busy()); + furi_check(!furi_hal_infrared_is_busy()); } void infrared_send_raw(const uint32_t timings[], uint32_t timings_cnt, bool start_from_mark) { @@ -95,9 +95,9 @@ FuriHalInfraredTxGetDataState } void infrared_send(const InfraredMessage* message, int times) { - furi_assert(message); - furi_assert(times); - furi_assert(infrared_is_protocol_valid(message->protocol)); + furi_check(message); + furi_check(times); + furi_check(infrared_is_protocol_valid(message->protocol)); InfraredEncoderHandler* handler = infrared_alloc_encoder(); infrared_reset_encoder(handler, message); @@ -113,5 +113,5 @@ void infrared_send(const InfraredMessage* message, int times) { infrared_free_encoder(handler); - furi_assert(!furi_hal_infrared_is_busy()); + furi_check(!furi_hal_infrared_is_busy()); } diff --git a/lib/infrared/worker/infrared_worker.c b/lib/infrared/worker/infrared_worker.c index 38392fc06..a867542e0 100644 --- a/lib/infrared/worker/infrared_worker.c +++ b/lib/infrared/worker/infrared_worker.c @@ -217,12 +217,13 @@ void infrared_worker_rx_set_received_signal_callback( InfraredWorker* instance, InfraredWorkerReceivedSignalCallback callback, void* context) { - furi_assert(instance); + furi_check(instance); + instance->rx.received_signal_callback = callback; instance->rx.received_signal_context = context; } -InfraredWorker* infrared_worker_alloc() { +InfraredWorker* infrared_worker_alloc(void) { InfraredWorker* instance = malloc(sizeof(InfraredWorker)); instance->thread = furi_thread_alloc_ex("InfraredWorker", 2048, NULL, instance); @@ -242,8 +243,8 @@ InfraredWorker* infrared_worker_alloc() { } void infrared_worker_free(InfraredWorker* instance) { - furi_assert(instance); - furi_assert(instance->state == InfraredWorkerStateIdle); + furi_check(instance); + furi_check(instance->state == InfraredWorkerStateIdle); furi_record_close(RECORD_NOTIFICATION); infrared_free_decoder(instance->infrared_decoder); @@ -255,8 +256,8 @@ void infrared_worker_free(InfraredWorker* instance) { } void infrared_worker_rx_start(InfraredWorker* instance) { - furi_assert(instance); - furi_assert(instance->state == InfraredWorkerStateIdle); + furi_check(instance); + furi_check(instance->state == InfraredWorkerStateIdle); furi_stream_set_trigger_level(instance->stream, sizeof(LevelDuration)); @@ -274,8 +275,8 @@ void infrared_worker_rx_start(InfraredWorker* instance) { } void infrared_worker_rx_stop(InfraredWorker* instance) { - furi_assert(instance); - furi_assert(instance->state == InfraredWorkerStateRunRx); + furi_check(instance); + furi_check(instance->state == InfraredWorkerStateRunRx); furi_hal_infrared_async_rx_set_timeout_isr_callback(NULL, NULL); furi_hal_infrared_async_rx_set_capture_isr_callback(NULL, NULL); @@ -284,15 +285,14 @@ void infrared_worker_rx_stop(InfraredWorker* instance) { furi_thread_flags_set(furi_thread_get_id(instance->thread), INFRARED_WORKER_EXIT); furi_thread_join(instance->thread); - FuriStatus status = furi_stream_buffer_reset(instance->stream); - furi_assert(status == FuriStatusOk); - (void)status; + furi_check(furi_stream_buffer_reset(instance->stream) == FuriStatusOk); instance->state = InfraredWorkerStateIdle; } bool infrared_worker_signal_is_decoded(const InfraredWorkerSignal* signal) { - furi_assert(signal); + furi_check(signal); + return signal->decoded; } @@ -300,33 +300,36 @@ void infrared_worker_get_raw_signal( const InfraredWorkerSignal* signal, const uint32_t** timings, size_t* timings_cnt) { - furi_assert(signal); - furi_assert(timings); - furi_assert(timings_cnt); + furi_check(signal); + furi_check(timings); + furi_check(timings_cnt); *timings = signal->raw.timings; *timings_cnt = signal->timings_cnt; } const InfraredMessage* infrared_worker_get_decoded_signal(const InfraredWorkerSignal* signal) { - furi_assert(signal); + furi_check(signal); + return &signal->message; } void infrared_worker_rx_enable_blink_on_receiving(InfraredWorker* instance, bool enable) { - furi_assert(instance); + furi_check(instance); + instance->blink_enable = enable; } void infrared_worker_rx_enable_signal_decoding(InfraredWorker* instance, bool enable) { - furi_assert(instance); + furi_check(instance); + instance->decode_enable = enable; } void infrared_worker_tx_start(InfraredWorker* instance) { - furi_assert(instance); - furi_assert(instance->state == InfraredWorkerStateIdle); - furi_assert(instance->tx.get_signal_callback); + furi_check(instance); + furi_check(instance->state == InfraredWorkerStateIdle); + furi_check(instance->tx.get_signal_callback); // size have to be greater than api hal infrared async tx buffer size furi_stream_set_trigger_level(instance->stream, sizeof(InfraredWorkerTiming)); @@ -560,7 +563,8 @@ void infrared_worker_tx_set_get_signal_callback( InfraredWorker* instance, InfraredWorkerGetSignalCallback callback, void* context) { - furi_assert(instance); + furi_check(instance); + instance->tx.get_signal_callback = callback; instance->tx.get_signal_context = context; } @@ -569,14 +573,15 @@ void infrared_worker_tx_set_signal_sent_callback( InfraredWorker* instance, InfraredWorkerMessageSentCallback callback, void* context) { - furi_assert(instance); + furi_check(instance); + instance->tx.message_sent_callback = callback; instance->tx.message_sent_context = context; } void infrared_worker_tx_stop(InfraredWorker* instance) { - furi_assert(instance); - furi_assert(instance->state != InfraredWorkerStateRunRx); + furi_check(instance); + furi_check(instance->state != InfraredWorkerStateRunRx); furi_thread_flags_set(furi_thread_get_id(instance->thread), INFRARED_WORKER_EXIT); furi_thread_join(instance->thread); @@ -584,15 +589,14 @@ void infrared_worker_tx_stop(InfraredWorker* instance) { furi_hal_infrared_async_tx_set_signal_sent_isr_callback(NULL, NULL); instance->signal.timings_cnt = 0; - FuriStatus status = furi_stream_buffer_reset(instance->stream); - furi_assert(status == FuriStatusOk); - (void)status; + furi_check(furi_stream_buffer_reset(instance->stream) == FuriStatusOk); + instance->state = InfraredWorkerStateIdle; } void infrared_worker_set_decoded_signal(InfraredWorker* instance, const InfraredMessage* message) { - furi_assert(instance); - furi_assert(message); + furi_check(instance); + furi_check(message); instance->signal.decoded = true; instance->signal.message = *message; @@ -604,11 +608,12 @@ void infrared_worker_set_raw_signal( size_t timings_cnt, uint32_t frequency, float duty_cycle) { - furi_assert(instance); - furi_assert(timings); - furi_assert(timings_cnt > 0); - furi_assert((frequency <= INFRARED_MAX_FREQUENCY) && (frequency >= INFRARED_MIN_FREQUENCY)); - furi_assert((duty_cycle < 1.0f) && (duty_cycle > 0.0f)); + furi_check(instance); + furi_check(timings); + furi_check(timings_cnt > 0); + furi_check((frequency <= INFRARED_MAX_FREQUENCY) && (frequency >= INFRARED_MIN_FREQUENCY)); + furi_check((duty_cycle < 1.0f) && (duty_cycle > 0.0f)); + size_t max_copy_num = COUNT_OF(instance->signal.raw.timings) - 1; furi_check(timings_cnt <= max_copy_num); @@ -623,6 +628,8 @@ void infrared_worker_set_raw_signal( InfraredWorkerGetSignalResponse infrared_worker_tx_get_signal_steady_callback(void* context, InfraredWorker* instance) { UNUSED(context); + furi_check(instance); + InfraredWorkerGetSignalResponse response = instance->tx.steady_signal_sent ? InfraredWorkerGetSignalResponseSame : InfraredWorkerGetSignalResponseNew; diff --git a/lib/infrared/worker/infrared_worker.h b/lib/infrared/worker/infrared_worker.h index e0e861983..2edb19227 100644 --- a/lib/infrared/worker/infrared_worker.h +++ b/lib/infrared/worker/infrared_worker.h @@ -37,7 +37,7 @@ typedef void ( * * @return just created instance of InfraredWorker */ -InfraredWorker* infrared_worker_alloc(); +InfraredWorker* infrared_worker_alloc(void); /** Free InfraredWorker * diff --git a/lib/lfrfid/lfrfid_dict_file.c b/lib/lfrfid/lfrfid_dict_file.c index 33a3b09db..367150812 100644 --- a/lib/lfrfid/lfrfid_dict_file.c +++ b/lib/lfrfid/lfrfid_dict_file.c @@ -6,7 +6,10 @@ #define LFRFID_DICT_FILETYPE "Flipper RFID key" bool lfrfid_dict_file_save(ProtocolDict* dict, ProtocolId protocol, const char* filename) { + furi_check(dict); furi_check(protocol != PROTOCOL_NO); + furi_check(filename); + Storage* storage = furi_record_open(RECORD_STORAGE); FlipperFormat* file = flipper_format_file_alloc(storage); size_t data_size = protocol_dict_get_data_size(dict, protocol); @@ -139,6 +142,9 @@ static ProtocolId lfrfid_dict_protocol_fallback( } ProtocolId lfrfid_dict_file_load(ProtocolDict* dict, const char* filename) { + furi_check(dict); + furi_check(filename); + Storage* storage = furi_record_open(RECORD_STORAGE); FlipperFormat* file = flipper_format_file_alloc(storage); ProtocolId result = PROTOCOL_NO; diff --git a/lib/lfrfid/lfrfid_raw_file.c b/lib/lfrfid/lfrfid_raw_file.c index ca29770f1..441cf7333 100644 --- a/lib/lfrfid/lfrfid_raw_file.c +++ b/lib/lfrfid/lfrfid_raw_file.c @@ -26,6 +26,8 @@ struct LFRFIDRawFile { }; LFRFIDRawFile* lfrfid_raw_file_alloc(Storage* storage) { + furi_check(storage); + LFRFIDRawFile* file = malloc(sizeof(LFRFIDRawFile)); file->stream = file_stream_alloc(storage); file->buffer = NULL; @@ -33,16 +35,24 @@ LFRFIDRawFile* lfrfid_raw_file_alloc(Storage* storage) { } void lfrfid_raw_file_free(LFRFIDRawFile* file) { + furi_check(file); + if(file->buffer) free(file->buffer); stream_free(file->stream); free(file); } bool lfrfid_raw_file_open_write(LFRFIDRawFile* file, const char* file_path) { + furi_check(file); + furi_check(file_path); + return file_stream_open(file->stream, file_path, FSAM_READ_WRITE, FSOM_CREATE_ALWAYS); } bool lfrfid_raw_file_open_read(LFRFIDRawFile* file, const char* file_path) { + furi_check(file); + furi_check(file_path); + return file_stream_open(file->stream, file_path, FSAM_READ, FSOM_OPEN_EXISTING); } @@ -51,6 +61,8 @@ bool lfrfid_raw_file_write_header( float frequency, float duty_cycle, uint32_t max_buffer_size) { + furi_check(file); + LFRFIDRawFileHeader header = { .magic = LFRFID_RAW_FILE_MAGIC, .version = LFRFID_RAW_FILE_VERSION, @@ -63,6 +75,10 @@ bool lfrfid_raw_file_write_header( } bool lfrfid_raw_file_write_buffer(LFRFIDRawFile* file, uint8_t* buffer_data, size_t buffer_size) { + furi_check(file); + furi_check(buffer_data); + furi_check(buffer_size); + size_t size; size = stream_write(file->stream, (uint8_t*)&buffer_size, sizeof(size_t)); if(size != sizeof(size_t)) return false; @@ -74,6 +90,10 @@ bool lfrfid_raw_file_write_buffer(LFRFIDRawFile* file, uint8_t* buffer_data, siz } bool lfrfid_raw_file_read_header(LFRFIDRawFile* file, float* frequency, float* duty_cycle) { + furi_check(file); + furi_check(frequency); + furi_check(duty_cycle); + LFRFIDRawFileHeader header; size_t size = stream_read(file->stream, (uint8_t*)&header, sizeof(LFRFIDRawFileHeader)); if(size == sizeof(LFRFIDRawFileHeader)) { @@ -98,6 +118,10 @@ bool lfrfid_raw_file_read_pair( uint32_t* duration, uint32_t* pulse, bool* pass_end) { + furi_check(file); + furi_check(duration); + furi_check(pulse); + size_t length = 0; if(file->buffer_counter >= file->buffer_size) { if(stream_eof(file->stream)) { diff --git a/lib/lfrfid/lfrfid_raw_worker.c b/lib/lfrfid/lfrfid_raw_worker.c index 344c2afa2..7c04b9dfa 100644 --- a/lib/lfrfid/lfrfid_raw_worker.c +++ b/lib/lfrfid/lfrfid_raw_worker.c @@ -58,21 +58,23 @@ typedef enum { static int32_t lfrfid_raw_read_worker_thread(void* thread_context); static int32_t lfrfid_raw_emulate_worker_thread(void* thread_context); -LFRFIDRawWorker* lfrfid_raw_worker_alloc() { +LFRFIDRawWorker* lfrfid_raw_worker_alloc(void) { LFRFIDRawWorker* worker = malloc(sizeof(LFRFIDRawWorker)); worker->thread = furi_thread_alloc_ex("LfrfidRawWorker", 2048, NULL, worker); - - worker->events = furi_event_flag_alloc(NULL); - + worker->events = furi_event_flag_alloc(); worker->file_path = furi_string_alloc(); + return worker; } void lfrfid_raw_worker_free(LFRFIDRawWorker* worker) { + furi_check(worker); + furi_thread_free(worker->thread); furi_event_flag_free(worker->events); furi_string_free(worker->file_path); + free(worker); } @@ -83,6 +85,8 @@ void lfrfid_raw_worker_start_read( float duty_cycle, LFRFIDWorkerReadRawCallback callback, void* context) { + furi_check(worker); + furi_check(file_path); furi_check(furi_thread_get_state(worker->thread) == FuriThreadStateStopped); furi_string_set(worker->file_path, file_path); @@ -102,7 +106,10 @@ void lfrfid_raw_worker_start_emulate( const char* file_path, LFRFIDWorkerEmulateRawCallback callback, void* context) { + furi_check(worker); + furi_check(file_path); furi_check(furi_thread_get_state(worker->thread) == FuriThreadStateStopped); + furi_string_set(worker->file_path, file_path); worker->emulate_callback = callback; worker->context = context; @@ -111,6 +118,8 @@ void lfrfid_raw_worker_start_emulate( } void lfrfid_raw_worker_stop(LFRFIDRawWorker* worker) { + furi_check(worker); + worker->emulate_callback = NULL; worker->context = NULL; worker->read_callback = NULL; diff --git a/lib/lfrfid/lfrfid_raw_worker.h b/lib/lfrfid/lfrfid_raw_worker.h index 1195dd587..e145dcaa3 100644 --- a/lib/lfrfid/lfrfid_raw_worker.h +++ b/lib/lfrfid/lfrfid_raw_worker.h @@ -15,7 +15,7 @@ typedef struct LFRFIDRawWorker LFRFIDRawWorker; * * @return LFRFIDRawWorker* */ -LFRFIDRawWorker* lfrfid_raw_worker_alloc(); +LFRFIDRawWorker* lfrfid_raw_worker_alloc(void); /** * @brief Free a LFRFIDRawWorker instance diff --git a/lib/lfrfid/lfrfid_worker.c b/lib/lfrfid/lfrfid_worker.c index 7fda36f0b..9554957f1 100644 --- a/lib/lfrfid/lfrfid_worker.c +++ b/lib/lfrfid/lfrfid_worker.c @@ -21,7 +21,7 @@ typedef enum { static int32_t lfrfid_worker_thread(void* thread_context); LFRFIDWorker* lfrfid_worker_alloc(ProtocolDict* dict) { - furi_assert(dict); + furi_check(dict); LFRFIDWorker* worker = malloc(sizeof(LFRFIDWorker)); worker->mode_index = LFRFIDWorkerIdle; @@ -39,6 +39,8 @@ LFRFIDWorker* lfrfid_worker_alloc(ProtocolDict* dict) { } void lfrfid_worker_free(LFRFIDWorker* worker) { + furi_check(worker); + if(worker->raw_filename) { free(worker->raw_filename); } @@ -52,7 +54,9 @@ void lfrfid_worker_read_start( LFRFIDWorkerReadType type, LFRFIDWorkerReadCallback callback, void* context) { - furi_assert(worker->mode_index == LFRFIDWorkerIdle); + furi_check(worker); + furi_check(worker->mode_index == LFRFIDWorkerIdle); + worker->read_type = type; worker->read_cb = callback; worker->cb_ctx = context; @@ -64,7 +68,7 @@ void lfrfid_worker_write_start( LFRFIDProtocol protocol, LFRFIDWorkerWriteCallback callback, void* context) { - furi_assert(worker->mode_index == LFRFIDWorkerIdle); + furi_check(worker->mode_index == LFRFIDWorkerIdle); worker->protocol = protocol; worker->write_cb = callback; worker->cb_ctx = context; @@ -84,7 +88,9 @@ void lfrfid_worker_write_and_set_pass_start( } void lfrfid_worker_emulate_start(LFRFIDWorker* worker, LFRFIDProtocol protocol) { - furi_assert(worker->mode_index == LFRFIDWorkerIdle); + furi_check(worker); + furi_check(worker->mode_index == LFRFIDWorkerIdle); + worker->protocol = protocol; furi_thread_flags_set(furi_thread_get_id(worker->thread), LFRFIDEventEmulate); } @@ -103,7 +109,9 @@ void lfrfid_worker_read_raw_start( LFRFIDWorkerReadType type, LFRFIDWorkerReadRawCallback callback, void* context) { - furi_assert(worker->mode_index == LFRFIDWorkerIdle); + furi_check(worker); + furi_check(worker->mode_index == LFRFIDWorkerIdle); + worker->read_type = type; worker->read_raw_cb = callback; worker->cb_ctx = context; @@ -116,7 +124,9 @@ void lfrfid_worker_emulate_raw_start( const char* filename, LFRFIDWorkerEmulateRawCallback callback, void* context) { - furi_assert(worker->mode_index == LFRFIDWorkerIdle); + furi_check(worker); + furi_check(worker->mode_index == LFRFIDWorkerIdle); + lfrfid_worker_set_filename(worker, filename); worker->emulate_raw_cb = callback; worker->cb_ctx = context; @@ -124,14 +134,20 @@ void lfrfid_worker_emulate_raw_start( } void lfrfid_worker_stop(LFRFIDWorker* worker) { + furi_check(worker); + furi_thread_flags_set(furi_thread_get_id(worker->thread), LFRFIDEventStopMode); } void lfrfid_worker_start_thread(LFRFIDWorker* worker) { + furi_check(worker); + furi_thread_start(worker->thread); } void lfrfid_worker_stop_thread(LFRFIDWorker* worker) { + furi_check(worker); + furi_thread_flags_set(furi_thread_get_id(worker->thread), LFRFIDEventStopThread); furi_thread_join(worker->thread); } diff --git a/lib/lfrfid/tools/t5577.c b/lib/lfrfid/tools/t5577.c index 4b24b742a..483762ff6 100644 --- a/lib/lfrfid/tools/t5577.c +++ b/lib/lfrfid/tools/t5577.c @@ -17,14 +17,14 @@ #define T5577_BLOCKS_IN_PAGE_0 8 #define T5577_BLOCKS_IN_PAGE_1 4 -static void t5577_start() { +static void t5577_start(void) { furi_hal_rfid_tim_read_start(125000, 0.5); // do not ground the antenna furi_hal_rfid_pin_pull_release(); } -static void t5577_stop() { +static void t5577_stop(void) { furi_hal_rfid_tim_read_stop(); furi_hal_rfid_pins_reset(); } @@ -49,7 +49,7 @@ static void t5577_write_opcode(uint8_t value) { t5577_write_bit((value >> 0) & 1); } -static void t5577_write_reset() { +static void t5577_write_reset(void) { t5577_write_gap(T5577_TIMING_START_GAP); t5577_write_bit(1); t5577_write_bit(0); diff --git a/lib/lfrfid/tools/varint_pair.c b/lib/lfrfid/tools/varint_pair.c index 1e6c82eee..48e0e4a13 100644 --- a/lib/lfrfid/tools/varint_pair.c +++ b/lib/lfrfid/tools/varint_pair.c @@ -8,7 +8,7 @@ struct VarintPair { uint8_t data[VARINT_PAIR_SIZE]; }; -VarintPair* varint_pair_alloc() { +VarintPair* varint_pair_alloc(void) { VarintPair* pair = malloc(sizeof(VarintPair)); pair->data_length = 0; return pair; diff --git a/lib/lfrfid/tools/varint_pair.h b/lib/lfrfid/tools/varint_pair.h index 3c8386423..12697a7a6 100644 --- a/lib/lfrfid/tools/varint_pair.h +++ b/lib/lfrfid/tools/varint_pair.h @@ -15,7 +15,7 @@ typedef struct VarintPair VarintPair; * VarintPair is a buffer that holds pair of varint values * @return VarintPair* */ -VarintPair* varint_pair_alloc(); +VarintPair* varint_pair_alloc(void); /** * @brief Free a VarintPair instance diff --git a/lib/music_worker/music_worker.c b/lib/music_worker/music_worker.c index 279d12673..3225134b7 100644 --- a/lib/music_worker/music_worker.c +++ b/lib/music_worker/music_worker.c @@ -97,7 +97,7 @@ static int32_t music_worker_thread_callback(void* context) { return 0; } -MusicWorker* music_worker_alloc() { +MusicWorker* music_worker_alloc(void) { MusicWorker* instance = malloc(sizeof(MusicWorker)); NoteBlockArray_init(instance->notes); diff --git a/lib/music_worker/music_worker.h b/lib/music_worker/music_worker.h index 5a7cb4936..26c5dee0a 100644 --- a/lib/music_worker/music_worker.h +++ b/lib/music_worker/music_worker.h @@ -12,7 +12,7 @@ typedef void (*MusicWorkerCallback)( typedef struct MusicWorker MusicWorker; -MusicWorker* music_worker_alloc(); +MusicWorker* music_worker_alloc(void); void music_worker_clear(MusicWorker* instance); diff --git a/lib/nfc/helpers/iso13239_crc.c b/lib/nfc/helpers/iso13239_crc.c index c54fbcfb2..c1affba46 100644 --- a/lib/nfc/helpers/iso13239_crc.c +++ b/lib/nfc/helpers/iso13239_crc.c @@ -33,6 +33,8 @@ static uint16_t } void iso13239_crc_append(Iso13239CrcType type, BitBuffer* buf) { + furi_check(buf); + const uint8_t* data = bit_buffer_get_data(buf); const size_t data_size = bit_buffer_get_size_bytes(buf); @@ -41,6 +43,8 @@ void iso13239_crc_append(Iso13239CrcType type, BitBuffer* buf) { } bool iso13239_crc_check(Iso13239CrcType type, const BitBuffer* buf) { + furi_check(buf); + const size_t data_size = bit_buffer_get_size_bytes(buf); if(data_size <= ISO13239_CRC_SIZE) return false; @@ -55,6 +59,8 @@ bool iso13239_crc_check(Iso13239CrcType type, const BitBuffer* buf) { } void iso13239_crc_trim(BitBuffer* buf) { + furi_check(buf); + const size_t data_size = bit_buffer_get_size_bytes(buf); furi_assert(data_size > ISO13239_CRC_SIZE); diff --git a/lib/nfc/helpers/iso14443_4_layer.c b/lib/nfc/helpers/iso14443_4_layer.c index b21e22423..87d820d64 100644 --- a/lib/nfc/helpers/iso14443_4_layer.c +++ b/lib/nfc/helpers/iso14443_4_layer.c @@ -29,7 +29,7 @@ static inline void iso14443_4_layer_update_pcb(Iso14443_4Layer* instance) { instance->pcb ^= (uint8_t)0x01; } -Iso14443_4Layer* iso14443_4_layer_alloc() { +Iso14443_4Layer* iso14443_4_layer_alloc(void) { Iso14443_4Layer* instance = malloc(sizeof(Iso14443_4Layer)); iso14443_4_layer_reset(instance); diff --git a/lib/nfc/helpers/iso14443_4_layer.h b/lib/nfc/helpers/iso14443_4_layer.h index 14e435c2f..f4f8db520 100644 --- a/lib/nfc/helpers/iso14443_4_layer.h +++ b/lib/nfc/helpers/iso14443_4_layer.h @@ -9,7 +9,7 @@ extern "C" { typedef struct Iso14443_4Layer Iso14443_4Layer; -Iso14443_4Layer* iso14443_4_layer_alloc(); +Iso14443_4Layer* iso14443_4_layer_alloc(void); void iso14443_4_layer_free(Iso14443_4Layer* instance); diff --git a/lib/nfc/helpers/iso14443_crc.c b/lib/nfc/helpers/iso14443_crc.c index fda9871aa..33789bd71 100644 --- a/lib/nfc/helpers/iso14443_crc.c +++ b/lib/nfc/helpers/iso14443_crc.c @@ -28,6 +28,8 @@ static uint16_t } void iso14443_crc_append(Iso14443CrcType type, BitBuffer* buf) { + furi_check(buf); + const uint8_t* data = bit_buffer_get_data(buf); const size_t data_size = bit_buffer_get_size_bytes(buf); @@ -36,6 +38,8 @@ void iso14443_crc_append(Iso14443CrcType type, BitBuffer* buf) { } bool iso14443_crc_check(Iso14443CrcType type, const BitBuffer* buf) { + furi_check(buf); + const size_t data_size = bit_buffer_get_size_bytes(buf); if(data_size <= ISO14443_CRC_SIZE) return false; @@ -50,8 +54,9 @@ bool iso14443_crc_check(Iso14443CrcType type, const BitBuffer* buf) { } void iso14443_crc_trim(BitBuffer* buf) { + furi_check(buf); const size_t data_size = bit_buffer_get_size_bytes(buf); - furi_assert(data_size > ISO14443_CRC_SIZE); + furi_check(data_size > ISO14443_CRC_SIZE); bit_buffer_set_size_bytes(buf, data_size - ISO14443_CRC_SIZE); } diff --git a/lib/nfc/helpers/nfc_data_generator.c b/lib/nfc/helpers/nfc_data_generator.c index 0ecccc3ac..c10e8fd94 100644 --- a/lib/nfc/helpers/nfc_data_generator.c +++ b/lib/nfc/helpers/nfc_data_generator.c @@ -552,9 +552,14 @@ static const NfcDataGenerator nfc_data_generator[NfcDataGeneratorTypeNum] = { }; const char* nfc_data_generator_get_name(NfcDataGeneratorType type) { + furi_check(type < NfcDataGeneratorTypeNum); + return nfc_data_generator[type].name; } void nfc_data_generator_fill_data(NfcDataGeneratorType type, NfcDevice* nfc_device) { + furi_check(type < NfcDataGeneratorTypeNum); + furi_check(nfc_device); + nfc_data_generator[type].handler(nfc_device); } diff --git a/lib/nfc/helpers/nfc_util.c b/lib/nfc/helpers/nfc_util.c index 7bbc9d621..31ade8fc7 100644 --- a/lib/nfc/helpers/nfc_util.c +++ b/lib/nfc/helpers/nfc_util.c @@ -25,8 +25,8 @@ uint8_t nfc_util_odd_parity8(uint8_t data) { } void nfc_util_odd_parity(const uint8_t* src, uint8_t* dst, uint8_t len) { - furi_assert(src); - furi_assert(dst); + furi_check(src); + furi_check(dst); uint8_t parity = 0; uint8_t bit = 0; diff --git a/lib/nfc/nfc.c b/lib/nfc/nfc.c index 22a21c9d2..59d254592 100644 --- a/lib/nfc/nfc.c +++ b/lib/nfc/nfc.c @@ -235,7 +235,7 @@ static int32_t nfc_worker_poller(void* context) { return 0; } -Nfc* nfc_alloc() { +Nfc* nfc_alloc(void) { furi_check(furi_hal_nfc_acquire() == FuriHalNfcErrorNone); Nfc* instance = malloc(sizeof(Nfc)); @@ -253,8 +253,8 @@ Nfc* nfc_alloc() { } void nfc_free(Nfc* instance) { - furi_assert(instance); - furi_assert(instance->state == NfcStateIdle); + furi_check(instance); + furi_check(instance->state == NfcStateIdle); furi_thread_free(instance->worker_thread); free(instance); @@ -263,10 +263,10 @@ void nfc_free(Nfc* instance) { } void nfc_config(Nfc* instance, NfcMode mode, NfcTech tech) { - furi_assert(instance); - furi_assert(mode < NfcModeNum); - furi_assert(tech < NfcTechNum); - furi_assert(instance->config_state == NfcConfigurationStateIdle); + furi_check(instance); + furi_check(mode < NfcModeNum); + furi_check(tech < NfcTechNum); + furi_check(instance->config_state == NfcConfigurationStateIdle); FuriHalNfcTech hal_tech = nfc_tech_table[mode][tech]; if(hal_tech == FuriHalNfcTechInvalid) { @@ -282,35 +282,35 @@ void nfc_config(Nfc* instance, NfcMode mode, NfcTech tech) { } void nfc_set_fdt_poll_fc(Nfc* instance, uint32_t fdt_poll_fc) { - furi_assert(instance); + furi_check(instance); instance->fdt_poll_fc = fdt_poll_fc; } void nfc_set_fdt_listen_fc(Nfc* instance, uint32_t fdt_listen_fc) { - furi_assert(instance); + furi_check(instance); instance->fdt_listen_fc = fdt_listen_fc; } void nfc_set_fdt_poll_poll_us(Nfc* instance, uint32_t fdt_poll_poll_us) { - furi_assert(instance); + furi_check(instance); instance->fdt_poll_poll_us = fdt_poll_poll_us; } void nfc_set_guard_time_us(Nfc* instance, uint32_t guard_time_us) { - furi_assert(instance); + furi_check(instance); instance->guard_time_us = guard_time_us; } void nfc_set_mask_receive_time_fc(Nfc* instance, uint32_t mask_rx_time_fc) { - furi_assert(instance); + furi_check(instance); instance->mask_rx_time_fc = mask_rx_time_fc; } void nfc_start(Nfc* instance, NfcEventCallback callback, void* context) { - furi_assert(instance); - furi_assert(instance->worker_thread); - furi_assert(callback); - furi_assert(instance->config_state == NfcConfigurationStateDone); + furi_check(instance); + furi_check(instance->worker_thread); + furi_check(callback); + furi_check(instance->config_state == NfcConfigurationStateDone); instance->callback = callback; instance->context = context; @@ -324,8 +324,8 @@ void nfc_start(Nfc* instance, NfcEventCallback callback, void* context) { } void nfc_stop(Nfc* instance) { - furi_assert(instance); - furi_assert(instance->state == NfcStateRunning); + furi_check(instance); + furi_check(instance->state == NfcStateRunning); if(instance->mode == NfcModeListener) { furi_hal_nfc_abort(); @@ -336,8 +336,8 @@ void nfc_stop(Nfc* instance) { } NfcError nfc_listener_tx(Nfc* instance, const BitBuffer* tx_buffer) { - furi_assert(instance); - furi_assert(tx_buffer); + furi_check(instance); + furi_check(tx_buffer); NfcError ret = NfcErrorNone; @@ -409,11 +409,11 @@ NfcError nfc_iso14443a_poller_trx_custom_parity( const BitBuffer* tx_buffer, BitBuffer* rx_buffer, uint32_t fwt) { - furi_assert(instance); - furi_assert(tx_buffer); - furi_assert(rx_buffer); + furi_check(instance); + furi_check(tx_buffer); + furi_check(rx_buffer); - furi_assert(instance->poller_state == NfcPollerStateReady); + furi_check(instance->poller_state == NfcPollerStateReady); NfcError ret = NfcErrorNone; FuriHalNfcError error = FuriHalNfcErrorNone; @@ -462,11 +462,11 @@ NfcError nfc_iso14443a_poller_trx_custom_parity( 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_check(instance); + furi_check(tx_buffer); + furi_check(rx_buffer); - furi_assert(instance->poller_state == NfcPollerStateReady); + furi_check(instance->poller_state == NfcPollerStateReady); NfcError ret = NfcErrorNone; FuriHalNfcError error = FuriHalNfcErrorNone; @@ -511,7 +511,7 @@ NfcError nfc_iso14443a_listener_set_col_res_data( uint8_t uid_len, uint8_t* atqa, uint8_t sak) { - furi_assert(instance); + furi_check(instance); FuriHalNfcError error = furi_hal_nfc_iso14443a_listener_set_col_res_data(uid, uid_len, atqa, sak); @@ -524,14 +524,14 @@ NfcError nfc_iso14443a_poller_trx_short_frame( NfcIso14443aShortFrame frame, BitBuffer* rx_buffer, uint32_t fwt) { - furi_assert(instance); - furi_assert(rx_buffer); + furi_check(instance); + furi_check(rx_buffer); FuriHalNfcaShortFrame short_frame = (frame == NfcIso14443aShortFrameAllReqa) ? FuriHalNfcaShortFrameAllReq : FuriHalNfcaShortFrameSensReq; - furi_assert(instance->poller_state == NfcPollerStateReady); + furi_check(instance->poller_state == NfcPollerStateReady); NfcError ret = NfcErrorNone; FuriHalNfcError error = FuriHalNfcErrorNone; @@ -574,11 +574,11 @@ NfcError nfc_iso14443a_poller_trx_sdd_frame( const BitBuffer* tx_buffer, BitBuffer* rx_buffer, uint32_t fwt) { - furi_assert(instance); - furi_assert(tx_buffer); - furi_assert(rx_buffer); + furi_check(instance); + furi_check(tx_buffer); + furi_check(rx_buffer); - furi_assert(instance->poller_state == NfcPollerStateReady); + furi_check(instance->poller_state == NfcPollerStateReady); NfcError ret = NfcErrorNone; FuriHalNfcError error = FuriHalNfcErrorNone; @@ -618,8 +618,8 @@ NfcError nfc_iso14443a_poller_trx_sdd_frame( } NfcError nfc_iso14443a_listener_tx_custom_parity(Nfc* instance, const BitBuffer* tx_buffer) { - furi_assert(instance); - furi_assert(tx_buffer); + furi_check(instance); + furi_check(tx_buffer); NfcError ret = NfcErrorNone; FuriHalNfcError error = FuriHalNfcErrorNone; @@ -635,7 +635,7 @@ NfcError nfc_iso14443a_listener_tx_custom_parity(Nfc* instance, const BitBuffer* } NfcError nfc_iso15693_listener_tx_sof(Nfc* instance) { - furi_assert(instance); + furi_check(instance); while(furi_hal_nfc_timer_block_tx_is_running()) { } @@ -652,9 +652,7 @@ NfcError nfc_felica_listener_set_sensf_res_data( const uint8_t idm_len, const uint8_t* pmm, const uint8_t pmm_len) { - furi_assert(instance); - furi_assert(idm); - furi_assert(pmm); + furi_check(instance); FuriHalNfcError error = furi_hal_nfc_felica_listener_set_sensf_res_data(idm, idm_len, pmm, pmm_len); diff --git a/lib/nfc/nfc.h b/lib/nfc/nfc.h index 6f3e25a5d..959bd018f 100644 --- a/lib/nfc/nfc.h +++ b/lib/nfc/nfc.h @@ -128,7 +128,7 @@ typedef enum { * * @returns pointer to the allocated Nfc instance. */ -Nfc* nfc_alloc(); +Nfc* nfc_alloc(void); /** * @brief Delete an Nfc instance. diff --git a/lib/nfc/nfc_device.c b/lib/nfc/nfc_device.c index 267824d16..9f95dfc15 100644 --- a/lib/nfc/nfc_device.c +++ b/lib/nfc/nfc_device.c @@ -14,7 +14,7 @@ #define NFC_DEVICE_UID_MAX_LEN (10U) -NfcDevice* nfc_device_alloc() { +NfcDevice* nfc_device_alloc(void) { NfcDevice* instance = malloc(sizeof(NfcDevice)); instance->protocol = NfcProtocolInvalid; @@ -22,14 +22,14 @@ NfcDevice* nfc_device_alloc() { } void nfc_device_free(NfcDevice* instance) { - furi_assert(instance); + furi_check(instance); nfc_device_clear(instance); free(instance); } void nfc_device_clear(NfcDevice* instance) { - furi_assert(instance); + furi_check(instance); if(instance->protocol == NfcProtocolInvalid) { furi_assert(instance->protocol_data == NULL); @@ -43,8 +43,8 @@ void nfc_device_clear(NfcDevice* instance) { } void nfc_device_reset(NfcDevice* instance) { - furi_assert(instance); - furi_assert(instance->protocol < NfcProtocolNum); + furi_check(instance); + furi_check(instance->protocol < NfcProtocolNum); if(instance->protocol_data) { nfc_devices[instance->protocol]->reset(instance->protocol_data); @@ -52,37 +52,40 @@ void nfc_device_reset(NfcDevice* instance) { } NfcProtocol nfc_device_get_protocol(const NfcDevice* instance) { - furi_assert(instance); + furi_check(instance); return instance->protocol; } const NfcDeviceData* nfc_device_get_data(const NfcDevice* instance, NfcProtocol protocol) { + furi_check(instance); return nfc_device_get_data_ptr(instance, protocol); } const char* nfc_device_get_protocol_name(NfcProtocol protocol) { - furi_assert(protocol < NfcProtocolNum); + furi_check(protocol < NfcProtocolNum); return nfc_devices[protocol]->protocol_name; } const char* nfc_device_get_name(const NfcDevice* instance, NfcDeviceNameType name_type) { - furi_assert(instance); - furi_assert(instance->protocol < NfcProtocolNum); + furi_check(instance); + furi_check(instance->protocol < NfcProtocolNum); return nfc_devices[instance->protocol]->get_name(instance->protocol_data, name_type); } const uint8_t* nfc_device_get_uid(const NfcDevice* instance, size_t* uid_len) { - furi_assert(instance); - furi_assert(instance->protocol < NfcProtocolNum); + furi_check(instance); + furi_check(uid_len); + furi_check(instance->protocol < NfcProtocolNum); return nfc_devices[instance->protocol]->get_uid(instance->protocol_data, uid_len); } bool nfc_device_set_uid(NfcDevice* instance, const uint8_t* uid, size_t uid_len) { - furi_assert(instance); - furi_assert(instance->protocol < NfcProtocolNum); + furi_check(instance); + furi_check(uid); + furi_check(instance->protocol < NfcProtocolNum); return nfc_devices[instance->protocol]->set_uid(instance->protocol_data, uid, uid_len); } @@ -91,8 +94,9 @@ void nfc_device_set_data( NfcDevice* instance, NfcProtocol protocol, const NfcDeviceData* protocol_data) { - furi_assert(instance); - furi_assert(protocol < NfcProtocolNum); + furi_check(instance); + furi_check(protocol_data); + furi_check(protocol < NfcProtocolNum); nfc_device_clear(instance); @@ -106,9 +110,9 @@ void nfc_device_copy_data( const NfcDevice* instance, NfcProtocol protocol, NfcDeviceData* protocol_data) { - furi_assert(instance); - furi_assert(protocol < NfcProtocolNum); - furi_assert(protocol_data); + furi_check(instance); + furi_check(protocol < NfcProtocolNum); + furi_check(protocol_data); if(instance->protocol != protocol) { furi_crash(NFC_DEV_TYPE_ERROR); @@ -121,17 +125,17 @@ bool nfc_device_is_equal_data( const NfcDevice* instance, NfcProtocol protocol, const NfcDeviceData* protocol_data) { - furi_assert(instance); - furi_assert(protocol < NfcProtocolNum); - furi_assert(protocol_data); + furi_check(instance); + furi_check(protocol < NfcProtocolNum); + furi_check(protocol_data); return instance->protocol == protocol && nfc_devices[protocol]->is_equal(instance->protocol_data, protocol_data); } bool nfc_device_is_equal(const NfcDevice* instance, const NfcDevice* other) { - furi_assert(instance); - furi_assert(other); + furi_check(instance); + furi_check(other); return nfc_device_is_equal_data(instance, other->protocol, other->protocol_data); } @@ -140,17 +144,17 @@ void nfc_device_set_loading_callback( NfcDevice* instance, NfcLoadingCallback callback, void* context) { - furi_assert(instance); - furi_assert(callback); + furi_check(instance); + furi_check(callback); instance->loading_callback = callback; instance->loading_callback_context = context; } bool nfc_device_save(NfcDevice* instance, const char* path) { - furi_assert(instance); - furi_assert(instance->protocol < NfcProtocolNum); - furi_assert(path); + furi_check(instance); + furi_check(instance->protocol < NfcProtocolNum); + furi_check(path); bool saved = false; Storage* storage = furi_record_open(RECORD_STORAGE); @@ -313,8 +317,8 @@ static bool nfc_device_load_legacy(NfcDevice* instance, FlipperFormat* ff, uint3 } bool nfc_device_load(NfcDevice* instance, const char* path) { - furi_assert(instance); - furi_assert(path); + furi_check(instance); + furi_check(path); bool loaded = false; Storage* storage = furi_record_open(RECORD_STORAGE); diff --git a/lib/nfc/nfc_device.h b/lib/nfc/nfc_device.h index 6636e7c76..055acec0a 100644 --- a/lib/nfc/nfc_device.h +++ b/lib/nfc/nfc_device.h @@ -47,7 +47,7 @@ typedef void (*NfcLoadingCallback)(void* context, bool state); * * @returns pointer to the allocated instance. */ -NfcDevice* nfc_device_alloc(); +NfcDevice* nfc_device_alloc(void); /** * @brief Delete an NfcDevice instance. diff --git a/lib/nfc/nfc_listener.c b/lib/nfc/nfc_listener.c index 57b00a875..4f711d62d 100644 --- a/lib/nfc/nfc_listener.c +++ b/lib/nfc/nfc_listener.c @@ -73,10 +73,10 @@ static void nfc_listener_list_free(NfcListener* instance) { } NfcListener* nfc_listener_alloc(Nfc* nfc, NfcProtocol protocol, const NfcDeviceData* data) { - furi_assert(nfc); - furi_assert(protocol < NfcProtocolNum); - furi_assert(data); - furi_assert(nfc_listeners_api[protocol]); + furi_check(nfc); + furi_check(protocol < NfcProtocolNum); + furi_check(data); + furi_check(nfc_listeners_api[protocol]); NfcListener* instance = malloc(sizeof(NfcListener)); instance->nfc = nfc; @@ -89,7 +89,7 @@ NfcListener* nfc_listener_alloc(Nfc* nfc, NfcProtocol protocol, const NfcDeviceD } void nfc_listener_free(NfcListener* instance) { - furi_assert(instance); + furi_check(instance); nfc_listener_list_free(instance); nfc_device_free(instance->nfc_dev); @@ -116,7 +116,7 @@ NfcCommand nfc_listener_start_callback(NfcEvent event, void* context) { } void nfc_listener_start(NfcListener* instance, NfcGenericCallback callback, void* context) { - furi_assert(instance); + furi_check(instance); NfcListenerListElement* tail_element = instance->list.tail; tail_element->listener_api->set_callback(tail_element->listener, callback, context); @@ -124,20 +124,20 @@ void nfc_listener_start(NfcListener* instance, NfcGenericCallback callback, void } void nfc_listener_stop(NfcListener* instance) { - furi_assert(instance); + furi_check(instance); nfc_stop(instance->nfc); } NfcProtocol nfc_listener_get_protocol(const NfcListener* instance) { - furi_assert(instance); + furi_check(instance); return instance->protocol; } const NfcDeviceData* nfc_listener_get_data(const NfcListener* instance, NfcProtocol protocol) { - furi_assert(instance); - furi_assert(instance->protocol == protocol); + furi_check(instance); + furi_check(instance->protocol == protocol); NfcListenerListElement* tail_element = instance->list.tail; return tail_element->listener_api->get_data(tail_element->listener); diff --git a/lib/nfc/nfc_poller.c b/lib/nfc/nfc_poller.c index 48be37d92..114ff3695 100644 --- a/lib/nfc/nfc_poller.c +++ b/lib/nfc/nfc_poller.c @@ -75,8 +75,8 @@ static void nfc_poller_list_free(NfcPoller* instance) { } NfcPoller* nfc_poller_alloc(Nfc* nfc, NfcProtocol protocol) { - furi_assert(nfc); - furi_assert(protocol < NfcProtocolNum); + furi_check(nfc); + furi_check(protocol < NfcProtocolNum); NfcPoller* instance = malloc(sizeof(NfcPoller)); instance->session_state = NfcPollerSessionStateIdle; @@ -88,7 +88,7 @@ NfcPoller* nfc_poller_alloc(Nfc* nfc, NfcProtocol protocol) { } void nfc_poller_free(NfcPoller* instance) { - furi_assert(instance); + furi_check(instance); nfc_poller_list_free(instance); free(instance); @@ -119,9 +119,9 @@ static NfcCommand nfc_poller_start_callback(NfcEvent event, void* context) { } void nfc_poller_start(NfcPoller* instance, NfcGenericCallback callback, void* context) { - furi_assert(instance); - furi_assert(callback); - furi_assert(instance->session_state == NfcPollerSessionStateIdle); + furi_check(instance); + furi_check(callback); + furi_check(instance->session_state == NfcPollerSessionStateIdle); NfcPollerListElement* tail_poller = instance->list.tail; tail_poller->poller_api->set_callback(tail_poller->poller, callback, context); @@ -180,9 +180,9 @@ static NfcCommand nfc_poller_start_ex_head_callback(NfcEvent event, void* contex } void nfc_poller_start_ex(NfcPoller* instance, NfcGenericCallbackEx callback, void* context) { - furi_assert(instance); - furi_assert(callback); - furi_assert(instance->session_state == NfcPollerSessionStateIdle); + furi_check(instance); + furi_check(callback); + furi_check(instance->session_state == NfcPollerSessionStateIdle); instance->callback = callback; instance->context = context; @@ -200,8 +200,8 @@ void nfc_poller_start_ex(NfcPoller* instance, NfcGenericCallbackEx callback, voi } void nfc_poller_stop(NfcPoller* instance) { - furi_assert(instance); - furi_assert(instance->nfc); + furi_check(instance); + furi_check(instance->nfc); instance->session_state = NfcPollerSessionStateStopRequest; nfc_stop(instance->nfc); @@ -246,8 +246,8 @@ static NfcCommand nfc_poller_detect_head_callback(NfcEvent event, void* context) } bool nfc_poller_detect(NfcPoller* instance) { - furi_assert(instance); - furi_assert(instance->session_state == NfcPollerSessionStateIdle); + furi_check(instance); + furi_check(instance->session_state == NfcPollerSessionStateIdle); instance->session_state = NfcPollerSessionStateActive; NfcPollerListElement* tail_poller = instance->list.tail; @@ -270,13 +270,13 @@ bool nfc_poller_detect(NfcPoller* instance) { } NfcProtocol nfc_poller_get_protocol(const NfcPoller* instance) { - furi_assert(instance); + furi_check(instance); return instance->protocol; } const NfcDeviceData* nfc_poller_get_data(const NfcPoller* instance) { - furi_assert(instance); + furi_check(instance); NfcPollerListElement* tail_poller = instance->list.tail; return tail_poller->poller_api->get_data(tail_poller->poller); diff --git a/lib/nfc/nfc_scanner.c b/lib/nfc/nfc_scanner.c index 0056dfb1c..23922a829 100644 --- a/lib/nfc/nfc_scanner.c +++ b/lib/nfc/nfc_scanner.c @@ -218,7 +218,7 @@ static int32_t nfc_scanner_worker(void* context) { } NfcScanner* nfc_scanner_alloc(Nfc* nfc) { - furi_assert(nfc); + furi_check(nfc); NfcScanner* instance = malloc(sizeof(NfcScanner)); instance->nfc = nfc; @@ -227,16 +227,17 @@ NfcScanner* nfc_scanner_alloc(Nfc* nfc) { } void nfc_scanner_free(NfcScanner* instance) { - furi_assert(instance); + furi_check(instance); + furi_check(instance->state == NfcScannerStateIdle); free(instance); } void nfc_scanner_start(NfcScanner* instance, NfcScannerCallback callback, void* context) { - furi_assert(instance); - furi_assert(callback); - furi_assert(instance->session_state == NfcScannerSessionStateIdle); - furi_assert(instance->scan_worker == NULL); + furi_check(instance); + furi_check(callback); + furi_check(instance->state == NfcScannerStateIdle); + furi_check(instance->scan_worker == NULL); instance->callback = callback; instance->context = context; @@ -252,8 +253,8 @@ void nfc_scanner_start(NfcScanner* instance, NfcScannerCallback callback, void* } void nfc_scanner_stop(NfcScanner* instance) { - furi_assert(instance); - furi_assert(instance->scan_worker); + furi_check(instance); + furi_check(instance->scan_worker); instance->session_state = NfcScannerSessionStateStopRequest; furi_thread_join(instance->scan_worker); diff --git a/lib/nfc/protocols/felica/felica.c b/lib/nfc/protocols/felica/felica.c index 4b7c91fb6..7de1310bf 100644 --- a/lib/nfc/protocols/felica/felica.c +++ b/lib/nfc/protocols/felica/felica.c @@ -29,7 +29,7 @@ const NfcDeviceBase nfc_device_felica = { .get_base_data = (NfcDeviceGetBaseData)felica_get_base_data, }; -FelicaData* felica_alloc() { +FelicaData* felica_alloc(void) { FelicaData* data = malloc(sizeof(FelicaData)); return data; } diff --git a/lib/nfc/protocols/felica/felica.h b/lib/nfc/protocols/felica/felica.h index 31e040b8a..e1820d4dc 100644 --- a/lib/nfc/protocols/felica/felica.h +++ b/lib/nfc/protocols/felica/felica.h @@ -50,7 +50,7 @@ typedef struct { extern const NfcDeviceBase nfc_device_felica; -FelicaData* felica_alloc(); +FelicaData* felica_alloc(void); void felica_free(FelicaData* data); diff --git a/lib/nfc/protocols/iso14443_3a/iso14443_3a.c b/lib/nfc/protocols/iso14443_3a/iso14443_3a.c index 96d0b3953..96e30e5c8 100644 --- a/lib/nfc/protocols/iso14443_3a/iso14443_3a.c +++ b/lib/nfc/protocols/iso14443_3a/iso14443_3a.c @@ -28,36 +28,40 @@ const NfcDeviceBase nfc_device_iso14443_3a = { .get_base_data = (NfcDeviceGetBaseData)iso14443_3a_get_base_data, }; -Iso14443_3aData* iso14443_3a_alloc() { +Iso14443_3aData* iso14443_3a_alloc(void) { Iso14443_3aData* data = malloc(sizeof(Iso14443_3aData)); return data; } void iso14443_3a_free(Iso14443_3aData* data) { - furi_assert(data); + furi_check(data); free(data); } void iso14443_3a_reset(Iso14443_3aData* data) { - furi_assert(data); + furi_check(data); + memset(data, 0, sizeof(Iso14443_3aData)); } void iso14443_3a_copy(Iso14443_3aData* data, const Iso14443_3aData* other) { - furi_assert(data); - furi_assert(other); + furi_check(data); + furi_check(other); *data = *other; } bool iso14443_3a_verify(Iso14443_3aData* data, const FuriString* device_type) { UNUSED(data); + furi_check(device_type); + return furi_string_equal(device_type, ISO14443_3A_PROTOCOL_NAME_LEGACY); } bool iso14443_3a_load(Iso14443_3aData* data, FlipperFormat* ff, uint32_t version) { - furi_assert(data); + furi_check(data); + furi_check(ff); bool parsed = false; @@ -78,7 +82,8 @@ bool iso14443_3a_load(Iso14443_3aData* data, FlipperFormat* ff, uint32_t version } bool iso14443_3a_save(const Iso14443_3aData* data, FlipperFormat* ff) { - furi_assert(data); + furi_check(data); + furi_check(ff); bool saved = false; @@ -98,8 +103,8 @@ bool iso14443_3a_save(const Iso14443_3aData* data, FlipperFormat* ff) { } bool iso14443_3a_is_equal(const Iso14443_3aData* data, const Iso14443_3aData* other) { - furi_assert(data); - furi_assert(other); + furi_check(data); + furi_check(other); return memcmp(data, other, sizeof(Iso14443_3aData)) == 0; } @@ -111,7 +116,7 @@ const char* iso14443_3a_get_device_name(const Iso14443_3aData* data, NfcDeviceNa } const uint8_t* iso14443_3a_get_uid(const Iso14443_3aData* data, size_t* uid_len) { - furi_assert(data); + furi_check(data); if(uid_len) { *uid_len = data->uid_len; @@ -121,7 +126,8 @@ const uint8_t* iso14443_3a_get_uid(const Iso14443_3aData* data, size_t* uid_len) } bool iso14443_3a_set_uid(Iso14443_3aData* data, const uint8_t* uid, size_t uid_len) { - furi_assert(data); + furi_check(data); + furi_check(uid); const bool uid_valid = uid_len == ISO14443_3A_UID_4_BYTES || uid_len == ISO14443_3A_UID_7_BYTES || @@ -141,7 +147,7 @@ Iso14443_3aData* iso14443_3a_get_base_data(const Iso14443_3aData* data) { } uint32_t iso14443_3a_get_cuid(const Iso14443_3aData* data) { - furi_assert(data); + furi_check(data); uint32_t cuid = 0; const uint8_t* cuid_start = data->uid; @@ -154,33 +160,33 @@ uint32_t iso14443_3a_get_cuid(const Iso14443_3aData* data) { } bool iso14443_3a_supports_iso14443_4(const Iso14443_3aData* data) { - furi_assert(data); + furi_check(data); return data->sak & ISO14443A_ATS_BIT; } uint8_t iso14443_3a_get_sak(const Iso14443_3aData* data) { - furi_assert(data); + furi_check(data); return data->sak; } void iso14443_3a_get_atqa(const Iso14443_3aData* data, uint8_t atqa[2]) { - furi_assert(data); - furi_assert(atqa); + furi_check(data); + furi_check(atqa); memcpy(atqa, data->atqa, sizeof(data->atqa)); } void iso14443_3a_set_sak(Iso14443_3aData* data, uint8_t sak) { - furi_assert(data); + furi_check(data); data->sak = sak; } void iso14443_3a_set_atqa(Iso14443_3aData* data, const uint8_t atqa[2]) { - furi_assert(data); - furi_assert(atqa); + furi_check(data); + furi_check(atqa); memcpy(data->atqa, atqa, sizeof(data->atqa)); } diff --git a/lib/nfc/protocols/iso14443_3a/iso14443_3a.h b/lib/nfc/protocols/iso14443_3a/iso14443_3a.h index 005626e62..714c1dada 100644 --- a/lib/nfc/protocols/iso14443_3a/iso14443_3a.h +++ b/lib/nfc/protocols/iso14443_3a/iso14443_3a.h @@ -62,7 +62,7 @@ typedef struct { uint8_t sak; } Iso14443_3aData; -Iso14443_3aData* iso14443_3a_alloc(); +Iso14443_3aData* iso14443_3a_alloc(void); void iso14443_3a_free(Iso14443_3aData* data); diff --git a/lib/nfc/protocols/iso14443_3a/iso14443_3a_poller_i.c b/lib/nfc/protocols/iso14443_3a/iso14443_3a_poller_i.c index 2be88bc51..2cf66edba 100644 --- a/lib/nfc/protocols/iso14443_3a/iso14443_3a_poller_i.c +++ b/lib/nfc/protocols/iso14443_3a/iso14443_3a_poller_i.c @@ -55,8 +55,8 @@ static Iso14443_3aError iso14443_3a_poller_standard_frame_exchange( } Iso14443_3aError iso14443_3a_poller_check_presence(Iso14443_3aPoller* instance) { - furi_assert(instance); - furi_assert(instance->nfc); + furi_check(instance); + furi_check(instance->nfc); NfcError error = NfcErrorNone; Iso14443_3aError ret = Iso14443_3aErrorNone; @@ -80,9 +80,9 @@ Iso14443_3aError iso14443_3a_poller_check_presence(Iso14443_3aPoller* instance) } Iso14443_3aError iso14443_3a_poller_halt(Iso14443_3aPoller* instance) { - furi_assert(instance); - furi_assert(instance->nfc); - furi_assert(instance->tx_buffer); + furi_check(instance); + furi_check(instance->nfc); + furi_check(instance->tx_buffer); uint8_t halt_cmd[2] = {0x50, 0x00}; bit_buffer_copy_bytes(instance->tx_buffer, halt_cmd, sizeof(halt_cmd)); @@ -96,10 +96,10 @@ Iso14443_3aError iso14443_3a_poller_halt(Iso14443_3aPoller* instance) { Iso14443_3aError iso14443_3a_poller_activate(Iso14443_3aPoller* instance, Iso14443_3aData* iso14443_3a_data) { - furi_assert(instance); - furi_assert(instance->nfc); - furi_assert(instance->tx_buffer); - furi_assert(instance->rx_buffer); + furi_check(instance); + furi_check(instance->nfc); + furi_check(instance->tx_buffer); + furi_check(instance->rx_buffer); // Reset Iso14443_3a poller state memset(&instance->col_res, 0, sizeof(instance->col_res)); @@ -244,9 +244,9 @@ Iso14443_3aError iso14443_3a_poller_txrx_custom_parity( const BitBuffer* tx_buffer, BitBuffer* rx_buffer, uint32_t fwt) { - furi_assert(instance); - furi_assert(tx_buffer); - furi_assert(rx_buffer); + furi_check(instance); + furi_check(tx_buffer); + furi_check(rx_buffer); Iso14443_3aError ret = Iso14443_3aErrorNone; NfcError error = @@ -263,9 +263,9 @@ Iso14443_3aError iso14443_3a_poller_txrx( const BitBuffer* tx_buffer, BitBuffer* rx_buffer, uint32_t fwt) { - furi_assert(instance); - furi_assert(tx_buffer); - furi_assert(rx_buffer); + furi_check(instance); + furi_check(tx_buffer); + furi_check(rx_buffer); Iso14443_3aError ret = Iso14443_3aErrorNone; NfcError error = nfc_poller_trx(instance->nfc, tx_buffer, rx_buffer, fwt); @@ -281,9 +281,9 @@ Iso14443_3aError iso14443_3a_poller_send_standard_frame( const BitBuffer* tx_buffer, BitBuffer* rx_buffer, uint32_t fwt) { - furi_assert(instance); - furi_assert(tx_buffer); - furi_assert(rx_buffer); + furi_check(instance); + furi_check(tx_buffer); + furi_check(rx_buffer); Iso14443_3aError ret = iso14443_3a_poller_standard_frame_exchange(instance, tx_buffer, rx_buffer, fwt); diff --git a/lib/nfc/protocols/iso14443_3a/iso14443_3a_poller_sync.c b/lib/nfc/protocols/iso14443_3a/iso14443_3a_poller_sync.c index ea7a6ae15..751a1c4ff 100644 --- a/lib/nfc/protocols/iso14443_3a/iso14443_3a_poller_sync.c +++ b/lib/nfc/protocols/iso14443_3a/iso14443_3a_poller_sync.c @@ -35,8 +35,8 @@ NfcCommand iso14443_3a_poller_read_callback(NfcGenericEvent event, void* context } Iso14443_3aError iso14443_3a_poller_sync_read(Nfc* nfc, Iso14443_3aData* iso14443_3a_data) { - furi_assert(nfc); - furi_assert(iso14443_3a_data); + furi_check(nfc); + furi_check(iso14443_3a_data); Iso14443_3aPollerContext poller_context = {}; poller_context.thread_id = furi_thread_get_current_id(); diff --git a/lib/nfc/protocols/iso14443_3b/iso14443_3b.c b/lib/nfc/protocols/iso14443_3b/iso14443_3b.c index fd81e390d..c2dc7e5a0 100644 --- a/lib/nfc/protocols/iso14443_3b/iso14443_3b.c +++ b/lib/nfc/protocols/iso14443_3b/iso14443_3b.c @@ -30,24 +30,26 @@ const NfcDeviceBase nfc_device_iso14443_3b = { .get_base_data = (NfcDeviceGetBaseData)iso14443_3b_get_base_data, }; -Iso14443_3bData* iso14443_3b_alloc() { +Iso14443_3bData* iso14443_3b_alloc(void) { Iso14443_3bData* data = malloc(sizeof(Iso14443_3bData)); return data; } void iso14443_3b_free(Iso14443_3bData* data) { - furi_assert(data); + furi_check(data); free(data); } void iso14443_3b_reset(Iso14443_3bData* data) { + furi_check(data); + memset(data, 0, sizeof(Iso14443_3bData)); } void iso14443_3b_copy(Iso14443_3bData* data, const Iso14443_3bData* other) { - furi_assert(data); - furi_assert(other); + furi_check(data); + furi_check(other); *data = *other; } @@ -60,7 +62,8 @@ bool iso14443_3b_verify(Iso14443_3bData* data, const FuriString* device_type) { } bool iso14443_3b_load(Iso14443_3bData* data, FlipperFormat* ff, uint32_t version) { - furi_assert(data); + furi_check(data); + furi_check(ff); bool parsed = false; @@ -84,7 +87,8 @@ bool iso14443_3b_load(Iso14443_3bData* data, FlipperFormat* ff, uint32_t version } bool iso14443_3b_save(const Iso14443_3bData* data, FlipperFormat* ff) { - furi_assert(data); + furi_check(data); + furi_check(ff); bool saved = false; @@ -107,8 +111,8 @@ bool iso14443_3b_save(const Iso14443_3bData* data, FlipperFormat* ff) { } bool iso14443_3b_is_equal(const Iso14443_3bData* data, const Iso14443_3bData* other) { - furi_assert(data); - furi_assert(other); + furi_check(data); + furi_check(other); return memcmp(data, other, sizeof(Iso14443_3bData)) == 0; } @@ -121,15 +125,16 @@ const char* iso14443_3b_get_device_name(const Iso14443_3bData* data, NfcDeviceNa } const uint8_t* iso14443_3b_get_uid(const Iso14443_3bData* data, size_t* uid_len) { - furi_assert(data); - furi_assert(uid_len); + furi_check(data); + furi_check(uid_len); *uid_len = ISO14443_3B_UID_SIZE; return data->uid; } bool iso14443_3b_set_uid(Iso14443_3bData* data, const uint8_t* uid, size_t uid_len) { - furi_assert(data); + furi_check(data); + furi_check(uid); const bool uid_valid = uid_len == ISO14443_3B_UID_SIZE; @@ -146,13 +151,13 @@ Iso14443_3bData* iso14443_3b_get_base_data(const Iso14443_3bData* data) { } bool iso14443_3b_supports_iso14443_4(const Iso14443_3bData* data) { - furi_assert(data); + furi_check(data); return data->protocol_info.protocol_type == 0x01; } bool iso14443_3b_supports_bit_rate(const Iso14443_3bData* data, Iso14443_3bBitRate bit_rate) { - furi_assert(data); + furi_check(data); const uint8_t capability = data->protocol_info.bit_rate_capability; @@ -177,7 +182,7 @@ bool iso14443_3b_supports_bit_rate(const Iso14443_3bData* data, Iso14443_3bBitRa } bool iso14443_3b_supports_frame_option(const Iso14443_3bData* data, Iso14443_3bFrameOption option) { - furi_assert(data); + furi_check(data); switch(option) { case Iso14443_3bFrameOptionNad: @@ -190,15 +195,15 @@ bool iso14443_3b_supports_frame_option(const Iso14443_3bData* data, Iso14443_3bF } const uint8_t* iso14443_3b_get_application_data(const Iso14443_3bData* data, size_t* data_size) { - furi_assert(data); - furi_assert(data_size); + furi_check(data); + furi_check(data_size); *data_size = ISO14443_3B_APP_DATA_SIZE; return data->app_data; } uint16_t iso14443_3b_get_frame_size_max(const Iso14443_3bData* data) { - furi_assert(data); + furi_check(data); const uint8_t fs_bits = data->protocol_info.max_frame_size; @@ -216,7 +221,7 @@ uint16_t iso14443_3b_get_frame_size_max(const Iso14443_3bData* data) { } uint32_t iso14443_3b_get_fwt_fc_max(const Iso14443_3bData* data) { - furi_assert(data); + furi_check(data); const uint8_t fwi = data->protocol_info.fwi; return fwi < 0x0F ? 4096UL << fwi : ISO14443_3B_FDT_POLL_DEFAULT_FC; diff --git a/lib/nfc/protocols/iso14443_3b/iso14443_3b.h b/lib/nfc/protocols/iso14443_3b/iso14443_3b.h index 848e610c3..7281dc62b 100644 --- a/lib/nfc/protocols/iso14443_3b/iso14443_3b.h +++ b/lib/nfc/protocols/iso14443_3b/iso14443_3b.h @@ -40,7 +40,7 @@ typedef struct Iso14443_3bData Iso14443_3bData; // Virtual methods -Iso14443_3bData* iso14443_3b_alloc(); +Iso14443_3bData* iso14443_3b_alloc(void); void iso14443_3b_free(Iso14443_3bData* data); diff --git a/lib/nfc/protocols/iso14443_3b/iso14443_3b_poller_i.c b/lib/nfc/protocols/iso14443_3b/iso14443_3b_poller_i.c index 1266e2482..e20a49d24 100644 --- a/lib/nfc/protocols/iso14443_3b/iso14443_3b_poller_i.c +++ b/lib/nfc/protocols/iso14443_3b/iso14443_3b_poller_i.c @@ -64,8 +64,9 @@ static Iso14443_3bError iso14443_3b_poller_frame_exchange( } Iso14443_3bError iso14443_3b_poller_activate(Iso14443_3bPoller* instance, Iso14443_3bData* data) { - furi_assert(instance); - furi_assert(instance->nfc); + furi_check(instance); + furi_check(instance->nfc); + furi_check(data); iso14443_3b_reset(data); @@ -155,7 +156,7 @@ Iso14443_3bError iso14443_3b_poller_activate(Iso14443_3bPoller* instance, Iso144 } Iso14443_3bError iso14443_3b_poller_halt(Iso14443_3bPoller* instance) { - furi_assert(instance); + furi_check(instance); bit_buffer_reset(instance->tx_buffer); bit_buffer_reset(instance->rx_buffer); @@ -188,6 +189,10 @@ Iso14443_3bError iso14443_3b_poller_send_frame( Iso14443_3bPoller* instance, const BitBuffer* tx_buffer, BitBuffer* rx_buffer) { + furi_check(instance); + furi_check(tx_buffer); + furi_check(rx_buffer); + Iso14443_3bError ret; do { diff --git a/lib/nfc/protocols/iso14443_4a/iso14443_4a.c b/lib/nfc/protocols/iso14443_4a/iso14443_4a.c index bfa2e71c6..756c35084 100644 --- a/lib/nfc/protocols/iso14443_4a/iso14443_4a.c +++ b/lib/nfc/protocols/iso14443_4a/iso14443_4a.c @@ -35,7 +35,7 @@ const NfcDeviceBase nfc_device_iso14443_4a = { .get_base_data = (NfcDeviceGetBaseData)iso14443_4a_get_base_data, }; -Iso14443_4aData* iso14443_4a_alloc() { +Iso14443_4aData* iso14443_4a_alloc(void) { Iso14443_4aData* data = malloc(sizeof(Iso14443_4aData)); data->iso14443_3a_data = iso14443_3a_alloc(); @@ -45,7 +45,7 @@ Iso14443_4aData* iso14443_4a_alloc() { } void iso14443_4a_free(Iso14443_4aData* data) { - furi_assert(data); + furi_check(data); simple_array_free(data->ats_data.t1_tk); iso14443_3a_free(data->iso14443_3a_data); @@ -54,7 +54,7 @@ void iso14443_4a_free(Iso14443_4aData* data) { } void iso14443_4a_reset(Iso14443_4aData* data) { - furi_assert(data); + furi_check(data); iso14443_3a_reset(data->iso14443_3a_data); @@ -68,8 +68,8 @@ void iso14443_4a_reset(Iso14443_4aData* data) { } void iso14443_4a_copy(Iso14443_4aData* data, const Iso14443_4aData* other) { - furi_assert(data); - furi_assert(other); + furi_check(data); + furi_check(other); iso14443_3a_copy(data->iso14443_3a_data, other->iso14443_3a_data); @@ -91,7 +91,8 @@ bool iso14443_4a_verify(Iso14443_4aData* data, const FuriString* device_type) { } bool iso14443_4a_load(Iso14443_4aData* data, FlipperFormat* ff, uint32_t version) { - furi_assert(data); + furi_check(data); + furi_check(ff); bool parsed = false; @@ -145,7 +146,8 @@ bool iso14443_4a_load(Iso14443_4aData* data, FlipperFormat* ff, uint32_t version } bool iso14443_4a_save(const Iso14443_4aData* data, FlipperFormat* ff) { - furi_assert(data); + furi_check(data); + furi_check(ff); bool saved = false; @@ -186,6 +188,9 @@ bool iso14443_4a_save(const Iso14443_4aData* data, FlipperFormat* ff) { } bool iso14443_4a_is_equal(const Iso14443_4aData* data, const Iso14443_4aData* other) { + furi_check(data); + furi_check(other); + return iso14443_3a_is_equal(data->iso14443_3a_data, other->iso14443_3a_data); } @@ -196,23 +201,26 @@ const char* iso14443_4a_get_device_name(const Iso14443_4aData* data, NfcDeviceNa } const uint8_t* iso14443_4a_get_uid(const Iso14443_4aData* data, size_t* uid_len) { + furi_check(data); + furi_check(uid_len); + return iso14443_3a_get_uid(data->iso14443_3a_data, uid_len); } bool iso14443_4a_set_uid(Iso14443_4aData* data, const uint8_t* uid, size_t uid_len) { - furi_assert(data); + furi_check(data); return iso14443_3a_set_uid(data->iso14443_3a_data, uid, uid_len); } Iso14443_3aData* iso14443_4a_get_base_data(const Iso14443_4aData* data) { - furi_assert(data); + furi_check(data); return data->iso14443_3a_data; } uint16_t iso14443_4a_get_frame_size_max(const Iso14443_4aData* data) { - furi_assert(data); + furi_check(data); const uint8_t fsci = data->ats_data.t0 & 0x0F; @@ -230,7 +238,7 @@ uint16_t iso14443_4a_get_frame_size_max(const Iso14443_4aData* data) { } uint32_t iso14443_4a_get_fwt_fc_max(const Iso14443_4aData* data) { - furi_assert(data); + furi_check(data); uint32_t fwt_fc_max = ISO14443_4A_FDT_DEFAULT_FC; @@ -248,8 +256,8 @@ uint32_t iso14443_4a_get_fwt_fc_max(const Iso14443_4aData* data) { } const uint8_t* iso14443_4a_get_historical_bytes(const Iso14443_4aData* data, uint32_t* count) { - furi_assert(data); - furi_assert(count); + furi_check(data); + furi_check(count); *count = simple_array_get_count(data->ats_data.t1_tk); const uint8_t* hist_bytes = NULL; @@ -261,7 +269,7 @@ const uint8_t* iso14443_4a_get_historical_bytes(const Iso14443_4aData* data, uin } bool iso14443_4a_supports_bit_rate(const Iso14443_4aData* data, Iso14443_4aBitRate bit_rate) { - furi_assert(data); + furi_check(data); if(!(data->ats_data.t0 & ISO14443_4A_ATS_T0_TA1)) return bit_rate == Iso14443_4aBitRateBoth106Kbit; @@ -289,7 +297,7 @@ bool iso14443_4a_supports_bit_rate(const Iso14443_4aData* data, Iso14443_4aBitRa } bool iso14443_4a_supports_frame_option(const Iso14443_4aData* data, Iso14443_4aFrameOption option) { - furi_assert(data); + furi_check(data); const Iso14443_4aAtsData* ats_data = &data->ats_data; if(!(ats_data->t0 & ISO14443_4A_ATS_T0_TC1)) return false; diff --git a/lib/nfc/protocols/iso14443_4a/iso14443_4a.h b/lib/nfc/protocols/iso14443_4a/iso14443_4a.h index 05a7bd577..6955d1c20 100644 --- a/lib/nfc/protocols/iso14443_4a/iso14443_4a.h +++ b/lib/nfc/protocols/iso14443_4a/iso14443_4a.h @@ -47,7 +47,7 @@ typedef struct { // Virtual methods -Iso14443_4aData* iso14443_4a_alloc(); +Iso14443_4aData* iso14443_4a_alloc(void); void iso14443_4a_free(Iso14443_4aData* data); diff --git a/lib/nfc/protocols/iso14443_4a/iso14443_4a_poller_i.c b/lib/nfc/protocols/iso14443_4a/iso14443_4a_poller_i.c index 45f427dc6..4caeb7bfd 100644 --- a/lib/nfc/protocols/iso14443_4a/iso14443_4a_poller_i.c +++ b/lib/nfc/protocols/iso14443_4a/iso14443_4a_poller_i.c @@ -10,7 +10,7 @@ #define ISO14443_4A_SEND_BLOCK_MAX_ATTEMPTS (20) Iso14443_4aError iso14443_4a_poller_halt(Iso14443_4aPoller* instance) { - furi_assert(instance); + furi_check(instance); iso14443_3a_poller_halt(instance->iso14443_3a_poller); instance->poller_state = Iso14443_4aPollerStateIdle; @@ -20,7 +20,8 @@ Iso14443_4aError iso14443_4a_poller_halt(Iso14443_4aPoller* instance) { Iso14443_4aError iso14443_4a_poller_read_ats(Iso14443_4aPoller* instance, Iso14443_4aAtsData* data) { - furi_assert(instance); + furi_check(instance); + furi_check(data); bit_buffer_reset(instance->tx_buffer); bit_buffer_append_byte(instance->tx_buffer, ISO14443_4A_CMD_READ_ATS); @@ -55,7 +56,9 @@ Iso14443_4aError iso14443_4a_poller_send_block( Iso14443_4aPoller* instance, const BitBuffer* tx_buffer, BitBuffer* rx_buffer) { - furi_assert(instance); + furi_check(instance); + furi_check(tx_buffer); + furi_check(rx_buffer); bit_buffer_reset(instance->tx_buffer); iso14443_4_layer_encode_block(instance->iso14443_4_layer, tx_buffer, instance->tx_buffer); diff --git a/lib/nfc/protocols/iso14443_4b/iso14443_4b.c b/lib/nfc/protocols/iso14443_4b/iso14443_4b.c index 19f2939da..b859f9b8e 100644 --- a/lib/nfc/protocols/iso14443_4b/iso14443_4b.c +++ b/lib/nfc/protocols/iso14443_4b/iso14443_4b.c @@ -22,7 +22,7 @@ const NfcDeviceBase nfc_device_iso14443_4b = { .get_base_data = (NfcDeviceGetBaseData)iso14443_4b_get_base_data, }; -Iso14443_4bData* iso14443_4b_alloc() { +Iso14443_4bData* iso14443_4b_alloc(void) { Iso14443_4bData* data = malloc(sizeof(Iso14443_4bData)); data->iso14443_3b_data = iso14443_3b_alloc(); @@ -30,21 +30,21 @@ Iso14443_4bData* iso14443_4b_alloc() { } void iso14443_4b_free(Iso14443_4bData* data) { - furi_assert(data); + furi_check(data); iso14443_3b_free(data->iso14443_3b_data); free(data); } void iso14443_4b_reset(Iso14443_4bData* data) { - furi_assert(data); + furi_check(data); iso14443_3b_reset(data->iso14443_3b_data); } void iso14443_4b_copy(Iso14443_4bData* data, const Iso14443_4bData* other) { - furi_assert(data); - furi_assert(other); + furi_check(data); + furi_check(other); iso14443_3b_copy(data->iso14443_3b_data, other->iso14443_3b_data); } @@ -58,16 +58,21 @@ bool iso14443_4b_verify(Iso14443_4bData* data, const FuriString* device_type) { } bool iso14443_4b_load(Iso14443_4bData* data, FlipperFormat* ff, uint32_t version) { - furi_assert(data); + furi_check(data); + furi_check(ff); return iso14443_3b_load(data->iso14443_3b_data, ff, version); } bool iso14443_4b_save(const Iso14443_4bData* data, FlipperFormat* ff) { - furi_assert(data); + furi_check(data); + furi_check(ff); return iso14443_3b_save(data->iso14443_3b_data, ff); } bool iso14443_4b_is_equal(const Iso14443_4bData* data, const Iso14443_4bData* other) { + furi_check(data); + furi_check(other); + return iso14443_3b_is_equal(data->iso14443_3b_data, other->iso14443_3b_data); } @@ -78,17 +83,21 @@ const char* iso14443_4b_get_device_name(const Iso14443_4bData* data, NfcDeviceNa } const uint8_t* iso14443_4b_get_uid(const Iso14443_4bData* data, size_t* uid_len) { + furi_check(data); + furi_check(uid_len); + return iso14443_3b_get_uid(data->iso14443_3b_data, uid_len); } bool iso14443_4b_set_uid(Iso14443_4bData* data, const uint8_t* uid, size_t uid_len) { - furi_assert(data); + furi_check(data); + furi_check(uid); return iso14443_3b_set_uid(data->iso14443_3b_data, uid, uid_len); } Iso14443_3bData* iso14443_4b_get_base_data(const Iso14443_4bData* data) { - furi_assert(data); + furi_check(data); return data->iso14443_3b_data; } diff --git a/lib/nfc/protocols/iso14443_4b/iso14443_4b.h b/lib/nfc/protocols/iso14443_4b/iso14443_4b.h index 1f269ed91..c7a2ae882 100644 --- a/lib/nfc/protocols/iso14443_4b/iso14443_4b.h +++ b/lib/nfc/protocols/iso14443_4b/iso14443_4b.h @@ -17,7 +17,7 @@ typedef struct Iso14443_4bData Iso14443_4bData; // Virtual methods -Iso14443_4bData* iso14443_4b_alloc(); +Iso14443_4bData* iso14443_4b_alloc(void); void iso14443_4b_free(Iso14443_4bData* data); diff --git a/lib/nfc/protocols/iso14443_4b/iso14443_4b_poller_i.c b/lib/nfc/protocols/iso14443_4b/iso14443_4b_poller_i.c index 82de1d538..da82e1417 100644 --- a/lib/nfc/protocols/iso14443_4b/iso14443_4b_poller_i.c +++ b/lib/nfc/protocols/iso14443_4b/iso14443_4b_poller_i.c @@ -7,7 +7,7 @@ #define TAG "Iso14443_4bPoller" Iso14443_4bError iso14443_4b_poller_halt(Iso14443_4bPoller* instance) { - furi_assert(instance); + furi_check(instance); iso14443_3b_poller_halt(instance->iso14443_3b_poller); instance->poller_state = Iso14443_4bPollerStateIdle; @@ -19,7 +19,9 @@ Iso14443_4bError iso14443_4b_poller_send_block( Iso14443_4bPoller* instance, const BitBuffer* tx_buffer, BitBuffer* rx_buffer) { - furi_assert(instance); + furi_check(instance); + furi_check(tx_buffer); + furi_check(rx_buffer); bit_buffer_reset(instance->tx_buffer); iso14443_4_layer_encode_block(instance->iso14443_4_layer, tx_buffer, instance->tx_buffer); diff --git a/lib/nfc/protocols/iso15693_3/iso15693_3.c b/lib/nfc/protocols/iso15693_3/iso15693_3.c index 472edfa95..d322cd5d9 100644 --- a/lib/nfc/protocols/iso15693_3/iso15693_3.c +++ b/lib/nfc/protocols/iso15693_3/iso15693_3.c @@ -36,7 +36,7 @@ const NfcDeviceBase nfc_device_iso15693_3 = { .get_base_data = (NfcDeviceGetBaseData)iso15693_3_get_base_data, }; -Iso15693_3Data* iso15693_3_alloc() { +Iso15693_3Data* iso15693_3_alloc(void) { Iso15693_3Data* data = malloc(sizeof(Iso15693_3Data)); data->block_data = simple_array_alloc(&simple_array_config_uint8_t); @@ -46,7 +46,7 @@ Iso15693_3Data* iso15693_3_alloc() { } void iso15693_3_free(Iso15693_3Data* data) { - furi_assert(data); + furi_check(data); simple_array_free(data->block_data); simple_array_free(data->block_security); @@ -54,7 +54,7 @@ void iso15693_3_free(Iso15693_3Data* data) { } void iso15693_3_reset(Iso15693_3Data* data) { - furi_assert(data); + furi_check(data); memset(data->uid, 0, ISO15693_3_UID_SIZE); memset(&data->system_info, 0, sizeof(Iso15693_3SystemInfo)); @@ -65,8 +65,8 @@ void iso15693_3_reset(Iso15693_3Data* data) { } void iso15693_3_copy(Iso15693_3Data* data, const Iso15693_3Data* other) { - furi_assert(data); - furi_assert(other); + furi_check(data); + furi_check(other); memcpy(data->uid, other->uid, ISO15693_3_UID_SIZE); @@ -79,6 +79,8 @@ void iso15693_3_copy(Iso15693_3Data* data, const Iso15693_3Data* other) { bool iso15693_3_verify(Iso15693_3Data* data, const FuriString* device_type) { UNUSED(data); + furi_check(device_type); + return furi_string_equal(device_type, ISO15693_3_PROTOCOL_NAME_LEGACY); } @@ -136,7 +138,8 @@ static inline bool iso15693_3_load_security(Iso15693_3Data* data, FlipperFormat* } bool iso15693_3_load(Iso15693_3Data* data, FlipperFormat* ff, uint32_t version) { - furi_assert(data); + furi_check(data); + furi_check(ff); UNUSED(version); bool loaded = false; @@ -207,7 +210,8 @@ bool iso15693_3_load(Iso15693_3Data* data, FlipperFormat* ff, uint32_t version) } bool iso15693_3_save(const Iso15693_3Data* data, FlipperFormat* ff) { - furi_assert(data); + furi_check(data); + furi_check(ff); bool saved = false; @@ -280,12 +284,15 @@ bool iso15693_3_save(const Iso15693_3Data* data, FlipperFormat* ff) { } bool iso15693_3_is_equal(const Iso15693_3Data* data, const Iso15693_3Data* other) { - furi_assert(data); - furi_assert(other); + furi_check(data); + furi_check(other); return memcmp(data->uid, other->uid, ISO15693_3_UID_SIZE) == 0 && memcmp(&data->settings, &other->settings, sizeof(Iso15693_3Settings)) == 0 && - memcmp(&data->system_info, &other->system_info, sizeof(Iso15693_3SystemInfo)) == 0 && + memcmp( //-V1103 + &data->system_info, + &other->system_info, + sizeof(Iso15693_3SystemInfo)) == 0 && simple_array_is_equal(data->block_data, other->block_data) && simple_array_is_equal(data->block_security, other->block_security); } @@ -298,15 +305,15 @@ const char* iso15693_3_get_device_name(const Iso15693_3Data* data, NfcDeviceName } const uint8_t* iso15693_3_get_uid(const Iso15693_3Data* data, size_t* uid_len) { - furi_assert(data); + furi_check(data); if(uid_len) *uid_len = ISO15693_3_UID_SIZE; return data->uid; } bool iso15693_3_set_uid(Iso15693_3Data* data, const uint8_t* uid, size_t uid_len) { - furi_assert(data); - furi_assert(uid); + furi_check(data); + furi_check(uid); bool uid_valid = uid_len == ISO15693_3_UID_SIZE; @@ -325,8 +332,8 @@ Iso15693_3Data* iso15693_3_get_base_data(const Iso15693_3Data* data) { } bool iso15693_3_is_block_locked(const Iso15693_3Data* data, uint8_t block_index) { - furi_assert(data); - furi_assert(block_index < data->system_info.block_count); + furi_check(data); + furi_check(block_index < data->system_info.block_count); // TODO: make proper fix for this, old format had no Block Security Status in file if(simple_array_get_count(data->block_security) != 0) { @@ -337,26 +344,26 @@ bool iso15693_3_is_block_locked(const Iso15693_3Data* data, uint8_t block_index) } uint8_t iso15693_3_get_manufacturer_id(const Iso15693_3Data* data) { - furi_assert(data); + furi_check(data); return data->uid[1]; } uint16_t iso15693_3_get_block_count(const Iso15693_3Data* data) { - furi_assert(data); + furi_check(data); return data->system_info.block_count; } uint8_t iso15693_3_get_block_size(const Iso15693_3Data* data) { - furi_assert(data); + furi_check(data); return data->system_info.block_size; } const uint8_t* iso15693_3_get_block_data(const Iso15693_3Data* data, uint8_t block_index) { - furi_assert(data); - furi_assert(data->system_info.block_count > block_index); + furi_check(data); + furi_check(data->system_info.block_count > block_index); return (const uint8_t*)simple_array_cget( data->block_data, block_index * data->system_info.block_size); diff --git a/lib/nfc/protocols/iso15693_3/iso15693_3.h b/lib/nfc/protocols/iso15693_3/iso15693_3.h index 5d4158ab9..1120ac56e 100644 --- a/lib/nfc/protocols/iso15693_3/iso15693_3.h +++ b/lib/nfc/protocols/iso15693_3/iso15693_3.h @@ -122,7 +122,7 @@ typedef struct { SimpleArray* block_security; } Iso15693_3Data; -Iso15693_3Data* iso15693_3_alloc(); +Iso15693_3Data* iso15693_3_alloc(void); void iso15693_3_free(Iso15693_3Data* data); diff --git a/lib/nfc/protocols/iso15693_3/iso15693_3_poller_i.c b/lib/nfc/protocols/iso15693_3/iso15693_3_poller_i.c index 949390305..6aee84a3f 100644 --- a/lib/nfc/protocols/iso15693_3/iso15693_3_poller_i.c +++ b/lib/nfc/protocols/iso15693_3/iso15693_3_poller_i.c @@ -38,6 +38,8 @@ Iso15693_3Error iso15693_3_poller_send_frame( BitBuffer* rx_buffer, uint32_t fwt) { furi_assert(instance); + furi_check(tx_buffer); + furi_check(rx_buffer); Iso15693_3Error ret = Iso15693_3ErrorNone; diff --git a/lib/nfc/protocols/mf_classic/crypto1.c b/lib/nfc/protocols/mf_classic/crypto1.c index e06eae370..938d2765a 100644 --- a/lib/nfc/protocols/mf_classic/crypto1.c +++ b/lib/nfc/protocols/mf_classic/crypto1.c @@ -13,7 +13,7 @@ #define BEBIT(x, n) FURI_BIT(x, (n) ^ 24) -Crypto1* crypto1_alloc() { +Crypto1* crypto1_alloc(void) { Crypto1* instance = malloc(sizeof(Crypto1)); return instance; diff --git a/lib/nfc/protocols/mf_classic/crypto1.h b/lib/nfc/protocols/mf_classic/crypto1.h index 7cc16fcff..e71ab9a40 100644 --- a/lib/nfc/protocols/mf_classic/crypto1.h +++ b/lib/nfc/protocols/mf_classic/crypto1.h @@ -11,7 +11,7 @@ typedef struct { uint32_t even; } Crypto1; -Crypto1* crypto1_alloc(); +Crypto1* crypto1_alloc(void); void crypto1_free(Crypto1* instance); diff --git a/lib/nfc/protocols/mf_classic/mf_classic.c b/lib/nfc/protocols/mf_classic/mf_classic.c index 361c53c3d..5fee3eb7b 100644 --- a/lib/nfc/protocols/mf_classic/mf_classic.c +++ b/lib/nfc/protocols/mf_classic/mf_classic.c @@ -56,28 +56,28 @@ const NfcDeviceBase nfc_device_mf_classic = { .get_base_data = (NfcDeviceGetBaseData)mf_classic_get_base_data, }; -MfClassicData* mf_classic_alloc() { +MfClassicData* mf_classic_alloc(void) { MfClassicData* data = malloc(sizeof(MfClassicData)); data->iso14443_3a_data = iso14443_3a_alloc(); return data; } void mf_classic_free(MfClassicData* data) { - furi_assert(data); + furi_check(data); iso14443_3a_free(data->iso14443_3a_data); free(data); } void mf_classic_reset(MfClassicData* data) { - furi_assert(data); + furi_check(data); iso14443_3a_reset(data->iso14443_3a_data); } void mf_classic_copy(MfClassicData* data, const MfClassicData* other) { - furi_assert(data); - furi_assert(other); + furi_check(data); + furi_check(other); iso14443_3a_copy(data->iso14443_3a_data, other->iso14443_3a_data); for(size_t i = 0; i < COUNT_OF(data->block); i++) { @@ -92,7 +92,9 @@ void mf_classic_copy(MfClassicData* data, const MfClassicData* other) { } bool mf_classic_verify(MfClassicData* data, const FuriString* device_type) { + furi_check(device_type); UNUSED(data); + return furi_string_equal_str(device_type, "Mifare Classic"); } @@ -146,7 +148,8 @@ static void mf_classic_parse_block(FuriString* block_str, MfClassicData* data, u } bool mf_classic_load(MfClassicData* data, FlipperFormat* ff, uint32_t version) { - furi_assert(data); + furi_check(data); + furi_check(ff); FuriString* temp_str = furi_string_alloc(); bool parsed = false; @@ -255,7 +258,8 @@ static void } bool mf_classic_save(const MfClassicData* data, FlipperFormat* ff) { - furi_assert(data); + furi_check(data); + furi_check(ff); FuriString* temp_str = furi_string_alloc(); bool saved = false; @@ -297,6 +301,9 @@ bool mf_classic_save(const MfClassicData* data, FlipperFormat* ff) { } bool mf_classic_is_equal(const MfClassicData* data, const MfClassicData* other) { + furi_check(data); + furi_check(other); + bool is_equal = false; bool data_array_is_equal = true; @@ -329,8 +336,8 @@ bool mf_classic_is_equal(const MfClassicData* data, const MfClassicData* other) } const char* mf_classic_get_device_name(const MfClassicData* data, NfcDeviceNameType name_type) { - furi_assert(data); - furi_assert(data->type < MfClassicTypeNum); + furi_check(data); + furi_check(data->type < MfClassicTypeNum); if(name_type == NfcDeviceNameTypeFull) { return mf_classic_features[data->type].full_name; @@ -340,13 +347,13 @@ const char* mf_classic_get_device_name(const MfClassicData* data, NfcDeviceNameT } const uint8_t* mf_classic_get_uid(const MfClassicData* data, size_t* uid_len) { - furi_assert(data); + furi_check(data); return iso14443_3a_get_uid(data->iso14443_3a_data, uid_len); } bool mf_classic_set_uid(MfClassicData* data, const uint8_t* uid, size_t uid_len) { - furi_assert(data); + furi_check(data); bool uid_valid = iso14443_3a_set_uid(data->iso14443_3a_data, uid, uid_len); @@ -370,16 +377,18 @@ bool mf_classic_set_uid(MfClassicData* data, const uint8_t* uid, size_t uid_len) } Iso14443_3aData* mf_classic_get_base_data(const MfClassicData* data) { - furi_assert(data); + furi_check(data); return data->iso14443_3a_data; } uint8_t mf_classic_get_total_sectors_num(MfClassicType type) { + furi_check(type < MfClassicTypeNum); return mf_classic_features[type].sectors_total; } uint16_t mf_classic_get_total_block_num(MfClassicType type) { + furi_check(type < MfClassicTypeNum); return mf_classic_features[type].blocks_total; } @@ -411,7 +420,7 @@ uint8_t mf_classic_get_sector_trailer_num_by_block(uint8_t block) { MfClassicSectorTrailer* mf_classic_get_sector_trailer_by_sector(const MfClassicData* data, uint8_t sector_num) { - furi_assert(data); + furi_check(data); uint8_t sec_tr_block = mf_classic_get_sector_trailer_num_by_sector(sector_num); MfClassicSectorTrailer* sec_trailer = (MfClassicSectorTrailer*)&data->block[sec_tr_block]; @@ -436,7 +445,8 @@ uint8_t mf_classic_get_sector_by_block(uint8_t block) { } bool mf_classic_block_to_value(const MfClassicBlock* block, int32_t* value, uint8_t* addr) { - furi_assert(block); + furi_check(block); + furi_check(value); uint32_t v = *(uint32_t*)&block->data[0]; uint32_t v_inv = *(uint32_t*)&block->data[sizeof(uint32_t)]; @@ -445,9 +455,7 @@ bool mf_classic_block_to_value(const MfClassicBlock* block, int32_t* value, uint bool val_checks = ((v == v1) && (v == ~v_inv) && (block->data[12] == (~block->data[13] & 0xFF)) && (block->data[14] == (~block->data[15] & 0xFF)) && (block->data[12] == block->data[14])); - if(value) { - *value = (int32_t)v; - } + *value = (int32_t)v; if(addr) { *addr = block->data[12]; } @@ -455,7 +463,7 @@ bool mf_classic_block_to_value(const MfClassicBlock* block, int32_t* value, uint } void mf_classic_value_to_block(int32_t value, uint8_t addr, MfClassicBlock* block) { - furi_assert(block); + furi_check(block); uint32_t v_inv = ~((uint32_t)value); @@ -473,7 +481,7 @@ bool mf_classic_is_key_found( const MfClassicData* data, uint8_t sector_num, MfClassicKeyType key_type) { - furi_assert(data); + furi_check(data); bool key_found = false; if(key_type == MfClassicKeyTypeA) { @@ -490,7 +498,7 @@ void mf_classic_set_key_found( uint8_t sector_num, MfClassicKeyType key_type, uint64_t key) { - furi_assert(data); + furi_check(data); uint8_t key_arr[6] = {}; MfClassicSectorTrailer* sec_trailer = @@ -509,7 +517,7 @@ void mf_classic_set_key_not_found( MfClassicData* data, uint8_t sector_num, MfClassicKeyType key_type) { - furi_assert(data); + furi_check(data); if(key_type == MfClassicKeyTypeA) { FURI_BIT_CLEAR(data->key_a_mask, sector_num); @@ -519,13 +527,14 @@ void mf_classic_set_key_not_found( } bool mf_classic_is_block_read(const MfClassicData* data, uint8_t block_num) { - furi_assert(data); + furi_check(data); return (FURI_BIT(data->block_read_mask[block_num / 32], block_num % 32) == 1); } void mf_classic_set_block_read(MfClassicData* data, uint8_t block_num, MfClassicBlock* block_data) { - furi_assert(data); + furi_check(data); + furi_check(block_data); if(mf_classic_is_sector_trailer(block_num)) { memcpy(&data->block[block_num].data[6], &block_data->data[6], 4); @@ -536,7 +545,7 @@ void mf_classic_set_block_read(MfClassicData* data, uint8_t block_num, MfClassic } uint8_t mf_classic_get_first_block_num_of_sector(uint8_t sector) { - furi_assert(sector < 40); + furi_check(sector < 40); uint8_t block = 0; if(sector < 32) { @@ -549,7 +558,8 @@ uint8_t mf_classic_get_first_block_num_of_sector(uint8_t sector) { } uint8_t mf_classic_get_blocks_num_in_sector(uint8_t sector) { - furi_assert(sector < 40); + furi_check(sector < 40); + return sector < 32 ? 4 : 16; } @@ -557,9 +567,9 @@ void mf_classic_get_read_sectors_and_keys( const MfClassicData* data, uint8_t* sectors_read, uint8_t* keys_found) { - furi_assert(data); - furi_assert(sectors_read); - furi_assert(keys_found); + furi_check(data); + furi_check(sectors_read); + furi_check(keys_found); *sectors_read = 0; *keys_found = 0; @@ -585,7 +595,7 @@ void mf_classic_get_read_sectors_and_keys( } bool mf_classic_is_card_read(const MfClassicData* data) { - furi_assert(data); + furi_check(data); uint8_t sectors_total = mf_classic_get_total_sectors_num(data->type); uint8_t sectors_read = 0; @@ -597,7 +607,7 @@ bool mf_classic_is_card_read(const MfClassicData* data) { } bool mf_classic_is_sector_read(const MfClassicData* data, uint8_t sector_num) { - furi_assert(data); + furi_check(data); bool sector_read = false; do { @@ -662,7 +672,7 @@ bool mf_classic_is_allowed_access_data_block( uint8_t block_num, MfClassicKeyType key_type, MfClassicAction action) { - furi_assert(sec_tr); + furi_check(sec_tr); uint8_t* access_bits_arr = sec_tr->access_bits.data; @@ -732,7 +742,7 @@ bool mf_classic_is_allowed_access( uint8_t block_num, MfClassicKeyType key_type, MfClassicAction action) { - furi_assert(data); + furi_check(data); bool access_allowed = false; if(mf_classic_is_sector_trailer(block_num)) { @@ -749,7 +759,7 @@ bool mf_classic_is_allowed_access( } bool mf_classic_is_value_block(MfClassicSectorTrailer* sec_tr, uint8_t block_num) { - furi_assert(sec_tr); + furi_check(sec_tr); // Check if key A can write, if it can, it's transport configuration, not data block return !mf_classic_is_allowed_access_data_block( diff --git a/lib/nfc/protocols/mf_classic/mf_classic.h b/lib/nfc/protocols/mf_classic/mf_classic.h index 755c457d1..b42e09ab1 100644 --- a/lib/nfc/protocols/mf_classic/mf_classic.h +++ b/lib/nfc/protocols/mf_classic/mf_classic.h @@ -143,7 +143,7 @@ typedef struct { extern const NfcDeviceBase nfc_device_mf_classic; -MfClassicData* mf_classic_alloc(); +MfClassicData* mf_classic_alloc(void); void mf_classic_free(MfClassicData* data); diff --git a/lib/nfc/protocols/mf_classic/mf_classic_poller_i.c b/lib/nfc/protocols/mf_classic/mf_classic_poller_i.c index 3f8b93482..2b01e74ee 100644 --- a/lib/nfc/protocols/mf_classic/mf_classic_poller_i.c +++ b/lib/nfc/protocols/mf_classic/mf_classic_poller_i.c @@ -90,6 +90,8 @@ MfClassicError mf_classic_poller_get_nt( uint8_t block_num, MfClassicKeyType key_type, MfClassicNt* nt) { + furi_check(instance); + return mf_classic_poller_get_nt_common(instance, block_num, key_type, nt, false); } @@ -98,6 +100,8 @@ MfClassicError mf_classic_poller_get_nt_nested( uint8_t block_num, MfClassicKeyType key_type, MfClassicNt* nt) { + furi_check(instance); + return mf_classic_poller_get_nt_common(instance, block_num, key_type, nt, true); } @@ -179,6 +183,8 @@ MfClassicError mf_classic_poller_auth( MfClassicKey* key, MfClassicKeyType key_type, MfClassicAuthContext* data) { + furi_check(instance); + furi_check(key); return mf_classic_poller_auth_common(instance, block_num, key, key_type, data, false); } @@ -188,10 +194,14 @@ MfClassicError mf_classic_poller_auth_nested( MfClassicKey* key, MfClassicKeyType key_type, MfClassicAuthContext* data) { + furi_check(instance); + furi_check(key); return mf_classic_poller_auth_common(instance, block_num, key, key_type, data, true); } MfClassicError mf_classic_poller_halt(MfClassicPoller* instance) { + furi_check(instance); + MfClassicError ret = MfClassicErrorNone; Iso14443_3aError error = Iso14443_3aErrorNone; @@ -223,6 +233,9 @@ MfClassicError mf_classic_poller_read_block( MfClassicPoller* instance, uint8_t block_num, MfClassicBlock* data) { + furi_check(instance); + furi_check(data); + MfClassicError ret = MfClassicErrorNone; Iso14443_3aError error = Iso14443_3aErrorNone; @@ -269,6 +282,9 @@ MfClassicError mf_classic_poller_write_block( MfClassicPoller* instance, uint8_t block_num, MfClassicBlock* data) { + furi_check(instance); + furi_check(data); + MfClassicError ret = MfClassicErrorNone; Iso14443_3aError error = Iso14443_3aErrorNone; @@ -341,6 +357,8 @@ MfClassicError mf_classic_poller_value_cmd( uint8_t block_num, MfClassicValueCommand cmd, int32_t data) { + furi_check(instance); + MfClassicError ret = MfClassicErrorNone; Iso14443_3aError error = Iso14443_3aErrorNone; @@ -407,6 +425,8 @@ MfClassicError mf_classic_poller_value_cmd( } MfClassicError mf_classic_poller_value_transfer(MfClassicPoller* instance, uint8_t block_num) { + furi_check(instance); + MfClassicError ret = MfClassicErrorNone; Iso14443_3aError error = Iso14443_3aErrorNone; diff --git a/lib/nfc/protocols/mf_classic/mf_classic_poller_sync.c b/lib/nfc/protocols/mf_classic/mf_classic_poller_sync.c index 8566a8612..cc6bc0908 100644 --- a/lib/nfc/protocols/mf_classic/mf_classic_poller_sync.c +++ b/lib/nfc/protocols/mf_classic/mf_classic_poller_sync.c @@ -225,7 +225,7 @@ MfClassicError mf_classic_poller_sync_collect_nt( uint8_t block_num, MfClassicKeyType key_type, MfClassicNt* nt) { - furi_assert(nfc); + furi_check(nfc); MfClassicPollerContext poller_context = { .cmd_type = MfClassicPollerCmdTypeCollectNt, @@ -250,8 +250,8 @@ MfClassicError mf_classic_poller_sync_auth( MfClassicKey* key, MfClassicKeyType key_type, MfClassicAuthContext* data) { - furi_assert(nfc); - furi_assert(key); + furi_check(nfc); + furi_check(key); MfClassicPollerContext poller_context = { .cmd_type = MfClassicPollerCmdTypeAuth, @@ -277,9 +277,9 @@ MfClassicError mf_classic_poller_sync_read_block( MfClassicKey* key, MfClassicKeyType key_type, MfClassicBlock* data) { - furi_assert(nfc); - furi_assert(key); - furi_assert(data); + furi_check(nfc); + furi_check(key); + furi_check(data); MfClassicPollerContext poller_context = { .cmd_type = MfClassicPollerCmdTypeReadBlock, @@ -303,9 +303,9 @@ MfClassicError mf_classic_poller_sync_write_block( MfClassicKey* key, MfClassicKeyType key_type, MfClassicBlock* data) { - furi_assert(nfc); - furi_assert(key); - furi_assert(data); + furi_check(nfc); + furi_check(key); + furi_check(data); MfClassicPollerContext poller_context = { .cmd_type = MfClassicPollerCmdTypeWriteBlock, @@ -326,9 +326,9 @@ MfClassicError mf_classic_poller_sync_read_value( MfClassicKey* key, MfClassicKeyType key_type, int32_t* value) { - furi_assert(nfc); - furi_assert(key); - furi_assert(value); + furi_check(nfc); + furi_check(key); + furi_check(value); MfClassicPollerContext poller_context = { .cmd_type = MfClassicPollerCmdTypeReadValue, @@ -353,9 +353,9 @@ MfClassicError mf_classic_poller_sync_change_value( MfClassicKeyType key_type, int32_t data, int32_t* new_value) { - furi_assert(nfc); - furi_assert(key); - furi_assert(new_value); + furi_check(nfc); + furi_check(key); + furi_check(new_value); MfClassicValueCommand command = MfClassicValueCommandRestore; int32_t command_data = 0; @@ -459,9 +459,9 @@ NfcCommand mf_classic_poller_read_callback(NfcGenericEvent event, void* context) MfClassicError mf_classic_poller_sync_read(Nfc* nfc, const MfClassicDeviceKeys* keys, MfClassicData* data) { - furi_assert(nfc); - furi_assert(keys); - furi_assert(data); + furi_check(nfc); + furi_check(keys); + furi_check(data); MfClassicError error = MfClassicErrorNone; MfClassicPollerContext poller_context = {}; @@ -493,8 +493,8 @@ MfClassicError } MfClassicError mf_classic_poller_sync_detect_type(Nfc* nfc, MfClassicType* type) { - furi_assert(nfc); - furi_assert(type); + furi_check(nfc); + furi_check(type); MfClassicError error = MfClassicErrorNone; diff --git a/lib/nfc/protocols/mf_desfire/mf_desfire.c b/lib/nfc/protocols/mf_desfire/mf_desfire.c index b83198a25..4d54a2c0e 100644 --- a/lib/nfc/protocols/mf_desfire/mf_desfire.c +++ b/lib/nfc/protocols/mf_desfire/mf_desfire.c @@ -20,7 +20,7 @@ const NfcDeviceBase nfc_device_mf_desfire = { .get_base_data = (NfcDeviceGetBaseData)mf_desfire_get_base_data, }; -MfDesfireData* mf_desfire_alloc() { +MfDesfireData* mf_desfire_alloc(void) { MfDesfireData* data = malloc(sizeof(MfDesfireData)); data->iso14443_4a_data = iso14443_4a_alloc(); data->master_key_versions = simple_array_alloc(&mf_desfire_key_version_array_config); @@ -31,7 +31,7 @@ MfDesfireData* mf_desfire_alloc() { } void mf_desfire_free(MfDesfireData* data) { - furi_assert(data); + furi_check(data); mf_desfire_reset(data); simple_array_free(data->applications); @@ -42,7 +42,7 @@ void mf_desfire_free(MfDesfireData* data) { } void mf_desfire_reset(MfDesfireData* data) { - furi_assert(data); + furi_check(data); iso14443_4a_reset(data->iso14443_4a_data); @@ -55,8 +55,8 @@ void mf_desfire_reset(MfDesfireData* data) { } void mf_desfire_copy(MfDesfireData* data, const MfDesfireData* other) { - furi_assert(data); - furi_assert(other); + furi_check(data); + furi_check(other); mf_desfire_reset(data); @@ -77,7 +77,8 @@ bool mf_desfire_verify(MfDesfireData* data, const FuriString* device_type) { } bool mf_desfire_load(MfDesfireData* data, FlipperFormat* ff, uint32_t version) { - furi_assert(data); + furi_check(data); + furi_check(ff); FuriString* prefix = furi_string_alloc(); @@ -143,7 +144,8 @@ bool mf_desfire_load(MfDesfireData* data, FlipperFormat* ff, uint32_t version) { } bool mf_desfire_save(const MfDesfireData* data, FlipperFormat* ff) { - furi_assert(data); + furi_check(data); + furi_check(ff); FuriString* prefix = furi_string_alloc(); @@ -208,12 +210,15 @@ bool mf_desfire_save(const MfDesfireData* data, FlipperFormat* ff) { } bool mf_desfire_is_equal(const MfDesfireData* data, const MfDesfireData* other) { - furi_assert(data); - furi_assert(other); + furi_check(data); + furi_check(other); return iso14443_4a_is_equal(data->iso14443_4a_data, other->iso14443_4a_data) && memcmp(&data->version, &other->version, sizeof(MfDesfireVersion)) == 0 && - memcmp(&data->free_memory, &other->free_memory, sizeof(MfDesfireFreeMemory)) == 0 && + memcmp( //-V1103 + &data->free_memory, + &other->free_memory, + sizeof(MfDesfireFreeMemory)) == 0 && memcmp( &data->master_key_settings, &other->master_key_settings, @@ -230,25 +235,29 @@ const char* mf_desfire_get_device_name(const MfDesfireData* data, NfcDeviceNameT } const uint8_t* mf_desfire_get_uid(const MfDesfireData* data, size_t* uid_len) { - furi_assert(data); + furi_check(data); + furi_check(uid_len); return iso14443_4a_get_uid(data->iso14443_4a_data, uid_len); } bool mf_desfire_set_uid(MfDesfireData* data, const uint8_t* uid, size_t uid_len) { - furi_assert(data); + furi_check(data); return iso14443_4a_set_uid(data->iso14443_4a_data, uid, uid_len); } Iso14443_4aData* mf_desfire_get_base_data(const MfDesfireData* data) { - furi_assert(data); + furi_check(data); return data->iso14443_4a_data; } const MfDesfireApplication* mf_desfire_get_application(const MfDesfireData* data, const MfDesfireApplicationId* app_id) { + furi_check(data); + furi_check(app_id); + MfDesfireApplication* app = NULL; for(uint32_t i = 0; i < simple_array_get_count(data->application_ids); ++i) { @@ -263,6 +272,9 @@ const MfDesfireApplication* const MfDesfireFileSettings* mf_desfire_get_file_settings(const MfDesfireApplication* data, const MfDesfireFileId* file_id) { + furi_check(data); + furi_check(file_id); + MfDesfireFileSettings* file_settings = NULL; for(uint32_t i = 0; i < simple_array_get_count(data->file_ids); ++i) { @@ -277,6 +289,9 @@ const MfDesfireFileSettings* const MfDesfireFileData* mf_desfire_get_file_data(const MfDesfireApplication* data, const MfDesfireFileId* file_id) { + furi_check(data); + furi_check(file_id); + MfDesfireFileData* file_data = NULL; for(uint32_t i = 0; i < simple_array_get_count(data->file_ids); ++i) { diff --git a/lib/nfc/protocols/mf_desfire/mf_desfire.h b/lib/nfc/protocols/mf_desfire/mf_desfire.h index 8505b792a..4c3075386 100644 --- a/lib/nfc/protocols/mf_desfire/mf_desfire.h +++ b/lib/nfc/protocols/mf_desfire/mf_desfire.h @@ -152,7 +152,7 @@ extern const NfcDeviceBase nfc_device_mf_desfire; // Virtual methods -MfDesfireData* mf_desfire_alloc(); +MfDesfireData* mf_desfire_alloc(void); void mf_desfire_free(MfDesfireData* data); diff --git a/lib/nfc/protocols/mf_desfire/mf_desfire_poller_i.c b/lib/nfc/protocols/mf_desfire/mf_desfire_poller_i.c index 1a91c5261..f4e6e3681 100644 --- a/lib/nfc/protocols/mf_desfire/mf_desfire_poller_i.c +++ b/lib/nfc/protocols/mf_desfire/mf_desfire_poller_i.c @@ -23,12 +23,12 @@ MfDesfireError mf_desfire_send_chunks( MfDesfirePoller* instance, const BitBuffer* tx_buffer, BitBuffer* rx_buffer) { - furi_assert(instance); - furi_assert(instance->iso14443_4a_poller); - furi_assert(instance->tx_buffer); - furi_assert(instance->rx_buffer); - furi_assert(tx_buffer); - furi_assert(rx_buffer); + furi_check(instance); + furi_check(instance->iso14443_4a_poller); + furi_check(instance->tx_buffer); + furi_check(instance->rx_buffer); + furi_check(tx_buffer); + furi_check(rx_buffer); MfDesfireError error = MfDesfireErrorNone; @@ -75,7 +75,7 @@ MfDesfireError mf_desfire_send_chunks( } MfDesfireError mf_desfire_poller_read_version(MfDesfirePoller* instance, MfDesfireVersion* data) { - furi_assert(instance); + furi_check(instance); bit_buffer_reset(instance->input_buffer); bit_buffer_append_byte(instance->input_buffer, MF_DESFIRE_CMD_GET_VERSION); @@ -97,7 +97,7 @@ MfDesfireError mf_desfire_poller_read_version(MfDesfirePoller* instance, MfDesfi MfDesfireError mf_desfire_poller_read_free_memory(MfDesfirePoller* instance, MfDesfireFreeMemory* data) { - furi_assert(instance); + furi_check(instance); bit_buffer_reset(instance->input_buffer); bit_buffer_append_byte(instance->input_buffer, MF_DESFIRE_CMD_GET_FREE_MEMORY); @@ -119,7 +119,7 @@ MfDesfireError MfDesfireError mf_desfire_poller_read_key_settings(MfDesfirePoller* instance, MfDesfireKeySettings* data) { - furi_assert(instance); + furi_check(instance); bit_buffer_reset(instance->input_buffer); bit_buffer_append_byte(instance->input_buffer, MF_DESFIRE_CMD_GET_KEY_SETTINGS); @@ -165,8 +165,8 @@ MfDesfireError mf_desfire_poller_read_key_versions( MfDesfirePoller* instance, SimpleArray* data, uint32_t count) { - furi_assert(instance); - furi_assert(count > 0); + furi_check(instance); + furi_check(count > 0); simple_array_init(data, count); @@ -182,7 +182,8 @@ MfDesfireError mf_desfire_poller_read_key_versions( MfDesfireError mf_desfire_poller_read_application_ids(MfDesfirePoller* instance, SimpleArray* data) { - furi_assert(instance); + furi_check(instance); + furi_check(data); bit_buffer_reset(instance->input_buffer); bit_buffer_append_byte(instance->input_buffer, MF_DESFIRE_CMD_GET_APPLICATION_IDS); @@ -215,7 +216,7 @@ MfDesfireError MfDesfireError mf_desfire_poller_select_application( MfDesfirePoller* instance, const MfDesfireApplicationId* id) { - furi_assert(instance); + furi_check(instance); bit_buffer_reset(instance->input_buffer); bit_buffer_append_byte(instance->input_buffer, MF_DESFIRE_CMD_SELECT_APPLICATION); @@ -229,7 +230,8 @@ MfDesfireError mf_desfire_poller_select_application( } MfDesfireError mf_desfire_poller_read_file_ids(MfDesfirePoller* instance, SimpleArray* data) { - furi_assert(instance); + furi_check(instance); + furi_check(data); bit_buffer_reset(instance->input_buffer); bit_buffer_append_byte(instance->input_buffer, MF_DESFIRE_CMD_GET_FILE_IDS); @@ -262,7 +264,8 @@ MfDesfireError mf_desfire_poller_read_file_settings( MfDesfirePoller* instance, MfDesfireFileId id, MfDesfireFileSettings* data) { - furi_assert(instance); + furi_check(instance); + furi_check(data); bit_buffer_reset(instance->input_buffer); bit_buffer_append_byte(instance->input_buffer, MF_DESFIRE_CMD_GET_FILE_SETTINGS); @@ -287,7 +290,9 @@ MfDesfireError mf_desfire_poller_read_file_settings_multi( MfDesfirePoller* instance, const SimpleArray* file_ids, SimpleArray* data) { - furi_assert(instance); + furi_check(instance); + furi_check(file_ids); + furi_check(data); MfDesfireError error = MfDesfireErrorNone; @@ -311,7 +316,8 @@ MfDesfireError mf_desfire_poller_read_file_data( uint32_t offset, size_t size, MfDesfireFileData* data) { - furi_assert(instance); + furi_check(instance); + furi_check(data); bit_buffer_reset(instance->input_buffer); bit_buffer_append_byte(instance->input_buffer, MF_DESFIRE_CMD_READ_DATA); @@ -338,7 +344,8 @@ MfDesfireError mf_desfire_poller_read_file_value( MfDesfirePoller* instance, MfDesfireFileId id, MfDesfireFileData* data) { - furi_assert(instance); + furi_check(instance); + furi_check(data); bit_buffer_reset(instance->input_buffer); bit_buffer_append_byte(instance->input_buffer, MF_DESFIRE_CMD_GET_VALUE); @@ -365,7 +372,8 @@ MfDesfireError mf_desfire_poller_read_file_records( uint32_t offset, size_t size, MfDesfireFileData* data) { - furi_assert(instance); + furi_check(instance); + furi_check(data); bit_buffer_reset(instance->input_buffer); bit_buffer_append_byte(instance->input_buffer, MF_DESFIRE_CMD_READ_RECORDS); @@ -393,8 +401,11 @@ MfDesfireError mf_desfire_poller_read_file_data_multi( const SimpleArray* file_ids, const SimpleArray* file_settings, SimpleArray* data) { - furi_assert(instance); - furi_assert(simple_array_get_count(file_ids) == simple_array_get_count(file_settings)); + furi_check(instance); + furi_check(file_ids); + furi_check(file_settings); + furi_check(data); + furi_check(simple_array_get_count(file_ids) == simple_array_get_count(file_settings)); MfDesfireError error = MfDesfireErrorNone; @@ -430,8 +441,8 @@ MfDesfireError mf_desfire_poller_read_file_data_multi( MfDesfireError mf_desfire_poller_read_application(MfDesfirePoller* instance, MfDesfireApplication* data) { - furi_assert(instance); - furi_assert(data); + furi_check(instance); + furi_check(data); MfDesfireError error; @@ -463,7 +474,8 @@ MfDesfireError mf_desfire_poller_read_applications( MfDesfirePoller* instance, const SimpleArray* app_ids, SimpleArray* data) { - furi_assert(instance); + furi_check(instance); + furi_check(data); MfDesfireError error = MfDesfireErrorNone; diff --git a/lib/nfc/protocols/mf_ultralight/mf_ultralight.c b/lib/nfc/protocols/mf_ultralight/mf_ultralight.c index d4c5ba103..74436dc08 100644 --- a/lib/nfc/protocols/mf_ultralight/mf_ultralight.c +++ b/lib/nfc/protocols/mf_ultralight/mf_ultralight.c @@ -168,28 +168,28 @@ const NfcDeviceBase nfc_device_mf_ultralight = { .get_base_data = (NfcDeviceGetBaseData)mf_ultralight_get_base_data, }; -MfUltralightData* mf_ultralight_alloc() { +MfUltralightData* mf_ultralight_alloc(void) { MfUltralightData* data = malloc(sizeof(MfUltralightData)); data->iso14443_3a_data = iso14443_3a_alloc(); return data; } void mf_ultralight_free(MfUltralightData* data) { - furi_assert(data); + furi_check(data); iso14443_3a_free(data->iso14443_3a_data); free(data); } void mf_ultralight_reset(MfUltralightData* data) { - furi_assert(data); + furi_check(data); iso14443_3a_reset(data->iso14443_3a_data); } void mf_ultralight_copy(MfUltralightData* data, const MfUltralightData* other) { - furi_assert(data); - furi_assert(other); + furi_check(data); + furi_check(other); iso14443_3a_copy(data->iso14443_3a_data, other->iso14443_3a_data); for(size_t i = 0; i < COUNT_OF(data->counter); i++) { @@ -222,7 +222,8 @@ static const char* } bool mf_ultralight_verify(MfUltralightData* data, const FuriString* device_type) { - furi_assert(data); + furi_check(data); + furi_check(device_type); bool verified = false; @@ -239,7 +240,8 @@ bool mf_ultralight_verify(MfUltralightData* data, const FuriString* device_type) } bool mf_ultralight_load(MfUltralightData* data, FlipperFormat* ff, uint32_t version) { - furi_assert(data); + furi_check(data); + furi_check(ff); FuriString* temp_str = furi_string_alloc(); bool parsed = false; @@ -338,7 +340,8 @@ bool mf_ultralight_load(MfUltralightData* data, FlipperFormat* ff, uint32_t vers } bool mf_ultralight_save(const MfUltralightData* data, FlipperFormat* ff) { - furi_assert(data); + furi_check(data); + furi_check(ff); FuriString* temp_str = furi_string_alloc(); bool saved = false; @@ -419,6 +422,9 @@ bool mf_ultralight_save(const MfUltralightData* data, FlipperFormat* ff) { } bool mf_ultralight_is_equal(const MfUltralightData* data, const MfUltralightData* other) { + furi_check(data); + furi_check(other); + bool is_equal = false; bool data_array_is_equal = true; @@ -467,20 +473,20 @@ bool mf_ultralight_is_equal(const MfUltralightData* data, const MfUltralightData const char* mf_ultralight_get_device_name(const MfUltralightData* data, NfcDeviceNameType name_type) { - furi_assert(data); - furi_assert(data->type < MfUltralightTypeNum); + furi_check(data); + furi_check(data->type < MfUltralightTypeNum); return mf_ultralight_get_device_name_by_type(data->type, name_type); } const uint8_t* mf_ultralight_get_uid(const MfUltralightData* data, size_t* uid_len) { - furi_assert(data); + furi_check(data); return iso14443_3a_get_uid(data->iso14443_3a_data, uid_len); } bool mf_ultralight_set_uid(MfUltralightData* data, const uint8_t* uid, size_t uid_len) { - furi_assert(data); + furi_check(data); bool uid_valid = iso14443_3a_set_uid(data->iso14443_3a_data, uid, uid_len); @@ -498,13 +504,13 @@ bool mf_ultralight_set_uid(MfUltralightData* data, const uint8_t* uid, size_t ui } Iso14443_3aData* mf_ultralight_get_base_data(const MfUltralightData* data) { - furi_assert(data); + furi_check(data); return data->iso14443_3a_data; } MfUltralightType mf_ultralight_get_type_by_version(MfUltralightVersion* version) { - furi_assert(version); + furi_check(version); MfUltralightType type = MfUltralightTypeUnknown; @@ -538,15 +544,19 @@ MfUltralightType mf_ultralight_get_type_by_version(MfUltralightVersion* version) } uint16_t mf_ultralight_get_pages_total(MfUltralightType type) { + furi_check(type < MfUltralightTypeNum); + return mf_ultralight_features[type].total_pages; } uint32_t mf_ultralight_get_feature_support_set(MfUltralightType type) { + furi_check(type < MfUltralightTypeNum); + return mf_ultralight_features[type].feature_set; } bool mf_ultralight_detect_protocol(const Iso14443_3aData* iso14443_3a_data) { - furi_assert(iso14443_3a_data); + furi_check(iso14443_3a_data); bool mfu_detected = (iso14443_3a_data->atqa[0] == 0x44) && (iso14443_3a_data->atqa[1] == 0x00) && (iso14443_3a_data->sak == 0x00); @@ -555,10 +565,14 @@ bool mf_ultralight_detect_protocol(const Iso14443_3aData* iso14443_3a_data) { } uint16_t mf_ultralight_get_config_page_num(MfUltralightType type) { + furi_check(type < MfUltralightTypeNum); + return mf_ultralight_features[type].config_page; } uint8_t mf_ultralight_get_pwd_page_num(MfUltralightType type) { + furi_check(type < MfUltralightTypeNum); + uint8_t config_page = mf_ultralight_features[type].config_page; return (config_page != 0) ? config_page + 2 : 0; } @@ -574,8 +588,8 @@ bool mf_ultralight_support_feature(const uint32_t feature_set, const uint32_t fe } bool mf_ultralight_get_config_page(const MfUltralightData* data, MfUltralightConfigPages** config) { - furi_assert(data); - furi_assert(config); + furi_check(data); + furi_check(config); bool config_pages_found = false; @@ -589,7 +603,7 @@ bool mf_ultralight_get_config_page(const MfUltralightData* data, MfUltralightCon } bool mf_ultralight_is_all_data_read(const MfUltralightData* data) { - furi_assert(data); + furi_check(data); bool all_read = false; if(data->pages_read == data->pages_total || @@ -616,7 +630,7 @@ bool mf_ultralight_is_all_data_read(const MfUltralightData* data) { } bool mf_ultralight_is_counter_configured(const MfUltralightData* data) { - furi_assert(data); + furi_check(data); MfUltralightConfigPages* config = NULL; bool configured = false; diff --git a/lib/nfc/protocols/mf_ultralight/mf_ultralight.h b/lib/nfc/protocols/mf_ultralight/mf_ultralight.h index 4786b1825..5e348a0c9 100644 --- a/lib/nfc/protocols/mf_ultralight/mf_ultralight.h +++ b/lib/nfc/protocols/mf_ultralight/mf_ultralight.h @@ -177,7 +177,7 @@ typedef struct { extern const NfcDeviceBase nfc_device_mf_ultralight; -MfUltralightData* mf_ultralight_alloc(); +MfUltralightData* mf_ultralight_alloc(void); void mf_ultralight_free(MfUltralightData* data); diff --git a/lib/nfc/protocols/mf_ultralight/mf_ultralight_poller_i.c b/lib/nfc/protocols/mf_ultralight/mf_ultralight_poller_i.c index 2d88db3e5..cc3433f73 100644 --- a/lib/nfc/protocols/mf_ultralight/mf_ultralight_poller_i.c +++ b/lib/nfc/protocols/mf_ultralight/mf_ultralight_poller_i.c @@ -33,6 +33,9 @@ MfUltralightError mf_ultralight_process_error(Iso14443_3aError error) { MfUltralightError mf_ultralight_poller_auth_pwd( MfUltralightPoller* instance, MfUltralightPollerAuthContext* data) { + furi_check(instance); + furi_check(data); + uint8_t auth_cmd[5] = {MF_ULTRALIGHT_CMD_PWD_AUTH}; //-V1009 memccpy(&auth_cmd[1], data->password.data, 0, MF_ULTRALIGHT_AUTH_PASSWORD_SIZE); bit_buffer_copy_bytes(instance->tx_buffer, auth_cmd, sizeof(auth_cmd)); @@ -60,6 +63,8 @@ MfUltralightError mf_ultralight_poller_auth_pwd( } MfUltralightError mf_ultralight_poller_authenticate(MfUltralightPoller* instance) { + furi_check(instance); + uint8_t auth_cmd[2] = {MF_ULTRALIGHT_CMD_AUTH, 0x00}; bit_buffer_copy_bytes(instance->tx_buffer, auth_cmd, sizeof(auth_cmd)); @@ -91,6 +96,9 @@ MfUltralightError mf_ultralight_poller_read_page_from_sector( uint8_t sector, uint8_t tag, MfUltralightPageReadCommandData* data) { + furi_check(instance); + furi_check(data); + MfUltralightError ret = MfUltralightErrorNone; Iso14443_3aError error = Iso14443_3aErrorNone; @@ -132,6 +140,9 @@ MfUltralightError mf_ultralight_poller_read_page( MfUltralightPoller* instance, uint8_t start_page, MfUltralightPageReadCommandData* data) { + furi_check(instance); + furi_check(data); + MfUltralightError ret = MfUltralightErrorNone; Iso14443_3aError error = Iso14443_3aErrorNone; @@ -162,6 +173,9 @@ MfUltralightError mf_ultralight_poller_write_page( MfUltralightPoller* instance, uint8_t page, const MfUltralightPage* data) { + furi_check(instance); + furi_check(data); + MfUltralightError ret = MfUltralightErrorNone; Iso14443_3aError error = Iso14443_3aErrorNone; @@ -193,6 +207,9 @@ MfUltralightError mf_ultralight_poller_write_page( MfUltralightError mf_ultralight_poller_read_version(MfUltralightPoller* instance, MfUltralightVersion* data) { + furi_check(instance); + furi_check(data); + MfUltralightError ret = MfUltralightErrorNone; Iso14443_3aError error = Iso14443_3aErrorNone; @@ -222,6 +239,9 @@ MfUltralightError MfUltralightError mf_ultralight_poller_read_signature(MfUltralightPoller* instance, MfUltralightSignature* data) { + furi_check(instance); + furi_check(data); + MfUltralightError ret = MfUltralightErrorNone; Iso14443_3aError error = Iso14443_3aErrorNone; @@ -251,6 +271,9 @@ MfUltralightError mf_ultralight_poller_read_counter( MfUltralightPoller* instance, uint8_t counter_num, MfUltralightCounter* data) { + furi_check(instance); + furi_check(data); + MfUltralightError ret = MfUltralightErrorNone; Iso14443_3aError error = Iso14443_3aErrorNone; @@ -280,6 +303,9 @@ MfUltralightError mf_ultralight_poller_read_tearing_flag( MfUltralightPoller* instance, uint8_t tearing_falg_num, MfUltralightTearingFlag* data) { + furi_check(instance); + furi_check(data); + MfUltralightError ret = MfUltralightErrorNone; Iso14443_3aError error = Iso14443_3aErrorNone; diff --git a/lib/nfc/protocols/mf_ultralight/mf_ultralight_poller_sync.c b/lib/nfc/protocols/mf_ultralight/mf_ultralight_poller_sync.c index c4833facf..157e2bdef 100644 --- a/lib/nfc/protocols/mf_ultralight/mf_ultralight_poller_sync.c +++ b/lib/nfc/protocols/mf_ultralight/mf_ultralight_poller_sync.c @@ -119,8 +119,8 @@ static MfUltralightError MfUltralightError mf_ultralight_poller_sync_read_page(Nfc* nfc, uint16_t page, MfUltralightPage* data) { - furi_assert(nfc); - furi_assert(data); + furi_check(nfc); + furi_check(data); MfUltralightPollerContext poller_context = { .cmd_type = MfUltralightPollerCmdTypeReadPage, @@ -138,8 +138,8 @@ MfUltralightError MfUltralightError mf_ultralight_poller_sync_write_page(Nfc* nfc, uint16_t page, MfUltralightPage* data) { - furi_assert(nfc); - furi_assert(data); + furi_check(nfc); + furi_check(data); MfUltralightPollerContext poller_context = { .cmd_type = MfUltralightPollerCmdTypeWritePage, @@ -156,8 +156,8 @@ MfUltralightError } MfUltralightError mf_ultralight_poller_sync_read_version(Nfc* nfc, MfUltralightVersion* data) { - furi_assert(nfc); - furi_assert(data); + furi_check(nfc); + furi_check(data); MfUltralightPollerContext poller_context = { .cmd_type = MfUltralightPollerCmdTypeReadVersion, @@ -173,8 +173,8 @@ MfUltralightError mf_ultralight_poller_sync_read_version(Nfc* nfc, MfUltralightV } MfUltralightError mf_ultralight_poller_sync_read_signature(Nfc* nfc, MfUltralightSignature* data) { - furi_assert(nfc); - furi_assert(data); + furi_check(nfc); + furi_check(data); MfUltralightPollerContext poller_context = { .cmd_type = MfUltralightPollerCmdTypeReadSignature, @@ -193,8 +193,8 @@ MfUltralightError mf_ultralight_poller_sync_read_counter( Nfc* nfc, uint8_t counter_num, MfUltralightCounter* data) { - furi_assert(nfc); - furi_assert(data); + furi_check(nfc); + furi_check(data); MfUltralightPollerContext poller_context = { .cmd_type = MfUltralightPollerCmdTypeReadCounter, @@ -214,8 +214,8 @@ MfUltralightError mf_ultralight_poller_sync_read_tearing_flag( Nfc* nfc, uint8_t flag_num, MfUltralightTearingFlag* data) { - furi_assert(nfc); - furi_assert(data); + furi_check(nfc); + furi_check(data); MfUltralightPollerContext poller_context = { .cmd_type = MfUltralightPollerCmdTypeReadTearingFlag, @@ -261,8 +261,8 @@ static NfcCommand mf_ultralight_poller_read_callback(NfcGenericEvent event, void } MfUltralightError mf_ultralight_poller_sync_read_card(Nfc* nfc, MfUltralightData* data) { - furi_assert(nfc); - furi_assert(data); + furi_check(nfc); + furi_check(data); MfUltralightPollerContext poller_context = {}; poller_context.thread_id = furi_thread_get_current_id(); diff --git a/lib/nfc/protocols/nfc_device_base_i.h b/lib/nfc/protocols/nfc_device_base_i.h index 946ae76dc..c440e7b93 100644 --- a/lib/nfc/protocols/nfc_device_base_i.h +++ b/lib/nfc/protocols/nfc_device_base_i.h @@ -20,7 +20,7 @@ extern "C" { * * @returns pointer to the allocated instance. */ -typedef NfcDeviceData* (*NfcDeviceAlloc)(); +typedef NfcDeviceData* (*NfcDeviceAlloc)(void); /** * @brief Delete the protocol-specific NFC device data instance. diff --git a/lib/nfc/protocols/nfc_protocol.c b/lib/nfc/protocols/nfc_protocol.c index 252f86de2..17c39fc9f 100644 --- a/lib/nfc/protocols/nfc_protocol.c +++ b/lib/nfc/protocols/nfc_protocol.c @@ -159,14 +159,14 @@ static const NfcProtocolTreeNode nfc_protocol_nodes[NfcProtocolNum] = { }; NfcProtocol nfc_protocol_get_parent(NfcProtocol protocol) { - furi_assert(protocol < NfcProtocolNum); + furi_check(protocol < NfcProtocolNum); return nfc_protocol_nodes[protocol].parent_protocol; } bool nfc_protocol_has_parent(NfcProtocol protocol, NfcProtocol parent_protocol) { - furi_assert(protocol < NfcProtocolNum); - furi_assert(parent_protocol < NfcProtocolNum); + furi_check(protocol < NfcProtocolNum); + furi_check(parent_protocol < NfcProtocolNum); bool parent_found = false; const NfcProtocolTreeNode* iter = &nfc_protocol_nodes[protocol]; diff --git a/lib/nfc/protocols/slix/slix.c b/lib/nfc/protocols/slix/slix.c index 6361787d3..533ecff74 100644 --- a/lib/nfc/protocols/slix/slix.c +++ b/lib/nfc/protocols/slix/slix.c @@ -89,7 +89,7 @@ static void slix_password_set_defaults(SlixPassword* passwords) { } } -SlixData* slix_alloc() { +SlixData* slix_alloc(void) { SlixData* data = malloc(sizeof(SlixData)); data->iso15693_3_data = iso15693_3_alloc(); @@ -99,7 +99,7 @@ SlixData* slix_alloc() { } void slix_free(SlixData* data) { - furi_assert(data); + furi_check(data); iso15693_3_free(data->iso15693_3_data); @@ -107,7 +107,7 @@ void slix_free(SlixData* data) { } void slix_reset(SlixData* data) { - furi_assert(data); + furi_check(data); iso15693_3_reset(data->iso15693_3_data); slix_password_set_defaults(data->passwords); @@ -119,8 +119,8 @@ void slix_reset(SlixData* data) { } void slix_copy(SlixData* data, const SlixData* other) { - furi_assert(data); - furi_assert(other); + furi_check(data); + furi_check(other); iso15693_3_copy(data->iso15693_3_data, other->iso15693_3_data); @@ -160,7 +160,8 @@ static bool slix_load_passwords(SlixPassword* passwords, SlixType slix_type, Fli } bool slix_load(SlixData* data, FlipperFormat* ff, uint32_t version) { - furi_assert(data); + furi_check(data); + furi_check(ff); bool loaded = false; @@ -238,7 +239,8 @@ static bool } bool slix_save(const SlixData* data, FlipperFormat* ff) { - furi_assert(data); + furi_check(data); + furi_check(ff); bool saved = false; @@ -303,6 +305,9 @@ bool slix_save(const SlixData* data, FlipperFormat* ff) { } bool slix_is_equal(const SlixData* data, const SlixData* other) { + furi_check(data); + furi_check(other); + return iso15693_3_is_equal(data->iso15693_3_data, other->iso15693_3_data) && memcmp(&data->system_info, &other->system_info, sizeof(SlixSystemInfo)) == 0 && memcmp( @@ -313,6 +318,7 @@ bool slix_is_equal(const SlixData* data, const SlixData* other) { } const char* slix_get_device_name(const SlixData* data, NfcDeviceNameType name_type) { + furi_check(data); UNUSED(name_type); const SlixType slix_type = slix_get_type(data); @@ -322,22 +328,25 @@ const char* slix_get_device_name(const SlixData* data, NfcDeviceNameType name_ty } const uint8_t* slix_get_uid(const SlixData* data, size_t* uid_len) { + furi_check(data); return iso15693_3_get_uid(data->iso15693_3_data, uid_len); } bool slix_set_uid(SlixData* data, const uint8_t* uid, size_t uid_len) { - furi_assert(data); + furi_check(data); return iso15693_3_set_uid(data->iso15693_3_data, uid, uid_len); } const Iso15693_3Data* slix_get_base_data(const SlixData* data) { - furi_assert(data); + furi_check(data); return data->iso15693_3_data; } SlixType slix_get_type(const SlixData* data) { + furi_check(data); + SlixType type = SlixTypeUnknown; do { @@ -364,14 +373,14 @@ SlixType slix_get_type(const SlixData* data) { } SlixPassword slix_get_password(const SlixData* data, SlixPasswordType password_type) { - furi_assert(data); - furi_assert(password_type < SlixPasswordTypeCount); + furi_check(data); + furi_check(password_type < SlixPasswordTypeCount); return data->passwords[password_type]; } uint16_t slix_get_counter(const SlixData* data) { - furi_assert(data); + furi_check(data); const SlixCounter* counter = (const SlixCounter*)iso15693_3_get_block_data( data->iso15693_3_data, SLIX_COUNTER_BLOCK_NUM); @@ -379,7 +388,7 @@ uint16_t slix_get_counter(const SlixData* data) { } bool slix_is_privacy_mode(const SlixData* data) { - furi_assert(data); + furi_check(data); return data->privacy; } @@ -388,8 +397,8 @@ bool slix_is_block_protected( const SlixData* data, SlixPasswordType password_type, uint8_t block_num) { - furi_assert(data); - furi_assert(password_type < SlixPasswordTypeCount); + furi_check(data); + furi_check(password_type < SlixPasswordTypeCount); bool ret = false; @@ -411,7 +420,7 @@ bool slix_is_block_protected( } bool slix_is_counter_increment_protected(const SlixData* data) { - furi_assert(data); + furi_check(data); const SlixCounter* counter = (const SlixCounter*)iso15693_3_get_block_data( data->iso15693_3_data, SLIX_COUNTER_BLOCK_NUM); @@ -420,14 +429,14 @@ bool slix_is_counter_increment_protected(const SlixData* data) { } bool slix_type_has_features(SlixType slix_type, SlixTypeFeatures features) { - furi_assert(slix_type < SlixTypeCount); + furi_check(slix_type < SlixTypeCount); return (slix_type_features[slix_type] & features) == features; } bool slix_type_supports_password(SlixType slix_type, SlixPasswordType password_type) { - furi_assert(slix_type < SlixTypeCount); - furi_assert(password_type < SlixPasswordTypeCount); + furi_check(slix_type < SlixTypeCount); + furi_check(password_type < SlixPasswordTypeCount); return slix_type_features[slix_type] & slix_password_configs[password_type].feature_flag; } diff --git a/lib/nfc/protocols/slix/slix.h b/lib/nfc/protocols/slix/slix.h index 26341072b..2de26847a 100644 --- a/lib/nfc/protocols/slix/slix.h +++ b/lib/nfc/protocols/slix/slix.h @@ -99,7 +99,7 @@ typedef struct { SlixPrivacy privacy; } SlixData; -SlixData* slix_alloc(); +SlixData* slix_alloc(void); void slix_free(SlixData* data); diff --git a/lib/nfc/protocols/st25tb/st25tb.c b/lib/nfc/protocols/st25tb/st25tb.c index 2b3eebf9e..8b1e9be2e 100644 --- a/lib/nfc/protocols/st25tb/st25tb.c +++ b/lib/nfc/protocols/st25tb/st25tb.c @@ -79,35 +79,39 @@ const NfcDeviceBase nfc_device_st25tb = { .get_base_data = (NfcDeviceGetBaseData)st25tb_get_base_data, }; -St25tbData* st25tb_alloc() { +St25tbData* st25tb_alloc(void) { St25tbData* data = malloc(sizeof(St25tbData)); return data; } void st25tb_free(St25tbData* data) { - furi_assert(data); + furi_check(data); free(data); } void st25tb_reset(St25tbData* data) { + furi_check(data); memset(data, 0, sizeof(St25tbData)); } void st25tb_copy(St25tbData* data, const St25tbData* other) { - furi_assert(data); - furi_assert(other); + furi_check(data); + furi_check(other); *data = *other; } bool st25tb_verify(St25tbData* data, const FuriString* device_type) { + furi_check(device_type); UNUSED(data); + return furi_string_equal_str(device_type, ST25TB_PROTOCOL_NAME); } bool st25tb_load(St25tbData* data, FlipperFormat* ff, uint32_t version) { - furi_assert(data); + furi_check(data); + furi_check(ff); bool parsed = false; @@ -150,7 +154,8 @@ bool st25tb_load(St25tbData* data, FlipperFormat* ff, uint32_t version) { } bool st25tb_save(const St25tbData* data, FlipperFormat* ff) { - furi_assert(data); + furi_check(data); + furi_check(ff); FuriString* temp_str = furi_string_alloc(); bool saved = false; @@ -184,19 +189,21 @@ bool st25tb_save(const St25tbData* data, FlipperFormat* ff) { } bool st25tb_is_equal(const St25tbData* data, const St25tbData* other) { - furi_assert(data); - furi_assert(other); + furi_check(data); + furi_check(other); - return memcmp(data, other, sizeof(St25tbData)) == 0; + return memcmp(data, other, sizeof(St25tbData)) == 0; //-V1103 } uint8_t st25tb_get_block_count(St25tbType type) { + furi_check(type < St25tbTypeNum); + return st25tb_features[type].blocks_total; } const char* st25tb_get_device_name(const St25tbData* data, NfcDeviceNameType name_type) { - furi_assert(data); - furi_assert(data->type < St25tbTypeNum); + furi_check(data); + furi_check(data->type < St25tbTypeNum); if(name_type == NfcDeviceNameTypeFull) { return st25tb_features[data->type].full_name; @@ -206,7 +213,7 @@ const char* st25tb_get_device_name(const St25tbData* data, NfcDeviceNameType nam } const uint8_t* st25tb_get_uid(const St25tbData* data, size_t* uid_len) { - furi_assert(data); + furi_check(data); if(uid_len) { *uid_len = ST25TB_UID_SIZE; @@ -216,7 +223,8 @@ const uint8_t* st25tb_get_uid(const St25tbData* data, size_t* uid_len) { } bool st25tb_set_uid(St25tbData* data, const uint8_t* uid, size_t uid_len) { - furi_assert(data); + furi_check(data); + furi_check(uid); const bool uid_valid = uid_len == ST25TB_UID_SIZE; @@ -233,6 +241,8 @@ St25tbData* st25tb_get_base_data(const St25tbData* data) { } St25tbType st25tb_get_type_from_uid(const uint8_t* uid) { + furi_check(uid); + switch(uid[2] >> 2) { case 0x0: case 0x3: diff --git a/lib/nfc/protocols/st25tb/st25tb.h b/lib/nfc/protocols/st25tb/st25tb.h index ed02dc2b2..67d733315 100644 --- a/lib/nfc/protocols/st25tb/st25tb.h +++ b/lib/nfc/protocols/st25tb/st25tb.h @@ -48,7 +48,7 @@ typedef struct { extern const NfcDeviceBase nfc_device_st25tb; -St25tbData* st25tb_alloc(); +St25tbData* st25tb_alloc(void); void st25tb_free(St25tbData* data); diff --git a/lib/nfc/protocols/st25tb/st25tb_poller_i.c b/lib/nfc/protocols/st25tb/st25tb_poller_i.c index adb8626a3..2bf025563 100644 --- a/lib/nfc/protocols/st25tb/st25tb_poller_i.c +++ b/lib/nfc/protocols/st25tb/st25tb_poller_i.c @@ -20,7 +20,9 @@ St25tbError st25tb_poller_send_frame( const BitBuffer* tx_buffer, BitBuffer* rx_buffer, uint32_t fwt) { - furi_assert(instance); + furi_check(instance); + furi_check(tx_buffer); + furi_check(rx_buffer); const size_t tx_bytes = bit_buffer_get_size_bytes(tx_buffer); furi_assert( @@ -54,8 +56,8 @@ St25tbError st25tb_poller_send_frame( St25tbError st25tb_poller_initiate(St25tbPoller* instance, uint8_t* chip_id_ptr) { // Send Initiate() - furi_assert(instance); - furi_assert(instance->nfc); + furi_check(instance); + furi_check(instance->nfc); bit_buffer_reset(instance->tx_buffer); bit_buffer_reset(instance->rx_buffer); @@ -86,8 +88,8 @@ St25tbError st25tb_poller_initiate(St25tbPoller* instance, uint8_t* chip_id_ptr) } St25tbError st25tb_poller_select(St25tbPoller* instance, uint8_t* chip_id_ptr) { - furi_assert(instance); - furi_assert(instance->nfc); + furi_check(instance); + furi_check(instance->nfc); St25tbError ret; @@ -169,8 +171,9 @@ St25tbError st25tb_poller_read(St25tbPoller* instance, St25tbData* data) { } St25tbError st25tb_poller_get_uid(St25tbPoller* instance, uint8_t* uid) { - furi_assert(instance); - furi_assert(instance->nfc); + furi_check(instance); + furi_check(instance->nfc); + furi_check(uid); St25tbError ret; @@ -213,10 +216,10 @@ St25tbError st25tb_poller_get_uid(St25tbPoller* instance, uint8_t* uid) { St25tbError st25tb_poller_read_block(St25tbPoller* instance, uint32_t* block, uint8_t block_number) { - furi_assert(instance); - furi_assert(instance->nfc); - furi_assert(block); - furi_assert( + furi_check(instance); + furi_check(instance->nfc); + furi_check(block); + furi_check( (block_number <= st25tb_get_block_count(instance->data->type)) || block_number == ST25TB_SYSTEM_OTP_BLOCK); FURI_LOG_T(TAG, "reading block %d", block_number); @@ -248,9 +251,9 @@ St25tbError St25tbError st25tb_poller_write_block(St25tbPoller* instance, uint32_t block, uint8_t block_number) { - furi_assert(instance); - furi_assert(instance->nfc); - furi_assert( + furi_check(instance); + furi_check(instance->nfc); + furi_check( (block_number <= st25tb_get_block_count(instance->data->type)) || block_number == ST25TB_SYSTEM_OTP_BLOCK); FURI_LOG_T(TAG, "writing block %d", block_number); @@ -292,7 +295,7 @@ St25tbError } St25tbError st25tb_poller_halt(St25tbPoller* instance) { - furi_assert(instance); + furi_check(instance); bit_buffer_reset(instance->tx_buffer); bit_buffer_reset(instance->rx_buffer); diff --git a/lib/nfc/protocols/st25tb/st25tb_poller_sync.c b/lib/nfc/protocols/st25tb/st25tb_poller_sync.c index 3cd0b3792..359435034 100644 --- a/lib/nfc/protocols/st25tb/st25tb_poller_sync.c +++ b/lib/nfc/protocols/st25tb/st25tb_poller_sync.c @@ -109,7 +109,8 @@ static St25tbError st25tb_poller_cmd_execute(Nfc* nfc, St25tbPollerSyncContext* } St25tbError st25tb_poller_sync_read_block(Nfc* nfc, uint8_t block_num, uint32_t* block) { - furi_assert(block); + furi_check(nfc); + furi_check(block); St25tbPollerSyncContext poller_context = { .cmd_type = St25tbPollerCmdTypeReadBlock, .cmd_data = @@ -125,6 +126,7 @@ St25tbError st25tb_poller_sync_read_block(Nfc* nfc, uint8_t block_num, uint32_t* } St25tbError st25tb_poller_sync_write_block(Nfc* nfc, uint8_t block_num, uint32_t block) { + furi_check(nfc); St25tbPollerSyncContext poller_context = { .cmd_type = St25tbPollerCmdTypeWriteBlock, .cmd_data = @@ -140,7 +142,8 @@ St25tbError st25tb_poller_sync_write_block(Nfc* nfc, uint8_t block_num, uint32_t } St25tbError st25tb_poller_sync_detect_type(Nfc* nfc, St25tbType* type) { - furi_assert(type); + furi_check(nfc); + furi_check(type); St25tbPollerSyncContext poller_context = { .cmd_type = St25tbPollerCmdTypeDetectType, .cmd_data = @@ -185,8 +188,8 @@ static NfcCommand nfc_scene_read_poller_callback_st25tb(NfcGenericEvent event, v } St25tbError st25tb_poller_sync_read(Nfc* nfc, St25tbData* data) { - furi_assert(nfc); - furi_assert(data); + furi_check(nfc); + furi_check(data); St25tbPollerSyncContext poller_context = { .thread_id = furi_thread_get_current_id(), diff --git a/lib/one_wire/maxim_crc.c b/lib/one_wire/maxim_crc.c index a5d099b10..ee60163e7 100644 --- a/lib/one_wire/maxim_crc.c +++ b/lib/one_wire/maxim_crc.c @@ -1,6 +1,9 @@ #include "maxim_crc.h" +#include uint8_t maxim_crc8(const uint8_t* data, const uint8_t data_size, const uint8_t crc_init) { + furi_check(data); + uint8_t crc = crc_init; for(uint8_t index = 0; index < data_size; ++index) { diff --git a/lib/one_wire/one_wire_host.c b/lib/one_wire/one_wire_host.c index 678812105..9383e0f15 100644 --- a/lib/one_wire/one_wire_host.c +++ b/lib/one_wire/one_wire_host.c @@ -56,19 +56,26 @@ struct OneWireHost { }; OneWireHost* onewire_host_alloc(const GpioPin* gpio_pin) { + furi_check(gpio_pin); + OneWireHost* host = malloc(sizeof(OneWireHost)); host->gpio_pin = gpio_pin; onewire_host_reset_search(host); onewire_host_set_overdrive(host, false); + return host; } void onewire_host_free(OneWireHost* host) { + furi_check(host); + onewire_host_stop(host); free(host); } bool onewire_host_reset(OneWireHost* host) { + furi_check(host); + uint8_t r; uint8_t retries = 125; @@ -100,6 +107,8 @@ bool onewire_host_reset(OneWireHost* host) { } bool onewire_host_read_bit(OneWireHost* host) { + furi_check(host); + bool result; const OneWireHostTimings* timings = host->timings; @@ -120,6 +129,8 @@ bool onewire_host_read_bit(OneWireHost* host) { } uint8_t onewire_host_read(OneWireHost* host) { + furi_check(host); + uint8_t result = 0; for(uint8_t bitMask = 0x01; bitMask; bitMask <<= 1) { @@ -132,12 +143,17 @@ uint8_t onewire_host_read(OneWireHost* host) { } void onewire_host_read_bytes(OneWireHost* host, uint8_t* buffer, uint16_t count) { + furi_check(host); + furi_check(buffer); + for(uint16_t i = 0; i < count; i++) { buffer[i] = onewire_host_read(host); } } void onewire_host_write_bit(OneWireHost* host, bool value) { + furi_check(host); + const OneWireHostTimings* timings = host->timings; if(value) { @@ -160,6 +176,8 @@ void onewire_host_write_bit(OneWireHost* host, bool value) { } void onewire_host_write(OneWireHost* host, uint8_t value) { + furi_check(host); + uint8_t bitMask; for(bitMask = 0x01; bitMask; bitMask <<= 1) { @@ -168,22 +186,31 @@ void onewire_host_write(OneWireHost* host, uint8_t value) { } void onewire_host_write_bytes(OneWireHost* host, const uint8_t* buffer, uint16_t count) { + furi_check(host); + furi_check(buffer); + for(uint16_t i = 0; i < count; ++i) { onewire_host_write(host, buffer[i]); } } void onewire_host_start(OneWireHost* host) { + furi_check(host); + furi_hal_gpio_write(host->gpio_pin, true); furi_hal_gpio_init(host->gpio_pin, GpioModeOutputOpenDrain, GpioPullNo, GpioSpeedLow); } void onewire_host_stop(OneWireHost* host) { + furi_check(host); + furi_hal_gpio_write(host->gpio_pin, true); furi_hal_gpio_init(host->gpio_pin, GpioModeAnalog, GpioPullNo, GpioSpeedLow); } void onewire_host_reset_search(OneWireHost* host) { + furi_check(host); + host->last_discrepancy = 0; host->last_device_flag = false; host->last_family_discrepancy = 0; @@ -194,6 +221,8 @@ void onewire_host_reset_search(OneWireHost* host) { } void onewire_host_target_search(OneWireHost* host, uint8_t family_code) { + furi_check(host); + host->saved_rom[0] = family_code; for(uint8_t i = 1; i < 8; i++) host->saved_rom[i] = 0; host->last_discrepancy = 64; @@ -202,6 +231,8 @@ void onewire_host_target_search(OneWireHost* host, uint8_t family_code) { } bool onewire_host_search(OneWireHost* host, uint8_t* new_addr, OneWireHostSearchMode mode) { + furi_check(host); + uint8_t id_bit_number; uint8_t last_zero, rom_byte_number, search_result; uint8_t id_bit, cmp_id_bit; @@ -317,5 +348,7 @@ bool onewire_host_search(OneWireHost* host, uint8_t* new_addr, OneWireHostSearch } void onewire_host_set_overdrive(OneWireHost* host, bool set) { + furi_check(host); + host->timings = set ? &onewire_host_timings_overdrive : &onewire_host_timings_normal; } diff --git a/lib/one_wire/one_wire_slave.c b/lib/one_wire/one_wire_slave.c index 6fff75214..8dfbe4aa5 100644 --- a/lib/one_wire/one_wire_slave.c +++ b/lib/one_wire/one_wire_slave.c @@ -209,6 +209,7 @@ static void onewire_slave_exti_callback(void* context) { /*********************** PUBLIC ***********************/ OneWireSlave* onewire_slave_alloc(const GpioPin* gpio_pin) { + furi_check(gpio_pin); OneWireSlave* bus = malloc(sizeof(OneWireSlave)); bus->gpio_pin = gpio_pin; @@ -219,17 +220,23 @@ OneWireSlave* onewire_slave_alloc(const GpioPin* gpio_pin) { } void onewire_slave_free(OneWireSlave* bus) { + furi_check(bus); + onewire_slave_stop(bus); free(bus); } void onewire_slave_start(OneWireSlave* bus) { + furi_check(bus); + furi_hal_gpio_add_int_callback(bus->gpio_pin, onewire_slave_exti_callback, bus); furi_hal_gpio_write(bus->gpio_pin, true); furi_hal_gpio_init(bus->gpio_pin, GpioModeInterruptRiseFall, GpioPullNo, GpioSpeedLow); } void onewire_slave_stop(OneWireSlave* bus) { + furi_check(bus); + furi_hal_gpio_write(bus->gpio_pin, true); furi_hal_gpio_init(bus->gpio_pin, GpioModeAnalog, GpioPullNo, GpioSpeedLow); furi_hal_gpio_remove_int_callback(bus->gpio_pin); @@ -239,6 +246,7 @@ void onewire_slave_set_reset_callback( OneWireSlave* bus, OneWireSlaveResetCallback callback, void* context) { + furi_check(bus); bus->reset_callback = callback; bus->reset_callback_context = context; } @@ -247,6 +255,8 @@ void onewire_slave_set_command_callback( OneWireSlave* bus, OneWireSlaveCommandCallback callback, void* context) { + furi_check(bus); + bus->command_callback = callback; bus->command_callback_context = context; } @@ -255,11 +265,14 @@ void onewire_slave_set_result_callback( OneWireSlave* bus, OneWireSlaveResultCallback result_cb, void* context) { + furi_check(bus); bus->result_callback = result_cb; bus->result_callback_context = context; } bool onewire_slave_receive_bit(OneWireSlave* bus) { + furi_check(bus); + const OneWireSlaveTimings* timings = bus->timings; // wait while bus is low if(!onewire_slave_wait_while_gpio_is(bus, timings->tslot_max, false)) { @@ -278,6 +291,8 @@ bool onewire_slave_receive_bit(OneWireSlave* bus) { } bool onewire_slave_send_bit(OneWireSlave* bus, bool value) { + furi_check(bus); + const OneWireSlaveTimings* timings = bus->timings; // wait while bus is low if(!onewire_slave_wait_while_gpio_is(bus, timings->tslot_max, false)) { @@ -309,6 +324,8 @@ bool onewire_slave_send_bit(OneWireSlave* bus, bool value) { } bool onewire_slave_send(OneWireSlave* bus, const uint8_t* data, size_t data_size) { + furi_check(bus); + furi_hal_gpio_write(bus->gpio_pin, true); size_t bytes_sent = 0; @@ -328,6 +345,8 @@ bool onewire_slave_send(OneWireSlave* bus, const uint8_t* data, size_t data_size } bool onewire_slave_receive(OneWireSlave* bus, uint8_t* data, size_t data_size) { + furi_check(bus); + furi_hal_gpio_write(bus->gpio_pin, true); size_t bytes_received = 0; @@ -351,6 +370,7 @@ bool onewire_slave_receive(OneWireSlave* bus, uint8_t* data, size_t data_size) { } void onewire_slave_set_overdrive(OneWireSlave* bus, bool set) { + furi_check(bus); const OneWireSlaveTimings* new_timings = set ? &onewire_slave_timings_overdrive : &onewire_slave_timings_normal; if(bus->timings != new_timings) { diff --git a/lib/signal_reader/signal_reader.c b/lib/signal_reader/signal_reader.c index c06c7a5c0..f457cd29c 100644 --- a/lib/signal_reader/signal_reader.c +++ b/lib/signal_reader/signal_reader.c @@ -86,9 +86,9 @@ SignalReader* signal_reader_alloc(const GpioPin* gpio_pin, uint32_t size) { } void signal_reader_free(SignalReader* instance) { - furi_assert(instance); - furi_assert(instance->gpio_buffer); - furi_assert(instance->bitstream_buffer); + furi_check(instance); + furi_check(instance->gpio_buffer); + furi_check(instance->bitstream_buffer); free(instance->gpio_buffer); free(instance->bitstream_buffer); @@ -96,13 +96,13 @@ void signal_reader_free(SignalReader* instance) { } void signal_reader_set_pull(SignalReader* instance, GpioPull pull) { - furi_assert(instance); + furi_check(instance); instance->pull = pull; } void signal_reader_set_polarity(SignalReader* instance, SignalReaderPolarity polarity) { - furi_assert(instance); + furi_check(instance); instance->polarity = polarity; } @@ -111,14 +111,14 @@ void signal_reader_set_sample_rate( SignalReader* instance, SignalReaderTimeUnit time_unit, uint32_t time) { - furi_assert(instance); + furi_check(instance); UNUSED(time_unit); instance->tim_arr = time; } void signal_reader_set_trigger(SignalReader* instance, SignalReaderTrigger trigger) { - furi_assert(instance); + furi_check(instance); instance->trigger = trigger; } @@ -186,8 +186,8 @@ static void furi_hal_sw_digital_pin_dma_rx_isr(void* context) { } void signal_reader_start(SignalReader* instance, SignalReaderCallback callback, void* context) { - furi_assert(instance); - furi_assert(callback); + furi_check(instance); + furi_check(callback); instance->callback = callback; instance->context = context; @@ -306,7 +306,7 @@ void signal_reader_start(SignalReader* instance, SignalReaderCallback callback, } void signal_reader_stop(SignalReader* instance) { - furi_assert(instance); + furi_check(instance); furi_hal_interrupt_set_isr(SIGNAL_READER_DMA_GPIO_IRQ, NULL, NULL); diff --git a/lib/subghz/blocks/encoder.c b/lib/subghz/blocks/encoder.c index 49ec4f177..4968c5e40 100644 --- a/lib/subghz/blocks/encoder.c +++ b/lib/subghz/blocks/encoder.c @@ -2,8 +2,6 @@ #include "math.h" #include -#include "furi.h" - #define TAG "SubGhzBlockEncoder" void subghz_protocol_blocks_set_bit_array( @@ -11,7 +9,7 @@ void subghz_protocol_blocks_set_bit_array( uint8_t data_array[], size_t set_index_bit, size_t max_size_array) { - furi_assert(set_index_bit < max_size_array * 8); + furi_check(set_index_bit < max_size_array * 8); bit_write(data_array[set_index_bit >> 3], 7 - (set_index_bit & 0x7), bit_value); } diff --git a/lib/subghz/blocks/generic.c b/lib/subghz/blocks/generic.c index 1827388af..f11178c63 100644 --- a/lib/subghz/blocks/generic.c +++ b/lib/subghz/blocks/generic.c @@ -24,7 +24,7 @@ SubGhzProtocolStatus subghz_block_generic_serialize( SubGhzBlockGeneric* instance, FlipperFormat* flipper_format, SubGhzRadioPreset* preset) { - furi_assert(instance); + furi_check(instance); SubGhzProtocolStatus res = SubGhzProtocolStatusError; FuriString* temp_str; temp_str = furi_string_alloc(); @@ -104,7 +104,8 @@ SubGhzProtocolStatus subghz_block_generic_serialize( SubGhzProtocolStatus subghz_block_generic_deserialize(SubGhzBlockGeneric* instance, FlipperFormat* flipper_format) { - furi_assert(instance); + furi_check(instance); + SubGhzProtocolStatus res = SubGhzProtocolStatusError; FuriString* temp_str; temp_str = furi_string_alloc(); @@ -145,6 +146,7 @@ SubGhzProtocolStatus subghz_block_generic_deserialize_check_count_bit( SubGhzBlockGeneric* instance, FlipperFormat* flipper_format, uint16_t count_bit) { + furi_check(instance); SubGhzProtocolStatus ret = SubGhzProtocolStatusError; do { ret = subghz_block_generic_deserialize(instance, flipper_format); diff --git a/lib/subghz/devices/devices.c b/lib/subghz/devices/devices.c index e034c474d..c3fb3168b 100644 --- a/lib/subghz/devices/devices.c +++ b/lib/subghz/devices/devices.c @@ -2,7 +2,7 @@ #include "registry.h" -void subghz_devices_init() { +void subghz_devices_init(void) { furi_check(!subghz_device_registry_is_valid()); subghz_device_registry_init(); } @@ -27,8 +27,8 @@ const char* subghz_devices_get_name(const SubGhzDevice* device) { } bool subghz_devices_begin(const SubGhzDevice* device) { + furi_check(device); bool ret = false; - furi_assert(device); if(device->interconnect->begin) { SubGhzDeviceConf conf = { .ver = 1, @@ -42,15 +42,15 @@ bool subghz_devices_begin(const SubGhzDevice* device) { } void subghz_devices_end(const SubGhzDevice* device) { - furi_assert(device); + furi_check(device); if(device->interconnect->end) { device->interconnect->end(); } } bool subghz_devices_is_connect(const SubGhzDevice* device) { + furi_check(device); bool ret = false; - furi_assert(device); if(device->interconnect->is_connect) { ret = device->interconnect->is_connect(); } @@ -58,21 +58,21 @@ bool subghz_devices_is_connect(const SubGhzDevice* device) { } void subghz_devices_reset(const SubGhzDevice* device) { - furi_assert(device); + furi_check(device); if(device->interconnect->reset) { device->interconnect->reset(); } } void subghz_devices_sleep(const SubGhzDevice* device) { - furi_assert(device); + furi_check(device); if(device->interconnect->sleep) { device->interconnect->sleep(); } } void subghz_devices_idle(const SubGhzDevice* device) { - furi_assert(device); + furi_check(device); if(device->interconnect->idle) { device->interconnect->idle(); } @@ -82,15 +82,15 @@ void subghz_devices_load_preset( const SubGhzDevice* device, FuriHalSubGhzPreset preset, uint8_t* preset_data) { - furi_assert(device); + furi_check(device); if(device->interconnect->load_preset) { device->interconnect->load_preset(preset, preset_data); } } uint32_t subghz_devices_set_frequency(const SubGhzDevice* device, uint32_t frequency) { + furi_check(device); uint32_t ret = 0; - furi_assert(device); if(device->interconnect->set_frequency) { ret = device->interconnect->set_frequency(frequency); } @@ -99,7 +99,7 @@ uint32_t subghz_devices_set_frequency(const SubGhzDevice* device, uint32_t frequ bool subghz_devices_is_frequency_valid(const SubGhzDevice* device, uint32_t frequency) { bool ret = false; - furi_assert(device); + furi_check(device); if(device->interconnect->is_frequency_valid) { ret = device->interconnect->is_frequency_valid(frequency); } @@ -107,15 +107,15 @@ bool subghz_devices_is_frequency_valid(const SubGhzDevice* device, uint32_t freq } void subghz_devices_set_async_mirror_pin(const SubGhzDevice* device, const GpioPin* gpio) { - furi_assert(device); + furi_check(device); if(device->interconnect->set_async_mirror_pin) { device->interconnect->set_async_mirror_pin(gpio); } } const GpioPin* subghz_devices_get_data_gpio(const SubGhzDevice* device) { + furi_check(device); const GpioPin* ret = NULL; - furi_assert(device); if(device->interconnect->get_data_gpio) { ret = device->interconnect->get_data_gpio(); } @@ -124,7 +124,7 @@ const GpioPin* subghz_devices_get_data_gpio(const SubGhzDevice* device) { bool subghz_devices_set_tx(const SubGhzDevice* device) { bool ret = 0; - furi_assert(device); + furi_check(device); if(device->interconnect->set_tx) { ret = device->interconnect->set_tx(); } @@ -132,7 +132,7 @@ bool subghz_devices_set_tx(const SubGhzDevice* device) { } void subghz_devices_flush_tx(const SubGhzDevice* device) { - furi_assert(device); + furi_check(device); if(device->interconnect->flush_tx) { device->interconnect->flush_tx(); } @@ -140,7 +140,7 @@ void subghz_devices_flush_tx(const SubGhzDevice* device) { bool subghz_devices_start_async_tx(const SubGhzDevice* device, void* callback, void* context) { bool ret = false; - furi_assert(device); + furi_check(device); if(device->interconnect->start_async_tx) { ret = device->interconnect->start_async_tx(callback, context); } @@ -149,7 +149,7 @@ bool subghz_devices_start_async_tx(const SubGhzDevice* device, void* callback, v bool subghz_devices_is_async_complete_tx(const SubGhzDevice* device) { bool ret = false; - furi_assert(device); + furi_check(device); if(device->interconnect->is_async_complete_tx) { ret = device->interconnect->is_async_complete_tx(); } @@ -157,35 +157,35 @@ bool subghz_devices_is_async_complete_tx(const SubGhzDevice* device) { } void subghz_devices_stop_async_tx(const SubGhzDevice* device) { - furi_assert(device); + furi_check(device); if(device->interconnect->stop_async_tx) { device->interconnect->stop_async_tx(); } } void subghz_devices_set_rx(const SubGhzDevice* device) { - furi_assert(device); + furi_check(device); if(device->interconnect->set_rx) { device->interconnect->set_rx(); } } void subghz_devices_flush_rx(const SubGhzDevice* device) { - furi_assert(device); + furi_check(device); if(device->interconnect->flush_rx) { device->interconnect->flush_rx(); } } void subghz_devices_start_async_rx(const SubGhzDevice* device, void* callback, void* context) { - furi_assert(device); + furi_check(device); if(device->interconnect->start_async_rx) { device->interconnect->start_async_rx(callback, context); } } void subghz_devices_stop_async_rx(const SubGhzDevice* device) { - furi_assert(device); + furi_check(device); if(device->interconnect->stop_async_rx) { device->interconnect->stop_async_rx(); } @@ -193,7 +193,7 @@ void subghz_devices_stop_async_rx(const SubGhzDevice* device) { float subghz_devices_get_rssi(const SubGhzDevice* device) { float ret = 0; - furi_assert(device); + furi_check(device); if(device->interconnect->get_rssi) { ret = device->interconnect->get_rssi(); } @@ -201,8 +201,8 @@ float subghz_devices_get_rssi(const SubGhzDevice* device) { } uint8_t subghz_devices_get_lqi(const SubGhzDevice* device) { + furi_check(device); uint8_t ret = 0; - furi_assert(device); if(device->interconnect->get_lqi) { ret = device->interconnect->get_lqi(); } @@ -210,8 +210,8 @@ uint8_t subghz_devices_get_lqi(const SubGhzDevice* device) { } bool subghz_devices_rx_pipe_not_empty(const SubGhzDevice* device) { + furi_check(device); bool ret = false; - furi_assert(device); if(device->interconnect->rx_pipe_not_empty) { ret = device->interconnect->rx_pipe_not_empty(); } @@ -220,7 +220,7 @@ bool subghz_devices_rx_pipe_not_empty(const SubGhzDevice* device) { bool subghz_devices_is_rx_data_crc_valid(const SubGhzDevice* device) { bool ret = false; - furi_assert(device); + furi_check(device); if(device->interconnect->is_rx_data_crc_valid) { ret = device->interconnect->is_rx_data_crc_valid(); } @@ -228,15 +228,14 @@ bool subghz_devices_is_rx_data_crc_valid(const SubGhzDevice* device) { } void subghz_devices_read_packet(const SubGhzDevice* device, uint8_t* data, uint8_t* size) { - furi_assert(device); - furi_assert(device); + furi_check(device); if(device->interconnect->read_packet) { device->interconnect->read_packet(data, size); } } void subghz_devices_write_packet(const SubGhzDevice* device, const uint8_t* data, uint8_t size) { - furi_assert(device); + furi_check(device); if(device->interconnect->write_packet) { device->interconnect->write_packet(data, size); } diff --git a/lib/subghz/devices/devices.h b/lib/subghz/devices/devices.h index dad3c9aeb..9d6b7dbe5 100644 --- a/lib/subghz/devices/devices.h +++ b/lib/subghz/devices/devices.h @@ -8,7 +8,7 @@ extern "C" { typedef struct SubGhzDevice SubGhzDevice; -void subghz_devices_init(); +void subghz_devices_init(void); void subghz_devices_deinit(void); const SubGhzDevice* subghz_devices_get_by_name(const char* device_name); diff --git a/lib/subghz/environment.c b/lib/subghz/environment.c index 7b1e87b41..e129b689b 100644 --- a/lib/subghz/environment.c +++ b/lib/subghz/environment.c @@ -10,7 +10,7 @@ struct SubGhzEnvironment { uint8_t kl_type; }; -SubGhzEnvironment* subghz_environment_alloc() { +SubGhzEnvironment* subghz_environment_alloc(void) { SubGhzEnvironment* instance = malloc(sizeof(SubGhzEnvironment)); instance->keystore = subghz_keystore_alloc(); @@ -24,7 +24,7 @@ SubGhzEnvironment* subghz_environment_alloc() { } void subghz_environment_free(SubGhzEnvironment* instance) { - furi_assert(instance); + furi_check(instance); instance->protocol_registry = NULL; instance->nice_flor_s_rainbow_table_file_name = NULL; @@ -35,13 +35,13 @@ void subghz_environment_free(SubGhzEnvironment* instance) { } bool subghz_environment_load_keystore(SubGhzEnvironment* instance, const char* filename) { - furi_assert(instance); + furi_check(instance); return subghz_keystore_load(instance->keystore, filename); } SubGhzKeystore* subghz_environment_get_keystore(SubGhzEnvironment* instance) { - furi_assert(instance); + furi_check(instance); return instance->keystore; } @@ -65,14 +65,14 @@ const char* void subghz_environment_set_alutech_at_4n_rainbow_table_file_name( SubGhzEnvironment* instance, const char* filename) { - furi_assert(instance); + furi_check(instance); instance->alutech_at_4n_rainbow_table_file_name = filename; } const char* subghz_environment_get_alutech_at_4n_rainbow_table_file_name(SubGhzEnvironment* instance) { - furi_assert(instance); + furi_check(instance); return instance->alutech_at_4n_rainbow_table_file_name; } @@ -80,14 +80,14 @@ const char* void subghz_environment_set_nice_flor_s_rainbow_table_file_name( SubGhzEnvironment* instance, const char* filename) { - furi_assert(instance); + furi_check(instance); instance->nice_flor_s_rainbow_table_file_name = filename; } const char* subghz_environment_get_nice_flor_s_rainbow_table_file_name(SubGhzEnvironment* instance) { - furi_assert(instance); + furi_check(instance); return instance->nice_flor_s_rainbow_table_file_name; } @@ -95,22 +95,22 @@ const char* void subghz_environment_set_protocol_registry( SubGhzEnvironment* instance, const SubGhzProtocolRegistry* protocol_registry_items) { - furi_assert(instance); + furi_check(instance); const SubGhzProtocolRegistry* protocol_registry = protocol_registry_items; instance->protocol_registry = protocol_registry; } const SubGhzProtocolRegistry* subghz_environment_get_protocol_registry(SubGhzEnvironment* instance) { - furi_assert(instance); - furi_assert(instance->protocol_registry); + furi_check(instance); + furi_check(instance->protocol_registry); return instance->protocol_registry; } const char* subghz_environment_get_protocol_name_registry(SubGhzEnvironment* instance, size_t idx) { - furi_assert(instance); - furi_assert(instance->protocol_registry); + furi_check(instance); + furi_check(instance->protocol_registry); const SubGhzProtocol* protocol = subghz_protocol_registry_get_by_index(instance->protocol_registry, idx); if(protocol != NULL) { diff --git a/lib/subghz/environment.h b/lib/subghz/environment.h index ff694acb8..195b11d76 100644 --- a/lib/subghz/environment.h +++ b/lib/subghz/environment.h @@ -16,7 +16,7 @@ typedef struct SubGhzProtocolRegistry SubGhzProtocolRegistry; * Allocate SubGhzEnvironment. * @return SubGhzEnvironment* pointer to a SubGhzEnvironment instance */ -SubGhzEnvironment* subghz_environment_alloc(); +SubGhzEnvironment* subghz_environment_alloc(void); /** * Free SubGhzEnvironment. diff --git a/lib/subghz/protocols/base.c b/lib/subghz/protocols/base.c index 37d1a308f..99af45bb2 100644 --- a/lib/subghz/protocols/base.c +++ b/lib/subghz/protocols/base.c @@ -5,6 +5,8 @@ void subghz_protocol_decoder_base_set_decoder_callback( SubGhzProtocolDecoderBase* decoder_base, SubGhzProtocolDecoderBaseRxCallback callback, void* context) { + furi_check(decoder_base); + decoder_base->callback = callback; decoder_base->context = context; } @@ -12,6 +14,9 @@ void subghz_protocol_decoder_base_set_decoder_callback( bool subghz_protocol_decoder_base_get_string( SubGhzProtocolDecoderBase* decoder_base, FuriString* output) { + furi_check(decoder_base); + furi_check(output); + bool status = false; if(decoder_base->protocol && decoder_base->protocol->decoder && @@ -27,6 +32,9 @@ SubGhzProtocolStatus subghz_protocol_decoder_base_serialize( SubGhzProtocolDecoderBase* decoder_base, FlipperFormat* flipper_format, SubGhzRadioPreset* preset) { + furi_check(decoder_base); + furi_check(flipper_format); + SubGhzProtocolStatus status = SubGhzProtocolStatusError; if(decoder_base->protocol && decoder_base->protocol->decoder && @@ -40,6 +48,8 @@ SubGhzProtocolStatus subghz_protocol_decoder_base_serialize( SubGhzProtocolStatus subghz_protocol_decoder_base_deserialize( SubGhzProtocolDecoderBase* decoder_base, FlipperFormat* flipper_format) { + furi_check(decoder_base); + SubGhzProtocolStatus status = SubGhzProtocolStatusError; if(decoder_base->protocol && decoder_base->protocol->decoder && @@ -51,6 +61,8 @@ SubGhzProtocolStatus subghz_protocol_decoder_base_deserialize( } uint8_t subghz_protocol_decoder_base_get_hash_data(SubGhzProtocolDecoderBase* decoder_base) { + furi_check(decoder_base); + uint8_t hash = 0; if(decoder_base->protocol && decoder_base->protocol->decoder && diff --git a/lib/subghz/protocols/bin_raw.c b/lib/subghz/protocols/bin_raw.c index 511846797..6c0efd34d 100644 --- a/lib/subghz/protocols/bin_raw.c +++ b/lib/subghz/protocols/bin_raw.c @@ -882,7 +882,7 @@ static bool void subghz_protocol_decoder_bin_raw_data_input_rssi( SubGhzProtocolDecoderBinRAW* instance, float rssi) { - furi_assert(instance); + furi_check(instance); switch(instance->decoder.parser_step) { case BinRAWDecoderStepReset: diff --git a/lib/subghz/protocols/keeloq.c b/lib/subghz/protocols/keeloq.c index 0f20cc529..cd0c3f8c6 100644 --- a/lib/subghz/protocols/keeloq.c +++ b/lib/subghz/protocols/keeloq.c @@ -346,7 +346,7 @@ bool subghz_protocol_keeloq_create_data( uint16_t cnt, const char* manufacture_name, SubGhzRadioPreset* preset) { - furi_assert(context); + furi_check(context); SubGhzProtocolEncoderKeeloq* instance = context; instance->generic.serial = serial; instance->generic.cnt = cnt; diff --git a/lib/subghz/protocols/raw.c b/lib/subghz/protocols/raw.c index 35ac7fdd2..d837ea68b 100644 --- a/lib/subghz/protocols/raw.c +++ b/lib/subghz/protocols/raw.c @@ -87,7 +87,7 @@ bool subghz_protocol_raw_save_to_file_init( SubGhzProtocolDecoderRAW* instance, const char* dev_name, SubGhzRadioPreset* preset) { - furi_assert(instance); + furi_check(instance); instance->storage = furi_record_open(RECORD_STORAGE); instance->flipper_file = flipper_format_file_alloc(instance->storage); @@ -189,7 +189,7 @@ static bool subghz_protocol_raw_save_to_file_write(SubGhzProtocolDecoderRAW* ins } void subghz_protocol_raw_save_to_file_stop(SubGhzProtocolDecoderRAW* instance) { - furi_assert(instance); + furi_check(instance); if(instance->file_is_open == RAWFileIsOpenWrite && instance->ind_write) subghz_protocol_raw_save_to_file_write(instance); @@ -205,7 +205,7 @@ void subghz_protocol_raw_save_to_file_stop(SubGhzProtocolDecoderRAW* instance) { } void subghz_protocol_raw_save_to_file_pause(SubGhzProtocolDecoderRAW* instance, bool pause) { - furi_assert(instance); + furi_check(instance); if(instance->pause != pause) { instance->pause = pause; @@ -213,6 +213,7 @@ void subghz_protocol_raw_save_to_file_pause(SubGhzProtocolDecoderRAW* instance, } size_t subghz_protocol_raw_get_sample_write(SubGhzProtocolDecoderRAW* instance) { + furi_check(instance); return instance->sample_write + instance->ind_write; } @@ -230,21 +231,21 @@ void* subghz_protocol_decoder_raw_alloc(SubGhzEnvironment* environment) { } void subghz_protocol_decoder_raw_free(void* context) { - furi_assert(context); + furi_check(context); SubGhzProtocolDecoderRAW* instance = context; furi_string_free(instance->file_name); free(instance); } void subghz_protocol_decoder_raw_reset(void* context) { - furi_assert(context); + furi_check(context); SubGhzProtocolDecoderRAW* instance = context; instance->ind_write = 0; instance->last_level = false; } void subghz_protocol_decoder_raw_feed(void* context, bool level, uint32_t duration) { - furi_assert(context); + furi_check(context); SubGhzProtocolDecoderRAW* instance = context; // Add check if we got duration higher than 1 second, we skipping it, temp fix if((!instance->pause && (instance->upload_raw != NULL)) && (duration < ((uint32_t)1000000))) { @@ -263,7 +264,7 @@ void subghz_protocol_decoder_raw_feed(void* context, bool level, uint32_t durati SubGhzProtocolStatus subghz_protocol_decoder_raw_deserialize(void* context, FlipperFormat* flipper_format) { - furi_assert(context); + furi_check(context); UNUSED(context); UNUSED(flipper_format); // stub, for backwards compatibility @@ -271,7 +272,7 @@ SubGhzProtocolStatus } void subghz_protocol_decoder_raw_get_string(void* context, FuriString* output) { - furi_assert(context); + furi_check(context); //SubGhzProtocolDecoderRAW* instance = context; UNUSED(context); furi_string_cat_printf(output, "RAW Data"); @@ -289,6 +290,7 @@ void* subghz_protocol_encoder_raw_alloc(SubGhzEnvironment* environment) { } void subghz_protocol_encoder_raw_stop(void* context) { + furi_check(context); SubGhzProtocolEncoderRAW* instance = context; instance->is_running = false; if(subghz_file_encoder_worker_is_running(instance->file_worker_encoder)) { @@ -298,7 +300,7 @@ void subghz_protocol_encoder_raw_stop(void* context) { } void subghz_protocol_encoder_raw_free(void* context) { - furi_assert(context); + furi_check(context); SubGhzProtocolEncoderRAW* instance = context; subghz_protocol_encoder_raw_stop(instance); furi_string_free(instance->file_name); @@ -310,8 +312,8 @@ void subghz_protocol_raw_file_encoder_worker_set_callback_end( SubGhzProtocolEncoderRAW* instance, SubGhzProtocolEncoderRAWCallbackEnd callback_end, void* context_end) { - furi_assert(instance); - furi_assert(callback_end); + furi_check(instance); + furi_check(callback_end); subghz_file_encoder_worker_callback_end( instance->file_worker_encoder, callback_end, context_end); } @@ -337,6 +339,8 @@ void subghz_protocol_raw_gen_fff_data( FlipperFormat* flipper_format, const char* file_path, const char* radio_device_name) { + furi_check(flipper_format); + do { stream_clean(flipper_format_get_raw_stream(flipper_format)); if(!flipper_format_write_string_cstr(flipper_format, "Protocol", "RAW")) { @@ -359,7 +363,7 @@ void subghz_protocol_raw_gen_fff_data( SubGhzProtocolStatus subghz_protocol_encoder_raw_deserialize(void* context, FlipperFormat* flipper_format) { - furi_assert(context); + furi_check(context); SubGhzProtocolEncoderRAW* instance = context; SubGhzProtocolStatus res = SubGhzProtocolStatusError; FuriString* temp_str; @@ -396,6 +400,7 @@ SubGhzProtocolStatus } LevelDuration subghz_protocol_encoder_raw_yield(void* context) { + furi_check(context); SubGhzProtocolEncoderRAW* instance = context; if(!instance->is_running) return level_duration_reset(); diff --git a/lib/subghz/protocols/secplus_v2.c b/lib/subghz/protocols/secplus_v2.c index 3df74ba1d..e00cfba0e 100644 --- a/lib/subghz/protocols/secplus_v2.c +++ b/lib/subghz/protocols/secplus_v2.c @@ -614,7 +614,8 @@ bool subghz_protocol_secplus_v2_create_data( uint8_t btn, uint32_t cnt, SubGhzRadioPreset* preset) { - furi_assert(context); + furi_check(context); + SubGhzProtocolEncoderSecPlus_v2* instance = context; instance->generic.serial = serial; instance->generic.cnt = cnt; diff --git a/lib/subghz/receiver.c b/lib/subghz/receiver.c index 698fe098e..c70229a12 100644 --- a/lib/subghz/receiver.c +++ b/lib/subghz/receiver.c @@ -42,7 +42,7 @@ SubGhzReceiver* subghz_receiver_alloc_init(SubGhzEnvironment* environment) { } void subghz_receiver_free(SubGhzReceiver* instance) { - furi_assert(instance); + furi_check(instance); instance->callback = NULL; instance->context = NULL; @@ -59,8 +59,8 @@ void subghz_receiver_free(SubGhzReceiver* instance) { } void subghz_receiver_decode(SubGhzReceiver* instance, bool level, uint32_t duration) { - furi_assert(instance); - furi_assert(instance->slots); + furi_check(instance); + furi_check(instance->slots); for M_EACH(slot, instance->slots, SubGhzReceiverSlotArray_t) { @@ -71,8 +71,8 @@ void subghz_receiver_decode(SubGhzReceiver* instance, bool level, uint32_t durat } void subghz_receiver_reset(SubGhzReceiver* instance) { - furi_assert(instance); - furi_assert(instance->slots); + furi_check(instance); + furi_check(instance->slots); for M_EACH(slot, instance->slots, SubGhzReceiverSlotArray_t) { @@ -91,7 +91,7 @@ void subghz_receiver_set_rx_callback( SubGhzReceiver* instance, SubGhzReceiverCallback callback, void* context) { - furi_assert(instance); + furi_check(instance); for M_EACH(slot, instance->slots, SubGhzReceiverSlotArray_t) { @@ -104,13 +104,15 @@ void subghz_receiver_set_rx_callback( } void subghz_receiver_set_filter(SubGhzReceiver* instance, SubGhzProtocolFlag filter) { - furi_assert(instance); + furi_check(instance); instance->filter = filter; } SubGhzProtocolDecoderBase* subghz_receiver_search_decoder_base_by_name( SubGhzReceiver* instance, const char* decoder_name) { + furi_check(instance); + SubGhzProtocolDecoderBase* result = NULL; for diff --git a/lib/subghz/registry.c b/lib/subghz/registry.c index d0c22ea8c..be62b4649 100644 --- a/lib/subghz/registry.c +++ b/lib/subghz/registry.c @@ -3,7 +3,7 @@ const SubGhzProtocol* subghz_protocol_registry_get_by_name( const SubGhzProtocolRegistry* protocol_registry, const char* name) { - furi_assert(protocol_registry); + furi_check(protocol_registry); for(size_t i = 0; i < subghz_protocol_registry_count(protocol_registry); i++) { if(strcmp(name, protocol_registry->items[i]->name) == 0) { @@ -16,7 +16,7 @@ const SubGhzProtocol* subghz_protocol_registry_get_by_name( const SubGhzProtocol* subghz_protocol_registry_get_by_index( const SubGhzProtocolRegistry* protocol_registry, size_t index) { - furi_assert(protocol_registry); + furi_check(protocol_registry); if(index < subghz_protocol_registry_count(protocol_registry)) { return protocol_registry->items[index]; } else { @@ -25,6 +25,6 @@ const SubGhzProtocol* subghz_protocol_registry_get_by_index( } size_t subghz_protocol_registry_count(const SubGhzProtocolRegistry* protocol_registry) { - furi_assert(protocol_registry); + furi_check(protocol_registry); return protocol_registry->size; } diff --git a/lib/subghz/subghz_file_encoder_worker.c b/lib/subghz/subghz_file_encoder_worker.c index ade840a36..30654567e 100644 --- a/lib/subghz/subghz_file_encoder_worker.c +++ b/lib/subghz/subghz_file_encoder_worker.c @@ -190,7 +190,7 @@ static int32_t subghz_file_encoder_worker_thread(void* context) { return 0; } -SubGhzFileEncoderWorker* subghz_file_encoder_worker_alloc() { +SubGhzFileEncoderWorker* subghz_file_encoder_worker_alloc(void) { SubGhzFileEncoderWorker* instance = malloc(sizeof(SubGhzFileEncoderWorker)); instance->thread = diff --git a/lib/subghz/subghz_file_encoder_worker.h b/lib/subghz/subghz_file_encoder_worker.h index eace03348..f3964b26b 100644 --- a/lib/subghz/subghz_file_encoder_worker.h +++ b/lib/subghz/subghz_file_encoder_worker.h @@ -24,7 +24,7 @@ void subghz_file_encoder_worker_callback_end( * Allocate SubGhzFileEncoderWorker. * @return SubGhzFileEncoderWorker* pointer to a SubGhzFileEncoderWorker instance */ -SubGhzFileEncoderWorker* subghz_file_encoder_worker_alloc(); +SubGhzFileEncoderWorker* subghz_file_encoder_worker_alloc(void); /** * Free SubGhzFileEncoderWorker. diff --git a/lib/subghz/subghz_keystore.c b/lib/subghz/subghz_keystore.c index 636288aa6..c12e23b42 100644 --- a/lib/subghz/subghz_keystore.c +++ b/lib/subghz/subghz_keystore.c @@ -27,7 +27,7 @@ typedef enum { SubGhzKeystoreEncryptionAES256, } SubGhzKeystoreEncryption; -SubGhzKeystore* subghz_keystore_alloc() { +SubGhzKeystore* subghz_keystore_alloc(void) { SubGhzKeystore* instance = malloc(sizeof(SubGhzKeystore)); SubGhzKeyArray_init(instance->data); diff --git a/lib/subghz/subghz_keystore.h b/lib/subghz/subghz_keystore.h index dfb5c7373..c20eff36e 100644 --- a/lib/subghz/subghz_keystore.h +++ b/lib/subghz/subghz_keystore.h @@ -24,7 +24,7 @@ typedef struct SubGhzKeystore SubGhzKeystore; * Allocate SubGhzKeystore. * @return SubGhzKeystore* pointer to a SubGhzKeystore instance */ -SubGhzKeystore* subghz_keystore_alloc(); +SubGhzKeystore* subghz_keystore_alloc(void); /** * Free SubGhzKeystore. diff --git a/lib/subghz/subghz_setting.c b/lib/subghz/subghz_setting.c index a72c482d4..cdfe493c4 100644 --- a/lib/subghz/subghz_setting.c +++ b/lib/subghz/subghz_setting.c @@ -135,7 +135,7 @@ static void subghz_setting_preset_reset(SubGhzSetting* instance) { } void subghz_setting_free(SubGhzSetting* instance) { - furi_assert(instance); + furi_check(instance); FrequencyList_clear(instance->frequencies); FrequencyList_clear(instance->hopper_frequencies); for @@ -208,7 +208,7 @@ void subghz_setting_load_default(SubGhzSetting* instance) { } void subghz_setting_load(SubGhzSetting* instance, const char* file_path) { - furi_assert(instance); + furi_check(instance); Storage* storage = furi_record_open(RECORD_STORAGE); FlipperFormat* fff_data_file = flipper_format_file_alloc(storage); @@ -326,22 +326,22 @@ void subghz_setting_set_default_frequency(SubGhzSetting* instance, uint32_t freq } size_t subghz_setting_get_frequency_count(SubGhzSetting* instance) { - furi_assert(instance); + furi_check(instance); return FrequencyList_size(instance->frequencies); } size_t subghz_setting_get_hopper_frequency_count(SubGhzSetting* instance) { - furi_assert(instance); + furi_check(instance); return FrequencyList_size(instance->hopper_frequencies); } size_t subghz_setting_get_preset_count(SubGhzSetting* instance) { - furi_assert(instance); + furi_check(instance); return SubGhzSettingCustomPresetItemArray_size(instance->preset->data); } const char* subghz_setting_get_preset_name(SubGhzSetting* instance, size_t idx) { - furi_assert(instance); + furi_check(instance); if(idx >= SubGhzSettingCustomPresetItemArray_size(instance->preset->data)) { idx = 0; } @@ -351,7 +351,7 @@ const char* subghz_setting_get_preset_name(SubGhzSetting* instance, size_t idx) } int subghz_setting_get_inx_preset_by_name(SubGhzSetting* instance, const char* preset_name) { - furi_assert(instance); + furi_check(instance); size_t idx = 0; for M_EACH(item, instance->preset->data, SubGhzSettingCustomPresetItemArray_t) { @@ -368,8 +368,8 @@ bool subghz_setting_load_custom_preset( SubGhzSetting* instance, const char* preset_name, FlipperFormat* fff_data_file) { - furi_assert(instance); - furi_assert(preset_name); + furi_check(instance); + furi_check(preset_name); uint32_t temp_data32; SubGhzSettingCustomPresetItem* item = SubGhzSettingCustomPresetItemArray_push_raw(instance->preset->data); @@ -398,8 +398,8 @@ bool subghz_setting_load_custom_preset( } bool subghz_setting_delete_custom_preset(SubGhzSetting* instance, const char* preset_name) { - furi_assert(instance); - furi_assert(preset_name); + furi_check(instance); + furi_check(preset_name); SubGhzSettingCustomPresetItemArray_it_t it; SubGhzSettingCustomPresetItemArray_it_last(it, instance->preset->data); while(!SubGhzSettingCustomPresetItemArray_end_p(it)) { @@ -416,28 +416,28 @@ bool subghz_setting_delete_custom_preset(SubGhzSetting* instance, const char* pr } uint8_t* subghz_setting_get_preset_data(SubGhzSetting* instance, size_t idx) { - furi_assert(instance); + furi_check(instance); SubGhzSettingCustomPresetItem* item = SubGhzSettingCustomPresetItemArray_get(instance->preset->data, idx); return item->custom_preset_data; } size_t subghz_setting_get_preset_data_size(SubGhzSetting* instance, size_t idx) { - furi_assert(instance); + furi_check(instance); SubGhzSettingCustomPresetItem* item = SubGhzSettingCustomPresetItemArray_get(instance->preset->data, idx); return item->custom_preset_data_size; } uint8_t* subghz_setting_get_preset_data_by_name(SubGhzSetting* instance, const char* preset_name) { - furi_assert(instance); + furi_check(instance); SubGhzSettingCustomPresetItem* item = SubGhzSettingCustomPresetItemArray_get( instance->preset->data, subghz_setting_get_inx_preset_by_name(instance, preset_name)); return item->custom_preset_data; } uint32_t subghz_setting_get_frequency(SubGhzSetting* instance, size_t idx) { - furi_assert(instance); + furi_check(instance); if(idx < FrequencyList_size(instance->frequencies)) { return (*FrequencyList_get(instance->frequencies, idx)) & FREQUENCY_MASK; } else { @@ -446,7 +446,7 @@ uint32_t subghz_setting_get_frequency(SubGhzSetting* instance, size_t idx) { } uint32_t subghz_setting_get_hopper_frequency(SubGhzSetting* instance, size_t idx) { - furi_assert(instance); + furi_check(instance); if(idx < FrequencyList_size(instance->hopper_frequencies)) { return *FrequencyList_get(instance->hopper_frequencies, idx); } else { @@ -455,7 +455,7 @@ uint32_t subghz_setting_get_hopper_frequency(SubGhzSetting* instance, size_t idx } uint32_t subghz_setting_get_frequency_default_index(SubGhzSetting* instance) { - furi_assert(instance); + furi_check(instance); for(size_t i = 0; i < FrequencyList_size(instance->frequencies); i++) { uint32_t frequency = *FrequencyList_get(instance->frequencies, i); if(frequency & FREQUENCY_FLAG_DEFAULT) { @@ -466,7 +466,7 @@ uint32_t subghz_setting_get_frequency_default_index(SubGhzSetting* instance) { } uint32_t subghz_setting_get_default_frequency(SubGhzSetting* instance) { - furi_assert(instance); + furi_check(instance); return subghz_setting_get_frequency( instance, subghz_setting_get_frequency_default_index(instance)); } diff --git a/lib/subghz/subghz_tx_rx_worker.c b/lib/subghz/subghz_tx_rx_worker.c index 369f5206c..f5994d494 100644 --- a/lib/subghz/subghz_tx_rx_worker.c +++ b/lib/subghz/subghz_tx_rx_worker.c @@ -29,7 +29,7 @@ struct SubGhzTxRxWorker { }; bool subghz_tx_rx_worker_write(SubGhzTxRxWorker* instance, uint8_t* data, size_t size) { - furi_assert(instance); + furi_check(instance); bool ret = false; size_t stream_tx_free_byte = furi_stream_buffer_spaces_available(instance->stream_tx); if(size && (stream_tx_free_byte >= size)) { @@ -43,12 +43,12 @@ bool subghz_tx_rx_worker_write(SubGhzTxRxWorker* instance, uint8_t* data, size_t } size_t subghz_tx_rx_worker_available(SubGhzTxRxWorker* instance) { - furi_assert(instance); + furi_check(instance); return furi_stream_buffer_bytes_available(instance->stream_rx); } size_t subghz_tx_rx_worker_read(SubGhzTxRxWorker* instance, uint8_t* data, size_t size) { - furi_assert(instance); + furi_check(instance); return furi_stream_buffer_receive(instance->stream_rx, data, size, 0); } @@ -56,9 +56,9 @@ void subghz_tx_rx_worker_set_callback_have_read( SubGhzTxRxWorker* instance, SubGhzTxRxWorkerCallbackHaveRead callback, void* context) { - furi_assert(instance); - furi_assert(callback); - furi_assert(context); + furi_check(instance); + furi_check(callback); + furi_check(context); instance->callback_have_read = callback; instance->context_have_read = context; } @@ -132,7 +132,7 @@ void subghz_tx_rx_worker_tx(SubGhzTxRxWorker* instance, uint8_t* data, size_t si */ static int32_t subghz_tx_rx_worker_thread(void* context) { SubGhzTxRxWorker* instance = context; - furi_assert(instance->device); + furi_check(instance->device); FURI_LOG_I(TAG, "Worker start"); subghz_devices_begin(instance->device); @@ -205,7 +205,7 @@ static int32_t subghz_tx_rx_worker_thread(void* context) { return 0; } -SubGhzTxRxWorker* subghz_tx_rx_worker_alloc() { +SubGhzTxRxWorker* subghz_tx_rx_worker_alloc(void) { SubGhzTxRxWorker* instance = malloc(sizeof(SubGhzTxRxWorker)); instance->thread = @@ -222,8 +222,8 @@ SubGhzTxRxWorker* subghz_tx_rx_worker_alloc() { } void subghz_tx_rx_worker_free(SubGhzTxRxWorker* instance) { - furi_assert(instance); - furi_assert(!instance->worker_running); + furi_check(instance); + furi_check(!instance->worker_running); furi_stream_buffer_free(instance->stream_tx); furi_stream_buffer_free(instance->stream_rx); furi_thread_free(instance->thread); @@ -235,8 +235,8 @@ bool subghz_tx_rx_worker_start( SubGhzTxRxWorker* instance, const SubGhzDevice* device, uint32_t frequency) { - furi_assert(instance); - furi_assert(!instance->worker_running); + furi_check(instance); + furi_check(!instance->worker_running); bool res = false; furi_stream_buffer_reset(instance->stream_tx); furi_stream_buffer_reset(instance->stream_rx); @@ -255,8 +255,8 @@ bool subghz_tx_rx_worker_start( } void subghz_tx_rx_worker_stop(SubGhzTxRxWorker* instance) { - furi_assert(instance); - furi_assert(instance->worker_running); + furi_check(instance); + furi_check(instance->worker_running); instance->worker_running = false; @@ -264,6 +264,6 @@ void subghz_tx_rx_worker_stop(SubGhzTxRxWorker* instance) { } bool subghz_tx_rx_worker_is_running(SubGhzTxRxWorker* instance) { - furi_assert(instance); + furi_check(instance); return instance->worker_running; } diff --git a/lib/subghz/subghz_tx_rx_worker.h b/lib/subghz/subghz_tx_rx_worker.h index 56bdb0a1f..a8d547ab2 100644 --- a/lib/subghz/subghz_tx_rx_worker.h +++ b/lib/subghz/subghz_tx_rx_worker.h @@ -57,7 +57,7 @@ void subghz_tx_rx_worker_set_callback_have_read( * Allocate SubGhzTxRxWorker * @return SubGhzTxRxWorker* Pointer to a SubGhzTxRxWorker instance */ -SubGhzTxRxWorker* subghz_tx_rx_worker_alloc(); +SubGhzTxRxWorker* subghz_tx_rx_worker_alloc(void); /** * Free SubGhzTxRxWorker diff --git a/lib/subghz/subghz_worker.c b/lib/subghz/subghz_worker.c index 50b5aba51..fe68d5e2d 100644 --- a/lib/subghz/subghz_worker.c +++ b/lib/subghz/subghz_worker.c @@ -79,7 +79,7 @@ static int32_t subghz_worker_thread_callback(void* context) { return 0; } -SubGhzWorker* subghz_worker_alloc() { +SubGhzWorker* subghz_worker_alloc(void) { SubGhzWorker* instance = malloc(sizeof(SubGhzWorker)); instance->thread = @@ -95,7 +95,7 @@ SubGhzWorker* subghz_worker_alloc() { } void subghz_worker_free(SubGhzWorker* instance) { - furi_assert(instance); + furi_check(instance); furi_stream_buffer_free(instance->stream); furi_thread_free(instance->thread); @@ -106,23 +106,23 @@ void subghz_worker_free(SubGhzWorker* instance) { void subghz_worker_set_overrun_callback( SubGhzWorker* instance, SubGhzWorkerOverrunCallback callback) { - furi_assert(instance); + furi_check(instance); instance->overrun_callback = callback; } void subghz_worker_set_pair_callback(SubGhzWorker* instance, SubGhzWorkerPairCallback callback) { - furi_assert(instance); + furi_check(instance); instance->pair_callback = callback; } void subghz_worker_set_context(SubGhzWorker* instance, void* context) { - furi_assert(instance); + furi_check(instance); instance->context = context; } void subghz_worker_start(SubGhzWorker* instance) { - furi_assert(instance); - furi_assert(!instance->running); + furi_check(instance); + furi_check(!instance->running); instance->running = true; @@ -130,8 +130,8 @@ void subghz_worker_start(SubGhzWorker* instance) { } void subghz_worker_stop(SubGhzWorker* instance) { - furi_assert(instance); - furi_assert(instance->running); + furi_check(instance); + furi_check(instance->running); instance->running = false; @@ -139,11 +139,11 @@ void subghz_worker_stop(SubGhzWorker* instance) { } bool subghz_worker_is_running(SubGhzWorker* instance) { - furi_assert(instance); + furi_check(instance); return instance->running; } void subghz_worker_set_filter(SubGhzWorker* instance, uint16_t timeout) { - furi_assert(instance); + furi_check(instance); instance->filter_duration = timeout; } \ No newline at end of file diff --git a/lib/subghz/subghz_worker.h b/lib/subghz/subghz_worker.h index 657278f50..87ea3fc7c 100644 --- a/lib/subghz/subghz_worker.h +++ b/lib/subghz/subghz_worker.h @@ -18,7 +18,7 @@ void subghz_worker_rx_callback(bool level, uint32_t duration, void* context); * Allocate SubGhzWorker. * @return SubGhzWorker* Pointer to a SubGhzWorker instance */ -SubGhzWorker* subghz_worker_alloc(); +SubGhzWorker* subghz_worker_alloc(void); /** * Free SubGhzWorker. diff --git a/lib/subghz/transmitter.c b/lib/subghz/transmitter.c index 81be143b5..4f7922c35 100644 --- a/lib/subghz/transmitter.c +++ b/lib/subghz/transmitter.c @@ -27,18 +27,18 @@ SubGhzTransmitter* } void subghz_transmitter_free(SubGhzTransmitter* instance) { - furi_assert(instance); + furi_check(instance); instance->protocol->encoder->free(instance->protocol_instance); free(instance); } SubGhzProtocolEncoderBase* subghz_transmitter_get_protocol_instance(SubGhzTransmitter* instance) { - furi_assert(instance); + furi_check(instance); return instance->protocol_instance; } bool subghz_transmitter_stop(SubGhzTransmitter* instance) { - furi_assert(instance); + furi_check(instance); bool ret = false; if(instance->protocol && instance->protocol->encoder && instance->protocol->encoder->stop) { instance->protocol->encoder->stop(instance->protocol_instance); @@ -49,7 +49,7 @@ bool subghz_transmitter_stop(SubGhzTransmitter* instance) { SubGhzProtocolStatus subghz_transmitter_deserialize(SubGhzTransmitter* instance, FlipperFormat* flipper_format) { - furi_assert(instance); + furi_check(instance); SubGhzProtocolStatus ret = SubGhzProtocolStatusError; if(instance->protocol && instance->protocol->encoder && instance->protocol->encoder->deserialize) { diff --git a/lib/toolbox/bit_buffer.c b/lib/toolbox/bit_buffer.c index 1943ee833..85a52e79d 100644 --- a/lib/toolbox/bit_buffer.c +++ b/lib/toolbox/bit_buffer.c @@ -12,7 +12,7 @@ struct BitBuffer { }; BitBuffer* bit_buffer_alloc(size_t capacity_bytes) { - furi_assert(capacity_bytes); + furi_check(capacity_bytes); BitBuffer* buf = malloc(sizeof(BitBuffer)); @@ -26,7 +26,7 @@ BitBuffer* bit_buffer_alloc(size_t capacity_bytes) { } void bit_buffer_free(BitBuffer* buf) { - furi_assert(buf); + furi_check(buf); free(buf->data); free(buf->parity); @@ -34,7 +34,7 @@ void bit_buffer_free(BitBuffer* buf) { } void bit_buffer_reset(BitBuffer* buf) { - furi_assert(buf); + furi_check(buf); memset(buf->data, 0, buf->capacity_bytes); size_t parity_buf_size = (buf->capacity_bytes + BITS_IN_BYTE - 1) / BITS_IN_BYTE; @@ -43,50 +43,50 @@ void bit_buffer_reset(BitBuffer* buf) { } void bit_buffer_copy(BitBuffer* buf, const BitBuffer* other) { - furi_assert(buf); - furi_assert(other); + furi_check(buf); + furi_check(other); if(buf == other) return; - furi_assert(buf->capacity_bytes * BITS_IN_BYTE >= other->size_bits); + furi_check(buf->capacity_bytes * BITS_IN_BYTE >= other->size_bits); memcpy(buf->data, other->data, bit_buffer_get_size_bytes(other)); buf->size_bits = other->size_bits; } void bit_buffer_copy_right(BitBuffer* buf, const BitBuffer* other, size_t start_index) { - furi_assert(buf); - furi_assert(other); - furi_assert(bit_buffer_get_size_bytes(other) > start_index); - furi_assert(buf->capacity_bytes >= bit_buffer_get_size_bytes(other) - start_index); + furi_check(buf); + furi_check(other); + furi_check(bit_buffer_get_size_bytes(other) > start_index); + furi_check(buf->capacity_bytes >= bit_buffer_get_size_bytes(other) - start_index); memcpy(buf->data, other->data + start_index, bit_buffer_get_size_bytes(other) - start_index); buf->size_bits = other->size_bits - start_index * BITS_IN_BYTE; } void bit_buffer_copy_left(BitBuffer* buf, const BitBuffer* other, size_t end_index) { - furi_assert(buf); - furi_assert(other); - furi_assert(bit_buffer_get_capacity_bytes(buf) >= end_index); - furi_assert(bit_buffer_get_size_bytes(other) >= end_index); + furi_check(buf); + furi_check(other); + furi_check(bit_buffer_get_capacity_bytes(buf) >= end_index); + furi_check(bit_buffer_get_size_bytes(other) >= end_index); memcpy(buf->data, other->data, end_index); buf->size_bits = end_index * BITS_IN_BYTE; } void bit_buffer_copy_bytes(BitBuffer* buf, const uint8_t* data, size_t size_bytes) { - furi_assert(buf); - furi_assert(data); - furi_assert(buf->capacity_bytes >= size_bytes); + furi_check(buf); + furi_check(data); + furi_check(buf->capacity_bytes >= size_bytes); memcpy(buf->data, data, size_bytes); buf->size_bits = size_bytes * BITS_IN_BYTE; } void bit_buffer_copy_bits(BitBuffer* buf, const uint8_t* data, size_t size_bits) { - furi_assert(buf); - furi_assert(data); - furi_assert(buf->capacity_bytes * BITS_IN_BYTE >= size_bits); + furi_check(buf); + furi_check(data); + furi_check(buf->capacity_bytes * BITS_IN_BYTE >= size_bits); size_t size_bytes = (size_bits + BITS_IN_BYTE - 1) / BITS_IN_BYTE; memcpy(buf->data, data, size_bytes); @@ -94,8 +94,8 @@ void bit_buffer_copy_bits(BitBuffer* buf, const uint8_t* data, size_t size_bits) } void bit_buffer_copy_bytes_with_parity(BitBuffer* buf, const uint8_t* data, size_t size_bits) { - furi_assert(buf); - furi_assert(data); + furi_check(buf); + furi_check(data); size_t bits_processed = 0; size_t curr_byte = 0; @@ -104,7 +104,7 @@ void bit_buffer_copy_bytes_with_parity(BitBuffer* buf, const uint8_t* data, size buf->size_bits = size_bits; buf->data[0] = data[0]; } else { - furi_assert(size_bits % (BITS_IN_BYTE + 1) == 0); + furi_check(size_bits % (BITS_IN_BYTE + 1) == 0); while(bits_processed < size_bits) { buf->data[curr_byte] = data[bits_processed / BITS_IN_BYTE] >> (bits_processed % BITS_IN_BYTE); @@ -126,9 +126,9 @@ void bit_buffer_copy_bytes_with_parity(BitBuffer* buf, const uint8_t* data, size } void bit_buffer_write_bytes(const BitBuffer* buf, void* dest, size_t size_bytes) { - furi_assert(buf); - furi_assert(dest); - furi_assert(bit_buffer_get_size_bytes(buf) <= size_bytes); + furi_check(buf); + furi_check(dest); + furi_check(bit_buffer_get_size_bytes(buf) <= size_bytes); memcpy(dest, buf->data, bit_buffer_get_size_bytes(buf)); } @@ -138,14 +138,14 @@ void bit_buffer_write_bytes_with_parity( void* dest, size_t size_bytes, size_t* bits_written) { - furi_assert(buf); - furi_assert(dest); - furi_assert(bits_written); + furi_check(buf); + furi_check(dest); + furi_check(bits_written); size_t buf_size_bytes = bit_buffer_get_size_bytes(buf); size_t buf_size_with_parity_bytes = (buf_size_bytes * (BITS_IN_BYTE + 1) + BITS_IN_BYTE) / BITS_IN_BYTE; - furi_assert(buf_size_with_parity_bytes <= size_bytes); + furi_check(buf_size_with_parity_bytes <= size_bytes); uint8_t next_par_bit = 0; uint16_t curr_bit_pos = 0; @@ -177,53 +177,53 @@ void bit_buffer_write_bytes_mid( void* dest, size_t start_index, size_t size_bytes) { - furi_assert(buf); - furi_assert(dest); - furi_assert(start_index + size_bytes <= bit_buffer_get_size_bytes(buf)); + furi_check(buf); + furi_check(dest); + furi_check(start_index + size_bytes <= bit_buffer_get_size_bytes(buf)); memcpy(dest, buf->data + start_index, size_bytes); } bool bit_buffer_has_partial_byte(const BitBuffer* buf) { - furi_assert(buf); + furi_check(buf); return (buf->size_bits % BITS_IN_BYTE) != 0; } bool bit_buffer_starts_with_byte(const BitBuffer* buf, uint8_t byte) { - furi_assert(buf); + furi_check(buf); return bit_buffer_get_size_bytes(buf) && (buf->data[0] == byte); } size_t bit_buffer_get_capacity_bytes(const BitBuffer* buf) { - furi_assert(buf); + furi_check(buf); return buf->capacity_bytes; } size_t bit_buffer_get_size(const BitBuffer* buf) { - furi_assert(buf); + furi_check(buf); return buf->size_bits; } size_t bit_buffer_get_size_bytes(const BitBuffer* buf) { - furi_assert(buf); + furi_check(buf); return (buf->size_bits / BITS_IN_BYTE) + (buf->size_bits % BITS_IN_BYTE ? 1 : 0); } uint8_t bit_buffer_get_byte(const BitBuffer* buf, size_t index) { - furi_assert(buf); - furi_assert(buf->capacity_bytes > index); + furi_check(buf); + furi_check(buf->capacity_bytes > index); return buf->data[index]; } uint8_t bit_buffer_get_byte_from_bit(const BitBuffer* buf, size_t index_bits) { - furi_assert(buf); - furi_assert(buf->capacity_bytes * BITS_IN_BYTE > index_bits); + furi_check(buf); + furi_check(buf->capacity_bytes * BITS_IN_BYTE > index_bits); const size_t byte_index = index_bits / BITS_IN_BYTE; const size_t bit_offset = index_bits % BITS_IN_BYTE; @@ -235,29 +235,29 @@ uint8_t bit_buffer_get_byte_from_bit(const BitBuffer* buf, size_t index_bits) { } const uint8_t* bit_buffer_get_data(const BitBuffer* buf) { - furi_assert(buf); + furi_check(buf); return buf->data; } const uint8_t* bit_buffer_get_parity(const BitBuffer* buf) { - furi_assert(buf); + furi_check(buf); return buf->parity; } void bit_buffer_set_byte(BitBuffer* buf, size_t index, uint8_t byte) { - furi_assert(buf); + furi_check(buf); const size_t size_bytes = bit_buffer_get_size_bytes(buf); - furi_assert(size_bytes > index); + furi_check(size_bytes > index); buf->data[index] = byte; } void bit_buffer_set_byte_with_parity(BitBuffer* buff, size_t index, uint8_t byte, bool parity) { - furi_assert(buff); - furi_assert(buff->size_bits / BITS_IN_BYTE > index); + furi_check(buff); + furi_check(buff->size_bits / BITS_IN_BYTE > index); buff->data[index] = byte; if((index % BITS_IN_BYTE) == 0) { @@ -268,15 +268,15 @@ void bit_buffer_set_byte_with_parity(BitBuffer* buff, size_t index, uint8_t byte } void bit_buffer_set_size(BitBuffer* buf, size_t new_size) { - furi_assert(buf); - furi_assert(buf->capacity_bytes * BITS_IN_BYTE >= new_size); + furi_check(buf); + furi_check(buf->capacity_bytes * BITS_IN_BYTE >= new_size); buf->size_bits = new_size; } void bit_buffer_set_size_bytes(BitBuffer* buf, size_t new_size_bytes) { - furi_assert(buf); - furi_assert(buf->capacity_bytes >= new_size_bytes); + furi_check(buf); + furi_check(buf->capacity_bytes >= new_size_bytes); buf->size_bits = new_size_bytes * BITS_IN_BYTE; } @@ -286,43 +286,43 @@ void bit_buffer_append(BitBuffer* buf, const BitBuffer* other) { } void bit_buffer_append_right(BitBuffer* buf, const BitBuffer* other, size_t start_index) { - furi_assert(buf); - furi_assert(other); + furi_check(buf); + furi_check(other); const size_t size_bytes = bit_buffer_get_size_bytes(buf); const size_t other_size_bytes = bit_buffer_get_size_bytes(other) - start_index; - furi_assert(buf->capacity_bytes >= size_bytes + other_size_bytes); + furi_check(buf->capacity_bytes >= size_bytes + other_size_bytes); memcpy(buf->data + size_bytes, other->data + start_index, other_size_bytes); buf->size_bits += other->size_bits - start_index * BITS_IN_BYTE; } void bit_buffer_append_byte(BitBuffer* buf, uint8_t byte) { - furi_assert(buf); + furi_check(buf); const size_t data_size_bytes = bit_buffer_get_size_bytes(buf); const size_t new_data_size_bytes = data_size_bytes + 1; - furi_assert(new_data_size_bytes <= buf->capacity_bytes); + furi_check(new_data_size_bytes <= buf->capacity_bytes); buf->data[data_size_bytes] = byte; buf->size_bits = new_data_size_bytes * BITS_IN_BYTE; } void bit_buffer_append_bytes(BitBuffer* buf, const uint8_t* data, size_t size_bytes) { - furi_assert(buf); - furi_assert(data); + furi_check(buf); + furi_check(data); const size_t buf_size_bytes = bit_buffer_get_size_bytes(buf); - furi_assert(buf->capacity_bytes >= buf_size_bytes + size_bytes); + furi_check(buf->capacity_bytes >= buf_size_bytes + size_bytes); memcpy(&buf->data[buf_size_bytes], data, size_bytes); buf->size_bits += size_bytes * BITS_IN_BYTE; } void bit_buffer_append_bit(BitBuffer* buf, bool bit) { - furi_assert(buf); - furi_assert( + furi_check(buf); + furi_check( bit_buffer_get_size_bytes(buf) <= (buf->capacity_bytes - (bit_buffer_has_partial_byte(buf) ? 0 : 1))); diff --git a/lib/toolbox/compress.c b/lib/toolbox/compress.c index 0d5e1c654..70db47968 100644 --- a/lib/toolbox/compress.c +++ b/lib/toolbox/compress.c @@ -27,7 +27,7 @@ struct CompressIcon { uint8_t decoded_buff[COMPRESS_ICON_DECODED_BUFF_SIZE]; }; -CompressIcon* compress_icon_alloc() { +CompressIcon* compress_icon_alloc(void) { CompressIcon* instance = malloc(sizeof(CompressIcon)); instance->decoder = heatshrink_decoder_alloc( COMPRESS_ICON_ENCODED_BUFF_SIZE, @@ -40,15 +40,15 @@ CompressIcon* compress_icon_alloc() { } void compress_icon_free(CompressIcon* instance) { - furi_assert(instance); + furi_check(instance); heatshrink_decoder_free(instance->decoder); free(instance); } void compress_icon_decode(CompressIcon* instance, const uint8_t* icon_data, uint8_t** decoded_buff) { - furi_assert(instance); - furi_assert(icon_data); - furi_assert(decoded_buff); + furi_check(instance); + furi_check(icon_data); + furi_check(decoded_buff); CompressHeader* header = (CompressHeader*)icon_data; if(header->is_compressed) { @@ -64,7 +64,7 @@ void compress_icon_decode(CompressIcon* instance, const uint8_t* icon_data, uint instance->decoded_buff, sizeof(instance->decoded_buff), &data_processed); - furi_assert((res == HSDR_POLL_EMPTY) || (res == HSDR_POLL_MORE)); + furi_check((res == HSDR_POLL_EMPTY) || (res == HSDR_POLL_MORE)); if(res != HSDR_POLL_MORE) { break; } @@ -98,7 +98,7 @@ Compress* compress_alloc(uint16_t compress_buff_size) { } void compress_free(Compress* compress) { - furi_assert(compress); + furi_check(compress); heatshrink_encoder_free(compress->encoder); heatshrink_decoder_free(compress->decoder); diff --git a/lib/toolbox/compress.h b/lib/toolbox/compress.h index a18551d7f..b61bdb022 100644 --- a/lib/toolbox/compress.h +++ b/lib/toolbox/compress.h @@ -19,7 +19,7 @@ typedef struct CompressIcon CompressIcon; * * @return Compress Icon instance */ -CompressIcon* compress_icon_alloc(); +CompressIcon* compress_icon_alloc(void); /** Free icon compressor * diff --git a/lib/toolbox/dir_walk.c b/lib/toolbox/dir_walk.c index 509ceb5b4..ed8c65866 100644 --- a/lib/toolbox/dir_walk.c +++ b/lib/toolbox/dir_walk.c @@ -14,6 +14,8 @@ struct DirWalk { }; DirWalk* dir_walk_alloc(Storage* storage) { + furi_check(storage); + DirWalk* dir_walk = malloc(sizeof(DirWalk)); dir_walk->path = furi_string_alloc(); dir_walk->file = storage_file_alloc(storage); @@ -24,6 +26,8 @@ DirWalk* dir_walk_alloc(Storage* storage) { } void dir_walk_free(DirWalk* dir_walk) { + furi_check(dir_walk); + storage_file_free(dir_walk->file); furi_string_free(dir_walk->path); DirIndexList_clear(dir_walk->index_list); @@ -31,15 +35,18 @@ void dir_walk_free(DirWalk* dir_walk) { } void dir_walk_set_recursive(DirWalk* dir_walk, bool recursive) { + furi_check(dir_walk); dir_walk->recursive = recursive; } void dir_walk_set_filter_cb(DirWalk* dir_walk, DirWalkFilterCb cb, void* context) { + furi_check(dir_walk); dir_walk->filter_cb = cb; dir_walk->filter_context = context; } bool dir_walk_open(DirWalk* dir_walk, const char* path) { + furi_check(dir_walk); furi_string_set(dir_walk->path, path); dir_walk->current_index = 0; return storage_dir_open(dir_walk->file, path); @@ -139,14 +146,17 @@ static DirWalkResult } FS_Error dir_walk_get_error(DirWalk* dir_walk) { + furi_check(dir_walk); return storage_file_get_error(dir_walk->file); } DirWalkResult dir_walk_read(DirWalk* dir_walk, FuriString* return_path, FileInfo* fileinfo) { + furi_check(dir_walk); return dir_walk_iter(dir_walk, return_path, fileinfo); } void dir_walk_close(DirWalk* dir_walk) { + furi_check(dir_walk); if(storage_file_is_open(dir_walk->file)) { storage_dir_close(dir_walk->file); } diff --git a/lib/toolbox/hex.c b/lib/toolbox/hex.c index 25dcb0950..e5cdfff17 100644 --- a/lib/toolbox/hex.c +++ b/lib/toolbox/hex.c @@ -1,6 +1,9 @@ #include "hex.h" +#include bool hex_char_to_hex_nibble(char c, uint8_t* nibble) { + furi_check(nibble); + if((c >= '0' && c <= '9')) { *nibble = c - '0'; return true; @@ -16,6 +19,8 @@ bool hex_char_to_hex_nibble(char c, uint8_t* nibble) { } bool hex_char_to_uint8(char hi, char low, uint8_t* value) { + furi_check(value); + uint8_t hi_nibble_value, low_nibble_value; if(hex_char_to_hex_nibble(hi, &hi_nibble_value) && @@ -28,6 +33,9 @@ bool hex_char_to_uint8(char hi, char low, uint8_t* value) { } bool hex_chars_to_uint8(const char* value_str, uint8_t* value) { + furi_check(value_str); + furi_check(value); + bool parse_success = false; while(*value_str && value_str[1]) { parse_success = hex_char_to_uint8(*value_str, value_str[1], value++); @@ -38,6 +46,9 @@ bool hex_chars_to_uint8(const char* value_str, uint8_t* value) { } bool hex_chars_to_uint64(const char* value_str, uint64_t* value) { + furi_check(value_str); + furi_check(value); + uint8_t* _value = (uint8_t*)value; bool parse_success = false; @@ -45,10 +56,14 @@ bool hex_chars_to_uint64(const char* value_str, uint64_t* value) { parse_success = hex_char_to_uint8(value_str[i * 2], value_str[i * 2 + 1], &_value[7 - i]); if(!parse_success) break; } + return parse_success; } void uint8_to_hex_chars(const uint8_t* src, uint8_t* target, int length) { + furi_check(src); + furi_check(target); + const char chars[] = "0123456789ABCDEF"; while(--length >= 0) target[length] = chars[(src[length >> 1] >> ((1 - (length & 1)) << 2)) & 0xF]; diff --git a/lib/toolbox/keys_dict.c b/lib/toolbox/keys_dict.c index 8d6f8c846..09fc241ee 100644 --- a/lib/toolbox/keys_dict.c +++ b/lib/toolbox/keys_dict.c @@ -53,7 +53,7 @@ static bool keys_dict_read_key_line(KeysDict* instance, FuriString* line, bool* } bool keys_dict_check_presence(const char* path) { - furi_assert(path); + furi_check(path); Storage* storage = furi_record_open(RECORD_STORAGE); @@ -65,16 +65,13 @@ bool keys_dict_check_presence(const char* path) { } KeysDict* keys_dict_alloc(const char* path, KeysDictMode mode, size_t key_size) { - furi_assert(path); - furi_assert(key_size > 0); + furi_check(path); + furi_check(key_size > 0); KeysDict* instance = malloc(sizeof(KeysDict)); Storage* storage = furi_record_open(RECORD_STORAGE); - furi_assert(storage); - instance->stream = buffered_file_stream_alloc(storage); - furi_assert(instance->stream); FS_OpenMode open_mode = (mode == KeysDictModeOpenAlways) ? FSOM_OPEN_ALWAYS : FSOM_OPEN_EXISTING; @@ -116,8 +113,8 @@ KeysDict* keys_dict_alloc(const char* path, KeysDictMode mode, size_t key_size) } void keys_dict_free(KeysDict* instance) { - furi_assert(instance); - furi_assert(instance->stream); + furi_check(instance); + furi_check(instance->stream); buffered_file_stream_close(instance->stream); stream_free(instance->stream); @@ -157,14 +154,14 @@ static void keys_dict_str_to_int(KeysDict* instance, FuriString* key_str, uint64 } size_t keys_dict_get_total_keys(KeysDict* instance) { - furi_assert(instance); + furi_check(instance); return instance->total_keys; } bool keys_dict_rewind(KeysDict* instance) { - furi_assert(instance); - furi_assert(instance->stream); + furi_check(instance); + furi_check(instance->stream); return stream_rewind(instance->stream); } @@ -185,10 +182,10 @@ static bool keys_dict_get_next_key_str(KeysDict* instance, FuriString* key) { } bool keys_dict_get_next_key(KeysDict* instance, uint8_t* key, size_t key_size) { - furi_assert(instance); - furi_assert(instance->stream); - furi_assert(instance->key_size == key_size); - furi_assert(key); + furi_check(instance); + furi_check(instance->stream); + furi_check(instance->key_size == key_size); + furi_check(key); FuriString* temp_key = furi_string_alloc(); @@ -237,10 +234,10 @@ static bool keys_dict_is_key_present_str(KeysDict* instance, FuriString* key) { } bool keys_dict_is_key_present(KeysDict* instance, const uint8_t* key, size_t key_size) { - furi_assert(instance); - furi_assert(instance->stream); - furi_assert(instance->key_size == key_size); - furi_assert(key); + furi_check(instance); + furi_check(instance->stream); + furi_check(instance->key_size == key_size); + furi_check(key); FuriString* temp_key = furi_string_alloc(); @@ -274,13 +271,12 @@ static bool keys_dict_add_key_str(KeysDict* instance, FuriString* key) { } bool keys_dict_add_key(KeysDict* instance, const uint8_t* key, size_t key_size) { - furi_assert(instance); - furi_assert(instance->stream); - furi_assert(instance->key_size == key_size); - furi_assert(key); + furi_check(instance); + furi_check(instance->stream); + furi_check(instance->key_size == key_size); + furi_check(key); FuriString* temp_key = furi_string_alloc(); - furi_assert(temp_key); keys_dict_int_to_str(instance, key, temp_key); bool key_added = keys_dict_add_key_str(instance, temp_key); @@ -293,10 +289,10 @@ bool keys_dict_add_key(KeysDict* instance, const uint8_t* key, size_t key_size) } bool keys_dict_delete_key(KeysDict* instance, const uint8_t* key, size_t key_size) { - furi_assert(instance); - furi_assert(instance->stream); - furi_assert(instance->key_size == key_size); - furi_assert(key); + furi_check(instance); + furi_check(instance->stream); + furi_check(instance->key_size == key_size); + furi_check(key); bool key_removed = false; diff --git a/lib/toolbox/manchester_encoder.c b/lib/toolbox/manchester_encoder.c index c22e4a177..38b94eb86 100644 --- a/lib/toolbox/manchester_encoder.c +++ b/lib/toolbox/manchester_encoder.c @@ -1,7 +1,9 @@ #include "manchester_encoder.h" #include +#include void manchester_encoder_reset(ManchesterEncoderState* state) { + furi_check(state); state->step = 0; } @@ -9,6 +11,9 @@ bool manchester_encoder_advance( ManchesterEncoderState* state, const bool curr_bit, ManchesterEncoderResult* result) { + furi_check(state); + furi_check(result); + bool advance = false; switch(state->step) { case 0: @@ -41,14 +46,16 @@ bool manchester_encoder_advance( advance = true; break; default: - printf("DO CRASH HERE\r\n"); - // furi_crash + furi_crash(); break; } return advance; } ManchesterEncoderResult manchester_encoder_finish(ManchesterEncoderState* state) { + furi_check(state); + state->step = 0; + return (state->prev_bit << 1) + state->prev_bit; } diff --git a/lib/toolbox/name_generator.c b/lib/toolbox/name_generator.c index e8b8c586f..7c4d10b6b 100644 --- a/lib/toolbox/name_generator.c +++ b/lib/toolbox/name_generator.c @@ -44,8 +44,8 @@ void name_generator_make_auto_basic(char* name, size_t max_name_size, const char } void name_generator_make_random_prefixed(char* name, size_t max_name_size, const char* prefix) { - furi_assert(name); - furi_assert(max_name_size); + furi_check(name); + furi_check(max_name_size); uint8_t name_generator_left_i = rand() % COUNT_OF(name_generator_left); uint8_t name_generator_right_i = rand() % COUNT_OF(name_generator_right); @@ -72,9 +72,9 @@ void name_generator_make_detailed_datetime( size_t max_name_size, const char* prefix, DateTime* custom_time) { - furi_assert(name); - furi_assert(max_name_size); - furi_assert(prefix); + furi_check(name); + furi_check(max_name_size); + furi_check(prefix); DateTime dateTime; if(custom_time) { diff --git a/lib/toolbox/path.c b/lib/toolbox/path.c index 3d161a196..37bacd65a 100644 --- a/lib/toolbox/path.c +++ b/lib/toolbox/path.c @@ -2,6 +2,9 @@ #include void path_extract_filename_no_ext(const char* path, FuriString* filename) { + furi_check(path); + furi_check(filename); + furi_string_set(filename, path); size_t start_position = furi_string_search_rchar(filename, '/'); @@ -21,6 +24,9 @@ void path_extract_filename_no_ext(const char* path, FuriString* filename) { } void path_extract_filename(FuriString* path, FuriString* name, bool trim_ext) { + furi_check(path); + furi_check(name); + size_t filename_start = furi_string_search_rchar(path, '/'); if(filename_start > 0) { filename_start++; @@ -35,6 +41,9 @@ void path_extract_filename(FuriString* path, FuriString* name, bool trim_ext) { } void path_extract_extension(FuriString* path, char* ext, size_t ext_len_max) { + furi_check(path); + furi_check(ext); + size_t dot = furi_string_search_rchar(path, '.'); size_t filename_start = furi_string_search_rchar(path, '/'); @@ -51,6 +60,9 @@ static inline void path_cleanup(FuriString* path) { } void path_extract_basename(const char* path, FuriString* basename) { + furi_check(path); + furi_check(basename); + furi_string_set(basename, path); path_cleanup(basename); size_t pos = furi_string_search_rchar(basename, '/'); @@ -60,6 +72,9 @@ void path_extract_basename(const char* path, FuriString* basename) { } void path_extract_dirname(const char* path, FuriString* dirname) { + furi_check(path); + furi_check(dirname); + furi_string_set(dirname, path); path_cleanup(dirname); size_t pos = furi_string_search_rchar(dirname, '/'); @@ -69,6 +84,9 @@ void path_extract_dirname(const char* path, FuriString* dirname) { } void path_append(FuriString* path, const char* suffix) { + furi_check(path); + furi_check(suffix); + path_cleanup(path); FuriString* suffix_str; suffix_str = furi_string_alloc_set(suffix); @@ -79,6 +97,10 @@ void path_append(FuriString* path, const char* suffix) { } void path_concat(const char* path, const char* suffix, FuriString* out_path) { + furi_check(path); + furi_check(suffix); + furi_check(out_path); + furi_string_set(out_path, path); path_append(out_path, suffix); } diff --git a/lib/toolbox/pretty_format.c b/lib/toolbox/pretty_format.c index d5ba10381..2dcfdb6d9 100644 --- a/lib/toolbox/pretty_format.c +++ b/lib/toolbox/pretty_format.c @@ -11,7 +11,7 @@ void pretty_format_bytes_hex_canonical( const char* line_prefix, const uint8_t* data, size_t data_size) { - furi_assert(data); + furi_check(data); bool is_truncated = false; diff --git a/lib/toolbox/profiler.c b/lib/toolbox/profiler.c index 96f38dce2..4e7cade1a 100644 --- a/lib/toolbox/profiler.c +++ b/lib/toolbox/profiler.c @@ -17,7 +17,7 @@ struct Profiler { ProfilerRecordDict_t records; }; -Profiler* profiler_alloc() { +Profiler* profiler_alloc(void) { Profiler* profiler = malloc(sizeof(Profiler)); ProfilerRecordDict_init(profiler->records); return profiler; diff --git a/lib/toolbox/profiler.h b/lib/toolbox/profiler.h index 840146332..037711a8f 100644 --- a/lib/toolbox/profiler.h +++ b/lib/toolbox/profiler.h @@ -6,7 +6,7 @@ extern "C" { typedef struct Profiler Profiler; -Profiler* profiler_alloc(); +Profiler* profiler_alloc(void); void profiler_free(Profiler* profiler); diff --git a/lib/toolbox/property.c b/lib/toolbox/property.c index c258cdd6a..900948b45 100644 --- a/lib/toolbox/property.c +++ b/lib/toolbox/property.c @@ -3,7 +3,7 @@ #include void property_value_out(PropertyValueContext* ctx, const char* fmt, unsigned int nparts, ...) { - furi_assert(ctx); + furi_check(ctx); furi_string_reset(ctx->key); va_list args; diff --git a/lib/toolbox/protocols/protocol_dict.c b/lib/toolbox/protocols/protocol_dict.c index 136dc1372..e8da4b1cd 100644 --- a/lib/toolbox/protocols/protocol_dict.c +++ b/lib/toolbox/protocols/protocol_dict.c @@ -8,6 +8,8 @@ struct ProtocolDict { }; ProtocolDict* protocol_dict_alloc(const ProtocolBase** protocols, size_t count) { + furi_check(protocols); + ProtocolDict* dict = malloc(sizeof(ProtocolDict)); dict->base = protocols; dict->count = count; @@ -21,6 +23,8 @@ ProtocolDict* protocol_dict_alloc(const ProtocolBase** protocols, size_t count) } void protocol_dict_free(ProtocolDict* dict) { + furi_check(dict); + for(size_t i = 0; i < dict->count; i++) { dict->base[i]->free(dict->data[i]); } @@ -34,8 +38,9 @@ void protocol_dict_set_data( size_t protocol_index, const uint8_t* data, size_t data_size) { - furi_assert(protocol_index < dict->count); - furi_assert(dict->base[protocol_index]->get_data != NULL); + furi_check(protocol_index < dict->count); + furi_check(dict->base[protocol_index]->get_data != NULL); + uint8_t* protocol_data = dict->base[protocol_index]->get_data(dict->data[protocol_index]); size_t protocol_data_size = dict->base[protocol_index]->data_size; furi_check(data_size >= protocol_data_size); @@ -47,8 +52,9 @@ void protocol_dict_get_data( size_t protocol_index, uint8_t* data, size_t data_size) { - furi_assert(protocol_index < dict->count); - furi_assert(dict->base[protocol_index]->get_data != NULL); + furi_check(protocol_index < dict->count); + furi_check(dict->base[protocol_index]->get_data != NULL); + uint8_t* protocol_data = dict->base[protocol_index]->get_data(dict->data[protocol_index]); size_t protocol_data_size = dict->base[protocol_index]->data_size; furi_check(data_size >= protocol_data_size); @@ -56,11 +62,12 @@ void protocol_dict_get_data( } size_t protocol_dict_get_data_size(ProtocolDict* dict, size_t protocol_index) { - furi_assert(protocol_index < dict->count); + furi_check(protocol_index < dict->count); return dict->base[protocol_index]->data_size; } size_t protocol_dict_get_max_data_size(ProtocolDict* dict) { + furi_check(dict); size_t max_data_size = 0; for(size_t i = 0; i < dict->count; i++) { size_t data_size = dict->base[i]->data_size; @@ -73,16 +80,18 @@ size_t protocol_dict_get_max_data_size(ProtocolDict* dict) { } const char* protocol_dict_get_name(ProtocolDict* dict, size_t protocol_index) { - furi_assert(protocol_index < dict->count); + furi_check(protocol_index < dict->count); return dict->base[protocol_index]->name; } const char* protocol_dict_get_manufacturer(ProtocolDict* dict, size_t protocol_index) { - furi_assert(protocol_index < dict->count); + furi_check(protocol_index < dict->count); return dict->base[protocol_index]->manufacturer; } void protocol_dict_decoders_start(ProtocolDict* dict) { + furi_check(dict); + for(size_t i = 0; i < dict->count; i++) { ProtocolDecoderStart fn = dict->base[i]->decoder.start; @@ -93,11 +102,13 @@ void protocol_dict_decoders_start(ProtocolDict* dict) { } uint32_t protocol_dict_get_features(ProtocolDict* dict, size_t protocol_index) { - furi_assert(protocol_index < dict->count); + furi_check(protocol_index < dict->count); return dict->base[protocol_index]->features; } ProtocolId protocol_dict_decoders_feed(ProtocolDict* dict, bool level, uint32_t duration) { + furi_check(dict); + bool done = false; ProtocolId ready_protocol_id = PROTOCOL_NO; @@ -122,6 +133,8 @@ ProtocolId protocol_dict_decoders_feed_by_feature( uint32_t feature, bool level, uint32_t duration) { + furi_check(dict); + bool done = false; ProtocolId ready_protocol_id = PROTOCOL_NO; @@ -149,7 +162,7 @@ ProtocolId protocol_dict_decoders_feed_by_id( size_t protocol_index, bool level, uint32_t duration) { - furi_assert(protocol_index < dict->count); + furi_check(protocol_index < dict->count); ProtocolId ready_protocol_id = PROTOCOL_NO; ProtocolDecoderFeed fn = dict->base[protocol_index]->decoder.feed; @@ -164,7 +177,7 @@ ProtocolId protocol_dict_decoders_feed_by_id( } bool protocol_dict_encoder_start(ProtocolDict* dict, size_t protocol_index) { - furi_assert(protocol_index < dict->count); + furi_check(protocol_index < dict->count); ProtocolEncoderStart fn = dict->base[protocol_index]->encoder.start; if(fn) { @@ -175,7 +188,7 @@ bool protocol_dict_encoder_start(ProtocolDict* dict, size_t protocol_index) { } LevelDuration protocol_dict_encoder_yield(ProtocolDict* dict, size_t protocol_index) { - furi_assert(protocol_index < dict->count); + furi_check(protocol_index < dict->count); ProtocolEncoderYield fn = dict->base[protocol_index]->encoder.yield; if(fn) { @@ -186,7 +199,7 @@ LevelDuration protocol_dict_encoder_yield(ProtocolDict* dict, size_t protocol_in } void protocol_dict_render_data(ProtocolDict* dict, FuriString* result, size_t protocol_index) { - furi_assert(protocol_index < dict->count); + furi_check(protocol_index < dict->count); ProtocolRenderData fn = dict->base[protocol_index]->render_data; if(fn) { @@ -195,7 +208,7 @@ void protocol_dict_render_data(ProtocolDict* dict, FuriString* result, size_t pr } void protocol_dict_render_brief_data(ProtocolDict* dict, FuriString* result, size_t protocol_index) { - furi_assert(protocol_index < dict->count); + furi_check(protocol_index < dict->count); ProtocolRenderData fn = dict->base[protocol_index]->render_brief_data; if(fn) { @@ -204,11 +217,13 @@ void protocol_dict_render_brief_data(ProtocolDict* dict, FuriString* result, siz } uint32_t protocol_dict_get_validate_count(ProtocolDict* dict, size_t protocol_index) { - furi_assert(protocol_index < dict->count); + furi_check(protocol_index < dict->count); return dict->base[protocol_index]->validate_count; } ProtocolId protocol_dict_get_protocol_by_name(ProtocolDict* dict, const char* name) { + furi_check(dict); + furi_check(name); for(size_t i = 0; i < dict->count; i++) { if(strcmp(name, protocol_dict_get_name(dict, i)) == 0) { return i; @@ -218,9 +233,9 @@ ProtocolId protocol_dict_get_protocol_by_name(ProtocolDict* dict, const char* na } bool protocol_dict_get_write_data(ProtocolDict* dict, size_t protocol_index, void* data) { - furi_assert(protocol_index < dict->count); + furi_check(protocol_index < dict->count); ProtocolWriteData fn = dict->base[protocol_index]->write_data; - furi_assert(fn); + furi_check(fn); return fn(dict->data[protocol_index], data); } \ No newline at end of file diff --git a/lib/toolbox/pulse_joiner.c b/lib/toolbox/pulse_joiner.c index b6206486c..dce63b823 100644 --- a/lib/toolbox/pulse_joiner.c +++ b/lib/toolbox/pulse_joiner.c @@ -13,7 +13,7 @@ struct PulseJoiner { Pulse pulses[PULSE_MAX_COUNT]; }; -PulseJoiner* pulse_joiner_alloc() { +PulseJoiner* pulse_joiner_alloc(void) { PulseJoiner* pulse_joiner = malloc(sizeof(PulseJoiner)); pulse_joiner->pulse_index = 0; diff --git a/lib/toolbox/pulse_joiner.h b/lib/toolbox/pulse_joiner.h index 25f702e72..f9597280f 100644 --- a/lib/toolbox/pulse_joiner.h +++ b/lib/toolbox/pulse_joiner.h @@ -13,7 +13,7 @@ typedef struct PulseJoiner PulseJoiner; * * @return PulseJoiner* */ -PulseJoiner* pulse_joiner_alloc(); +PulseJoiner* pulse_joiner_alloc(void); /** * @brief Free PulseJoiner diff --git a/lib/toolbox/pulse_protocols/pulse_glue.c b/lib/toolbox/pulse_protocols/pulse_glue.c index 9cb914db5..f8574691d 100644 --- a/lib/toolbox/pulse_protocols/pulse_glue.c +++ b/lib/toolbox/pulse_protocols/pulse_glue.c @@ -6,7 +6,7 @@ struct PulseGlue { int32_t next_hi_period; }; -PulseGlue* pulse_glue_alloc() { +PulseGlue* pulse_glue_alloc(void) { PulseGlue* pulse_glue = malloc(sizeof(PulseGlue)); pulse_glue_reset(pulse_glue); return pulse_glue; diff --git a/lib/toolbox/pulse_protocols/pulse_glue.h b/lib/toolbox/pulse_protocols/pulse_glue.h index 4954e2719..9f707d0c2 100644 --- a/lib/toolbox/pulse_protocols/pulse_glue.h +++ b/lib/toolbox/pulse_protocols/pulse_glue.h @@ -14,7 +14,7 @@ extern "C" { typedef struct PulseGlue PulseGlue; -PulseGlue* pulse_glue_alloc(); +PulseGlue* pulse_glue_alloc(void); void pulse_glue_free(PulseGlue* pulse_glue); void pulse_glue_reset(PulseGlue* pulse_glue); diff --git a/lib/toolbox/saved_struct.c b/lib/toolbox/saved_struct.c index 2f1c09c8e..e96d5b6cb 100644 --- a/lib/toolbox/saved_struct.c +++ b/lib/toolbox/saved_struct.c @@ -14,9 +14,9 @@ typedef struct { } SavedStructHeader; bool saved_struct_save(const char* path, void* data, size_t size, uint8_t magic, uint8_t version) { - furi_assert(path); - furi_assert(data); - furi_assert(size); + furi_check(path); + furi_check(data); + furi_check(size); SavedStructHeader header; FURI_LOG_I(TAG, "Saving \"%s\"", path); @@ -131,8 +131,8 @@ bool saved_struct_get_payload_size( uint8_t magic, uint8_t version, size_t* payload_size) { - furi_assert(path); - furi_assert(payload_size); + furi_check(path); + furi_check(payload_size); SavedStructHeader header; Storage* storage = furi_record_open(RECORD_STORAGE); diff --git a/lib/toolbox/simple_array.c b/lib/toolbox/simple_array.c index 7aed8e34b..af20444df 100644 --- a/lib/toolbox/simple_array.c +++ b/lib/toolbox/simple_array.c @@ -15,15 +15,15 @@ SimpleArray* simple_array_alloc(const SimpleArrayConfig* config) { } void simple_array_free(SimpleArray* instance) { - furi_assert(instance); + furi_check(instance); simple_array_reset(instance); free(instance); } void simple_array_init(SimpleArray* instance, uint32_t count) { - furi_assert(instance); - furi_assert(count > 0); + furi_check(instance); + furi_check(count > 0); simple_array_reset(instance); @@ -39,7 +39,7 @@ void simple_array_init(SimpleArray* instance, uint32_t count) { } void simple_array_reset(SimpleArray* instance) { - furi_assert(instance); + furi_check(instance); if(instance->data) { SimpleArrayReset reset = instance->config->reset; @@ -58,9 +58,9 @@ void simple_array_reset(SimpleArray* instance) { } void simple_array_copy(SimpleArray* instance, const SimpleArray* other) { - furi_assert(instance); - furi_assert(other); - furi_assert(instance->config == other->config); + furi_check(instance); + furi_check(other); + furi_check(instance->config == other->config); simple_array_reset(instance); @@ -81,8 +81,8 @@ void simple_array_copy(SimpleArray* instance, const SimpleArray* other) { } bool simple_array_is_equal(const SimpleArray* instance, const SimpleArray* other) { - furi_assert(instance); - furi_assert(other); + furi_check(instance); + furi_check(other); // Equal if the same object if(instance == other) return true; @@ -93,29 +93,31 @@ bool simple_array_is_equal(const SimpleArray* instance, const SimpleArray* other } uint32_t simple_array_get_count(const SimpleArray* instance) { - furi_assert(instance); + furi_check(instance); return instance->count; } SimpleArrayElement* simple_array_get(SimpleArray* instance, uint32_t index) { - furi_assert(instance); - furi_assert(index < instance->count); + furi_check(instance); + furi_check(index < instance->count); return instance->data + index * instance->config->type_size; } const SimpleArrayElement* simple_array_cget(const SimpleArray* instance, uint32_t index) { + furi_check(instance); return simple_array_get((SimpleArrayElement*)instance, index); } SimpleArrayData* simple_array_get_data(SimpleArray* instance) { - furi_assert(instance); - furi_assert(instance->data); + furi_check(instance); + furi_check(instance->data); return instance->data; } const SimpleArrayData* simple_array_cget_data(const SimpleArray* instance) { + furi_check(instance); return simple_array_get_data((SimpleArray*)instance); } diff --git a/lib/toolbox/stream/buffered_file_stream.c b/lib/toolbox/stream/buffered_file_stream.c index 3b485e80d..819e499c1 100644 --- a/lib/toolbox/stream/buffered_file_stream.c +++ b/lib/toolbox/stream/buffered_file_stream.c @@ -58,14 +58,14 @@ bool buffered_file_stream_open( const char* path, FS_AccessMode access_mode, FS_OpenMode open_mode) { - furi_assert(_stream); + furi_check(_stream); BufferedFileStream* stream = (BufferedFileStream*)_stream; furi_check(stream->stream_base.vtable == &buffered_file_stream_vtable); return file_stream_open(stream->file_stream, path, access_mode, open_mode); } bool buffered_file_stream_close(Stream* _stream) { - furi_assert(_stream); + furi_check(_stream); BufferedFileStream* stream = (BufferedFileStream*)_stream; furi_check(stream->stream_base.vtable == &buffered_file_stream_vtable); bool success = false; @@ -80,21 +80,21 @@ bool buffered_file_stream_close(Stream* _stream) { } bool buffered_file_stream_sync(Stream* _stream) { - furi_assert(_stream); + furi_check(_stream); BufferedFileStream* stream = (BufferedFileStream*)_stream; furi_check(stream->stream_base.vtable == &buffered_file_stream_vtable); return stream->sync_pending ? buffered_file_stream_flush(stream) : true; } FS_Error buffered_file_stream_get_error(Stream* _stream) { - furi_assert(_stream); + furi_check(_stream); BufferedFileStream* stream = (BufferedFileStream*)_stream; furi_check(stream->stream_base.vtable == &buffered_file_stream_vtable); return file_stream_get_error(stream->file_stream); } static void buffered_file_stream_free(BufferedFileStream* stream) { - furi_assert(stream); + furi_check(stream); buffered_file_stream_sync((Stream*)stream); stream_free(stream->file_stream); stream_cache_free(stream->cache); diff --git a/lib/toolbox/stream/file_stream.c b/lib/toolbox/stream/file_stream.c index 2b5348b3e..80cbb7d5f 100644 --- a/lib/toolbox/stream/file_stream.c +++ b/lib/toolbox/stream/file_stream.c @@ -35,6 +35,8 @@ const StreamVTable file_stream_vtable = { }; Stream* file_stream_alloc(Storage* storage) { + furi_check(storage); + FileStream* stream = malloc(sizeof(FileStream)); stream->file = storage_file_alloc(storage); stream->storage = storage; @@ -48,21 +50,21 @@ bool file_stream_open( const char* path, FS_AccessMode access_mode, FS_OpenMode open_mode) { - furi_assert(_stream); + furi_check(_stream); FileStream* stream = (FileStream*)_stream; furi_check(stream->stream_base.vtable == &file_stream_vtable); return storage_file_open(stream->file, path, access_mode, open_mode); } bool file_stream_close(Stream* _stream) { - furi_assert(_stream); + furi_check(_stream); FileStream* stream = (FileStream*)_stream; furi_check(stream->stream_base.vtable == &file_stream_vtable); return storage_file_close(stream->file); } FS_Error file_stream_get_error(Stream* _stream) { - furi_assert(_stream); + furi_check(_stream); FileStream* stream = (FileStream*)_stream; furi_check(stream->stream_base.vtable == &file_stream_vtable); return storage_file_get_error(stream->file); diff --git a/lib/toolbox/stream/stream.c b/lib/toolbox/stream/stream.c index 407da0f2c..9aff8bd4f 100644 --- a/lib/toolbox/stream/stream.c +++ b/lib/toolbox/stream/stream.c @@ -7,22 +7,22 @@ #define STREAM_BUFFER_SIZE (32U) void stream_free(Stream* stream) { - furi_assert(stream); + furi_check(stream); stream->vtable->free(stream); } void stream_clean(Stream* stream) { - furi_assert(stream); + furi_check(stream); stream->vtable->clean(stream); } bool stream_eof(Stream* stream) { - furi_assert(stream); + furi_check(stream); return stream->vtable->eof(stream); } bool stream_seek(Stream* stream, int32_t offset, StreamOffset offset_type) { - furi_assert(stream); + furi_check(stream); return stream->vtable->seek(stream, offset, offset_type); } @@ -85,6 +85,8 @@ static bool stream_seek_to_char_backward(Stream* stream, char c) { } bool stream_seek_to_char(Stream* stream, char c, StreamDirection direction) { + furi_check(stream); + const size_t old_position = stream_tell(stream); bool result = false; @@ -103,22 +105,22 @@ bool stream_seek_to_char(Stream* stream, char c, StreamDirection direction) { } size_t stream_tell(Stream* stream) { - furi_assert(stream); + furi_check(stream); return stream->vtable->tell(stream); } size_t stream_size(Stream* stream) { - furi_assert(stream); + furi_check(stream); return stream->vtable->size(stream); } size_t stream_write(Stream* stream, const uint8_t* data, size_t size) { - furi_assert(stream); + furi_check(stream); return stream->vtable->write(stream, data, size); } size_t stream_read(Stream* stream, uint8_t* data, size_t size) { - furi_assert(stream); + furi_check(stream); return stream->vtable->read(stream, data, size); } @@ -127,7 +129,7 @@ bool stream_delete_and_insert( size_t delete_size, StreamWriteCB write_callback, const void* ctx) { - furi_assert(stream); + furi_check(stream); return stream->vtable->delete_and_insert(stream, delete_size, write_callback, ctx); } @@ -139,13 +141,16 @@ typedef struct { } StreamWriteData; static bool stream_write_struct(Stream* stream, const void* context) { - furi_assert(stream); - furi_assert(context); + furi_check(stream); + furi_check(context); const StreamWriteData* write_data = context; return (stream_write(stream, write_data->data, write_data->size) == write_data->size); } bool stream_read_line(Stream* stream, FuriString* str_result) { + furi_check(stream); + furi_check(str_result); + furi_string_reset(str_result); uint8_t buffer[STREAM_BUFFER_SIZE]; @@ -180,28 +185,28 @@ bool stream_read_line(Stream* stream, FuriString* str_result) { } bool stream_rewind(Stream* stream) { - furi_assert(stream); + furi_check(stream); return stream_seek(stream, 0, StreamOffsetFromStart); } size_t stream_write_char(Stream* stream, char c) { - furi_assert(stream); + furi_check(stream); return stream_write(stream, (const uint8_t*)&c, 1); } size_t stream_write_string(Stream* stream, FuriString* string) { - furi_assert(stream); + furi_check(stream); return stream_write( stream, (const uint8_t*)furi_string_get_cstr(string), furi_string_size(string)); } size_t stream_write_cstring(Stream* stream, const char* string) { - furi_assert(stream); + furi_check(stream); return stream_write(stream, (const uint8_t*)string, strlen(string)); } size_t stream_write_format(Stream* stream, const char* format, ...) { - furi_assert(stream); + furi_check(stream); size_t size; va_list args; va_start(args, format); @@ -211,7 +216,7 @@ size_t stream_write_format(Stream* stream, const char* format, ...) { } size_t stream_write_vaformat(Stream* stream, const char* format, va_list args) { - furi_assert(stream); + furi_check(stream); FuriString* data; data = furi_string_alloc_vprintf(format, args); size_t size = stream_write_string(stream, data); @@ -221,28 +226,28 @@ size_t stream_write_vaformat(Stream* stream, const char* format, va_list args) { } bool stream_insert(Stream* stream, const uint8_t* data, size_t size) { - furi_assert(stream); + furi_check(stream); StreamWriteData write_data = {.data = data, .size = size}; return stream_delete_and_insert(stream, 0, stream_write_struct, &write_data); } bool stream_insert_char(Stream* stream, char c) { - furi_assert(stream); + furi_check(stream); return stream_delete_and_insert_char(stream, 0, c); } bool stream_insert_string(Stream* stream, FuriString* string) { - furi_assert(stream); + furi_check(stream); return stream_delete_and_insert_string(stream, 0, string); } bool stream_insert_cstring(Stream* stream, const char* string) { - furi_assert(stream); + furi_check(stream); return stream_delete_and_insert_cstring(stream, 0, string); } bool stream_insert_format(Stream* stream, const char* format, ...) { - furi_assert(stream); + furi_check(stream); va_list args; va_start(args, format); bool result = stream_insert_vaformat(stream, format, args); @@ -252,31 +257,31 @@ bool stream_insert_format(Stream* stream, const char* format, ...) { } bool stream_insert_vaformat(Stream* stream, const char* format, va_list args) { - furi_assert(stream); + furi_check(stream); return stream_delete_and_insert_vaformat(stream, 0, format, args); } bool stream_delete_and_insert_char(Stream* stream, size_t delete_size, char c) { - furi_assert(stream); + furi_check(stream); StreamWriteData write_data = {.data = (uint8_t*)&c, .size = 1}; return stream_delete_and_insert(stream, delete_size, stream_write_struct, &write_data); } bool stream_delete_and_insert_string(Stream* stream, size_t delete_size, FuriString* string) { - furi_assert(stream); + furi_check(stream); StreamWriteData write_data = { .data = (uint8_t*)furi_string_get_cstr(string), .size = furi_string_size(string)}; return stream_delete_and_insert(stream, delete_size, stream_write_struct, &write_data); } bool stream_delete_and_insert_cstring(Stream* stream, size_t delete_size, const char* string) { - furi_assert(stream); + furi_check(stream); StreamWriteData write_data = {.data = (uint8_t*)string, .size = strlen(string)}; return stream_delete_and_insert(stream, delete_size, stream_write_struct, &write_data); } bool stream_delete_and_insert_format(Stream* stream, size_t delete_size, const char* format, ...) { - furi_assert(stream); + furi_check(stream); va_list args; va_start(args, format); bool result = stream_delete_and_insert_vaformat(stream, delete_size, format, args); @@ -290,9 +295,9 @@ bool stream_delete_and_insert_vaformat( size_t delete_size, const char* format, va_list args) { - furi_assert(stream); - FuriString* data; - data = furi_string_alloc_vprintf(format, args); + furi_check(stream); + + FuriString* data = furi_string_alloc_vprintf(format, args); StreamWriteData write_data = { .data = (uint8_t*)furi_string_get_cstr(data), .size = furi_string_size(data)}; bool result = stream_delete_and_insert(stream, delete_size, stream_write_struct, &write_data); @@ -302,11 +307,14 @@ bool stream_delete_and_insert_vaformat( } bool stream_delete(Stream* stream, size_t size) { - furi_assert(stream); + furi_check(stream); return stream_delete_and_insert(stream, size, NULL, NULL); } size_t stream_copy(Stream* stream_from, Stream* stream_to, size_t size) { + furi_check(stream_from); + furi_check(stream_to); + uint8_t* buffer = malloc(STREAM_CACHE_SIZE); size_t copied = 0; @@ -330,6 +338,9 @@ size_t stream_copy(Stream* stream_from, Stream* stream_to, size_t size) { } size_t stream_copy_full(Stream* stream_from, Stream* stream_to) { + furi_check(stream_from); + furi_check(stream_to); + size_t was_written = 0; do { @@ -342,6 +353,8 @@ size_t stream_copy_full(Stream* stream_from, Stream* stream_to) { } bool stream_split(Stream* stream, Stream* stream_left, Stream* stream_right) { + furi_check(stream); + bool result = false; size_t size = stream_size(stream); size_t tell = stream_tell(stream); @@ -363,6 +376,9 @@ bool stream_split(Stream* stream, Stream* stream_left, Stream* stream_right) { } size_t stream_load_from_file(Stream* stream, Storage* storage, const char* path) { + furi_check(stream); + furi_check(storage); + size_t was_written = 0; Stream* file = file_stream_alloc(storage); @@ -376,6 +392,9 @@ size_t stream_load_from_file(Stream* stream, Storage* storage, const char* path) } size_t stream_save_to_file(Stream* stream, Storage* storage, const char* path, FS_OpenMode mode) { + furi_check(stream); + furi_check(storage); + size_t was_written = 0; Stream* file = file_stream_alloc(storage); @@ -389,6 +408,8 @@ size_t stream_save_to_file(Stream* stream, Storage* storage, const char* path, F } void stream_dump_data(Stream* stream) { + furi_check(stream); + size_t size = stream_size(stream); size_t tell = stream_tell(stream); printf("stream %p\r\n", stream); diff --git a/lib/toolbox/stream/stream_cache.c b/lib/toolbox/stream/stream_cache.c index f5e147dfe..d38a2f7b7 100644 --- a/lib/toolbox/stream/stream_cache.c +++ b/lib/toolbox/stream/stream_cache.c @@ -8,7 +8,7 @@ struct StreamCache { size_t position; }; -StreamCache* stream_cache_alloc() { +StreamCache* stream_cache_alloc(void) { StreamCache* cache = malloc(sizeof(StreamCache)); cache->data_size = 0; cache->position = 0; diff --git a/lib/toolbox/stream/stream_cache.h b/lib/toolbox/stream/stream_cache.h index f61e5e8f2..b00538ae3 100644 --- a/lib/toolbox/stream/stream_cache.h +++ b/lib/toolbox/stream/stream_cache.h @@ -12,7 +12,7 @@ typedef struct StreamCache StreamCache; * Allocate stream cache. * @return StreamCache* pointer to a StreamCache instance */ -StreamCache* stream_cache_alloc(); +StreamCache* stream_cache_alloc(void); /** * Free stream cache. diff --git a/lib/toolbox/stream/string_stream.c b/lib/toolbox/stream/string_stream.c index f8a360c03..742547fb7 100644 --- a/lib/toolbox/stream/string_stream.c +++ b/lib/toolbox/stream/string_stream.c @@ -37,7 +37,7 @@ const StreamVTable string_stream_vtable = { .delete_and_insert = (StreamDeleteAndInsertFn)string_stream_delete_and_insert, }; -Stream* string_stream_alloc() { +Stream* string_stream_alloc(void) { StringStream* stream = malloc(sizeof(StringStream)); stream->string = furi_string_alloc(); stream->index = 0; diff --git a/lib/toolbox/stream/string_stream.h b/lib/toolbox/stream/string_stream.h index f882a246b..279f053f2 100644 --- a/lib/toolbox/stream/string_stream.h +++ b/lib/toolbox/stream/string_stream.h @@ -10,7 +10,7 @@ extern "C" { * Allocate string stream * @return Stream* */ -Stream* string_stream_alloc(); +Stream* string_stream_alloc(void); #ifdef __cplusplus } diff --git a/lib/toolbox/tar/tar_archive.c b/lib/toolbox/tar/tar_archive.c index fcfc22a70..639f2eaec 100644 --- a/lib/toolbox/tar/tar_archive.c +++ b/lib/toolbox/tar/tar_archive.c @@ -59,7 +59,7 @@ TarArchive* tar_archive_alloc(Storage* storage) { } bool tar_archive_open(TarArchive* archive, const char* path, TarOpenMode mode) { - furi_assert(archive); + furi_check(archive); FS_AccessMode access_mode; FS_OpenMode open_mode; int mtar_access = 0; @@ -90,7 +90,7 @@ bool tar_archive_open(TarArchive* archive, const char* path, TarOpenMode mode) { } void tar_archive_free(TarArchive* archive) { - furi_assert(archive); + furi_check(archive); if(mtar_is_open(&archive->tar)) { mtar_close(&archive->tar); } @@ -98,7 +98,7 @@ void tar_archive_free(TarArchive* archive) { } void tar_archive_set_file_callback(TarArchive* archive, tar_unpack_file_cb callback, void* context) { - furi_assert(archive); + furi_check(archive); archive->unpack_cb = callback; archive->unpack_cb_context = context; } @@ -113,6 +113,7 @@ static int tar_archive_entry_counter(mtar_t* tar, const mtar_header_t* header, v } int32_t tar_archive_get_entries_count(TarArchive* archive) { + furi_check(archive); int32_t counter = 0; if(mtar_foreach(&archive->tar, tar_archive_entry_counter, &counter) != MTAR_ESUCCESS) { counter = -1; @@ -121,12 +122,12 @@ int32_t tar_archive_get_entries_count(TarArchive* archive) { } bool tar_archive_dir_add_element(TarArchive* archive, const char* dirpath) { - furi_assert(archive); + furi_check(archive); return (mtar_write_dir_header(&archive->tar, dirpath) == MTAR_ESUCCESS); } bool tar_archive_finalize(TarArchive* archive) { - furi_assert(archive); + furi_check(archive); return (mtar_finalize(&archive->tar) == MTAR_ESUCCESS); } @@ -135,7 +136,7 @@ bool tar_archive_store_data( const char* path, const uint8_t* data, const int32_t data_len) { - furi_assert(archive); + furi_check(archive); return ( tar_archive_file_add_header(archive, path, data_len) && @@ -144,7 +145,7 @@ bool tar_archive_store_data( } bool tar_archive_file_add_header(TarArchive* archive, const char* path, const int32_t data_len) { - furi_assert(archive); + furi_check(archive); return (mtar_write_file_header(&archive->tar, path, data_len) == MTAR_ESUCCESS); } @@ -153,13 +154,13 @@ bool tar_archive_file_add_data_block( TarArchive* archive, const uint8_t* data_block, const int32_t block_len) { - furi_assert(archive); + furi_check(archive); return (mtar_write_data(&archive->tar, data_block, block_len) == block_len); } bool tar_archive_file_finalize(TarArchive* archive) { - furi_assert(archive); + furi_check(archive); return (mtar_end_data(&archive->tar) == MTAR_ESUCCESS); } @@ -259,7 +260,7 @@ bool tar_archive_unpack_to( TarArchive* archive, const char* destination, Storage_name_converter converter) { - furi_assert(archive); + furi_check(archive); TarArchiveDirectoryOpParams param = { .archive = archive, .work_dir = destination, @@ -276,7 +277,7 @@ bool tar_archive_add_file( const char* fs_file_path, const char* archive_fname, const int32_t file_size) { - furi_assert(archive); + furi_check(archive); uint8_t* file_buffer = malloc(FILE_BLOCK_SIZE); bool success = false; File* src_file = storage_file_alloc(archive->storage); @@ -314,8 +315,9 @@ bool tar_archive_add_file( } bool tar_archive_add_dir(TarArchive* archive, const char* fs_full_path, const char* path_prefix) { - furi_assert(archive); + furi_check(archive); furi_check(path_prefix); + File* directory = storage_file_alloc(archive->storage); FileInfo file_info; @@ -376,9 +378,9 @@ bool tar_archive_unpack_file( TarArchive* archive, const char* archive_fname, const char* destination) { - furi_assert(archive); - furi_assert(archive_fname); - furi_assert(destination); + furi_check(archive); + furi_check(archive_fname); + furi_check(destination); if(mtar_find(&archive->tar, archive_fname) != MTAR_ESUCCESS) { return false; } diff --git a/lib/update_util/update_manifest.c b/lib/update_util/update_manifest.c index 42ab073b0..eef27cb42 100644 --- a/lib/update_util/update_manifest.c +++ b/lib/update_util/update_manifest.c @@ -19,7 +19,7 @@ #define MANIFEST_KEY_OB_WRITE_MASK "OB write mask" #define MANIFEST_KEY_SPLASH_FILE "Splashscreen" -UpdateManifest* update_manifest_alloc() { +UpdateManifest* update_manifest_alloc(void) { UpdateManifest* update_manifest = malloc(sizeof(UpdateManifest)); update_manifest->version = furi_string_alloc(); update_manifest->firmware_dfu_image = furi_string_alloc(); diff --git a/lib/update_util/update_manifest.h b/lib/update_util/update_manifest.h index c26e4f87b..0c6284516 100644 --- a/lib/update_util/update_manifest.h +++ b/lib/update_util/update_manifest.h @@ -45,7 +45,7 @@ typedef struct { bool valid; } UpdateManifest; -UpdateManifest* update_manifest_alloc(); +UpdateManifest* update_manifest_alloc(void); void update_manifest_free(UpdateManifest* update_manifest); diff --git a/lib/update_util/update_operation.c b/lib/update_util/update_operation.c index 39a7ea075..cb603abe0 100644 --- a/lib/update_util/update_operation.c +++ b/lib/update_util/update_operation.c @@ -218,7 +218,7 @@ UpdatePrepareResult update_operation_prepare(const char* manifest_file_path) { return result; } -bool update_operation_is_armed() { +bool update_operation_is_armed(void) { FuriHalRtcBootMode boot_mode = furi_hal_rtc_get_boot_mode(); const uint32_t rtc_upd_index = furi_hal_rtc_get_register(FuriHalRtcRegisterUpdateFolderFSIndex); @@ -231,7 +231,7 @@ bool update_operation_is_armed() { ((rtc_upd_index != INT_MAX) || upd_fn_ptr_exists); } -void update_operation_disarm() { +void update_operation_disarm(void) { furi_hal_rtc_set_boot_mode(FuriHalRtcBootModeNormal); furi_hal_rtc_set_register(FuriHalRtcRegisterUpdateFolderFSIndex, INT_MAX); Storage* storage = furi_record_open(RECORD_STORAGE); diff --git a/lib/update_util/update_operation.h b/lib/update_util/update_operation.h index 8e36b5a13..063f577e2 100644 --- a/lib/update_util/update_operation.h +++ b/lib/update_util/update_operation.h @@ -56,12 +56,12 @@ bool update_operation_get_current_package_manifest_path(Storage* storage, FuriSt /* * Checks if an update operation step is pending after reset */ -bool update_operation_is_armed(); +bool update_operation_is_armed(void); /* * Cancels pending update operation */ -void update_operation_disarm(); +void update_operation_disarm(void); #ifdef __cplusplus } diff --git a/targets/f18/api_symbols.csv b/targets/f18/api_symbols.csv index e11c85759..a23034ad4 100644 --- a/targets/f18/api_symbols.csv +++ b/targets/f18/api_symbols.csv @@ -1,5 +1,5 @@ entry,status,name,type,params -Version,+,58.1,, +Version,+,59.0,, Header,+,applications/services/bt/bt_service/bt.h,, Header,+,applications/services/cli/cli.h,, Header,+,applications/services/cli/cli_vcp.h,, @@ -756,7 +756,7 @@ Function,+,cli_cmd_interrupt_received,_Bool,Cli* Function,+,cli_delete_command,void,"Cli*, const char*" Function,+,cli_getc,char,Cli* Function,+,cli_is_connected,_Bool,Cli* -Function,+,cli_nl,void, +Function,+,cli_nl,void,Cli* Function,+,cli_print_usage,void,"const char*, const char*, const char*" Function,+,cli_read,size_t,"Cli*, uint8_t*, size_t" Function,+,cli_read_timeout,size_t,"Cli*, uint8_t*, size_t, uint32_t" diff --git a/targets/f18/furi_hal/furi_hal.c b/targets/f18/furi_hal/furi_hal.c index 957d9d673..6e0a254c1 100644 --- a/targets/f18/furi_hal/furi_hal.c +++ b/targets/f18/furi_hal/furi_hal.c @@ -6,7 +6,7 @@ #define TAG "FuriHal" -void furi_hal_init_early() { +void furi_hal_init_early(void) { furi_hal_cortex_init_early(); furi_hal_clock_init_early(); furi_hal_bus_init_early(); @@ -19,7 +19,7 @@ void furi_hal_init_early() { furi_hal_rtc_init_early(); } -void furi_hal_deinit_early() { +void furi_hal_deinit_early(void) { furi_hal_rtc_deinit_early(); furi_hal_i2c_deinit_early(); furi_hal_spi_config_deinit_early(); @@ -29,7 +29,7 @@ void furi_hal_deinit_early() { furi_hal_clock_deinit_early(); } -void furi_hal_init() { +void furi_hal_init(void) { furi_hal_mpu_init(); furi_hal_clock_init(); furi_hal_random_init(); diff --git a/targets/f18/furi_hal/furi_hal_resources.c b/targets/f18/furi_hal/furi_hal_resources.c index 118935874..9935d4124 100644 --- a/targets/f18/furi_hal/furi_hal_resources.c +++ b/targets/f18/furi_hal/furi_hal_resources.c @@ -144,7 +144,7 @@ static void furi_hal_resources_init_gpio_pins(GpioMode mode) { } } -void furi_hal_resources_init_early() { +void furi_hal_resources_init_early(void) { furi_hal_bus_enable(FuriHalBusGPIOA); furi_hal_bus_enable(FuriHalBusGPIOB); furi_hal_bus_enable(FuriHalBusGPIOC); @@ -190,7 +190,7 @@ void furi_hal_resources_init_early() { furi_hal_resources_init_gpio_pins(GpioModeAnalog); } -void furi_hal_resources_deinit_early() { +void furi_hal_resources_deinit_early(void) { furi_hal_resources_init_input_pins(GpioModeAnalog); furi_hal_bus_disable(FuriHalBusGPIOA); furi_hal_bus_disable(FuriHalBusGPIOB); @@ -200,7 +200,7 @@ void furi_hal_resources_deinit_early() { furi_hal_bus_disable(FuriHalBusGPIOH); } -void furi_hal_resources_init() { +void furi_hal_resources_init(void) { // Button pins furi_hal_resources_init_input_pins(GpioModeInterruptRiseFall); diff --git a/targets/f18/furi_hal/furi_hal_resources.h b/targets/f18/furi_hal/furi_hal_resources.h index fed7802a5..3d45ad885 100644 --- a/targets/f18/furi_hal/furi_hal_resources.h +++ b/targets/f18/furi_hal/furi_hal_resources.h @@ -109,11 +109,11 @@ extern const GpioPin gpio_periph_power; extern const GpioPin gpio_usb_dm; extern const GpioPin gpio_usb_dp; -void furi_hal_resources_init_early(); +void furi_hal_resources_init_early(void); -void furi_hal_resources_deinit_early(); +void furi_hal_resources_deinit_early(void); -void furi_hal_resources_init(); +void furi_hal_resources_init(void); /** * Get a corresponding external connector pin number for a gpio diff --git a/targets/f18/furi_hal/furi_hal_spi_config.c b/targets/f18/furi_hal/furi_hal_spi_config.c index 5ac84906f..8957bfe3a 100644 --- a/targets/f18/furi_hal/furi_hal_spi_config.c +++ b/targets/f18/furi_hal/furi_hal_spi_config.c @@ -77,17 +77,17 @@ const LL_SPI_InitTypeDef furi_hal_spi_preset_1edge_low_2m = { FuriMutex* furi_hal_spi_bus_r_mutex = NULL; -void furi_hal_spi_config_init_early() { +void furi_hal_spi_config_init_early(void) { furi_hal_spi_bus_init(&furi_hal_spi_bus_d); furi_hal_spi_bus_handle_init(&furi_hal_spi_bus_handle_display); } -void furi_hal_spi_config_deinit_early() { +void furi_hal_spi_config_deinit_early(void) { furi_hal_spi_bus_handle_deinit(&furi_hal_spi_bus_handle_display); furi_hal_spi_bus_deinit(&furi_hal_spi_bus_d); } -void furi_hal_spi_config_init() { +void furi_hal_spi_config_init(void) { furi_hal_spi_bus_handle_init(&furi_hal_spi_bus_handle_sd_fast); furi_hal_spi_bus_handle_init(&furi_hal_spi_bus_handle_sd_slow); diff --git a/targets/f18/furi_hal/furi_hal_version_device.c b/targets/f18/furi_hal/furi_hal_version_device.c index 198ceb3f1..8b8526031 100644 --- a/targets/f18/furi_hal/furi_hal_version_device.c +++ b/targets/f18/furi_hal/furi_hal_version_device.c @@ -1,33 +1,33 @@ #include -bool furi_hal_version_do_i_belong_here() { +bool furi_hal_version_do_i_belong_here(void) { return (furi_hal_version_get_hw_target() == 18) || (furi_hal_version_get_hw_target() == 0); } -const char* furi_hal_version_get_model_name() { +const char* furi_hal_version_get_model_name(void) { return "Flipper Nano"; } -const char* furi_hal_version_get_model_code() { +const char* furi_hal_version_get_model_code(void) { return "FN.1"; } -const char* furi_hal_version_get_fcc_id() { +const char* furi_hal_version_get_fcc_id(void) { return "Pending"; } -const char* furi_hal_version_get_ic_id() { +const char* furi_hal_version_get_ic_id(void) { return "Pending"; } -const char* furi_hal_version_get_mic_id() { +const char* furi_hal_version_get_mic_id(void) { return "Pending"; } -const char* furi_hal_version_get_srrc_id() { +const char* furi_hal_version_get_srrc_id(void) { return "Pending"; } -const char* furi_hal_version_get_ncc_id() { +const char* furi_hal_version_get_ncc_id(void) { return "Pending"; } \ No newline at end of file diff --git a/targets/f7/api_symbols.csv b/targets/f7/api_symbols.csv index 3d9160c9c..883cfef79 100644 --- a/targets/f7/api_symbols.csv +++ b/targets/f7/api_symbols.csv @@ -1,5 +1,5 @@ entry,status,name,type,params -Version,+,58.1,, +Version,+,59.0,, Header,+,applications/drivers/subghz/cc1101_ext/cc1101_ext_interconnect.h,, Header,+,applications/services/bt/bt_service/bt.h,, Header,+,applications/services/cli/cli.h,, @@ -834,7 +834,7 @@ Function,+,cli_cmd_interrupt_received,_Bool,Cli* Function,+,cli_delete_command,void,"Cli*, const char*" Function,+,cli_getc,char,Cli* Function,+,cli_is_connected,_Bool,Cli* -Function,+,cli_nl,void, +Function,+,cli_nl,void,Cli* Function,+,cli_print_usage,void,"const char*, const char*, const char*" Function,+,cli_read,size_t,"Cli*, uint8_t*, size_t" Function,+,cli_read_timeout,size_t,"Cli*, uint8_t*, size_t, uint32_t" diff --git a/targets/f7/ble_glue/app_debug.c b/targets/f7/ble_glue/app_debug.c index fe76687b9..eab17e5b7 100644 --- a/targets/f7/ble_glue/app_debug.c +++ b/targets/f7/ble_glue/app_debug.c @@ -110,7 +110,7 @@ static const APPD_GpioConfig_t aRfConfigList[GPIO_NBR_OF_RF_SIGNALS] = { static void APPD_SetCPU2GpioConfig(void); static void APPD_BleDtbCfg(void); -void APPD_Init() { +void APPD_Init(void) { APPD_SetCPU2GpioConfig(); APPD_BleDtbCfg(); } diff --git a/targets/f7/ble_glue/ble_glue.c b/targets/f7/ble_glue/ble_glue.c index 9d5a1e3f9..ecc2f83c5 100644 --- a/targets/f7/ble_glue/ble_glue.c +++ b/targets/f7/ble_glue/ble_glue.c @@ -54,8 +54,8 @@ static void ble_glue_clear_shared_memory(); void ble_glue_set_key_storage_changed_callback( BleGlueKeyStorageChangedCallback callback, void* context) { - furi_assert(ble_glue); - furi_assert(callback); + furi_check(ble_glue); + furi_check(callback); ble_glue->callback = callback; ble_glue->context = context; } diff --git a/targets/f7/ble_glue/ble_glue.h b/targets/f7/ble_glue/ble_glue.h index 05c34148c..94821cc88 100644 --- a/targets/f7/ble_glue/ble_glue.h +++ b/targets/f7/ble_glue/ble_glue.h @@ -100,7 +100,7 @@ void ble_glue_set_key_storage_changed_callback( BleGlueKeyStorageChangedCallback callback, void* context); -bool ble_glue_reinit_c2(); +bool ble_glue_reinit_c2(void); typedef enum { BleGlueCommandResultUnknown, diff --git a/targets/f7/ble_glue/extra_beacon.c b/targets/f7/ble_glue/extra_beacon.c index 446b31380..2ef3e056f 100644 --- a/targets/f7/ble_glue/extra_beacon.c +++ b/targets/f7/ble_glue/extra_beacon.c @@ -21,7 +21,7 @@ typedef struct { static ExtraBeacon extra_beacon = {0}; -void gap_extra_beacon_init() { +void gap_extra_beacon_init(void) { if(extra_beacon.state_mutex) { // Already initialized - restore state if needed FURI_LOG_I(TAG, "Restoring state"); @@ -62,7 +62,7 @@ bool gap_extra_beacon_set_config(const GapExtraBeaconConfig* config) { return true; } -bool gap_extra_beacon_start() { +bool gap_extra_beacon_start(void) { furi_check(extra_beacon.state_mutex); furi_check(extra_beacon.last_config.min_adv_interval_ms >= GAP_MIN_ADV_INTERVAL_MS); @@ -91,7 +91,7 @@ bool gap_extra_beacon_start() { return true; } -bool gap_extra_beacon_stop() { +bool gap_extra_beacon_stop(void) { furi_check(extra_beacon.state_mutex); if(extra_beacon.extra_beacon_state != GapExtraBeaconStateStarted) { @@ -144,13 +144,13 @@ uint8_t gap_extra_beacon_get_data(uint8_t* data) { return extra_beacon.extra_beacon_data_len; } -GapExtraBeaconState gap_extra_beacon_get_state() { +GapExtraBeaconState gap_extra_beacon_get_state(void) { furi_check(extra_beacon.state_mutex); return extra_beacon.extra_beacon_state; } -const GapExtraBeaconConfig* gap_extra_beacon_get_config() { +const GapExtraBeaconConfig* gap_extra_beacon_get_config(void) { furi_check(extra_beacon.state_mutex); if(extra_beacon.last_config.min_adv_interval_ms < GAP_MIN_ADV_INTERVAL_MS) { diff --git a/targets/f7/ble_glue/extra_beacon.h b/targets/f7/ble_glue/extra_beacon.h index 675ea538c..d011bbeb8 100644 --- a/targets/f7/ble_glue/extra_beacon.h +++ b/targets/f7/ble_glue/extra_beacon.h @@ -76,17 +76,17 @@ typedef enum { GapExtraBeaconStateStarted, } GapExtraBeaconState; -void gap_extra_beacon_init(); +void gap_extra_beacon_init(void); -GapExtraBeaconState gap_extra_beacon_get_state(); +GapExtraBeaconState gap_extra_beacon_get_state(void); -bool gap_extra_beacon_start(); +bool gap_extra_beacon_start(void); -bool gap_extra_beacon_stop(); +bool gap_extra_beacon_stop(void); bool gap_extra_beacon_set_config(const GapExtraBeaconConfig* config); -const GapExtraBeaconConfig* gap_extra_beacon_get_config(); +const GapExtraBeaconConfig* gap_extra_beacon_get_config(void); bool gap_extra_beacon_set_data(const uint8_t* data, uint8_t length); diff --git a/targets/f7/ble_glue/furi_ble/gatt.c b/targets/f7/ble_glue/furi_ble/gatt.c index bbcf86b0e..e40786583 100644 --- a/targets/f7/ble_glue/furi_ble/gatt.c +++ b/targets/f7/ble_glue/furi_ble/gatt.c @@ -11,8 +11,8 @@ void ble_gatt_characteristic_init( uint16_t svc_handle, const BleGattCharacteristicParams* char_descriptor, BleGattCharacteristicInstance* char_instance) { - furi_assert(char_descriptor); - furi_assert(char_instance); + furi_check(char_descriptor); + furi_check(char_instance); // Copy the descriptor to the instance, since it may point to stack memory char_instance->characteristic = malloc(sizeof(BleGattCharacteristicParams)); diff --git a/targets/f7/ble_glue/hw_ipcc.c b/targets/f7/ble_glue/hw_ipcc.c index c2397f351..6a3aace5a 100644 --- a/targets/f7/ble_glue/hw_ipcc.c +++ b/targets/f7/ble_glue/hw_ipcc.c @@ -24,7 +24,7 @@ static void HW_IPCC_SYS_CmdEvtHandler(); static void HW_IPCC_SYS_EvtHandler(); static void HW_IPCC_TRACES_EvtHandler(); -void HW_IPCC_Rx_Handler() { +void HW_IPCC_Rx_Handler(void) { if(HW_IPCC_RX_PENDING(HW_IPCC_SYSTEM_EVENT_CHANNEL)) { HW_IPCC_SYS_EvtHandler(); } else if(HW_IPCC_RX_PENDING(HW_IPCC_BLE_EVENT_CHANNEL)) { @@ -34,7 +34,7 @@ void HW_IPCC_Rx_Handler() { } } -void HW_IPCC_Tx_Handler() { +void HW_IPCC_Tx_Handler(void) { if(HW_IPCC_TX_PENDING(HW_IPCC_SYSTEM_CMD_RSP_CHANNEL)) { HW_IPCC_SYS_CmdEvtHandler(); } else if(HW_IPCC_TX_PENDING(HW_IPCC_SYSTEM_CMD_RSP_CHANNEL)) { @@ -46,7 +46,7 @@ void HW_IPCC_Tx_Handler() { } } -void HW_IPCC_Enable() { +void HW_IPCC_Enable(void) { /** * Such as IPCC IP available to the CPU2, it is required to keep the IPCC clock running when FUS is running on CPU2 and CPU1 enters deep sleep mode @@ -71,7 +71,7 @@ void HW_IPCC_Enable() { LL_PWR_EnableBootC2(); } -void HW_IPCC_Init() { +void HW_IPCC_Init(void) { LL_C1_IPCC_EnableIT_RXO(IPCC); LL_C1_IPCC_EnableIT_TXF(IPCC); @@ -81,36 +81,36 @@ void HW_IPCC_Init() { NVIC_EnableIRQ(IPCC_C1_TX_IRQn); } -void HW_IPCC_BLE_Init() { +void HW_IPCC_BLE_Init(void) { LL_C1_IPCC_EnableReceiveChannel(IPCC, HW_IPCC_BLE_EVENT_CHANNEL); } -void HW_IPCC_BLE_SendCmd() { +void HW_IPCC_BLE_SendCmd(void) { LL_C1_IPCC_SetFlag_CHx(IPCC, HW_IPCC_BLE_CMD_CHANNEL); } -static void HW_IPCC_BLE_EvtHandler() { +static void HW_IPCC_BLE_EvtHandler(void) { HW_IPCC_BLE_RxEvtNot(); LL_C1_IPCC_ClearFlag_CHx(IPCC, HW_IPCC_BLE_EVENT_CHANNEL); } -void HW_IPCC_BLE_SendAclData() { +void HW_IPCC_BLE_SendAclData(void) { LL_C1_IPCC_SetFlag_CHx(IPCC, HW_IPCC_HCI_ACL_DATA_CHANNEL); LL_C1_IPCC_EnableTransmitChannel(IPCC, HW_IPCC_HCI_ACL_DATA_CHANNEL); } -static void HW_IPCC_BLE_AclDataEvtHandler() { +static void HW_IPCC_BLE_AclDataEvtHandler(void) { LL_C1_IPCC_DisableTransmitChannel(IPCC, HW_IPCC_HCI_ACL_DATA_CHANNEL); HW_IPCC_BLE_AclDataAckNot(); } -void HW_IPCC_SYS_Init() { +void HW_IPCC_SYS_Init(void) { LL_C1_IPCC_EnableReceiveChannel(IPCC, HW_IPCC_SYSTEM_EVENT_CHANNEL); } -void HW_IPCC_SYS_SendCmd() { +void HW_IPCC_SYS_SendCmd(void) { LL_C1_IPCC_SetFlag_CHx(IPCC, HW_IPCC_SYSTEM_CMD_RSP_CHANNEL); FuriHalCortexTimer timer = furi_hal_cortex_timer_get(33000000); @@ -122,13 +122,13 @@ void HW_IPCC_SYS_SendCmd() { HW_IPCC_SYS_CmdEvtHandler(); } -static void HW_IPCC_SYS_CmdEvtHandler() { +static void HW_IPCC_SYS_CmdEvtHandler(void) { LL_C1_IPCC_DisableTransmitChannel(IPCC, HW_IPCC_SYSTEM_CMD_RSP_CHANNEL); HW_IPCC_SYS_CmdEvtNot(); } -static void HW_IPCC_SYS_EvtHandler() { +static void HW_IPCC_SYS_EvtHandler(void) { HW_IPCC_SYS_EvtNot(); LL_C1_IPCC_ClearFlag_CHx(IPCC, HW_IPCC_SYSTEM_EVENT_CHANNEL); @@ -145,7 +145,7 @@ void HW_IPCC_MM_SendFreeBuf(void (*cb)()) { } } -static void HW_IPCC_MM_FreeBufHandler() { +static void HW_IPCC_MM_FreeBufHandler(void) { LL_C1_IPCC_DisableTransmitChannel(IPCC, HW_IPCC_MM_RELEASE_BUFFER_CHANNEL); FreeBufCb(); @@ -153,11 +153,11 @@ static void HW_IPCC_MM_FreeBufHandler() { LL_C1_IPCC_SetFlag_CHx(IPCC, HW_IPCC_MM_RELEASE_BUFFER_CHANNEL); } -void HW_IPCC_TRACES_Init() { +void HW_IPCC_TRACES_Init(void) { LL_C1_IPCC_EnableReceiveChannel(IPCC, HW_IPCC_TRACES_CHANNEL); } -static void HW_IPCC_TRACES_EvtHandler() { +static void HW_IPCC_TRACES_EvtHandler(void) { HW_IPCC_TRACES_EvtNot(); LL_C1_IPCC_ClearFlag_CHx(IPCC, HW_IPCC_TRACES_CHANNEL); diff --git a/targets/f7/ble_glue/services/battery_service.c b/targets/f7/ble_glue/services/battery_service.c index f4bc1ff7b..4250b356c 100644 --- a/targets/f7/ble_glue/services/battery_service.c +++ b/targets/f7/ble_glue/services/battery_service.c @@ -114,7 +114,7 @@ BleServiceBattery* ble_svc_battery_start(bool auto_update) { } void ble_svc_battery_stop(BleServiceBattery* battery_svc) { - furi_assert(battery_svc); + furi_check(battery_svc); if(battery_svc->auto_update) { BatterySvcInstanceList_it_t it; for(BatterySvcInstanceList_it(it, instances); !BatterySvcInstanceList_end_p(it); diff --git a/targets/f7/ble_glue/services/dev_info_service.c b/targets/f7/ble_glue/services/dev_info_service.c index 5f0603922..0db1f65ee 100644 --- a/targets/f7/ble_glue/services/dev_info_service.c +++ b/targets/f7/ble_glue/services/dev_info_service.c @@ -137,7 +137,7 @@ BleServiceDevInfo* ble_svc_dev_info_start(void) { } void ble_svc_dev_info_stop(BleServiceDevInfo* dev_info_svc) { - furi_assert(dev_info_svc); + furi_check(dev_info_svc); /* Delete service characteristics */ for(size_t i = 0; i < DevInfoSvcGattCharacteristicCount; i++) { ble_gatt_characteristic_delete( diff --git a/targets/f7/ble_glue/services/serial_service.c b/targets/f7/ble_glue/services/serial_service.c index a8f10e6d7..6fe6a7130 100644 --- a/targets/f7/ble_glue/services/serial_service.c +++ b/targets/f7/ble_glue/services/serial_service.c @@ -179,7 +179,7 @@ void ble_svc_serial_set_callbacks( uint16_t buff_size, SerialServiceEventCallback callback, void* context) { - furi_assert(serial_svc); + furi_check(serial_svc); serial_svc->callback = callback; serial_svc->context = context; serial_svc->buff_size = buff_size; @@ -193,8 +193,8 @@ void ble_svc_serial_set_callbacks( } void ble_svc_serial_notify_buffer_is_empty(BleServiceSerial* serial_svc) { - furi_assert(serial_svc); - furi_assert(serial_svc->buff_size_mtx); + furi_check(serial_svc); + furi_check(serial_svc->buff_size_mtx); furi_check(furi_mutex_acquire(serial_svc->buff_size_mtx, FuriWaitForever) == FuriStatusOk); if(serial_svc->bytes_ready_to_receive == 0) { @@ -253,7 +253,7 @@ bool ble_svc_serial_update_tx(BleServiceSerial* serial_svc, uint8_t* data, uint1 } void ble_svc_serial_set_rpc_active(BleServiceSerial* serial_svc, bool active) { - furi_assert(serial_svc); + furi_check(serial_svc); ble_svc_serial_update_rpc_char( serial_svc, active ? SerialServiceRpcStatusActive : SerialServiceRpcStatusNotActive); } diff --git a/targets/f7/fatfs/fatfs.c b/targets/f7/fatfs/fatfs.c index 0e17f75c1..fa791f122 100644 --- a/targets/f7/fatfs/fatfs.c +++ b/targets/f7/fatfs/fatfs.c @@ -14,7 +14,7 @@ void fatfs_init(void) { * * @return Time in DWORD (toasters per square washing machine) */ -DWORD get_fattime() { +DWORD get_fattime(void) { DateTime furi_time; furi_hal_rtc_get_datetime(&furi_time); diff --git a/targets/f7/fatfs/sector_cache.c b/targets/f7/fatfs/sector_cache.c index efb520ec8..319dd2173 100644 --- a/targets/f7/fatfs/sector_cache.c +++ b/targets/f7/fatfs/sector_cache.c @@ -17,7 +17,7 @@ typedef struct { static SectorCache* cache = NULL; -void sector_cache_init() { +void sector_cache_init(void) { if(cache == NULL) { cache = memmgr_alloc_from_pool(sizeof(SectorCache)); } diff --git a/targets/f7/fatfs/sector_cache.h b/targets/f7/fatfs/sector_cache.h index 5fe4a2ed8..6792408a3 100644 --- a/targets/f7/fatfs/sector_cache.h +++ b/targets/f7/fatfs/sector_cache.h @@ -8,7 +8,7 @@ extern "C" { /** * @brief Init sector cache system */ -void sector_cache_init(); +void sector_cache_init(void); /** * @brief Get sector data from cache diff --git a/targets/f7/furi_hal/furi_hal.c b/targets/f7/furi_hal/furi_hal.c index 9054f4df5..1b7b827d1 100644 --- a/targets/f7/furi_hal/furi_hal.c +++ b/targets/f7/furi_hal/furi_hal.c @@ -6,7 +6,7 @@ #define TAG "FuriHal" -void furi_hal_init_early() { +void furi_hal_init_early(void) { furi_hal_cortex_init_early(); furi_hal_clock_init_early(); furi_hal_bus_init_early(); @@ -19,7 +19,7 @@ void furi_hal_init_early() { furi_hal_rtc_init_early(); } -void furi_hal_deinit_early() { +void furi_hal_deinit_early(void) { furi_hal_rtc_deinit_early(); furi_hal_i2c_deinit_early(); furi_hal_spi_config_deinit_early(); @@ -29,7 +29,7 @@ void furi_hal_deinit_early() { furi_hal_clock_deinit_early(); } -void furi_hal_init() { +void furi_hal_init(void) { furi_hal_mpu_init(); furi_hal_clock_init(); furi_hal_random_init(); diff --git a/targets/f7/furi_hal/furi_hal_bt.c b/targets/f7/furi_hal/furi_hal_bt.c index 2b1fbf04c..036d50ace 100644 --- a/targets/f7/furi_hal/furi_hal_bt.c +++ b/targets/f7/furi_hal/furi_hal_bt.c @@ -37,7 +37,7 @@ static FuriHalBt furi_hal_bt = { .stack = FuriHalBtStackUnknown, }; -void furi_hal_bt_init() { +void furi_hal_bt_init(void) { FURI_LOG_I(TAG, "Start BT initialization"); furi_hal_bus_enable(FuriHalBusHSEM); furi_hal_bus_enable(FuriHalBusIPCC); @@ -47,7 +47,7 @@ void furi_hal_bt_init() { if(!furi_hal_bt.core2_mtx) { furi_hal_bt.core2_mtx = furi_mutex_alloc(FuriMutexTypeNormal); - furi_assert(furi_hal_bt.core2_mtx); + furi_check(furi_hal_bt.core2_mtx); } // Explicitly tell that we are in charge of CLK48 domain @@ -57,13 +57,13 @@ void furi_hal_bt_init() { ble_glue_init(); } -void furi_hal_bt_lock_core2() { - furi_assert(furi_hal_bt.core2_mtx); +void furi_hal_bt_lock_core2(void) { + furi_check(furi_hal_bt.core2_mtx); furi_check(furi_mutex_acquire(furi_hal_bt.core2_mtx, FuriWaitForever) == FuriStatusOk); } -void furi_hal_bt_unlock_core2() { - furi_assert(furi_hal_bt.core2_mtx); +void furi_hal_bt_unlock_core2(void) { + furi_check(furi_hal_bt.core2_mtx); furi_check(furi_mutex_release(furi_hal_bt.core2_mtx) == FuriStatusOk); } @@ -87,9 +87,9 @@ static bool furi_hal_bt_radio_stack_is_supported(const BleGlueC2Info* info) { return supported; } -bool furi_hal_bt_start_radio_stack() { +bool furi_hal_bt_start_radio_stack(void) { bool res = false; - furi_assert(furi_hal_bt.core2_mtx); + furi_check(furi_hal_bt.core2_mtx); furi_mutex_acquire(furi_hal_bt.core2_mtx, FuriWaitForever); @@ -130,11 +130,11 @@ bool furi_hal_bt_start_radio_stack() { return res; } -FuriHalBtStack furi_hal_bt_get_radio_stack() { +FuriHalBtStack furi_hal_bt_get_radio_stack(void) { return furi_hal_bt.stack; } -bool furi_hal_bt_is_gatt_gap_supported() { +bool furi_hal_bt_is_gatt_gap_supported(void) { if(furi_hal_bt.stack == FuriHalBtStackLight || furi_hal_bt.stack == FuriHalBtStackFull) { return true; } else { @@ -142,7 +142,7 @@ bool furi_hal_bt_is_gatt_gap_supported() { } } -bool furi_hal_bt_is_testing_supported() { +bool furi_hal_bt_is_testing_supported(void) { if(furi_hal_bt.stack == FuriHalBtStackFull) { return true; } else { @@ -168,7 +168,7 @@ FuriHalBleProfileBase* furi_hal_bt_start_app( FuriHalBleProfileParams params, GapEventCallback event_cb, void* context) { - furi_assert(event_cb); + furi_check(event_cb); furi_check(profile_template); furi_check(current_profile == NULL); @@ -198,7 +198,7 @@ FuriHalBleProfileBase* furi_hal_bt_start_app( return current_profile; } -void furi_hal_bt_reinit() { +void furi_hal_bt_reinit(void) { furi_hal_power_insomnia_enter(); FURI_LOG_I(TAG, "Disconnect and stop advertising"); furi_hal_bt_stop_advertising(); @@ -239,13 +239,13 @@ FuriHalBleProfileBase* furi_hal_bt_change_app( FuriHalBleProfileParams profile_params, GapEventCallback event_cb, void* context) { - furi_assert(event_cb); + furi_check(event_cb); furi_hal_bt_reinit(); return furi_hal_bt_start_app(profile_template, profile_params, event_cb, context); } -bool furi_hal_bt_is_active() { +bool furi_hal_bt_is_active(void) { return gap_get_state() > GapStateIdle; } @@ -253,13 +253,13 @@ bool furi_hal_bt_is_connected() { return gap_get_state() == GapStateConnected; } -void furi_hal_bt_start_advertising() { +void furi_hal_bt_start_advertising(void) { if(gap_get_state() == GapStateIdle) { gap_start_advertising(); } } -void furi_hal_bt_stop_advertising() { +void furi_hal_bt_stop_advertising(void) { if(furi_hal_bt_is_active()) { gap_stop_advertising(); while(furi_hal_bt_is_active()) { @@ -283,21 +283,21 @@ void furi_hal_bt_get_key_storage_buff(uint8_t** key_buff_addr, uint16_t* key_buf void furi_hal_bt_set_key_storage_change_callback( BleGlueKeyStorageChangedCallback callback, void* context) { - furi_assert(callback); + furi_check(callback); ble_glue_set_key_storage_changed_callback(callback, context); } -void furi_hal_bt_nvm_sram_sem_acquire() { +void furi_hal_bt_nvm_sram_sem_acquire(void) { while(LL_HSEM_1StepLock(HSEM, CFG_HW_BLE_NVM_SRAM_SEMID)) { furi_thread_yield(); } } -void furi_hal_bt_nvm_sram_sem_release() { +void furi_hal_bt_nvm_sram_sem_release(void) { LL_HSEM_ReleaseLock(HSEM, CFG_HW_BLE_NVM_SRAM_SEMID, 0); } -bool furi_hal_bt_clear_white_list() { +bool furi_hal_bt_clear_white_list(void) { furi_hal_bt_nvm_sram_sem_acquire(); tBleStatus status = aci_gap_clear_security_db(); if(status) { @@ -308,6 +308,8 @@ bool furi_hal_bt_clear_white_list() { } void furi_hal_bt_dump_state(FuriString* buffer) { + furi_check(buffer); + if(furi_hal_bt_is_alive()) { uint8_t HCI_Version; uint16_t HCI_Revision; @@ -332,7 +334,7 @@ void furi_hal_bt_dump_state(FuriString* buffer) { } } -bool furi_hal_bt_is_alive() { +bool furi_hal_bt_is_alive(void) { return ble_glue_is_alive(); } @@ -341,7 +343,7 @@ void furi_hal_bt_start_tone_tx(uint8_t channel, uint8_t power) { aci_hal_tone_start(channel, 0); } -void furi_hal_bt_stop_tone_tx() { +void furi_hal_bt_stop_tone_tx(void) { aci_hal_tone_stop(); } @@ -353,7 +355,7 @@ void furi_hal_bt_start_packet_rx(uint8_t channel, uint8_t datarate) { hci_le_enhanced_receiver_test(channel, datarate, 0); } -uint16_t furi_hal_bt_stop_packet_test() { +uint16_t furi_hal_bt_stop_packet_test(void) { uint16_t num_of_packets = 0; hci_le_test_end(&num_of_packets); return num_of_packets; @@ -363,7 +365,7 @@ void furi_hal_bt_start_rx(uint8_t channel) { aci_hal_rx_start(channel); } -float furi_hal_bt_get_rssi() { +float furi_hal_bt_get_rssi(void) { float val; uint8_t rssi_raw[3]; @@ -411,13 +413,13 @@ void furi_hal_bt_reverse_mac_addr(uint8_t mac_addr[GAP_MAC_ADDR_SIZE]) { } } -uint32_t furi_hal_bt_get_transmitted_packets() { +uint32_t furi_hal_bt_get_transmitted_packets(void) { uint32_t packets = 0; aci_hal_le_tx_test_packet_number(&packets); return packets; } -void furi_hal_bt_stop_rx() { +void furi_hal_bt_stop_rx(void) { aci_hal_rx_stop(); } @@ -448,18 +450,18 @@ bool furi_hal_bt_extra_beacon_set_config(const GapExtraBeaconConfig* config) { return gap_extra_beacon_set_config(config); } -const GapExtraBeaconConfig* furi_hal_bt_extra_beacon_get_config() { +const GapExtraBeaconConfig* furi_hal_bt_extra_beacon_get_config(void) { return gap_extra_beacon_get_config(); } -bool furi_hal_bt_extra_beacon_start() { +bool furi_hal_bt_extra_beacon_start(void) { return gap_extra_beacon_start(); } -bool furi_hal_bt_extra_beacon_stop() { +bool furi_hal_bt_extra_beacon_stop(void) { return gap_extra_beacon_stop(); } -bool furi_hal_bt_extra_beacon_is_active() { +bool furi_hal_bt_extra_beacon_is_active(void) { return gap_extra_beacon_get_state() == GapExtraBeaconStateStarted; } diff --git a/targets/f7/furi_hal/furi_hal_bus.c b/targets/f7/furi_hal/furi_hal_bus.c index 2c6f1f1eb..85b121dc4 100644 --- a/targets/f7/furi_hal/furi_hal_bus.c +++ b/targets/f7/furi_hal/furi_hal_bus.c @@ -143,7 +143,7 @@ static const uint32_t furi_hal_bus[] = { [FuriHalBusRF] = LL_APB3_GRP1_PERIPH_RF, }; -void furi_hal_bus_init_early() { +void furi_hal_bus_init_early(void) { FURI_CRITICAL_ENTER(); // FURI_HAL_BUS_PERIPH_DISABLE(AHB1, FURI_HAL_BUS_AHB1_GRP1, 1); @@ -158,7 +158,7 @@ void furi_hal_bus_init_early() { FURI_CRITICAL_EXIT(); } -void furi_hal_bus_deinit_early() { +void furi_hal_bus_deinit_early(void) { FURI_CRITICAL_ENTER(); // FURI_HAL_BUS_PERIPH_ENABLE(AHB1, FURI_HAL_BUS_AHB1_GRP1, 1); diff --git a/targets/f7/furi_hal/furi_hal_bus.h b/targets/f7/furi_hal/furi_hal_bus.h index ad4bbec32..7c4fe6a03 100644 --- a/targets/f7/furi_hal/furi_hal_bus.h +++ b/targets/f7/furi_hal/furi_hal_bus.h @@ -68,10 +68,10 @@ typedef enum { } FuriHalBus; /** Early initialization */ -void furi_hal_bus_init_early(); +void furi_hal_bus_init_early(void); /** Early de-initialization */ -void furi_hal_bus_deinit_early(); +void furi_hal_bus_deinit_early(void); /** * Enable a peripheral by turning the clocking on and deasserting the reset. diff --git a/targets/f7/furi_hal/furi_hal_clock.c b/targets/f7/furi_hal/furi_hal_clock.c index 945dc323b..ad21031fe 100644 --- a/targets/f7/furi_hal/furi_hal_clock.c +++ b/targets/f7/furi_hal/furi_hal_clock.c @@ -22,15 +22,15 @@ #define HS_CLOCK_IS_READY() (LL_RCC_HSE_IsReady() && LL_RCC_HSI_IsReady()) #define LS_CLOCK_IS_READY() (LL_RCC_LSE_IsReady() && LL_RCC_LSI1_IsReady()) -void furi_hal_clock_init_early() { +void furi_hal_clock_init_early(void) { LL_SetSystemCoreClock(CPU_CLOCK_EARLY_HZ); LL_Init1msTick(SystemCoreClock); } -void furi_hal_clock_deinit_early() { +void furi_hal_clock_deinit_early(void) { } -void furi_hal_clock_init() { +void furi_hal_clock_init(void) { /* HSE and HSI configuration and activation */ LL_RCC_HSE_SetCapacitorTuning(0x26); LL_RCC_HSE_Enable(); @@ -125,7 +125,7 @@ void furi_hal_clock_init() { FURI_LOG_I(TAG, "Init OK"); } -void furi_hal_clock_switch_hse2hsi() { +void furi_hal_clock_switch_hse2hsi(void) { LL_RCC_HSI_Enable(); while(!LL_RCC_HSI_IsReady()) @@ -142,7 +142,7 @@ void furi_hal_clock_switch_hse2hsi() { ; } -void furi_hal_clock_switch_hsi2hse() { +void furi_hal_clock_switch_hsi2hse(void) { #ifdef FURI_HAL_CLOCK_TRACK_STARTUP uint32_t clock_start_time = DWT->CYCCNT; #endif @@ -168,7 +168,7 @@ void furi_hal_clock_switch_hsi2hse() { #endif } -bool furi_hal_clock_switch_hse2pll() { +bool furi_hal_clock_switch_hse2pll(void) { furi_assert(LL_RCC_GetSysClkSource() == LL_RCC_SYS_CLKSOURCE_STATUS_HSE); LL_RCC_PLL_Enable(); @@ -191,7 +191,7 @@ bool furi_hal_clock_switch_hse2pll() { return true; } -bool furi_hal_clock_switch_pll2hse() { +bool furi_hal_clock_switch_pll2hse(void) { furi_assert(LL_RCC_GetSysClkSource() == LL_RCC_SYS_CLKSOURCE_STATUS_PLL); LL_RCC_HSE_Enable(); @@ -210,11 +210,11 @@ bool furi_hal_clock_switch_pll2hse() { return true; } -void furi_hal_clock_suspend_tick() { +void furi_hal_clock_suspend_tick(void) { CLEAR_BIT(SysTick->CTRL, SysTick_CTRL_ENABLE_Msk); } -void furi_hal_clock_resume_tick() { +void furi_hal_clock_resume_tick(void) { SET_BIT(SysTick->CTRL, SysTick_CTRL_ENABLE_Msk); } @@ -271,7 +271,7 @@ void furi_hal_clock_mco_enable(FuriHalClockMcoSourceId source, FuriHalClockMcoDi } } -void furi_hal_clock_mco_disable() { +void furi_hal_clock_mco_disable(void) { LL_RCC_ConfigMCO(LL_RCC_MCO1SOURCE_NOCLOCK, FuriHalClockMcoDiv1); LL_RCC_MSI_Disable(); while(LL_RCC_MSI_IsReady() != 0) diff --git a/targets/f7/furi_hal/furi_hal_clock.h b/targets/f7/furi_hal/furi_hal_clock.h index 3100b619f..302e3d174 100644 --- a/targets/f7/furi_hal/furi_hal_clock.h +++ b/targets/f7/furi_hal/furi_hal_clock.h @@ -33,37 +33,37 @@ typedef enum { } FuriHalClockMcoDivisorId; /** Early initialization */ -void furi_hal_clock_init_early(); +void furi_hal_clock_init_early(void); /** Early deinitialization */ -void furi_hal_clock_deinit_early(); +void furi_hal_clock_deinit_early(void); /** Initialize clocks */ -void furi_hal_clock_init(); +void furi_hal_clock_init(void); /** Switch clock from HSE to HSI */ -void furi_hal_clock_switch_hse2hsi(); +void furi_hal_clock_switch_hse2hsi(void); /** Switch clock from HSI to HSE */ -void furi_hal_clock_switch_hsi2hse(); +void furi_hal_clock_switch_hsi2hse(void); /** Switch clock from HSE to PLL * * @return true if changed, false if failed or not possible at this moment */ -bool furi_hal_clock_switch_hse2pll(); +bool furi_hal_clock_switch_hse2pll(void); /** Switch clock from PLL to HSE * * @return true if changed, false if failed or not possible at this moment */ -bool furi_hal_clock_switch_pll2hse(); +bool furi_hal_clock_switch_pll2hse(void); /** Stop SysTick counter without resetting */ -void furi_hal_clock_suspend_tick(); +void furi_hal_clock_suspend_tick(void); /** Continue SysTick counter operation */ -void furi_hal_clock_resume_tick(); +void furi_hal_clock_resume_tick(void); /** Enable clock output on MCO pin * @@ -73,7 +73,7 @@ void furi_hal_clock_resume_tick(); void furi_hal_clock_mco_enable(FuriHalClockMcoSourceId source, FuriHalClockMcoDivisorId div); /** Disable clock output on MCO pin */ -void furi_hal_clock_mco_disable(); +void furi_hal_clock_mco_disable(void); #ifdef __cplusplus } diff --git a/targets/f7/furi_hal/furi_hal_cortex.c b/targets/f7/furi_hal/furi_hal_cortex.c index 9865e6ef8..9e184a597 100644 --- a/targets/f7/furi_hal/furi_hal_cortex.c +++ b/targets/f7/furi_hal/furi_hal_cortex.c @@ -5,7 +5,7 @@ #define FURI_HAL_CORTEX_INSTRUCTIONS_PER_MICROSECOND (SystemCoreClock / 1000000) -void furi_hal_cortex_init_early() { +void furi_hal_cortex_init_early(void) { CoreDebug->DEMCR |= (CoreDebug_DEMCR_TRCENA_Msk | CoreDebug_DEMCR_MON_EN_Msk); DWT->CTRL |= DWT_CTRL_CYCCNTENA_Msk; DWT->CYCCNT = 0U; @@ -24,7 +24,7 @@ void furi_hal_cortex_delay_us(uint32_t microseconds) { }; } -uint32_t furi_hal_cortex_instructions_per_microsecond() { +uint32_t furi_hal_cortex_instructions_per_microsecond(void) { return FURI_HAL_CORTEX_INSTRUCTIONS_PER_MICROSECOND; } diff --git a/targets/f7/furi_hal/furi_hal_crypto.c b/targets/f7/furi_hal/furi_hal_crypto.c index a897648a3..236573bca 100644 --- a/targets/f7/furi_hal/furi_hal_crypto.c +++ b/targets/f7/furi_hal/furi_hal_crypto.c @@ -80,7 +80,7 @@ static const uint8_t enclave_signature_expected[ENCLAVE_FACTORY_KEY_SLOTS][ENCLA {0xc9, 0xf7, 0x03, 0xf1, 0x6c, 0x65, 0xad, 0x49, 0x74, 0xbe, 0x00, 0x54, 0xfd, 0xa6, 0x9c, 0x32}, }; -void furi_hal_crypto_init() { +void furi_hal_crypto_init(void) { furi_hal_crypto_mutex = furi_mutex_alloc(FuriMutexTypeNormal); FURI_LOG_I(TAG, "Init OK"); } @@ -129,8 +129,8 @@ bool furi_hal_crypto_enclave_ensure_key(uint8_t key_slot) { } bool furi_hal_crypto_enclave_verify(uint8_t* keys_nb, uint8_t* valid_keys_nb) { - furi_assert(keys_nb); - furi_assert(valid_keys_nb); + furi_check(keys_nb); + furi_check(valid_keys_nb); uint8_t keys = 0; uint8_t keys_valid = 0; uint8_t buffer[ENCLAVE_SIGNATURE_SIZE]; @@ -155,8 +155,8 @@ bool furi_hal_crypto_enclave_verify(uint8_t* keys_nb, uint8_t* valid_keys_nb) { } bool furi_hal_crypto_enclave_store_key(FuriHalCryptoKey* key, uint8_t* slot) { - furi_assert(key); - furi_assert(slot); + furi_check(key); + furi_check(slot); furi_check(furi_mutex_acquire(furi_hal_crypto_mutex, FuriWaitForever) == FuriStatusOk); @@ -256,8 +256,8 @@ static bool crypto_process_block(uint32_t* in, uint32_t* out, uint8_t blk_len) { } bool furi_hal_crypto_enclave_load_key(uint8_t slot, const uint8_t* iv) { - furi_assert(slot > 0 && slot <= 100); - furi_assert(furi_hal_crypto_mutex); + furi_check(slot > 0 && slot <= 100); + furi_check(furi_hal_crypto_mutex); furi_check(furi_mutex_acquire(furi_hal_crypto_mutex, FuriWaitForever) == FuriStatusOk); furi_hal_bus_enable(FuriHalBusAES1); @@ -286,16 +286,16 @@ bool furi_hal_crypto_enclave_unload_key(uint8_t slot) { CLEAR_BIT(AES1->CR, AES_CR_EN); SHCI_CmdStatus_t shci_state = SHCI_C2_FUS_UnloadUsrKey(slot); - furi_assert(shci_state == SHCI_Success); furi_hal_bus_disable(FuriHalBusAES1); furi_check(furi_mutex_release(furi_hal_crypto_mutex) == FuriStatusOk); + return (shci_state == SHCI_Success); } bool furi_hal_crypto_load_key(const uint8_t* key, const uint8_t* iv) { - furi_assert(furi_hal_crypto_mutex); + furi_check(furi_hal_crypto_mutex); furi_check(furi_mutex_acquire(furi_hal_crypto_mutex, FuriWaitForever) == FuriStatusOk); furi_hal_bus_enable(FuriHalBusAES1); @@ -400,7 +400,7 @@ static void crypto_key_init_bswap(uint32_t* key, uint32_t* iv, uint32_t chaining static bool furi_hal_crypto_load_key_bswap(const uint8_t* key, const uint8_t* iv, uint32_t chaining_mode) { - furi_assert(furi_hal_crypto_mutex); + furi_check(furi_hal_crypto_mutex); furi_check(furi_mutex_acquire(furi_hal_crypto_mutex, FuriWaitForever) == FuriStatusOk); furi_hal_bus_enable(FuriHalBusAES1); diff --git a/targets/f7/furi_hal/furi_hal_debug.c b/targets/f7/furi_hal/furi_hal_debug.c index 3dc03ea69..7d1488fa5 100644 --- a/targets/f7/furi_hal/furi_hal_debug.c +++ b/targets/f7/furi_hal/furi_hal_debug.c @@ -8,7 +8,7 @@ volatile bool furi_hal_debug_gdb_session_active = false; -void furi_hal_debug_enable() { +void furi_hal_debug_enable(void) { // Low power mode debug LL_DBGMCU_EnableDBGSleepMode(); LL_DBGMCU_EnableDBGStopMode(); @@ -25,7 +25,7 @@ void furi_hal_debug_enable() { &gpio_swclk, GpioModeAltFunctionPushPull, GpioPullDown, GpioSpeedLow, GpioAltFn0JTCK_SWCLK); } -void furi_hal_debug_disable() { +void furi_hal_debug_disable(void) { // Low power mode debug LL_DBGMCU_DisableDBGSleepMode(); LL_DBGMCU_DisableDBGStopMode(); @@ -36,6 +36,6 @@ void furi_hal_debug_disable() { furi_hal_gpio_init_simple(&gpio_swclk, GpioModeAnalog); } -bool furi_hal_debug_is_gdb_session_active() { +bool furi_hal_debug_is_gdb_session_active(void) { return furi_hal_debug_gdb_session_active; } \ No newline at end of file diff --git a/targets/f7/furi_hal/furi_hal_dma.c b/targets/f7/furi_hal/furi_hal_dma.c index a6a30d906..e9bef9605 100644 --- a/targets/f7/furi_hal/furi_hal_dma.c +++ b/targets/f7/furi_hal/furi_hal_dma.c @@ -1,13 +1,13 @@ #include #include -void furi_hal_dma_init_early() { +void furi_hal_dma_init_early(void) { furi_hal_bus_enable(FuriHalBusDMA1); furi_hal_bus_enable(FuriHalBusDMA2); furi_hal_bus_enable(FuriHalBusDMAMUX1); } -void furi_hal_dma_deinit_early() { +void furi_hal_dma_deinit_early(void) { furi_hal_bus_disable(FuriHalBusDMA1); furi_hal_bus_disable(FuriHalBusDMA2); furi_hal_bus_disable(FuriHalBusDMAMUX1); diff --git a/targets/f7/furi_hal/furi_hal_dma.h b/targets/f7/furi_hal/furi_hal_dma.h index cadcc7733..281a8ff1b 100644 --- a/targets/f7/furi_hal/furi_hal_dma.h +++ b/targets/f7/furi_hal/furi_hal_dma.h @@ -5,10 +5,10 @@ extern "C" { #endif /** Early initialization */ -void furi_hal_dma_init_early(); +void furi_hal_dma_init_early(void); /** Early de-initialization */ -void furi_hal_dma_deinit_early(); +void furi_hal_dma_deinit_early(void); #ifdef __cplusplus } diff --git a/targets/f7/furi_hal/furi_hal_flash.c b/targets/f7/furi_hal/furi_hal_flash.c index 37eec744c..138e07eab 100644 --- a/targets/f7/furi_hal/furi_hal_flash.c +++ b/targets/f7/furi_hal/furi_hal_flash.c @@ -51,37 +51,37 @@ /* Free flash space borders, exported by linker */ extern const void __free_flash_start__; -size_t furi_hal_flash_get_base() { +size_t furi_hal_flash_get_base(void) { return FLASH_BASE; } -size_t furi_hal_flash_get_read_block_size() { +size_t furi_hal_flash_get_read_block_size(void) { return FURI_HAL_FLASH_READ_BLOCK; } -size_t furi_hal_flash_get_write_block_size() { +size_t furi_hal_flash_get_write_block_size(void) { return FURI_HAL_FLASH_WRITE_BLOCK; } -size_t furi_hal_flash_get_page_size() { +size_t furi_hal_flash_get_page_size(void) { return FURI_HAL_FLASH_PAGE_SIZE; } -size_t furi_hal_flash_get_cycles_count() { +size_t furi_hal_flash_get_cycles_count(void) { return FURI_HAL_FLASH_CYCLES_COUNT; } -const void* furi_hal_flash_get_free_start_address() { +const void* furi_hal_flash_get_free_start_address(void) { return &__free_flash_start__; } -const void* furi_hal_flash_get_free_end_address() { +const void* furi_hal_flash_get_free_end_address(void) { uint32_t sfr_reg_val = READ_REG(FLASH->SFR); uint32_t sfsa = (READ_BIT(sfr_reg_val, FLASH_SFR_SFSA) >> FLASH_SFR_SFSA_Pos); return (const void*)((sfsa * FURI_HAL_FLASH_PAGE_SIZE) + FLASH_BASE); } -size_t furi_hal_flash_get_free_page_start_address() { +size_t furi_hal_flash_get_free_page_start_address(void) { size_t start = (size_t)furi_hal_flash_get_free_start_address(); size_t page_start = start - start % FURI_HAL_FLASH_PAGE_SIZE; if(page_start != start) { @@ -90,13 +90,13 @@ size_t furi_hal_flash_get_free_page_start_address() { return page_start; } -size_t furi_hal_flash_get_free_page_count() { +size_t furi_hal_flash_get_free_page_count(void) { size_t end = (size_t)furi_hal_flash_get_free_end_address(); size_t page_start = (size_t)furi_hal_flash_get_free_page_start_address(); return (end - page_start) / FURI_HAL_FLASH_PAGE_SIZE; } -void furi_hal_flash_init() { +void furi_hal_flash_init(void) { /* Errata 2.2.9, Flash OPTVERR flag is always set after system reset */ // WRITE_REG(FLASH->SR, FLASH_SR_OPTVERR); /* Actually, reset all error flags on start */ @@ -106,7 +106,7 @@ void furi_hal_flash_init() { } } -static void furi_hal_flash_unlock() { +static void furi_hal_flash_unlock(void) { /* verify Flash is locked */ furi_check(READ_BIT(FLASH->CR, FLASH_CR_LOCK) != 0U); @@ -450,7 +450,7 @@ uint32_t furi_hal_flash_ob_get_word(size_t word_idx, bool complementary) { return ob_data[raw_word_idx]; } -void furi_hal_flash_ob_unlock() { +void furi_hal_flash_ob_unlock(void) { furi_check(READ_BIT(FLASH->CR, FLASH_CR_OPTLOCK) != 0U); furi_hal_flash_begin(true); WRITE_REG(FLASH->OPTKEYR, FURI_HAL_FLASH_OPT_KEY1); @@ -460,7 +460,7 @@ void furi_hal_flash_ob_unlock() { furi_check(READ_BIT(FLASH->CR, FLASH_CR_OPTLOCK) == 0U); } -void furi_hal_flash_ob_lock() { +void furi_hal_flash_ob_lock(void) { furi_check(READ_BIT(FLASH->CR, FLASH_CR_OPTLOCK) == 0U); SET_BIT(FLASH->CR, FLASH_CR_OPTLOCK); furi_hal_flash_end(true); @@ -511,7 +511,7 @@ static const FuriHalFlashObMapping furi_hal_flash_ob_reg_map[FURI_HAL_FLASH_OB_T }; #undef OB_REG_DEF -void furi_hal_flash_ob_apply() { +void furi_hal_flash_ob_apply(void) { furi_hal_flash_ob_unlock(); /* OBL_LAUNCH: When set to 1, this bit forces the option byte reloading. * It cannot be written if OPTLOCK is set */ @@ -558,6 +558,6 @@ bool furi_hal_flash_ob_set_word(size_t word_idx, const uint32_t value) { return true; } -const FuriHalFlashRawOptionByteData* furi_hal_flash_ob_get_raw_ptr() { +const FuriHalFlashRawOptionByteData* furi_hal_flash_ob_get_raw_ptr(void) { return (const FuriHalFlashRawOptionByteData*)OPTION_BYTE_BASE; } diff --git a/targets/f7/furi_hal/furi_hal_flash.h b/targets/f7/furi_hal/furi_hal_flash.h index 9fa8f94af..6a5d42222 100644 --- a/targets/f7/furi_hal/furi_hal_flash.h +++ b/targets/f7/furi_hal/furi_hal_flash.h @@ -29,61 +29,61 @@ _Static_assert( /** Init flash, applying necessary workarounds */ -void furi_hal_flash_init(); +void furi_hal_flash_init(void); /** Get flash base address * * @return pointer to flash base */ -size_t furi_hal_flash_get_base(); +size_t furi_hal_flash_get_base(void); /** Get flash read block size * * @return size in bytes */ -size_t furi_hal_flash_get_read_block_size(); +size_t furi_hal_flash_get_read_block_size(void); /** Get flash write block size * * @return size in bytes */ -size_t furi_hal_flash_get_write_block_size(); +size_t furi_hal_flash_get_write_block_size(void); /** Get flash page size * * @return size in bytes */ -size_t furi_hal_flash_get_page_size(); +size_t furi_hal_flash_get_page_size(void); /** Get expected flash cycles count * * @return count of erase-write operations */ -size_t furi_hal_flash_get_cycles_count(); +size_t furi_hal_flash_get_cycles_count(void); /** Get free flash start address * * @return pointer to free region start */ -const void* furi_hal_flash_get_free_start_address(); +const void* furi_hal_flash_get_free_start_address(void); /** Get free flash end address * * @return pointer to free region end */ -const void* furi_hal_flash_get_free_end_address(); +const void* furi_hal_flash_get_free_end_address(void); /** Get first free page start address * * @return first free page memory address */ -size_t furi_hal_flash_get_free_page_start_address(); +size_t furi_hal_flash_get_free_page_start_address(void); /** Get free page count * * @return free page count */ -size_t furi_hal_flash_get_free_page_count(); +size_t furi_hal_flash_get_free_page_count(void); /** Erase Flash * @@ -133,13 +133,13 @@ bool furi_hal_flash_ob_set_word(size_t word_idx, const uint32_t value); * @warning Initializes system restart * */ -void furi_hal_flash_ob_apply(); +void furi_hal_flash_ob_apply(void); /** Get raw OB storage data * * @return pointer to read-only data of OB (raw + complementary values) */ -const FuriHalFlashRawOptionByteData* furi_hal_flash_ob_get_raw_ptr(); +const FuriHalFlashRawOptionByteData* furi_hal_flash_ob_get_raw_ptr(void); #ifdef __cplusplus } diff --git a/targets/f7/furi_hal/furi_hal_gpio.c b/targets/f7/furi_hal/furi_hal_gpio.c index 64ba5913d..8e6192ca0 100644 --- a/targets/f7/furi_hal/furi_hal_gpio.c +++ b/targets/f7/furi_hal/furi_hal_gpio.c @@ -5,7 +5,7 @@ #include #include -static uint32_t furi_hal_gpio_invalid_argument_crash() { +static uint32_t furi_hal_gpio_invalid_argument_crash(void) { furi_crash("Invalid argument"); return 0; } @@ -194,8 +194,8 @@ void furi_hal_gpio_init_ex( } void furi_hal_gpio_add_int_callback(const GpioPin* gpio, GpioExtiCallback cb, void* ctx) { - furi_assert(gpio); - furi_assert(cb); + furi_check(gpio); + furi_check(cb); FURI_CRITICAL_ENTER(); @@ -211,7 +211,7 @@ void furi_hal_gpio_add_int_callback(const GpioPin* gpio, GpioExtiCallback cb, vo } void furi_hal_gpio_enable_int_callback(const GpioPin* gpio) { - furi_assert(gpio); + furi_check(gpio); FURI_CRITICAL_ENTER(); @@ -222,7 +222,7 @@ void furi_hal_gpio_enable_int_callback(const GpioPin* gpio) { } void furi_hal_gpio_disable_int_callback(const GpioPin* gpio) { - furi_assert(gpio); + furi_check(gpio); FURI_CRITICAL_ENTER(); @@ -234,7 +234,7 @@ void furi_hal_gpio_disable_int_callback(const GpioPin* gpio) { } void furi_hal_gpio_remove_int_callback(const GpioPin* gpio) { - furi_assert(gpio); + furi_check(gpio); FURI_CRITICAL_ENTER(); diff --git a/targets/f7/furi_hal/furi_hal_i2c.c b/targets/f7/furi_hal/furi_hal_i2c.c index 8c7b054e3..71e1a5814 100644 --- a/targets/f7/furi_hal/furi_hal_i2c.c +++ b/targets/f7/furi_hal/furi_hal_i2c.c @@ -9,15 +9,15 @@ #define TAG "FuriHalI2c" -void furi_hal_i2c_init_early() { +void furi_hal_i2c_init_early(void) { furi_hal_i2c_bus_power.callback(&furi_hal_i2c_bus_power, FuriHalI2cBusEventInit); } -void furi_hal_i2c_deinit_early() { +void furi_hal_i2c_deinit_early(void) { furi_hal_i2c_bus_power.callback(&furi_hal_i2c_bus_power, FuriHalI2cBusEventDeinit); } -void furi_hal_i2c_init() { +void furi_hal_i2c_init(void) { furi_hal_i2c_bus_external.callback(&furi_hal_i2c_bus_external, FuriHalI2cBusEventInit); FURI_LOG_I(TAG, "Init OK"); } @@ -235,7 +235,7 @@ bool furi_hal_i2c_tx( const uint8_t* data, size_t size, uint32_t timeout) { - furi_assert(timeout > 0); + furi_check(timeout > 0); return furi_hal_i2c_tx_ext( handle, address, false, data, size, FuriHalI2cBeginStart, FuriHalI2cEndStop, timeout); @@ -247,7 +247,7 @@ bool furi_hal_i2c_rx( uint8_t* data, size_t size, uint32_t timeout) { - furi_assert(timeout > 0); + furi_check(timeout > 0); return furi_hal_i2c_rx_ext( handle, address, false, data, size, FuriHalI2cBeginStart, FuriHalI2cEndStop, timeout); @@ -284,7 +284,7 @@ bool furi_hal_i2c_trx( bool furi_hal_i2c_is_device_ready(FuriHalI2cBusHandle* handle, uint8_t i2c_addr, uint32_t timeout) { furi_check(handle); furi_check(handle->bus->current_handle == handle); - furi_assert(timeout > 0); + furi_check(timeout > 0); bool ret = true; FuriHalCortexTimer timer = furi_hal_cortex_timer_get(timeout * 1000); @@ -393,7 +393,7 @@ bool furi_hal_i2c_write_mem( uint32_t timeout) { furi_check(handle); furi_check(handle->bus->current_handle == handle); - furi_assert(timeout > 0); + furi_check(timeout > 0); return furi_hal_i2c_tx_ext( handle, diff --git a/targets/f7/furi_hal/furi_hal_ibutton.c b/targets/f7/furi_hal/furi_hal_ibutton.c index bf1127a85..07cf8de6e 100644 --- a/targets/f7/furi_hal/furi_hal_ibutton.c +++ b/targets/f7/furi_hal/furi_hal_ibutton.c @@ -33,7 +33,7 @@ static void furi_hal_ibutton_emulate_isr(void* context) { } } -void furi_hal_ibutton_init() { +void furi_hal_ibutton_init(void) { furi_hal_ibutton = malloc(sizeof(FuriHalIbutton)); furi_hal_ibutton->state = FuriHalIbuttonStateIdle; @@ -44,8 +44,8 @@ void furi_hal_ibutton_emulate_start( uint32_t period, FuriHalIbuttonEmulateCallback callback, void* context) { - furi_assert(furi_hal_ibutton); - furi_assert(furi_hal_ibutton->state == FuriHalIbuttonStateIdle); + furi_check(furi_hal_ibutton); + furi_check(furi_hal_ibutton->state == FuriHalIbuttonStateIdle); furi_hal_ibutton->state = FuriHalIbuttonStateRunning; furi_hal_ibutton->callback = callback; @@ -74,8 +74,8 @@ void furi_hal_ibutton_emulate_set_next(uint32_t period) { LL_TIM_SetAutoReload(FURI_HAL_IBUTTON_TIMER, period); } -void furi_hal_ibutton_emulate_stop() { - furi_assert(furi_hal_ibutton); +void furi_hal_ibutton_emulate_stop(void) { + furi_check(furi_hal_ibutton); if(furi_hal_ibutton->state == FuriHalIbuttonStateRunning) { furi_hal_ibutton->state = FuriHalIbuttonStateIdle; @@ -89,12 +89,12 @@ void furi_hal_ibutton_emulate_stop() { } } -void furi_hal_ibutton_pin_configure() { +void furi_hal_ibutton_pin_configure(void) { furi_hal_gpio_write(&gpio_ibutton, true); furi_hal_gpio_init(&gpio_ibutton, GpioModeOutputOpenDrain, GpioPullNo, GpioSpeedLow); } -void furi_hal_ibutton_pin_reset() { +void furi_hal_ibutton_pin_reset(void) { furi_hal_gpio_write(&gpio_ibutton, true); furi_hal_gpio_init(&gpio_ibutton, GpioModeAnalog, GpioPullNo, GpioSpeedLow); } diff --git a/targets/f7/furi_hal/furi_hal_ibutton.h b/targets/f7/furi_hal/furi_hal_ibutton.h index b723fe176..ae676f8b5 100644 --- a/targets/f7/furi_hal/furi_hal_ibutton.h +++ b/targets/f7/furi_hal/furi_hal_ibutton.h @@ -15,7 +15,7 @@ extern "C" { typedef void (*FuriHalIbuttonEmulateCallback)(void* context); /** Initialize */ -void furi_hal_ibutton_init(); +void furi_hal_ibutton_init(void); /** * Start emulation timer @@ -37,17 +37,17 @@ void furi_hal_ibutton_emulate_set_next(uint32_t period); /** * Stop emulation timer */ -void furi_hal_ibutton_emulate_stop(); +void furi_hal_ibutton_emulate_stop(void); /** * Set the pin to normal mode (open collector), and sets it to float */ -void furi_hal_ibutton_pin_configure(); +void furi_hal_ibutton_pin_configure(void); /** * Sets the pin to analog mode, and sets it to float */ -void furi_hal_ibutton_pin_reset(); +void furi_hal_ibutton_pin_reset(void); /** * iButton write pin diff --git a/targets/f7/furi_hal/furi_hal_infrared.c b/targets/f7/furi_hal/furi_hal_infrared.c index 3cacc083d..09acf11f6 100644 --- a/targets/f7/furi_hal/furi_hal_infrared.c +++ b/targets/f7/furi_hal/furi_hal_infrared.c @@ -105,7 +105,7 @@ static void furi_hal_infrared_tim_rx_isr(void* context) { /* Timeout */ if(LL_TIM_IsActiveFlag_CC3(INFRARED_RX_TIMER)) { LL_TIM_ClearFlag_CC3(INFRARED_RX_TIMER); - furi_assert(furi_hal_infrared_state == InfraredStateAsyncRx); + furi_check(furi_hal_infrared_state == InfraredStateAsyncRx); /* Timers CNT register starts to counting from 0 to ARR, but it is * reseted when Channel 1 catches interrupt. It is not reseted by @@ -122,7 +122,7 @@ static void furi_hal_infrared_tim_rx_isr(void* context) { /* Rising Edge */ if(LL_TIM_IsActiveFlag_CC1(INFRARED_RX_TIMER)) { LL_TIM_ClearFlag_CC1(INFRARED_RX_TIMER); - furi_assert(furi_hal_infrared_state == InfraredStateAsyncRx); + furi_check(furi_hal_infrared_state == InfraredStateAsyncRx); if(READ_BIT(INFRARED_RX_TIMER->CCMR1, TIM_CCMR1_CC1S)) { /* Low pin level is a Mark state of INFRARED signal. Invert level for further processing. */ @@ -137,7 +137,7 @@ static void furi_hal_infrared_tim_rx_isr(void* context) { /* Falling Edge */ if(LL_TIM_IsActiveFlag_CC2(INFRARED_RX_TIMER)) { LL_TIM_ClearFlag_CC2(INFRARED_RX_TIMER); - furi_assert(furi_hal_infrared_state == InfraredStateAsyncRx); + furi_check(furi_hal_infrared_state == InfraredStateAsyncRx); if(READ_BIT(INFRARED_RX_TIMER->CCMR1, TIM_CCMR1_CC2S)) { /* High pin level is a Space state of INFRARED signal. Invert level for further processing. */ @@ -152,7 +152,7 @@ static void furi_hal_infrared_tim_rx_isr(void* context) { } void furi_hal_infrared_async_rx_start(void) { - furi_assert(furi_hal_infrared_state == InfraredStateIdle); + furi_check(furi_hal_infrared_state == InfraredStateIdle); furi_hal_gpio_init_ex( &gpio_infrared_rx, @@ -201,7 +201,7 @@ void furi_hal_infrared_async_rx_start(void) { } void furi_hal_infrared_async_rx_stop(void) { - furi_assert(furi_hal_infrared_state == InfraredStateAsyncRx); + furi_check(furi_hal_infrared_state == InfraredStateAsyncRx); FURI_CRITICAL_ENTER(); furi_hal_bus_disable(INFRARED_RX_TIMER_BUS); @@ -240,7 +240,7 @@ static void furi_hal_infrared_tx_dma_terminate(void) { LL_DMA_DisableIT_HT(INFRARED_DMA_CH2_DEF); LL_DMA_DisableIT_TC(INFRARED_DMA_CH2_DEF); - furi_assert(furi_hal_infrared_state == InfraredStateAsyncTxStopInProgress); + furi_check(furi_hal_infrared_state == InfraredStateAsyncTxStopInProgress); LL_DMA_DisableIT_TC(INFRARED_DMA_CH1_DEF); LL_DMA_DisableChannel(INFRARED_DMA_CH2_DEF); @@ -452,14 +452,14 @@ static void furi_hal_infrared_configure_tim_rcr_dma_tx(void) { } static void furi_hal_infrared_tx_fill_buffer_last(uint8_t buf_num) { - furi_assert(buf_num < 2); - furi_assert(furi_hal_infrared_state != InfraredStateAsyncRx); - furi_assert(furi_hal_infrared_state < InfraredStateMAX); - furi_assert(infrared_tim_tx.data_callback); + furi_check(buf_num < 2); + furi_check(furi_hal_infrared_state != InfraredStateAsyncRx); + furi_check(furi_hal_infrared_state < InfraredStateMAX); + furi_check(infrared_tim_tx.data_callback); InfraredTxBuf* buffer = &infrared_tim_tx.buffer[buf_num]; - furi_assert(buffer->data != NULL); + furi_check(buffer->data != NULL); (void)buffer->data; - furi_assert(buffer->polarity != NULL); + furi_check(buffer->polarity != NULL); (void)buffer->polarity; infrared_tim_tx.buffer[buf_num].data[0] = 0; // 1 pulse @@ -472,13 +472,13 @@ static void furi_hal_infrared_tx_fill_buffer_last(uint8_t buf_num) { } static void furi_hal_infrared_tx_fill_buffer(uint8_t buf_num, uint8_t polarity_shift) { - furi_assert(buf_num < 2); - furi_assert(furi_hal_infrared_state != InfraredStateAsyncRx); - furi_assert(furi_hal_infrared_state < InfraredStateMAX); - furi_assert(infrared_tim_tx.data_callback); + furi_check(buf_num < 2); + furi_check(furi_hal_infrared_state != InfraredStateAsyncRx); + furi_check(furi_hal_infrared_state < InfraredStateMAX); + furi_check(infrared_tim_tx.data_callback); InfraredTxBuf* buffer = &infrared_tim_tx.buffer[buf_num]; - furi_assert(buffer->data != NULL); - furi_assert(buffer->polarity != NULL); + furi_check(buffer->data != NULL); + furi_check(buffer->polarity != NULL); FuriHalInfraredTxGetDataState status = FuriHalInfraredTxGetDataStateOk; uint32_t duration = 0; @@ -544,10 +544,10 @@ static void furi_hal_infrared_tx_fill_buffer(uint8_t buf_num, uint8_t polarity_s } static void furi_hal_infrared_tx_dma_set_polarity(uint8_t buf_num, uint8_t polarity_shift) { - furi_assert(buf_num < 2); - furi_assert(furi_hal_infrared_state < InfraredStateMAX); + furi_check(buf_num < 2); + furi_check(furi_hal_infrared_state < InfraredStateMAX); InfraredTxBuf* buffer = &infrared_tim_tx.buffer[buf_num]; - furi_assert(buffer->polarity != NULL); + furi_check(buffer->polarity != NULL); FURI_CRITICAL_ENTER(); bool channel_enabled = LL_DMA_IsEnabledChannel(INFRARED_DMA_CH1_DEF); @@ -563,10 +563,10 @@ static void furi_hal_infrared_tx_dma_set_polarity(uint8_t buf_num, uint8_t polar } static void furi_hal_infrared_tx_dma_set_buffer(uint8_t buf_num) { - furi_assert(buf_num < 2); - furi_assert(furi_hal_infrared_state < InfraredStateMAX); + furi_check(buf_num < 2); + furi_check(furi_hal_infrared_state < InfraredStateMAX); InfraredTxBuf* buffer = &infrared_tim_tx.buffer[buf_num]; - furi_assert(buffer->data != NULL); + furi_check(buffer->data != NULL); /* non-circular mode requires disabled channel before setup */ FURI_CRITICAL_ENTER(); @@ -583,7 +583,7 @@ static void furi_hal_infrared_tx_dma_set_buffer(uint8_t buf_num) { } static void furi_hal_infrared_async_tx_free_resources(void) { - furi_assert( + furi_check( (furi_hal_infrared_state == InfraredStateIdle) || (furi_hal_infrared_state == InfraredStateAsyncTxStopped)); @@ -615,11 +615,11 @@ void furi_hal_infrared_async_tx_start(uint32_t freq, float duty_cycle) { furi_crash(); } - furi_assert(furi_hal_infrared_state == InfraredStateIdle); - furi_assert(infrared_tim_tx.buffer[0].data == NULL); - furi_assert(infrared_tim_tx.buffer[1].data == NULL); - furi_assert(infrared_tim_tx.buffer[0].polarity == NULL); - furi_assert(infrared_tim_tx.buffer[1].polarity == NULL); + furi_check(furi_hal_infrared_state == InfraredStateIdle); + furi_check(infrared_tim_tx.buffer[0].data == NULL); + furi_check(infrared_tim_tx.buffer[1].data == NULL); + furi_check(infrared_tim_tx.buffer[0].polarity == NULL); + furi_check(infrared_tim_tx.buffer[1].polarity == NULL); size_t alloc_size_data = INFRARED_TIM_TX_DMA_BUFFER_SIZE * sizeof(uint16_t); infrared_tim_tx.buffer[0].data = malloc(alloc_size_data); @@ -676,8 +676,8 @@ void furi_hal_infrared_async_tx_start(uint32_t freq, float duty_cycle) { } void furi_hal_infrared_async_tx_wait_termination(void) { - furi_assert(furi_hal_infrared_state >= InfraredStateAsyncTx); - furi_assert(furi_hal_infrared_state < InfraredStateMAX); + furi_check(furi_hal_infrared_state >= InfraredStateAsyncTx); + furi_check(furi_hal_infrared_state < InfraredStateMAX); FuriStatus status; status = furi_semaphore_acquire(infrared_tim_tx.stop_semaphore, FuriWaitForever); @@ -687,8 +687,8 @@ void furi_hal_infrared_async_tx_wait_termination(void) { } void furi_hal_infrared_async_tx_stop(void) { - furi_assert(furi_hal_infrared_state >= InfraredStateAsyncTx); - furi_assert(furi_hal_infrared_state < InfraredStateMAX); + furi_check(furi_hal_infrared_state >= InfraredStateAsyncTx); + furi_check(furi_hal_infrared_state < InfraredStateMAX); FURI_CRITICAL_ENTER(); if(furi_hal_infrared_state == InfraredStateAsyncTx) @@ -701,7 +701,7 @@ void furi_hal_infrared_async_tx_stop(void) { void furi_hal_infrared_async_tx_set_data_isr_callback( FuriHalInfraredTxGetDataISRCallback callback, void* context) { - furi_assert(furi_hal_infrared_state == InfraredStateIdle); + furi_check(furi_hal_infrared_state == InfraredStateIdle); infrared_tim_tx.data_callback = callback; infrared_tim_tx.data_context = context; } diff --git a/targets/f7/furi_hal/furi_hal_interrupt.c b/targets/f7/furi_hal/furi_hal_interrupt.c index a9cd4e7aa..a0ce2f665 100644 --- a/targets/f7/furi_hal/furi_hal_interrupt.c +++ b/targets/f7/furi_hal/furi_hal_interrupt.c @@ -101,7 +101,7 @@ __attribute__((always_inline)) static inline void NVIC_DisableIRQ(furi_hal_interrupt_irqn[index]); } -void furi_hal_interrupt_init() { +void furi_hal_interrupt_init(void) { NVIC_SetPriority( TAMP_STAMP_LSECSS_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 0, 0)); NVIC_EnableIRQ(TAMP_STAMP_LSECSS_IRQn); @@ -165,82 +165,82 @@ void furi_hal_interrupt_set_isr_ex( } /* Timer 2 */ -void TIM2_IRQHandler() { +void TIM2_IRQHandler(void) { furi_hal_interrupt_call(FuriHalInterruptIdTIM2); } /* Timer 1 Update */ -void TIM1_UP_TIM16_IRQHandler() { +void TIM1_UP_TIM16_IRQHandler(void) { furi_hal_interrupt_call(FuriHalInterruptIdTim1UpTim16); } -void TIM1_TRG_COM_TIM17_IRQHandler() { +void TIM1_TRG_COM_TIM17_IRQHandler(void) { furi_hal_interrupt_call(FuriHalInterruptIdTim1TrgComTim17); } -void TIM1_CC_IRQHandler() { +void TIM1_CC_IRQHandler(void) { furi_hal_interrupt_call(FuriHalInterruptIdTim1Cc); } /* DMA 1 */ -void DMA1_Channel1_IRQHandler() { +void DMA1_Channel1_IRQHandler(void) { furi_hal_interrupt_call(FuriHalInterruptIdDma1Ch1); } -void DMA1_Channel2_IRQHandler() { +void DMA1_Channel2_IRQHandler(void) { furi_hal_interrupt_call(FuriHalInterruptIdDma1Ch2); } -void DMA1_Channel3_IRQHandler() { +void DMA1_Channel3_IRQHandler(void) { furi_hal_interrupt_call(FuriHalInterruptIdDma1Ch3); } -void DMA1_Channel4_IRQHandler() { +void DMA1_Channel4_IRQHandler(void) { furi_hal_interrupt_call(FuriHalInterruptIdDma1Ch4); } -void DMA1_Channel5_IRQHandler() { +void DMA1_Channel5_IRQHandler(void) { furi_hal_interrupt_call(FuriHalInterruptIdDma1Ch5); } -void DMA1_Channel6_IRQHandler() { +void DMA1_Channel6_IRQHandler(void) { furi_hal_interrupt_call(FuriHalInterruptIdDma1Ch6); } -void DMA1_Channel7_IRQHandler() { +void DMA1_Channel7_IRQHandler(void) { furi_hal_interrupt_call(FuriHalInterruptIdDma1Ch7); } /* DMA 2 */ -void DMA2_Channel1_IRQHandler() { +void DMA2_Channel1_IRQHandler(void) { furi_hal_interrupt_call(FuriHalInterruptIdDma2Ch1); } -void DMA2_Channel2_IRQHandler() { +void DMA2_Channel2_IRQHandler(void) { furi_hal_interrupt_call(FuriHalInterruptIdDma2Ch2); } -void DMA2_Channel3_IRQHandler() { +void DMA2_Channel3_IRQHandler(void) { furi_hal_interrupt_call(FuriHalInterruptIdDma2Ch3); } -void DMA2_Channel4_IRQHandler() { +void DMA2_Channel4_IRQHandler(void) { furi_hal_interrupt_call(FuriHalInterruptIdDma2Ch4); } -void DMA2_Channel5_IRQHandler() { +void DMA2_Channel5_IRQHandler(void) { furi_hal_interrupt_call(FuriHalInterruptIdDma2Ch5); } -void DMA2_Channel6_IRQHandler() { +void DMA2_Channel6_IRQHandler(void) { furi_hal_interrupt_call(FuriHalInterruptIdDma2Ch6); } -void DMA2_Channel7_IRQHandler() { +void DMA2_Channel7_IRQHandler(void) { furi_hal_interrupt_call(FuriHalInterruptIdDma2Ch7); } -void HSEM_IRQHandler() { +void HSEM_IRQHandler(void) { furi_hal_interrupt_call(FuriHalInterruptIdHsem); } @@ -256,11 +256,11 @@ void TAMP_STAMP_LSECSS_IRQHandler(void) { } } -void RCC_IRQHandler() { +void RCC_IRQHandler(void) { furi_hal_interrupt_call(FuriHalInterruptIdRcc); } -void NMI_Handler() { +void NMI_Handler(void) { if(LL_RCC_IsActiveFlag_HSECSS()) { LL_RCC_ClearFlag_HSECSS(); FURI_LOG_E(TAG, "HSE CSS fired: resetting system"); @@ -268,11 +268,11 @@ void NMI_Handler() { } } -void HardFault_Handler() { +void HardFault_Handler(void) { furi_crash("HardFault"); } -void MemManage_Handler() { +void MemManage_Handler(void) { if(FURI_BIT(SCB->CFSR, SCB_CFSR_MMARVALID_Pos)) { uint32_t memfault_address = SCB->MMFAR; if(memfault_address < (1024 * 1024)) { @@ -290,15 +290,15 @@ void MemManage_Handler() { furi_crash("MemManage"); } -void BusFault_Handler() { +void BusFault_Handler(void) { furi_crash("BusFault"); } -void UsageFault_Handler() { +void UsageFault_Handler(void) { furi_crash("UsageFault"); } -void DebugMon_Handler() { +void DebugMon_Handler(void) { } #include "usbd_core.h" @@ -308,36 +308,36 @@ extern usbd_device udev; extern void HW_IPCC_Tx_Handler(); extern void HW_IPCC_Rx_Handler(); -void SysTick_Handler() { +void SysTick_Handler(void) { furi_hal_os_tick(); } -void USB_LP_IRQHandler() { +void USB_LP_IRQHandler(void) { #ifndef FURI_RAM_EXEC usbd_poll(&udev); #endif } -void USB_HP_IRQHandler() { +void USB_HP_IRQHandler(void) { } -void IPCC_C1_TX_IRQHandler() { +void IPCC_C1_TX_IRQHandler(void) { HW_IPCC_Tx_Handler(); } -void IPCC_C1_RX_IRQHandler() { +void IPCC_C1_RX_IRQHandler(void) { HW_IPCC_Rx_Handler(); } -void FPU_IRQHandler() { +void FPU_IRQHandler(void) { furi_crash("FpuFault"); } -void LPTIM1_IRQHandler() { +void LPTIM1_IRQHandler(void) { furi_hal_interrupt_call(FuriHalInterruptIdLpTim1); } -void LPTIM2_IRQHandler() { +void LPTIM2_IRQHandler(void) { furi_hal_interrupt_call(FuriHalInterruptIdLpTim2); } diff --git a/targets/f7/furi_hal/furi_hal_interrupt.h b/targets/f7/furi_hal/furi_hal_interrupt.h index 03d7850f9..74bb768ce 100644 --- a/targets/f7/furi_hal/furi_hal_interrupt.h +++ b/targets/f7/furi_hal/furi_hal_interrupt.h @@ -81,7 +81,7 @@ typedef enum { } FuriHalInterruptPriority; /** Initialize interrupt subsystem */ -void furi_hal_interrupt_init(); +void furi_hal_interrupt_init(void); /** Set ISR and enable interrupt with default priority * diff --git a/targets/f7/furi_hal/furi_hal_light.c b/targets/f7/furi_hal/furi_hal_light.c index 83e1603b7..b44342b52 100644 --- a/targets/f7/furi_hal/furi_hal_light.c +++ b/targets/f7/furi_hal/furi_hal_light.c @@ -4,12 +4,12 @@ #include #include -#define LED_CURRENT_RED 50 -#define LED_CURRENT_GREEN 50 -#define LED_CURRENT_BLUE 50 -#define LED_CURRENT_WHITE 150 +#define LED_CURRENT_RED (50u) +#define LED_CURRENT_GREEN (50u) +#define LED_CURRENT_BLUE (50u) +#define LED_CURRENT_WHITE (150u) -void furi_hal_light_init() { +void furi_hal_light_init(void) { furi_hal_i2c_acquire(&furi_hal_i2c_handle_power); lp5562_reset(&furi_hal_i2c_handle_power); @@ -64,7 +64,7 @@ void furi_hal_light_blink_start(Light light, uint8_t brightness, uint16_t on_tim furi_hal_i2c_release(&furi_hal_i2c_handle_power); } -void furi_hal_light_blink_stop() { +void furi_hal_light_blink_stop(void) { furi_hal_i2c_acquire(&furi_hal_i2c_handle_power); lp5562_set_channel_src( &furi_hal_i2c_handle_power, diff --git a/targets/f7/furi_hal/furi_hal_memory.c b/targets/f7/furi_hal/furi_hal_memory.c index 0d60a3af5..780a9d743 100644 --- a/targets/f7/furi_hal/furi_hal_memory.c +++ b/targets/f7/furi_hal/furi_hal_memory.c @@ -25,7 +25,7 @@ extern const void __sram2a_start__; extern const void __sram2a_free__; extern const void __sram2b_start__; -void furi_hal_memory_init() { +void furi_hal_memory_init(void) { if(furi_hal_rtc_get_boot_mode() != FuriHalRtcBootModeNormal) { return; } @@ -106,7 +106,7 @@ void* furi_hal_memory_alloc(size_t size) { return allocated_memory; } -size_t furi_hal_memory_get_free() { +size_t furi_hal_memory_get_free(void) { if(furi_hal_memory == NULL) return 0; size_t free = 0; @@ -116,7 +116,7 @@ size_t furi_hal_memory_get_free() { return free; } -size_t furi_hal_memory_max_pool_block() { +size_t furi_hal_memory_max_pool_block(void) { if(furi_hal_memory == NULL) return 0; size_t max = 0; diff --git a/targets/f7/furi_hal/furi_hal_mpu.c b/targets/f7/furi_hal/furi_hal_mpu.c index ea6cd55be..16724c975 100644 --- a/targets/f7/furi_hal/furi_hal_mpu.c +++ b/targets/f7/furi_hal/furi_hal_mpu.c @@ -7,18 +7,18 @@ #define FURI_HAL_MPU_STACK_PROTECT_REGION FuriHalMPURegionSize32B -void furi_hal_mpu_init() { +void furi_hal_mpu_init(void) { furi_hal_mpu_enable(); // NULL pointer dereference protection furi_hal_mpu_protect_no_access(FuriHalMpuRegionNULL, 0x00, FuriHalMPURegionSize1MB); } -void furi_hal_mpu_enable() { +void furi_hal_mpu_enable(void) { LL_MPU_Enable(LL_MPU_CTRL_PRIVILEGED_DEFAULT); } -void furi_hal_mpu_disable() { +void furi_hal_mpu_disable(void) { LL_MPU_Disable(); } diff --git a/targets/f7/furi_hal/furi_hal_nfc.c b/targets/f7/furi_hal/furi_hal_nfc.c index e8a1033d5..550f1b16e 100644 --- a/targets/f7/furi_hal/furi_hal_nfc.c +++ b/targets/f7/furi_hal/furi_hal_nfc.c @@ -46,7 +46,7 @@ static FuriHalNfcError furi_hal_nfc_turn_on_osc(FuriHalSpiBusHandle* handle) { return error; } -FuriHalNfcError furi_hal_nfc_is_hal_ready() { +FuriHalNfcError furi_hal_nfc_is_hal_ready(void) { FuriHalNfcError error = FuriHalNfcErrorNone; do { @@ -68,8 +68,8 @@ FuriHalNfcError furi_hal_nfc_is_hal_ready() { return error; } -FuriHalNfcError furi_hal_nfc_init() { - furi_assert(furi_hal_nfc.mutex == NULL); +FuriHalNfcError furi_hal_nfc_init(void) { + furi_check(furi_hal_nfc.mutex == NULL); furi_hal_nfc.mutex = furi_mutex_alloc(FuriMutexTypeNormal); FuriHalNfcError error = FuriHalNfcErrorNone; @@ -252,11 +252,11 @@ FuriHalNfcError furi_hal_nfc_init() { return error; } -static bool furi_hal_nfc_is_mine() { +static bool furi_hal_nfc_is_mine(void) { return (furi_mutex_get_owner(furi_hal_nfc.mutex) == furi_thread_get_current_id()); } -FuriHalNfcError furi_hal_nfc_acquire() { +FuriHalNfcError furi_hal_nfc_acquire(void) { furi_check(furi_hal_nfc.mutex); furi_hal_spi_acquire(&furi_hal_spi_bus_handle_nfc); @@ -270,7 +270,7 @@ FuriHalNfcError furi_hal_nfc_acquire() { return error; } -FuriHalNfcError furi_hal_nfc_release() { +FuriHalNfcError furi_hal_nfc_release(void) { furi_check(furi_hal_nfc.mutex); furi_check(furi_hal_nfc_is_mine()); furi_check(furi_mutex_release(furi_hal_nfc.mutex) == FuriStatusOk); @@ -280,7 +280,7 @@ FuriHalNfcError furi_hal_nfc_release() { return FuriHalNfcErrorNone; } -FuriHalNfcError furi_hal_nfc_low_power_mode_start() { +FuriHalNfcError furi_hal_nfc_low_power_mode_start(void) { FuriHalNfcError error = FuriHalNfcErrorNone; FuriHalSpiBusHandle* handle = &furi_hal_spi_bus_handle_nfc; @@ -298,7 +298,7 @@ FuriHalNfcError furi_hal_nfc_low_power_mode_start() { return error; } -FuriHalNfcError furi_hal_nfc_low_power_mode_stop() { +FuriHalNfcError furi_hal_nfc_low_power_mode_stop(void) { FuriHalNfcError error = FuriHalNfcErrorNone; FuriHalSpiBusHandle* handle = &furi_hal_spi_bus_handle_nfc; @@ -346,8 +346,8 @@ static FuriHalNfcError furi_hal_nfc_listener_init_common(FuriHalSpiBusHandle* ha } FuriHalNfcError furi_hal_nfc_set_mode(FuriHalNfcMode mode, FuriHalNfcTech tech) { - furi_assert(mode < FuriHalNfcModeNum); - furi_assert(tech < FuriHalNfcTechNum); + furi_check(mode < FuriHalNfcModeNum); + furi_check(tech < FuriHalNfcTechNum); FuriHalSpiBusHandle* handle = &furi_hal_spi_bus_handle_nfc; @@ -373,7 +373,7 @@ FuriHalNfcError furi_hal_nfc_set_mode(FuriHalNfcMode mode, FuriHalNfcTech tech) return error; } -FuriHalNfcError furi_hal_nfc_reset_mode() { +FuriHalNfcError furi_hal_nfc_reset_mode(void) { FuriHalNfcError error = FuriHalNfcErrorNone; FuriHalSpiBusHandle* handle = &furi_hal_spi_bus_handle_nfc; @@ -413,7 +413,7 @@ FuriHalNfcError furi_hal_nfc_reset_mode() { return error; } -FuriHalNfcError furi_hal_nfc_field_detect_start() { +FuriHalNfcError furi_hal_nfc_field_detect_start(void) { FuriHalNfcError error = FuriHalNfcErrorNone; FuriHalSpiBusHandle* handle = &furi_hal_spi_bus_handle_nfc; @@ -427,7 +427,7 @@ FuriHalNfcError furi_hal_nfc_field_detect_start() { return error; } -FuriHalNfcError furi_hal_nfc_field_detect_stop() { +FuriHalNfcError furi_hal_nfc_field_detect_stop(void) { FuriHalNfcError error = FuriHalNfcErrorNone; FuriHalSpiBusHandle* handle = &furi_hal_spi_bus_handle_nfc; @@ -439,7 +439,7 @@ FuriHalNfcError furi_hal_nfc_field_detect_stop() { return error; } -bool furi_hal_nfc_field_is_present() { +bool furi_hal_nfc_field_is_present(void) { bool is_present = false; FuriHalSpiBusHandle* handle = &furi_hal_spi_bus_handle_nfc; @@ -454,7 +454,7 @@ bool furi_hal_nfc_field_is_present() { return is_present; } -FuriHalNfcError furi_hal_nfc_poller_field_on() { +FuriHalNfcError furi_hal_nfc_poller_field_on(void) { FuriHalNfcError error = FuriHalNfcErrorNone; FuriHalSpiBusHandle* handle = &furi_hal_spi_bus_handle_nfc; @@ -479,7 +479,7 @@ FuriHalNfcError furi_hal_nfc_poller_tx_common( FuriHalSpiBusHandle* handle, const uint8_t* tx_data, size_t tx_bits) { - furi_assert(tx_data); + furi_check(tx_data); FuriHalNfcError err = FuriHalNfcErrorNone; @@ -521,40 +521,40 @@ FuriHalNfcError furi_hal_nfc_common_fifo_tx( } FuriHalNfcError furi_hal_nfc_poller_tx(const uint8_t* tx_data, size_t tx_bits) { - furi_assert(furi_hal_nfc.mode == FuriHalNfcModePoller); - furi_assert(furi_hal_nfc.tech < FuriHalNfcTechNum); + furi_check(furi_hal_nfc.mode == FuriHalNfcModePoller); + furi_check(furi_hal_nfc.tech < FuriHalNfcTechNum); FuriHalSpiBusHandle* handle = &furi_hal_spi_bus_handle_nfc; return furi_hal_nfc_tech[furi_hal_nfc.tech]->poller.tx(handle, tx_data, tx_bits); } FuriHalNfcError furi_hal_nfc_poller_rx(uint8_t* rx_data, size_t rx_data_size, size_t* rx_bits) { - furi_assert(furi_hal_nfc.mode == FuriHalNfcModePoller); - furi_assert(furi_hal_nfc.tech < FuriHalNfcTechNum); + furi_check(furi_hal_nfc.mode == FuriHalNfcModePoller); + furi_check(furi_hal_nfc.tech < FuriHalNfcTechNum); FuriHalSpiBusHandle* handle = &furi_hal_spi_bus_handle_nfc; return furi_hal_nfc_tech[furi_hal_nfc.tech]->poller.rx(handle, rx_data, rx_data_size, rx_bits); } FuriHalNfcEvent furi_hal_nfc_poller_wait_event(uint32_t timeout_ms) { - furi_assert(furi_hal_nfc.mode == FuriHalNfcModePoller); - furi_assert(furi_hal_nfc.tech < FuriHalNfcTechNum); + furi_check(furi_hal_nfc.mode == FuriHalNfcModePoller); + furi_check(furi_hal_nfc.tech < FuriHalNfcTechNum); return furi_hal_nfc_tech[furi_hal_nfc.tech]->poller.wait_event(timeout_ms); } FuriHalNfcEvent furi_hal_nfc_listener_wait_event(uint32_t timeout_ms) { - furi_assert(furi_hal_nfc.mode == FuriHalNfcModeListener); - furi_assert(furi_hal_nfc.tech < FuriHalNfcTechNum); + furi_check(furi_hal_nfc.mode == FuriHalNfcModeListener); + furi_check(furi_hal_nfc.tech < FuriHalNfcTechNum); return furi_hal_nfc_tech[furi_hal_nfc.tech]->listener.wait_event(timeout_ms); } FuriHalNfcError furi_hal_nfc_listener_tx(const uint8_t* tx_data, size_t tx_bits) { - furi_assert(tx_data); + furi_check(tx_data); - furi_assert(furi_hal_nfc.mode == FuriHalNfcModeListener); - furi_assert(furi_hal_nfc.tech < FuriHalNfcTechNum); + furi_check(furi_hal_nfc.mode == FuriHalNfcModeListener); + furi_check(furi_hal_nfc.tech < FuriHalNfcTechNum); FuriHalSpiBusHandle* handle = &furi_hal_spi_bus_handle_nfc; return furi_hal_nfc_tech[furi_hal_nfc.tech]->listener.tx(handle, tx_data, tx_bits); @@ -575,18 +575,18 @@ FuriHalNfcError furi_hal_nfc_common_fifo_rx( } FuriHalNfcError furi_hal_nfc_listener_rx(uint8_t* rx_data, size_t rx_data_size, size_t* rx_bits) { - furi_assert(rx_data); - furi_assert(rx_bits); + furi_check(rx_data); + furi_check(rx_bits); - furi_assert(furi_hal_nfc.mode == FuriHalNfcModeListener); - furi_assert(furi_hal_nfc.tech < FuriHalNfcTechNum); + furi_check(furi_hal_nfc.mode == FuriHalNfcModeListener); + furi_check(furi_hal_nfc.tech < FuriHalNfcTechNum); FuriHalSpiBusHandle* handle = &furi_hal_spi_bus_handle_nfc; return furi_hal_nfc_tech[furi_hal_nfc.tech]->listener.rx( handle, rx_data, rx_data_size, rx_bits); } -FuriHalNfcError furi_hal_nfc_trx_reset() { +FuriHalNfcError furi_hal_nfc_trx_reset(void) { FuriHalSpiBusHandle* handle = &furi_hal_spi_bus_handle_nfc; st25r3916_direct_cmd(handle, ST25R3916_CMD_STOP); @@ -594,25 +594,25 @@ FuriHalNfcError furi_hal_nfc_trx_reset() { return FuriHalNfcErrorNone; } -FuriHalNfcError furi_hal_nfc_listener_sleep() { - furi_assert(furi_hal_nfc.mode == FuriHalNfcModeListener); - furi_assert(furi_hal_nfc.tech < FuriHalNfcTechNum); +FuriHalNfcError furi_hal_nfc_listener_sleep(void) { + furi_check(furi_hal_nfc.mode == FuriHalNfcModeListener); + furi_check(furi_hal_nfc.tech < FuriHalNfcTechNum); FuriHalSpiBusHandle* handle = &furi_hal_spi_bus_handle_nfc; return furi_hal_nfc_tech[furi_hal_nfc.tech]->listener.sleep(handle); } -FuriHalNfcError furi_hal_nfc_listener_idle() { - furi_assert(furi_hal_nfc.mode == FuriHalNfcModeListener); - furi_assert(furi_hal_nfc.tech < FuriHalNfcTechNum); +FuriHalNfcError furi_hal_nfc_listener_idle(void) { + furi_check(furi_hal_nfc.mode == FuriHalNfcModeListener); + furi_check(furi_hal_nfc.tech < FuriHalNfcTechNum); FuriHalSpiBusHandle* handle = &furi_hal_spi_bus_handle_nfc; return furi_hal_nfc_tech[furi_hal_nfc.tech]->listener.idle(handle); } -FuriHalNfcError furi_hal_nfc_listener_enable_rx() { +FuriHalNfcError furi_hal_nfc_listener_enable_rx(void) { FuriHalSpiBusHandle* handle = &furi_hal_spi_bus_handle_nfc; st25r3916_direct_cmd(handle, ST25R3916_CMD_UNMASK_RECEIVE_DATA); diff --git a/targets/f7/furi_hal/furi_hal_nfc_event.c b/targets/f7/furi_hal/furi_hal_nfc_event.c index 266b606fd..e434e6a35 100644 --- a/targets/f7/furi_hal/furi_hal_nfc_event.c +++ b/targets/f7/furi_hal/furi_hal_nfc_event.c @@ -2,12 +2,12 @@ FuriHalNfcEventInternal* furi_hal_nfc_event = NULL; -void furi_hal_nfc_event_init() { +void furi_hal_nfc_event_init(void) { furi_hal_nfc_event = malloc(sizeof(FuriHalNfcEventInternal)); } -FuriHalNfcError furi_hal_nfc_event_start() { - furi_assert(furi_hal_nfc_event); +FuriHalNfcError furi_hal_nfc_event_start(void) { + furi_check(furi_hal_nfc_event); furi_hal_nfc_event->thread = furi_thread_get_current_id(); furi_thread_flags_clear(FURI_HAL_NFC_EVENT_INTERNAL_ALL); @@ -15,8 +15,8 @@ FuriHalNfcError furi_hal_nfc_event_start() { return FuriHalNfcErrorNone; } -FuriHalNfcError furi_hal_nfc_event_stop() { - furi_assert(furi_hal_nfc_event); +FuriHalNfcError furi_hal_nfc_event_stop(void) { + furi_check(furi_hal_nfc_event); furi_hal_nfc_event->thread = NULL; @@ -24,21 +24,21 @@ FuriHalNfcError furi_hal_nfc_event_stop() { } void furi_hal_nfc_event_set(FuriHalNfcEventInternalType event) { - furi_assert(furi_hal_nfc_event); + furi_check(furi_hal_nfc_event); if(furi_hal_nfc_event->thread) { furi_thread_flags_set(furi_hal_nfc_event->thread, event); } } -FuriHalNfcError furi_hal_nfc_abort() { +FuriHalNfcError furi_hal_nfc_abort(void) { furi_hal_nfc_event_set(FuriHalNfcEventInternalTypeAbort); return FuriHalNfcErrorNone; } FuriHalNfcEvent furi_hal_nfc_wait_event_common(uint32_t timeout_ms) { - furi_assert(furi_hal_nfc_event); - furi_assert(furi_hal_nfc_event->thread); + furi_check(furi_hal_nfc_event); + furi_check(furi_hal_nfc_event->thread); FuriHalNfcEvent event = 0; uint32_t event_timeout = timeout_ms == FURI_HAL_NFC_EVENT_WAIT_FOREVER ? FuriWaitForever : @@ -101,8 +101,8 @@ bool furi_hal_nfc_event_wait_for_specific_irq( FuriHalSpiBusHandle* handle, uint32_t mask, uint32_t timeout_ms) { - furi_assert(furi_hal_nfc_event); - furi_assert(furi_hal_nfc_event->thread); + furi_check(furi_hal_nfc_event); + furi_check(furi_hal_nfc_event->thread); bool irq_received = false; uint32_t event_flag = diff --git a/targets/f7/furi_hal/furi_hal_nfc_felica.c b/targets/f7/furi_hal/furi_hal_nfc_felica.c index f762a0ed3..82239fbc1 100644 --- a/targets/f7/furi_hal/furi_hal_nfc_felica.c +++ b/targets/f7/furi_hal/furi_hal_nfc_felica.c @@ -163,6 +163,9 @@ FuriHalNfcError furi_hal_nfc_felica_listener_set_sensf_res_data( const uint8_t idm_len, const uint8_t* pmm, const uint8_t pmm_len) { + furi_check(idm); + furi_check(pmm); + FuriHalSpiBusHandle* handle = &furi_hal_spi_bus_handle_nfc; // Write PT Memory uint8_t pt_memory[19] = {}; diff --git a/targets/f7/furi_hal/furi_hal_nfc_i.h b/targets/f7/furi_hal/furi_hal_nfc_i.h index 53a25644d..084196451 100644 --- a/targets/f7/furi_hal/furi_hal_nfc_i.h +++ b/targets/f7/furi_hal/furi_hal_nfc_i.h @@ -69,7 +69,7 @@ extern FuriHalNfc furi_hal_nfc; /** * @brief Initialise NFC HAL event system. */ -void furi_hal_nfc_event_init(); +void furi_hal_nfc_event_init(void); /** * @brief Forcibly emit (a) particular internal event(s). @@ -81,22 +81,22 @@ void furi_hal_nfc_event_set(FuriHalNfcEventInternalType event); /** * @brief Initialise GPIO to generate an interrupt from the NFC hardware. */ -void furi_hal_nfc_init_gpio_isr(); +void furi_hal_nfc_init_gpio_isr(void); /** * @brief Disable interrupts from the NFC hardware. */ -void furi_hal_nfc_deinit_gpio_isr(); +void furi_hal_nfc_deinit_gpio_isr(void); /** * @brief Initialise all NFC timers. */ -void furi_hal_nfc_timers_init(); +void furi_hal_nfc_timers_init(void); /** * @brief Disable all NFC timers. */ -void furi_hal_nfc_timers_deinit(); +void furi_hal_nfc_timers_deinit(void); /** * @brief Get the interrupt bitmask from the NFC hardware. diff --git a/targets/f7/furi_hal/furi_hal_nfc_irq.c b/targets/f7/furi_hal/furi_hal_nfc_irq.c index edacc52bf..90373955f 100644 --- a/targets/f7/furi_hal/furi_hal_nfc_irq.c +++ b/targets/f7/furi_hal/furi_hal_nfc_irq.c @@ -16,14 +16,14 @@ uint32_t furi_hal_nfc_get_irq(FuriHalSpiBusHandle* handle) { return irq; } -void furi_hal_nfc_init_gpio_isr() { +void furi_hal_nfc_init_gpio_isr(void) { furi_hal_gpio_init( &gpio_nfc_irq_rfid_pull, GpioModeInterruptRise, GpioPullDown, GpioSpeedVeryHigh); furi_hal_gpio_add_int_callback(&gpio_nfc_irq_rfid_pull, furi_hal_nfc_int_callback, NULL); furi_hal_gpio_enable_int_callback(&gpio_nfc_irq_rfid_pull); } -void furi_hal_nfc_deinit_gpio_isr() { +void furi_hal_nfc_deinit_gpio_isr(void) { furi_hal_gpio_remove_int_callback(&gpio_nfc_irq_rfid_pull); furi_hal_gpio_init(&gpio_nfc_irq_rfid_pull, GpioModeAnalog, GpioPullNo, GpioSpeedLow); } diff --git a/targets/f7/furi_hal/furi_hal_nfc_iso14443a.c b/targets/f7/furi_hal/furi_hal_nfc_iso14443a.c index 278ecf384..1ef23dfa4 100644 --- a/targets/f7/furi_hal/furi_hal_nfc_iso14443a.c +++ b/targets/f7/furi_hal/furi_hal_nfc_iso14443a.c @@ -182,7 +182,7 @@ FuriHalNfcError FuriHalNfcError furi_hal_nfc_iso14443a_poller_tx_custom_parity(const uint8_t* tx_data, size_t tx_bits) { - furi_assert(tx_data); + furi_check(tx_data); FuriHalNfcError err = FuriHalNfcErrorNone; FuriHalSpiBusHandle* handle = &furi_hal_spi_bus_handle_nfc; @@ -215,10 +215,9 @@ FuriHalNfcError furi_hal_nfc_iso14443a_listener_set_col_res_data( uint8_t uid_len, uint8_t* atqa, uint8_t sak) { - furi_assert(uid); - furi_assert(atqa); - UNUSED(uid_len); - UNUSED(sak); + furi_check(uid); + furi_check(atqa); + FuriHalNfcError error = FuriHalNfcErrorNone; FuriHalSpiBusHandle* handle = &furi_hal_spi_bus_handle_nfc; @@ -280,10 +279,10 @@ FuriHalNfcError furi_hal_nfc_iso14443a_listener_tx_custom_parity( const uint8_t* tx_data, const uint8_t* tx_parity, size_t tx_bits) { - furi_assert(tx_data); - furi_assert(tx_parity); + furi_check(tx_data); + furi_check(tx_parity); - furi_assert(iso14443_3a_signal); + furi_check(iso14443_3a_signal); FuriHalSpiBusHandle* handle = &furi_hal_spi_bus_handle_nfc; diff --git a/targets/f7/furi_hal/furi_hal_nfc_iso15693.c b/targets/f7/furi_hal/furi_hal_nfc_iso15693.c index cc936644b..9ab3532f9 100644 --- a/targets/f7/furi_hal/furi_hal_nfc_iso15693.c +++ b/targets/f7/furi_hal/furi_hal_nfc_iso15693.c @@ -43,7 +43,7 @@ typedef struct { static FuriHalNfcIso15693Listener* furi_hal_nfc_iso15693_listener = NULL; static FuriHalNfcIso15693Poller* furi_hal_nfc_iso15693_poller = NULL; -static FuriHalNfcIso15693Listener* furi_hal_nfc_iso15693_listener_alloc() { +static FuriHalNfcIso15693Listener* furi_hal_nfc_iso15693_listener_alloc(void) { FuriHalNfcIso15693Listener* instance = malloc(sizeof(FuriHalNfcIso15693Listener)); instance->signal = iso15693_signal_alloc(&gpio_spi_r_mosi); @@ -54,7 +54,7 @@ static FuriHalNfcIso15693Listener* furi_hal_nfc_iso15693_listener_alloc() { } static void furi_hal_nfc_iso15693_listener_free(FuriHalNfcIso15693Listener* instance) { - furi_assert(instance); + furi_check(instance); iso15693_signal_free(instance->signal); iso15693_parser_free(instance->parser); @@ -62,14 +62,14 @@ static void furi_hal_nfc_iso15693_listener_free(FuriHalNfcIso15693Listener* inst free(instance); } -static FuriHalNfcIso15693Poller* furi_hal_nfc_iso15693_poller_alloc() { +static FuriHalNfcIso15693Poller* furi_hal_nfc_iso15693_poller_alloc(void) { FuriHalNfcIso15693Poller* instance = malloc(sizeof(FuriHalNfcIso15693Poller)); return instance; } static void furi_hal_nfc_iso15693_poller_free(FuriHalNfcIso15693Poller* instance) { - furi_assert(instance); + furi_check(instance); free(instance); } @@ -113,7 +113,7 @@ static FuriHalNfcError furi_hal_nfc_iso15693_common_init(FuriHalSpiBusHandle* ha } static FuriHalNfcError furi_hal_nfc_iso15693_poller_init(FuriHalSpiBusHandle* handle) { - furi_assert(furi_hal_nfc_iso15693_poller == NULL); + furi_check(furi_hal_nfc_iso15693_poller == NULL); furi_hal_nfc_iso15693_poller = furi_hal_nfc_iso15693_poller_alloc(); @@ -143,7 +143,7 @@ static FuriHalNfcError furi_hal_nfc_iso15693_poller_init(FuriHalSpiBusHandle* ha static FuriHalNfcError furi_hal_nfc_iso15693_poller_deinit(FuriHalSpiBusHandle* handle) { UNUSED(handle); - furi_assert(furi_hal_nfc_iso15693_poller); + furi_check(furi_hal_nfc_iso15693_poller); furi_hal_nfc_iso15693_poller_free(furi_hal_nfc_iso15693_poller); furi_hal_nfc_iso15693_poller = NULL; @@ -159,7 +159,7 @@ static void iso15693_3_poller_encode_frame( size_t* frame_buf_bits) { static const uint8_t bit_patterns_1_out_of_4[] = {0x02, 0x08, 0x20, 0x80}; size_t frame_buf_size_calc = (tx_bits / 2) + 2; - furi_assert(frame_buf_size >= frame_buf_size_calc); + furi_check(frame_buf_size >= frame_buf_size_calc); // Add SOF 1 out of 4 frame_buf[0] = 0x21; @@ -300,7 +300,7 @@ static void furi_hal_nfc_iso15693_listener_transparent_mode_exit(FuriHalSpiBusHa } static FuriHalNfcError furi_hal_nfc_iso15693_listener_init(FuriHalSpiBusHandle* handle) { - furi_assert(furi_hal_nfc_iso15693_listener == NULL); + furi_check(furi_hal_nfc_iso15693_listener == NULL); furi_hal_nfc_iso15693_listener = furi_hal_nfc_iso15693_listener_alloc(); @@ -329,7 +329,7 @@ static FuriHalNfcError furi_hal_nfc_iso15693_listener_init(FuriHalSpiBusHandle* } static FuriHalNfcError furi_hal_nfc_iso15693_listener_deinit(FuriHalSpiBusHandle* handle) { - furi_assert(furi_hal_nfc_iso15693_listener); + furi_check(furi_hal_nfc_iso15693_listener); furi_hal_nfc_iso15693_listener_transparent_mode_exit(handle); @@ -348,7 +348,7 @@ static FuriHalNfcError } static void furi_hal_nfc_iso15693_parser_callback(Iso15693ParserEvent event, void* context) { - furi_assert(context); + furi_check(context); if(event == Iso15693ParserEventDataReceived) { FuriThreadId thread_id = context; @@ -391,7 +391,7 @@ static FuriHalNfcError furi_hal_nfc_iso15693_listener_tx( const uint8_t* tx_data, size_t tx_bits) { UNUSED(handle); - furi_assert(furi_hal_nfc_iso15693_listener); + furi_check(furi_hal_nfc_iso15693_listener); FuriHalNfcError error = FuriHalNfcErrorNone; @@ -400,7 +400,7 @@ static FuriHalNfcError furi_hal_nfc_iso15693_listener_tx( return error; } -FuriHalNfcError furi_hal_nfc_iso15693_listener_tx_sof() { +FuriHalNfcError furi_hal_nfc_iso15693_listener_tx_sof(void) { iso15693_signal_tx_sof(furi_hal_nfc_iso15693_listener->signal, Iso15693SignalDataRateHi); return FuriHalNfcErrorNone; @@ -411,7 +411,7 @@ static FuriHalNfcError furi_hal_nfc_iso15693_listener_rx( uint8_t* rx_data, size_t rx_data_size, size_t* rx_bits) { - furi_assert(furi_hal_nfc_iso15693_listener); + furi_check(furi_hal_nfc_iso15693_listener); UNUSED(handle); if(rx_data_size < diff --git a/targets/f7/furi_hal/furi_hal_nfc_timer.c b/targets/f7/furi_hal/furi_hal_nfc_timer.c index c9de9dfe8..dfc96bf1a 100644 --- a/targets/f7/furi_hal/furi_hal_nfc_timer.c +++ b/targets/f7/furi_hal/furi_hal_nfc_timer.c @@ -192,13 +192,13 @@ static void furi_hal_nfc_timer_stop(FuriHalNfcTimer timer) { #endif } -void furi_hal_nfc_timers_init() { +void furi_hal_nfc_timers_init(void) { for(size_t i = 0; i < FuriHalNfcTimerCount; i++) { furi_hal_nfc_timer_init(i); } } -void furi_hal_nfc_timers_deinit() { +void furi_hal_nfc_timers_deinit(void) { for(size_t i = 0; i < FuriHalNfcTimerCount; i++) { furi_hal_nfc_timer_deinit(i); } @@ -208,7 +208,7 @@ void furi_hal_nfc_timer_fwt_start(uint32_t time_fc) { furi_hal_nfc_timer_start_fc(FuriHalNfcTimerFwt, time_fc); } -void furi_hal_nfc_timer_fwt_stop() { +void furi_hal_nfc_timer_fwt_stop(void) { furi_hal_nfc_timer_stop(FuriHalNfcTimerFwt); } @@ -220,10 +220,10 @@ void furi_hal_nfc_timer_block_tx_start_us(uint32_t time_us) { furi_hal_nfc_timer_start_us(FuriHalNfcTimerBlockTx, time_us); } -void furi_hal_nfc_timer_block_tx_stop() { +void furi_hal_nfc_timer_block_tx_stop(void) { furi_hal_nfc_timer_stop(FuriHalNfcTimerBlockTx); } -bool furi_hal_nfc_timer_block_tx_is_running() { +bool furi_hal_nfc_timer_block_tx_is_running(void) { return furi_hal_nfc_timer_is_running(FuriHalNfcTimerBlockTx); } diff --git a/targets/f7/furi_hal/furi_hal_os.c b/targets/f7/furi_hal/furi_hal_os.c index efa760b47..4738faa7c 100644 --- a/targets/f7/furi_hal/furi_hal_os.c +++ b/targets/f7/furi_hal/furi_hal_os.c @@ -45,7 +45,7 @@ #ifdef FURI_HAL_OS_DEBUG #include -void furi_hal_os_timer_callback() { +void furi_hal_os_timer_callback(void) { furi_hal_gpio_write( FURI_HAL_OS_DEBUG_SECOND_GPIO, !furi_hal_gpio_read(FURI_HAL_OS_DEBUG_SECOND_GPIO)); } @@ -55,7 +55,7 @@ extern void xPortSysTickHandler(); static volatile uint32_t furi_hal_os_skew; -void furi_hal_os_init() { +void furi_hal_os_init(void) { furi_hal_idle_timer_init(); #ifdef FURI_HAL_OS_DEBUG @@ -72,7 +72,7 @@ void furi_hal_os_init() { FURI_LOG_I(TAG, "Init OK"); } -void furi_hal_os_tick() { +void furi_hal_os_tick(void) { if(xTaskGetSchedulerState() != taskSCHEDULER_NOT_STARTED) { #ifdef FURI_HAL_OS_DEBUG furi_hal_gpio_write( @@ -84,7 +84,7 @@ void furi_hal_os_tick() { #ifdef FURI_HAL_OS_DEBUG // Find out the IRQ number while debugging -static void furi_hal_os_nvic_dbg_trap() { +static void furi_hal_os_nvic_dbg_trap(void) { for(int32_t i = WWDG_IRQn; i <= DMAMUX1_OVR_IRQn; i++) { if(NVIC_GetPendingIRQ(i)) { (void)i; @@ -107,7 +107,7 @@ static void furi_hal_os_exti_dbg_trap(uint32_t exti, uint32_t val) { } #endif -static inline bool furi_hal_os_is_pending_irq() { +static inline bool furi_hal_os_is_pending_irq(void) { if(FURI_HAL_OS_NVIC_IS_PENDING()) { #ifdef FURI_HAL_OS_DEBUG furi_hal_os_nvic_dbg_trap(); diff --git a/targets/f7/furi_hal/furi_hal_os.h b/targets/f7/furi_hal/furi_hal_os.h index e13b2c258..f14a3da15 100644 --- a/targets/f7/furi_hal/furi_hal_os.h +++ b/targets/f7/furi_hal/furi_hal_os.h @@ -9,11 +9,11 @@ extern "C" { /* Initialize OS helpers * Configure and start tick timer */ -void furi_hal_os_init(); +void furi_hal_os_init(void); /* Advance OS tick counter */ -void furi_hal_os_tick(); +void furi_hal_os_tick(void); #ifdef __cplusplus } diff --git a/targets/f7/furi_hal/furi_hal_power.c b/targets/f7/furi_hal/furi_hal_power.c index f03aea75f..ccbc521a6 100644 --- a/targets/f7/furi_hal/furi_hal_power.c +++ b/targets/f7/furi_hal/furi_hal_power.c @@ -51,7 +51,7 @@ static volatile FuriHalPower furi_hal_power = { extern const BQ27220DMData furi_hal_power_gauge_data_memory[]; -void furi_hal_power_init() { +void furi_hal_power_init(void) { #ifdef FURI_HAL_POWER_DEBUG furi_hal_gpio_init_simple(FURI_HAL_POWER_DEBUG_WFI_GPIO, GpioModeOutputPushPull); furi_hal_gpio_init_simple(FURI_HAL_POWER_DEBUG_STOP_GPIO, GpioModeOutputPushPull); @@ -107,7 +107,7 @@ void furi_hal_power_init() { FURI_LOG_I(TAG, "Init OK"); } -bool furi_hal_power_gauge_is_ok() { +bool furi_hal_power_gauge_is_ok(void) { bool ret = true; BatteryStatus battery_status; @@ -129,7 +129,7 @@ bool furi_hal_power_gauge_is_ok() { return ret; } -bool furi_hal_power_is_shutdown_requested() { +bool furi_hal_power_is_shutdown_requested(void) { bool ret = false; BatteryStatus battery_status; @@ -145,34 +145,34 @@ bool furi_hal_power_is_shutdown_requested() { return ret; } -uint16_t furi_hal_power_insomnia_level() { +uint16_t furi_hal_power_insomnia_level(void) { return furi_hal_power.insomnia; } -void furi_hal_power_insomnia_enter() { +void furi_hal_power_insomnia_enter(void) { FURI_CRITICAL_ENTER(); - furi_assert(furi_hal_power.insomnia < UINT8_MAX); + furi_check(furi_hal_power.insomnia < UINT8_MAX); furi_hal_power.insomnia++; FURI_CRITICAL_EXIT(); } -void furi_hal_power_insomnia_exit() { +void furi_hal_power_insomnia_exit(void) { FURI_CRITICAL_ENTER(); - furi_assert(furi_hal_power.insomnia > 0); + furi_check(furi_hal_power.insomnia > 0); furi_hal_power.insomnia--; FURI_CRITICAL_EXIT(); } -bool furi_hal_power_sleep_available() { +bool furi_hal_power_sleep_available(void) { return furi_hal_power.insomnia == 0; } -static inline bool furi_hal_power_deep_sleep_available() { +static inline bool furi_hal_power_deep_sleep_available(void) { return furi_hal_bt_is_alive() && !furi_hal_rtc_is_flag_set(FuriHalRtcFlagLegacySleep) && !furi_hal_debug_is_gdb_session_active(); } -static inline void furi_hal_power_light_sleep() { +static inline void furi_hal_power_light_sleep(void) { #ifdef FURI_HAL_POWER_DEBUG furi_hal_gpio_write(FURI_HAL_POWER_DEBUG_WFI_GPIO, 1); #endif @@ -182,17 +182,17 @@ static inline void furi_hal_power_light_sleep() { #endif } -static inline void furi_hal_power_suspend_aux_periphs() { +static inline void furi_hal_power_suspend_aux_periphs(void) { // Disable USART furi_hal_serial_control_suspend(); } -static inline void furi_hal_power_resume_aux_periphs() { +static inline void furi_hal_power_resume_aux_periphs(void) { // Re-enable USART furi_hal_serial_control_resume(); } -static inline void furi_hal_power_deep_sleep() { +static inline void furi_hal_power_deep_sleep(void) { furi_hal_power_suspend_aux_periphs(); if(!furi_hal_clock_switch_pll2hse()) { @@ -260,7 +260,7 @@ static inline void furi_hal_power_deep_sleep() { furi_hal_rtc_sync_shadow(); } -void furi_hal_power_sleep() { +void furi_hal_power_sleep(void) { if(furi_hal_power_deep_sleep_available()) { furi_hal_power_deep_sleep(); } else { @@ -268,35 +268,35 @@ void furi_hal_power_sleep() { } } -uint8_t furi_hal_power_get_pct() { +uint8_t furi_hal_power_get_pct(void) { furi_hal_i2c_acquire(&furi_hal_i2c_handle_power); uint8_t ret = bq27220_get_state_of_charge(&furi_hal_i2c_handle_power); furi_hal_i2c_release(&furi_hal_i2c_handle_power); return ret; } -uint8_t furi_hal_power_get_bat_health_pct() { +uint8_t furi_hal_power_get_bat_health_pct(void) { furi_hal_i2c_acquire(&furi_hal_i2c_handle_power); uint8_t ret = bq27220_get_state_of_health(&furi_hal_i2c_handle_power); furi_hal_i2c_release(&furi_hal_i2c_handle_power); return ret; } -bool furi_hal_power_is_charging() { +bool furi_hal_power_is_charging(void) { furi_hal_i2c_acquire(&furi_hal_i2c_handle_power); bool ret = bq25896_is_charging(&furi_hal_i2c_handle_power); furi_hal_i2c_release(&furi_hal_i2c_handle_power); return ret; } -bool furi_hal_power_is_charging_done() { +bool furi_hal_power_is_charging_done(void) { furi_hal_i2c_acquire(&furi_hal_i2c_handle_power); bool ret = bq25896_is_charging_done(&furi_hal_i2c_handle_power); furi_hal_i2c_release(&furi_hal_i2c_handle_power); return ret; } -void furi_hal_power_shutdown() { +void furi_hal_power_shutdown(void) { furi_hal_power_insomnia_enter(); furi_hal_bt_reinit(); @@ -328,7 +328,7 @@ void furi_hal_power_shutdown() { furi_crash("Insomniac core2"); } -void furi_hal_power_off() { +void furi_hal_power_off(void) { // Crutch: shutting down with ext 3V3 off is causing LSE to stop furi_hal_power_enable_external_3_3v(); furi_hal_vibro_on(true); @@ -340,11 +340,11 @@ void furi_hal_power_off() { furi_hal_vibro_on(false); } -void furi_hal_power_reset() { +FURI_NORETURN void furi_hal_power_reset(void) { NVIC_SystemReset(); } -bool furi_hal_power_enable_otg() { +bool furi_hal_power_enable_otg(void) { furi_hal_i2c_acquire(&furi_hal_i2c_handle_power); bq25896_set_boost_lim(&furi_hal_i2c_handle_power, BoostLim_2150); bq25896_enable_otg(&furi_hal_i2c_handle_power); @@ -355,20 +355,20 @@ bool furi_hal_power_enable_otg() { return ret; } -void furi_hal_power_disable_otg() { +void furi_hal_power_disable_otg(void) { furi_hal_i2c_acquire(&furi_hal_i2c_handle_power); bq25896_disable_otg(&furi_hal_i2c_handle_power); furi_hal_i2c_release(&furi_hal_i2c_handle_power); } -bool furi_hal_power_is_otg_enabled() { +bool furi_hal_power_is_otg_enabled(void) { furi_hal_i2c_acquire(&furi_hal_i2c_handle_power); bool ret = bq25896_is_otg_enabled(&furi_hal_i2c_handle_power); furi_hal_i2c_release(&furi_hal_i2c_handle_power); return ret; } -float furi_hal_power_get_battery_charge_voltage_limit() { +float furi_hal_power_get_battery_charge_voltage_limit(void) { furi_hal_i2c_acquire(&furi_hal_i2c_handle_power); float ret = (float)bq25896_get_vreg_voltage(&furi_hal_i2c_handle_power) / 1000.0f; furi_hal_i2c_release(&furi_hal_i2c_handle_power); @@ -382,35 +382,35 @@ void furi_hal_power_set_battery_charge_voltage_limit(float voltage) { furi_hal_i2c_release(&furi_hal_i2c_handle_power); } -bool furi_hal_power_check_otg_fault() { +bool furi_hal_power_check_otg_fault(void) { furi_hal_i2c_acquire(&furi_hal_i2c_handle_power); bool ret = bq25896_check_otg_fault(&furi_hal_i2c_handle_power); furi_hal_i2c_release(&furi_hal_i2c_handle_power); return ret; } -void furi_hal_power_check_otg_status() { +void furi_hal_power_check_otg_status(void) { furi_hal_i2c_acquire(&furi_hal_i2c_handle_power); if(bq25896_check_otg_fault(&furi_hal_i2c_handle_power)) bq25896_disable_otg(&furi_hal_i2c_handle_power); furi_hal_i2c_release(&furi_hal_i2c_handle_power); } -uint32_t furi_hal_power_get_battery_remaining_capacity() { +uint32_t furi_hal_power_get_battery_remaining_capacity(void) { furi_hal_i2c_acquire(&furi_hal_i2c_handle_power); uint32_t ret = bq27220_get_remaining_capacity(&furi_hal_i2c_handle_power); furi_hal_i2c_release(&furi_hal_i2c_handle_power); return ret; } -uint32_t furi_hal_power_get_battery_full_capacity() { +uint32_t furi_hal_power_get_battery_full_capacity(void) { furi_hal_i2c_acquire(&furi_hal_i2c_handle_power); uint32_t ret = bq27220_get_full_charge_capacity(&furi_hal_i2c_handle_power); furi_hal_i2c_release(&furi_hal_i2c_handle_power); return ret; } -uint32_t furi_hal_power_get_battery_design_capacity() { +uint32_t furi_hal_power_get_battery_design_capacity(void) { furi_hal_i2c_acquire(&furi_hal_i2c_handle_power); uint32_t ret = bq27220_get_design_capacity(&furi_hal_i2c_handle_power); furi_hal_i2c_release(&furi_hal_i2c_handle_power); @@ -425,6 +425,8 @@ float furi_hal_power_get_battery_voltage(FuriHalPowerIC ic) { ret = (float)bq25896_get_vbat_voltage(&furi_hal_i2c_handle_power) / 1000.0f; } else if(ic == FuriHalPowerICFuelGauge) { ret = (float)bq27220_get_voltage(&furi_hal_i2c_handle_power) / 1000.0f; + } else { + furi_crash(); } furi_hal_i2c_release(&furi_hal_i2c_handle_power); @@ -439,6 +441,8 @@ float furi_hal_power_get_battery_current(FuriHalPowerIC ic) { ret = (float)bq25896_get_vbat_current(&furi_hal_i2c_handle_power) / 1000.0f; } else if(ic == FuriHalPowerICFuelGauge) { ret = (float)bq27220_get_current(&furi_hal_i2c_handle_power) / 1000.0f; + } else { + furi_crash(); } furi_hal_i2c_release(&furi_hal_i2c_handle_power); @@ -466,22 +470,22 @@ float furi_hal_power_get_battery_temperature(FuriHalPowerIC ic) { return ret; } -float furi_hal_power_get_usb_voltage() { +float furi_hal_power_get_usb_voltage(void) { furi_hal_i2c_acquire(&furi_hal_i2c_handle_power); float ret = (float)bq25896_get_vbus_voltage(&furi_hal_i2c_handle_power) / 1000.0f; furi_hal_i2c_release(&furi_hal_i2c_handle_power); return ret; } -void furi_hal_power_enable_external_3_3v() { +void furi_hal_power_enable_external_3_3v(void) { furi_hal_gpio_write(&gpio_periph_power, 1); } -void furi_hal_power_disable_external_3_3v() { +void furi_hal_power_disable_external_3_3v(void) { furi_hal_gpio_write(&gpio_periph_power, 0); } -void furi_hal_power_suppress_charge_enter() { +void furi_hal_power_suppress_charge_enter(void) { FURI_CRITICAL_ENTER(); bool disable_charging = furi_hal_power.suppress_charge == 0; furi_hal_power.suppress_charge++; @@ -494,7 +498,7 @@ void furi_hal_power_suppress_charge_enter() { } } -void furi_hal_power_suppress_charge_exit() { +void furi_hal_power_suppress_charge_exit(void) { FURI_CRITICAL_ENTER(); furi_hal_power.suppress_charge--; bool enable_charging = furi_hal_power.suppress_charge == 0; @@ -508,7 +512,7 @@ void furi_hal_power_suppress_charge_exit() { } void furi_hal_power_info_get(PropertyValueCallback out, char sep, void* context) { - furi_assert(out); + furi_check(out); FuriString* value = furi_string_alloc(); FuriString* key = furi_string_alloc(); @@ -581,7 +585,7 @@ void furi_hal_power_info_get(PropertyValueCallback out, char sep, void* context) } void furi_hal_power_debug_get(PropertyValueCallback out, void* context) { - furi_assert(out); + furi_check(out); FuriString* value = furi_string_alloc(); FuriString* key = furi_string_alloc(); diff --git a/targets/f7/furi_hal/furi_hal_pwm.c b/targets/f7/furi_hal/furi_hal_pwm.c index 879460e6b..4828cefbb 100644 --- a/targets/f7/furi_hal/furi_hal_pwm.c +++ b/targets/f7/furi_hal/furi_hal_pwm.c @@ -69,6 +69,8 @@ void furi_hal_pwm_start(FuriHalPwmOutputId channel, uint32_t freq, uint8_t duty) furi_hal_pwm_set_params(channel, freq, duty); LL_LPTIM_StartCounter(LPTIM2, LL_LPTIM_OPERATING_MODE_CONTINUOUS); + } else { + furi_crash(); } } @@ -79,6 +81,8 @@ void furi_hal_pwm_stop(FuriHalPwmOutputId channel) { } else if(channel == FuriHalPwmOutputIdLptim2PA4) { furi_hal_gpio_init_simple(&gpio_ext_pa4, GpioModeAnalog); furi_hal_bus_disable(FuriHalBusLPTIM2); + } else { + furi_crash(); } } @@ -88,7 +92,8 @@ bool furi_hal_pwm_is_running(FuriHalPwmOutputId channel) { } else if(channel == FuriHalPwmOutputIdLptim2PA4) { return furi_hal_bus_is_enabled(FuriHalBusLPTIM2); } - return false; + + furi_crash(); } void furi_hal_pwm_set_params(FuriHalPwmOutputId channel, uint32_t freq, uint8_t duty) { @@ -134,5 +139,7 @@ void furi_hal_pwm_set_params(FuriHalPwmOutputId channel, uint32_t freq, uint8_t } else { LL_RCC_SetLPTIMClockSource(LL_RCC_LPTIM2_CLKSOURCE_PCLK1); } + } else { + furi_crash(); } } diff --git a/targets/f7/furi_hal/furi_hal_random.c b/targets/f7/furi_hal/furi_hal_random.c index 225519303..fd557fa98 100644 --- a/targets/f7/furi_hal/furi_hal_random.c +++ b/targets/f7/furi_hal/furi_hal_random.c @@ -10,7 +10,7 @@ #define TAG "FuriHalRandom" -static uint32_t furi_hal_random_read_rng() { +static uint32_t furi_hal_random_read_rng(void) { while(LL_RNG_IsActiveFlag_CECS(RNG) && LL_RNG_IsActiveFlag_SECS(RNG) && !LL_RNG_IsActiveFlag_DRDY(RNG)) { /* Error handling as described in RM0434, pg. 582-583 */ @@ -33,12 +33,12 @@ static uint32_t furi_hal_random_read_rng() { return LL_RNG_ReadRandData32(RNG); } -void furi_hal_random_init() { +void furi_hal_random_init(void) { furi_hal_bus_enable(FuriHalBusRNG); LL_RCC_SetRNGClockSource(LL_RCC_RNG_CLKSOURCE_CLK48); } -uint32_t furi_hal_random_get() { +uint32_t furi_hal_random_get(void) { while(LL_HSEM_1StepLock(HSEM, CFG_HW_RNG_SEMID)) ; LL_RNG_Enable(RNG); @@ -53,6 +53,9 @@ uint32_t furi_hal_random_get() { } void furi_hal_random_fill_buf(uint8_t* buf, uint32_t len) { + furi_check(buf); + furi_check(len); + while(LL_HSEM_1StepLock(HSEM, CFG_HW_RNG_SEMID)) ; LL_RNG_Enable(RNG); @@ -71,10 +74,10 @@ void srand(unsigned seed) { UNUSED(seed); } -int rand() { +int rand(void) { return (furi_hal_random_get() & RAND_MAX); } -long random() { +long random(void) { return (furi_hal_random_get() & RAND_MAX); } diff --git a/targets/f7/furi_hal/furi_hal_resources.c b/targets/f7/furi_hal/furi_hal_resources.c index fe4640d5b..b98d93769 100644 --- a/targets/f7/furi_hal/furi_hal_resources.c +++ b/targets/f7/furi_hal/furi_hal_resources.c @@ -125,7 +125,7 @@ static void furi_hal_resources_init_gpio_pins(GpioMode mode) { } } -void furi_hal_resources_init_early() { +void furi_hal_resources_init_early(void) { furi_hal_bus_enable(FuriHalBusGPIOA); furi_hal_bus_enable(FuriHalBusGPIOB); furi_hal_bus_enable(FuriHalBusGPIOC); @@ -172,7 +172,7 @@ void furi_hal_resources_init_early() { furi_hal_resources_init_gpio_pins(GpioModeAnalog); } -void furi_hal_resources_deinit_early() { +void furi_hal_resources_deinit_early(void) { furi_hal_resources_init_input_pins(GpioModeAnalog); furi_hal_bus_disable(FuriHalBusGPIOA); furi_hal_bus_disable(FuriHalBusGPIOB); @@ -182,7 +182,7 @@ void furi_hal_resources_deinit_early() { furi_hal_bus_disable(FuriHalBusGPIOH); } -void furi_hal_resources_init() { +void furi_hal_resources_init(void) { // Button pins furi_hal_resources_init_input_pins(GpioModeInterruptRiseFall); diff --git a/targets/f7/furi_hal/furi_hal_resources.h b/targets/f7/furi_hal/furi_hal_resources.h index 6ca6f9df0..bb01b9bcd 100644 --- a/targets/f7/furi_hal/furi_hal_resources.h +++ b/targets/f7/furi_hal/furi_hal_resources.h @@ -214,11 +214,11 @@ extern const GpioPin gpio_usb_dp; #define NFC_IRQ_Pin RFID_PULL_Pin #define NFC_IRQ_GPIO_Port RFID_PULL_GPIO_Port -void furi_hal_resources_init_early(); +void furi_hal_resources_init_early(void); -void furi_hal_resources_deinit_early(); +void furi_hal_resources_deinit_early(void); -void furi_hal_resources_init(); +void furi_hal_resources_init(void); /** * Get a corresponding external connector pin number for a gpio diff --git a/targets/f7/furi_hal/furi_hal_rfid.c b/targets/f7/furi_hal/furi_hal_rfid.c index c40932922..07ea5ab0a 100644 --- a/targets/f7/furi_hal/furi_hal_rfid.c +++ b/targets/f7/furi_hal/furi_hal_rfid.c @@ -67,8 +67,8 @@ FuriHalRfid* furi_hal_rfid = NULL; #define LFRFID_LL_EMULATE_TIM TIM2 #define LFRFID_LL_EMULATE_CHANNEL LL_TIM_CHANNEL_CH3 -void furi_hal_rfid_init() { - furi_assert(furi_hal_rfid == NULL); +void furi_hal_rfid_init(void) { + furi_check(furi_hal_rfid == NULL); furi_hal_rfid = malloc(sizeof(FuriHalRfid)); furi_hal_rfid->field.counter = 0; furi_hal_rfid->field.set_tim_counter_cnt = 0; @@ -95,7 +95,7 @@ void furi_hal_rfid_init() { NVIC_EnableIRQ(COMP_IRQn); } -void furi_hal_rfid_pins_reset() { +void furi_hal_rfid_pins_reset(void) { // ibutton bus disable furi_hal_ibutton_pin_reset(); @@ -112,7 +112,7 @@ void furi_hal_rfid_pins_reset() { furi_hal_gpio_init(&gpio_rfid_data_in, GpioModeAnalog, GpioPullNo, GpioSpeedLow); } -static void furi_hal_rfid_pins_emulate() { +static void furi_hal_rfid_pins_emulate(void) { // ibutton low furi_hal_ibutton_pin_configure(); furi_hal_ibutton_pin_write(false); @@ -133,7 +133,7 @@ static void furi_hal_rfid_pins_emulate() { &gpio_rfid_carrier, GpioModeAltFunctionPushPull, GpioPullNo, GpioSpeedLow, GpioAltFn2TIM2); } -static void furi_hal_rfid_pins_read() { +static void furi_hal_rfid_pins_read(void) { // ibutton low furi_hal_ibutton_pin_configure(); furi_hal_ibutton_pin_write(false); @@ -154,7 +154,7 @@ static void furi_hal_rfid_pins_read() { furi_hal_gpio_init(&gpio_rfid_data_in, GpioModeAnalog, GpioPullNo, GpioSpeedLow); } -static void furi_hal_rfid_pins_field() { +static void furi_hal_rfid_pins_field(void) { // ibutton low furi_hal_ibutton_pin_configure(); furi_hal_ibutton_pin_write(false); @@ -171,11 +171,11 @@ static void furi_hal_rfid_pins_field() { &gpio_rfid_carrier, GpioModeAltFunctionPushPull, GpioPullNo, GpioSpeedLow, GpioAltFn2TIM2); } -void furi_hal_rfid_pin_pull_release() { +void furi_hal_rfid_pin_pull_release(void) { furi_hal_gpio_write(&gpio_nfc_irq_rfid_pull, true); } -void furi_hal_rfid_pin_pull_pulldown() { +void furi_hal_rfid_pin_pull_pulldown(void) { furi_hal_gpio_write(&gpio_nfc_irq_rfid_pull, false); } @@ -201,19 +201,19 @@ void furi_hal_rfid_tim_read_start(float freq, float duty_cycle) { furi_hal_rfid_tim_read_continue(); } -void furi_hal_rfid_tim_read_continue() { +void furi_hal_rfid_tim_read_continue(void) { LL_TIM_EnableAllOutputs(FURI_HAL_RFID_READ_TIMER); } -void furi_hal_rfid_tim_read_pause() { +void furi_hal_rfid_tim_read_pause(void) { LL_TIM_DisableAllOutputs(FURI_HAL_RFID_READ_TIMER); } -void furi_hal_rfid_tim_read_stop() { +void furi_hal_rfid_tim_read_stop(void) { furi_hal_bus_disable(FURI_HAL_RFID_READ_TIMER_BUS); } -static void furi_hal_rfid_tim_emulate() { +static void furi_hal_rfid_tim_emulate(void) { LL_TIM_SetPrescaler(FURI_HAL_RFID_EMULATE_TIMER, 0); LL_TIM_SetCounterMode(FURI_HAL_RFID_EMULATE_TIMER, LL_TIM_COUNTERMODE_UP); LL_TIM_SetAutoReload(FURI_HAL_RFID_EMULATE_TIMER, 1); @@ -258,7 +258,7 @@ static void furi_hal_capture_dma_isr(void* context) { } void furi_hal_rfid_tim_read_capture_start(FuriHalRfidReadCaptureCallback callback, void* context) { - furi_assert(furi_hal_rfid); + furi_check(furi_hal_rfid); furi_hal_rfid->read_capture_callback = callback; furi_hal_rfid->context = context; @@ -308,7 +308,7 @@ void furi_hal_rfid_tim_read_capture_start(FuriHalRfidReadCaptureCallback callbac furi_hal_rfid_comp_start(); } -void furi_hal_rfid_tim_read_capture_stop() { +void furi_hal_rfid_tim_read_capture_stop(void) { furi_hal_rfid_comp_stop(); furi_hal_interrupt_set_isr(FURI_HAL_RFID_EMULATE_TIMER_IRQ, NULL, NULL); @@ -338,7 +338,7 @@ void furi_hal_rfid_tim_emulate_dma_start( size_t length, FuriHalRfidDMACallback callback, void* context) { - furi_assert(furi_hal_rfid); + furi_check(furi_hal_rfid); // setup interrupts furi_hal_rfid->dma_callback = callback; @@ -401,7 +401,7 @@ void furi_hal_rfid_tim_emulate_dma_start( LL_TIM_EnableCounter(FURI_HAL_RFID_EMULATE_TIMER); } -void furi_hal_rfid_tim_emulate_dma_stop() { +void furi_hal_rfid_tim_emulate_dma_stop(void) { LL_TIM_DisableCounter(FURI_HAL_RFID_EMULATE_TIMER); LL_TIM_DisableAllOutputs(FURI_HAL_RFID_EMULATE_TIMER); @@ -431,7 +431,7 @@ void furi_hal_rfid_set_read_pulse(uint32_t pulse) { #endif } -void furi_hal_rfid_comp_start() { +void furi_hal_rfid_comp_start(void) { LL_COMP_Enable(COMP1); // Magic uint32_t wait_loop_index = ((80 / 10UL) * ((SystemCoreClock / (100000UL * 2UL)) + 1UL)); @@ -440,7 +440,7 @@ void furi_hal_rfid_comp_start() { } } -void furi_hal_rfid_comp_stop() { +void furi_hal_rfid_comp_stop(void) { LL_COMP_Disable(COMP1); } @@ -456,7 +456,7 @@ void furi_hal_rfid_comp_set_callback(FuriHalRfidCompCallback callback, void* con } /* Comparator trigger event */ -void COMP_IRQHandler() { +void COMP_IRQHandler(void) { if(LL_EXTI_IsActiveFlag_0_31(LL_EXTI_LINE_20)) { LL_EXTI_ClearFlag_0_31(LL_EXTI_LINE_20); } @@ -467,7 +467,7 @@ void COMP_IRQHandler() { } } -static void furi_hal_rfid_field_tim_setup() { +static void furi_hal_rfid_field_tim_setup(void) { // setup timer counter furi_hal_bus_enable(FURI_HAL_RFID_FIELD_COUNTER_TIMER_BUS); @@ -582,6 +582,8 @@ void furi_hal_rfid_field_detect_stop(void) { } bool furi_hal_rfid_field_is_present(uint32_t* frequency) { + furi_check(frequency); + *frequency = furi_hal_rfid->field.counter * 10; return ( (*frequency >= FURI_HAL_RFID_FIELD_FREQUENCY_MIN) && diff --git a/targets/f7/furi_hal/furi_hal_rfid.h b/targets/f7/furi_hal/furi_hal_rfid.h index 7087ba991..216e0d98c 100644 --- a/targets/f7/furi_hal/furi_hal_rfid.h +++ b/targets/f7/furi_hal/furi_hal_rfid.h @@ -15,19 +15,19 @@ extern "C" { /** Initialize RFID subsystem */ -void furi_hal_rfid_init(); +void furi_hal_rfid_init(void); /** Config rfid pins to reset state */ -void furi_hal_rfid_pins_reset(); +void furi_hal_rfid_pins_reset(void); /** Release rfid pull pin */ -void furi_hal_rfid_pin_pull_release(); +void furi_hal_rfid_pin_pull_release(void); /** Pulldown rfid pull pin */ -void furi_hal_rfid_pin_pull_pulldown(); +void furi_hal_rfid_pin_pull_pulldown(void); /** Start read timer * @param freq timer frequency @@ -37,21 +37,21 @@ void furi_hal_rfid_tim_read_start(float freq, float duty_cycle); /** Pause read timer, to be able to continue later */ -void furi_hal_rfid_tim_read_pause(); +void furi_hal_rfid_tim_read_pause(void); /** Continue read timer */ -void furi_hal_rfid_tim_read_continue(); +void furi_hal_rfid_tim_read_continue(void); /** Stop read timer */ -void furi_hal_rfid_tim_read_stop(); +void furi_hal_rfid_tim_read_stop(void); typedef void (*FuriHalRfidReadCaptureCallback)(bool level, uint32_t duration, void* context); void furi_hal_rfid_tim_read_capture_start(FuriHalRfidReadCaptureCallback callback, void* context); -void furi_hal_rfid_tim_read_capture_stop(); +void furi_hal_rfid_tim_read_capture_stop(void); typedef void (*FuriHalRfidDMACallback)(bool half, void* context); @@ -62,7 +62,7 @@ void furi_hal_rfid_tim_emulate_dma_start( FuriHalRfidDMACallback callback, void* context); -void furi_hal_rfid_tim_emulate_dma_stop(); +void furi_hal_rfid_tim_emulate_dma_stop(void); /** Set read timer period * @@ -77,10 +77,10 @@ void furi_hal_rfid_set_read_period(uint32_t period); void furi_hal_rfid_set_read_pulse(uint32_t pulse); /** Start/Enable comparator */ -void furi_hal_rfid_comp_start(); +void furi_hal_rfid_comp_start(void); /** Stop/Disable comparator */ -void furi_hal_rfid_comp_stop(); +void furi_hal_rfid_comp_stop(void); typedef void (*FuriHalRfidCompCallback)(bool level, void* context); @@ -88,10 +88,10 @@ typedef void (*FuriHalRfidCompCallback)(bool level, void* context); void furi_hal_rfid_comp_set_callback(FuriHalRfidCompCallback callback, void* context); /** Start/Enable Field Presence detect */ -void furi_hal_rfid_field_detect_start(); +void furi_hal_rfid_field_detect_start(void); /** Stop/Disable Field Presence detect */ -void furi_hal_rfid_field_detect_stop(); +void furi_hal_rfid_field_detect_stop(void); /** Check Field Presence * diff --git a/targets/f7/furi_hal/furi_hal_rtc.c b/targets/f7/furi_hal/furi_hal_rtc.c index cd4fa8b9b..a1c8b46c3 100644 --- a/targets/f7/furi_hal/furi_hal_rtc.c +++ b/targets/f7/furi_hal/furi_hal_rtc.c @@ -60,12 +60,12 @@ static const uint32_t furi_hal_rtc_log_baud_rates[] = { [FuriHalRtcLogBaudRate1843200] = 1843200, }; -static void furi_hal_rtc_reset() { +static void furi_hal_rtc_reset(void) { LL_RCC_ForceBackupDomainReset(); LL_RCC_ReleaseBackupDomainReset(); } -static bool furi_hal_rtc_start_clock_and_switch() { +static bool furi_hal_rtc_start_clock_and_switch(void) { // Clock operation require access to Backup Domain LL_PWR_EnableBkUpAccess(); @@ -90,7 +90,7 @@ static bool furi_hal_rtc_start_clock_and_switch() { } } -static void furi_hal_rtc_recover() { +static void furi_hal_rtc_recover(void) { DateTime datetime = {0}; // Handle fixable LSE failure @@ -127,7 +127,7 @@ static void furi_hal_rtc_recover() { } } -void furi_hal_rtc_init_early() { +void furi_hal_rtc_init_early(void) { // Enable RTCAPB clock LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_RTCAPB); @@ -151,10 +151,10 @@ void furi_hal_rtc_init_early() { } } -void furi_hal_rtc_deinit_early() { +void furi_hal_rtc_deinit_early(void) { } -void furi_hal_rtc_init() { +void furi_hal_rtc_init(void) { LL_RTC_InitTypeDef RTC_InitStruct; RTC_InitStruct.HourFormat = LL_RTC_HOURFORMAT_24HOUR; RTC_InitStruct.AsynchPrescaler = 127; @@ -169,7 +169,7 @@ void furi_hal_rtc_init() { FURI_LOG_I(TAG, "Init OK"); } -void furi_hal_rtc_sync_shadow() { +void furi_hal_rtc_sync_shadow(void) { if(!LL_RTC_IsShadowRegBypassEnabled(RTC)) { LL_RTC_ClearFlag_RS(RTC); while(!LL_RTC_IsActiveFlag_RS(RTC)) { @@ -177,7 +177,7 @@ void furi_hal_rtc_sync_shadow() { } } -void furi_hal_rtc_reset_registers() { +void furi_hal_rtc_reset_registers(void) { for(size_t i = 0; i < RTC_BKP_NUMBER; i++) { furi_hal_rtc_set_register(i, 0); } @@ -205,7 +205,7 @@ void furi_hal_rtc_set_log_level(uint8_t level) { furi_log_set_level(level); } -uint8_t furi_hal_rtc_get_log_level() { +uint8_t furi_hal_rtc_get_log_level(void) { uint32_t data_reg = furi_hal_rtc_get_register(FuriHalRtcRegisterSystem); SystemReg* data = (SystemReg*)&data_reg; return data->log_level; @@ -222,7 +222,7 @@ void furi_hal_rtc_set_log_device(FuriHalRtcLogDevice device) { furi_hal_rtc_log_baud_rates[furi_hal_rtc_get_log_baud_rate()]); } -FuriHalRtcLogDevice furi_hal_rtc_get_log_device() { +FuriHalRtcLogDevice furi_hal_rtc_get_log_device(void) { uint32_t data_reg = furi_hal_rtc_get_register(FuriHalRtcRegisterSystem); SystemReg* data = (SystemReg*)&data_reg; return data->log_device; @@ -239,7 +239,7 @@ void furi_hal_rtc_set_log_baud_rate(FuriHalRtcLogBaudRate baud_rate) { furi_hal_rtc_log_baud_rates[furi_hal_rtc_get_log_baud_rate()]); } -FuriHalRtcLogBaudRate furi_hal_rtc_get_log_baud_rate() { +FuriHalRtcLogBaudRate furi_hal_rtc_get_log_baud_rate(void) { uint32_t data_reg = furi_hal_rtc_get_register(FuriHalRtcRegisterSystem); SystemReg* data = (SystemReg*)&data_reg; return data->log_baud_rate; @@ -280,7 +280,7 @@ void furi_hal_rtc_set_boot_mode(FuriHalRtcBootMode mode) { furi_hal_rtc_set_register(FuriHalRtcRegisterSystem, data_reg); } -FuriHalRtcBootMode furi_hal_rtc_get_boot_mode() { +FuriHalRtcBootMode furi_hal_rtc_get_boot_mode(void) { uint32_t data_reg = furi_hal_rtc_get_register(FuriHalRtcRegisterSystem); SystemReg* data = (SystemReg*)&data_reg; return data->boot_mode; @@ -293,7 +293,7 @@ void furi_hal_rtc_set_heap_track_mode(FuriHalRtcHeapTrackMode mode) { furi_hal_rtc_set_register(FuriHalRtcRegisterSystem, data_reg); } -FuriHalRtcHeapTrackMode furi_hal_rtc_get_heap_track_mode() { +FuriHalRtcHeapTrackMode furi_hal_rtc_get_heap_track_mode(void) { uint32_t data_reg = furi_hal_rtc_get_register(FuriHalRtcRegisterSystem); SystemReg* data = (SystemReg*)&data_reg; return data->heap_track_mode; @@ -306,7 +306,7 @@ void furi_hal_rtc_set_locale_units(FuriHalRtcLocaleUnits value) { furi_hal_rtc_set_register(FuriHalRtcRegisterSystem, data_reg); } -FuriHalRtcLocaleUnits furi_hal_rtc_get_locale_units() { +FuriHalRtcLocaleUnits furi_hal_rtc_get_locale_units(void) { uint32_t data_reg = furi_hal_rtc_get_register(FuriHalRtcRegisterSystem); SystemReg* data = (SystemReg*)&data_reg; return data->locale_units; @@ -319,7 +319,7 @@ void furi_hal_rtc_set_locale_timeformat(FuriHalRtcLocaleTimeFormat value) { furi_hal_rtc_set_register(FuriHalRtcRegisterSystem, data_reg); } -FuriHalRtcLocaleTimeFormat furi_hal_rtc_get_locale_timeformat() { +FuriHalRtcLocaleTimeFormat furi_hal_rtc_get_locale_timeformat(void) { uint32_t data_reg = furi_hal_rtc_get_register(FuriHalRtcRegisterSystem); SystemReg* data = (SystemReg*)&data_reg; return data->locale_timeformat; @@ -332,7 +332,7 @@ void furi_hal_rtc_set_locale_dateformat(FuriHalRtcLocaleDateFormat value) { furi_hal_rtc_set_register(FuriHalRtcRegisterSystem, data_reg); } -FuriHalRtcLocaleDateFormat furi_hal_rtc_get_locale_dateformat() { +FuriHalRtcLocaleDateFormat furi_hal_rtc_get_locale_dateformat(void) { uint32_t data_reg = furi_hal_rtc_get_register(FuriHalRtcRegisterSystem); SystemReg* data = (SystemReg*)&data_reg; return data->locale_dateformat; @@ -340,7 +340,7 @@ FuriHalRtcLocaleDateFormat furi_hal_rtc_get_locale_dateformat() { void furi_hal_rtc_set_datetime(DateTime* datetime) { furi_check(!FURI_IS_IRQ_MODE()); - furi_assert(datetime); + furi_check(datetime); FURI_CRITICAL_ENTER(); /* Disable write protection */ @@ -379,7 +379,7 @@ void furi_hal_rtc_set_datetime(DateTime* datetime) { void furi_hal_rtc_get_datetime(DateTime* datetime) { furi_check(!FURI_IS_IRQ_MODE()); - furi_assert(datetime); + furi_check(datetime); FURI_CRITICAL_ENTER(); uint32_t time = LL_RTC_TIME_Get(RTC); // 0x00HHMMSS @@ -399,7 +399,7 @@ void furi_hal_rtc_set_fault_data(uint32_t value) { furi_hal_rtc_set_register(FuriHalRtcRegisterFaultData, value); } -uint32_t furi_hal_rtc_get_fault_data() { +uint32_t furi_hal_rtc_get_fault_data(void) { return furi_hal_rtc_get_register(FuriHalRtcRegisterFaultData); } @@ -407,11 +407,11 @@ void furi_hal_rtc_set_pin_fails(uint32_t value) { furi_hal_rtc_set_register(FuriHalRtcRegisterPinFails, value); } -uint32_t furi_hal_rtc_get_pin_fails() { +uint32_t furi_hal_rtc_get_pin_fails(void) { return furi_hal_rtc_get_register(FuriHalRtcRegisterPinFails); } -uint32_t furi_hal_rtc_get_timestamp() { +uint32_t furi_hal_rtc_get_timestamp(void) { DateTime datetime = {0}; furi_hal_rtc_get_datetime(&datetime); return datetime_datetime_to_timestamp(&datetime); diff --git a/targets/f7/furi_hal/furi_hal_rtc.h b/targets/f7/furi_hal/furi_hal_rtc.h index 353bd3494..3bdbb0c72 100644 --- a/targets/f7/furi_hal/furi_hal_rtc.h +++ b/targets/f7/furi_hal/furi_hal_rtc.h @@ -100,7 +100,7 @@ void furi_hal_rtc_init(void); void furi_hal_rtc_sync_shadow(void); /** Reset ALL RTC registers content */ -void furi_hal_rtc_reset_registers(); +void furi_hal_rtc_reset_registers(void); /** Get RTC register content * diff --git a/targets/f7/furi_hal/furi_hal_sd.c b/targets/f7/furi_hal/furi_hal_sd.c index 619f6f890..fb7f43ec8 100644 --- a/targets/f7/furi_hal/furi_hal_sd.c +++ b/targets/f7/furi_hal/furi_hal_sd.c @@ -206,17 +206,17 @@ typedef struct { /** Pointer to currently used SPI Handle */ FuriHalSpiBusHandle* furi_hal_sd_spi_handle = NULL; -static inline void sd_spi_select_card() { +static inline void sd_spi_select_card(void) { furi_hal_gpio_write(furi_hal_sd_spi_handle->cs, false); furi_delay_us(10); // Entry guard time for some SD cards } -static inline void sd_spi_deselect_card() { +static inline void sd_spi_deselect_card(void) { furi_delay_us(10); // Exit guard time for some SD cards furi_hal_gpio_write(furi_hal_sd_spi_handle->cs, true); } -static void sd_spi_bus_to_ground() { +static void sd_spi_bus_to_ground(void) { furi_hal_gpio_init_ex( furi_hal_sd_spi_handle->miso, GpioModeOutputPushPull, @@ -242,7 +242,7 @@ static void sd_spi_bus_to_ground() { furi_hal_gpio_write(furi_hal_sd_spi_handle->sck, false); } -static void sd_spi_bus_rise_up() { +static void sd_spi_bus_rise_up(void) { sd_spi_deselect_card(); furi_hal_gpio_init_ex( @@ -329,12 +329,12 @@ static FuriStatus sd_spi_wait_for_data(uint8_t data, uint32_t timeout_ms) { return FuriStatusOk; } -static inline void sd_spi_deselect_card_and_purge() { +static inline void sd_spi_deselect_card_and_purge(void) { sd_spi_deselect_card(); sd_spi_read_byte(); } -static inline void sd_spi_purge_crc() { +static inline void sd_spi_purge_crc(void) { sd_spi_read_byte(); sd_spi_read_byte(); } @@ -833,7 +833,7 @@ static inline void sd_cache_invalidate_range(uint32_t start_sector, uint32_t end sector_cache_invalidate_range(start_sector, end_sector); } -static inline void sd_cache_invalidate_all() { +static inline void sd_cache_invalidate_all(void) { sector_cache_init(); } @@ -907,7 +907,7 @@ bool furi_hal_sd_is_present(void) { return result; } -uint8_t furi_hal_sd_max_mount_retry_count() { +uint8_t furi_hal_sd_max_mount_retry_count(void) { return 10; } @@ -972,6 +972,8 @@ FuriStatus furi_hal_sd_get_card_state(void) { } FuriStatus furi_hal_sd_read_blocks(uint32_t* buff, uint32_t sector, uint32_t count) { + furi_check(buff); + FuriStatus status; bool single_sector = count == 1; @@ -1009,6 +1011,8 @@ FuriStatus furi_hal_sd_read_blocks(uint32_t* buff, uint32_t sector, uint32_t cou } FuriStatus furi_hal_sd_write_blocks(const uint32_t* buff, uint32_t sector, uint32_t count) { + furi_check(buff); + FuriStatus status; sd_cache_invalidate_range(sector, sector + count); @@ -1037,6 +1041,8 @@ FuriStatus furi_hal_sd_write_blocks(const uint32_t* buff, uint32_t sector, uint3 } FuriStatus furi_hal_sd_info(FuriHalSdInfo* info) { + furi_check(info); + FuriStatus status; SD_CSD csd; SD_CID cid; diff --git a/targets/f7/furi_hal/furi_hal_serial.c b/targets/f7/furi_hal/furi_hal_serial.c index e0e2d8d52..f26b412d2 100644 --- a/targets/f7/furi_hal/furi_hal_serial.c +++ b/targets/f7/furi_hal/furi_hal_serial.c @@ -658,6 +658,7 @@ void furi_hal_serial_resume(FuriHalSerialHandle* handle) { void furi_hal_serial_tx(FuriHalSerialHandle* handle, const uint8_t* buffer, size_t buffer_size) { furi_check(handle); + if(handle->id == FuriHalSerialIdUsart) { if(LL_USART_IsEnabled(USART1) == 0) return; @@ -787,7 +788,7 @@ void furi_hal_serial_async_rx_stop(FuriHalSerialHandle* handle) { bool furi_hal_serial_async_rx_available(FuriHalSerialHandle* handle) { furi_check(FURI_IS_IRQ_MODE()); - furi_assert(handle->id < FuriHalSerialIdMax); + furi_check(handle->id < FuriHalSerialIdMax); if(handle->id == FuriHalSerialIdUsart) { return LL_USART_IsActiveFlag_RXNE_RXFNE(USART1); @@ -798,7 +799,7 @@ bool furi_hal_serial_async_rx_available(FuriHalSerialHandle* handle) { uint8_t furi_hal_serial_async_rx(FuriHalSerialHandle* handle) { furi_check(FURI_IS_IRQ_MODE()); - furi_assert(handle->id < FuriHalSerialIdMax); + furi_check(handle->id < FuriHalSerialIdMax); if(handle->id == FuriHalSerialIdUsart) { return LL_USART_ReceiveData8(USART1); @@ -841,7 +842,7 @@ static uint8_t furi_hal_serial_dma_rx_read_byte(FuriHalSerialHandle* handle) { size_t furi_hal_serial_dma_rx(FuriHalSerialHandle* handle, uint8_t* data, size_t len) { furi_check(FURI_IS_IRQ_MODE()); - furi_assert(furi_hal_serial[handle->id].buffer_rx_ptr != NULL); + furi_check(furi_hal_serial[handle->id].buffer_rx_ptr != NULL); size_t i = 0; size_t available = furi_hal_serial_dma_bytes_available(handle->id); if(available < len) { diff --git a/targets/f7/furi_hal/furi_hal_speaker.c b/targets/f7/furi_hal/furi_hal_speaker.c index ad7ed994a..0aa8ce951 100644 --- a/targets/f7/furi_hal/furi_hal_speaker.c +++ b/targets/f7/furi_hal/furi_hal_speaker.c @@ -18,13 +18,13 @@ static FuriMutex* furi_hal_speaker_mutex = NULL; // #define FURI_HAL_SPEAKER_NEW_VOLUME -void furi_hal_speaker_init() { +void furi_hal_speaker_init(void) { furi_assert(furi_hal_speaker_mutex == NULL); furi_hal_speaker_mutex = furi_mutex_alloc(FuriMutexTypeNormal); FURI_LOG_I(TAG, "Init OK"); } -void furi_hal_speaker_deinit() { +void furi_hal_speaker_deinit(void) { furi_check(furi_hal_speaker_mutex != NULL); furi_mutex_free(furi_hal_speaker_mutex); furi_hal_speaker_mutex = NULL; @@ -44,7 +44,7 @@ bool furi_hal_speaker_acquire(uint32_t timeout) { } } -void furi_hal_speaker_release() { +void furi_hal_speaker_release(void) { furi_check(!FURI_IS_IRQ_MODE()); furi_check(furi_hal_speaker_is_mine()); @@ -57,7 +57,7 @@ void furi_hal_speaker_release() { furi_check(furi_mutex_release(furi_hal_speaker_mutex) == FuriStatusOk); } -bool furi_hal_speaker_is_mine() { +bool furi_hal_speaker_is_mine(void) { return (FURI_IS_IRQ_MODE()) || (furi_mutex_get_owner(furi_hal_speaker_mutex) == furi_thread_get_current_id()); } @@ -132,7 +132,7 @@ void furi_hal_speaker_set_volume(float volume) { #endif } -void furi_hal_speaker_stop() { +void furi_hal_speaker_stop(void) { furi_check(furi_hal_speaker_is_mine()); LL_TIM_DisableAllOutputs(FURI_HAL_SPEAKER_TIMER); LL_TIM_DisableCounter(FURI_HAL_SPEAKER_TIMER); diff --git a/targets/f7/furi_hal/furi_hal_spi.c b/targets/f7/furi_hal/furi_hal_spi.c index d295ad196..e2892572f 100644 --- a/targets/f7/furi_hal/furi_hal_spi.c +++ b/targets/f7/furi_hal/furi_hal_spi.c @@ -23,48 +23,48 @@ static FuriSemaphore* spi_dma_lock = NULL; static FuriSemaphore* spi_dma_completed = NULL; -void furi_hal_spi_dma_init() { +void furi_hal_spi_dma_init(void) { spi_dma_lock = furi_semaphore_alloc(1, 1); spi_dma_completed = furi_semaphore_alloc(1, 1); } void furi_hal_spi_bus_init(FuriHalSpiBus* bus) { - furi_assert(bus); + furi_check(bus); bus->callback(bus, FuriHalSpiBusEventInit); } void furi_hal_spi_bus_deinit(FuriHalSpiBus* bus) { - furi_assert(bus); + furi_check(bus); bus->callback(bus, FuriHalSpiBusEventDeinit); } void furi_hal_spi_bus_handle_init(FuriHalSpiBusHandle* handle) { - furi_assert(handle); + furi_check(handle); handle->callback(handle, FuriHalSpiBusHandleEventInit); } void furi_hal_spi_bus_handle_deinit(FuriHalSpiBusHandle* handle) { - furi_assert(handle); + furi_check(handle); handle->callback(handle, FuriHalSpiBusHandleEventDeinit); } void furi_hal_spi_acquire(FuriHalSpiBusHandle* handle) { - furi_assert(handle); + furi_check(handle); furi_hal_power_insomnia_enter(); handle->bus->callback(handle->bus, FuriHalSpiBusEventLock); handle->bus->callback(handle->bus, FuriHalSpiBusEventActivate); - furi_assert(handle->bus->current_handle == NULL); + furi_check(handle->bus->current_handle == NULL); handle->bus->current_handle = handle; handle->callback(handle, FuriHalSpiBusHandleEventActivate); } void furi_hal_spi_release(FuriHalSpiBusHandle* handle) { - furi_assert(handle); - furi_assert(handle->bus->current_handle == handle); + furi_check(handle); + furi_check(handle->bus->current_handle == handle); // Handle event and unset handle handle->callback(handle, FuriHalSpiBusHandleEventDeactivate); @@ -93,10 +93,10 @@ bool furi_hal_spi_bus_rx( uint8_t* buffer, size_t size, uint32_t timeout) { - furi_assert(handle); - furi_assert(handle->bus->current_handle == handle); - furi_assert(buffer); - furi_assert(size > 0); + furi_check(handle); + furi_check(handle->bus->current_handle == handle); + furi_check(buffer); + furi_check(size > 0); return furi_hal_spi_bus_trx(handle, buffer, buffer, size, timeout); } @@ -106,10 +106,11 @@ bool furi_hal_spi_bus_tx( const uint8_t* buffer, size_t size, uint32_t timeout) { - furi_assert(handle); - furi_assert(handle->bus->current_handle == handle); - furi_assert(buffer); - furi_assert(size > 0); + furi_check(handle); + furi_check(handle->bus->current_handle == handle); + furi_check(buffer); + furi_check(size > 0); + bool ret = true; while(size > 0) { @@ -132,9 +133,9 @@ bool furi_hal_spi_bus_trx( uint8_t* rx_buffer, size_t size, uint32_t timeout) { - furi_assert(handle); - furi_assert(handle->bus->current_handle == handle); - furi_assert(size > 0); + furi_check(handle); + furi_check(handle->bus->current_handle == handle); + furi_check(size > 0); bool ret = true; size_t tx_size = size; @@ -196,9 +197,9 @@ bool furi_hal_spi_bus_trx_dma( uint8_t* rx_buffer, size_t size, uint32_t timeout_ms) { - furi_assert(handle); - furi_assert(handle->bus->current_handle == handle); - furi_assert(size > 0); + furi_check(handle); + furi_check(handle->bus->current_handle == handle); + furi_check(size > 0); // If scheduler is not running, use blocking mode if(furi_kernel_is_running()) { diff --git a/targets/f7/furi_hal/furi_hal_spi_config.c b/targets/f7/furi_hal/furi_hal_spi_config.c index 757ac2366..8a694961a 100644 --- a/targets/f7/furi_hal/furi_hal_spi_config.c +++ b/targets/f7/furi_hal/furi_hal_spi_config.c @@ -77,17 +77,17 @@ const LL_SPI_InitTypeDef furi_hal_spi_preset_1edge_low_2m = { FuriMutex* furi_hal_spi_bus_r_mutex = NULL; -void furi_hal_spi_config_init_early() { +void furi_hal_spi_config_init_early(void) { furi_hal_spi_bus_init(&furi_hal_spi_bus_d); furi_hal_spi_bus_handle_init(&furi_hal_spi_bus_handle_display); } -void furi_hal_spi_config_deinit_early() { +void furi_hal_spi_config_deinit_early(void) { furi_hal_spi_bus_handle_deinit(&furi_hal_spi_bus_handle_display); furi_hal_spi_bus_deinit(&furi_hal_spi_bus_d); } -void furi_hal_spi_config_init() { +void furi_hal_spi_config_init(void) { furi_hal_spi_bus_init(&furi_hal_spi_bus_r); furi_hal_spi_bus_handle_init(&furi_hal_spi_bus_handle_subghz); diff --git a/targets/f7/furi_hal/furi_hal_subghz.c b/targets/f7/furi_hal/furi_hal_subghz.c index 6ebaaf2b0..ec85ff2c3 100644 --- a/targets/f7/furi_hal/furi_hal_subghz.c +++ b/targets/f7/furi_hal/furi_hal_subghz.c @@ -89,12 +89,12 @@ void furi_hal_subghz_set_async_mirror_pin(const GpioPin* pin) { furi_hal_subghz.async_mirror_pin = pin; } -const GpioPin* furi_hal_subghz_get_data_gpio() { +const GpioPin* furi_hal_subghz_get_data_gpio(void) { return &gpio_cc1101_g0; } -void furi_hal_subghz_init() { - furi_assert(furi_hal_subghz.state == SubGhzStateInit); +void furi_hal_subghz_init(void) { + furi_check(furi_hal_subghz.state == SubGhzStateInit); furi_hal_subghz.state = SubGhzStateBroken; furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz); @@ -162,8 +162,9 @@ void furi_hal_subghz_init() { } } -void furi_hal_subghz_sleep() { - furi_assert(furi_hal_subghz.state == SubGhzStateIdle); +void furi_hal_subghz_sleep(void) { + furi_check(furi_hal_subghz.state == SubGhzStateIdle); + furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz); cc1101_switch_to_idle(&furi_hal_spi_bus_handle_subghz); @@ -176,7 +177,7 @@ void furi_hal_subghz_sleep() { furi_hal_spi_release(&furi_hal_spi_bus_handle_subghz); } -void furi_hal_subghz_dump_state() { +void furi_hal_subghz_dump_state(void) { furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz); printf( "[furi_hal_subghz] cc1101 chip %d, version %d\r\n", @@ -186,6 +187,8 @@ void furi_hal_subghz_dump_state() { } void furi_hal_subghz_load_custom_preset(const uint8_t* preset_data) { + furi_check(preset_data); + //load config furi_hal_subghz_reset(); furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz); @@ -216,6 +219,8 @@ void furi_hal_subghz_load_custom_preset(const uint8_t* preset_data) { } void furi_hal_subghz_load_registers(const uint8_t* data) { + furi_check(data); + furi_hal_subghz_reset(); furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz); uint32_t i = 0; @@ -227,12 +232,17 @@ void furi_hal_subghz_load_registers(const uint8_t* data) { } void furi_hal_subghz_load_patable(const uint8_t data[8]) { + furi_check(data); + furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz); cc1101_set_pa_table(&furi_hal_spi_bus_handle_subghz, data); furi_hal_spi_release(&furi_hal_spi_bus_handle_subghz); } void furi_hal_subghz_write_packet(const uint8_t* data, uint8_t size) { + furi_check(data); + furi_check(size); + furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz); cc1101_flush_tx(&furi_hal_spi_bus_handle_subghz); cc1101_write_reg(&furi_hal_spi_bus_handle_subghz, CC1101_FIFO, size); @@ -240,19 +250,19 @@ void furi_hal_subghz_write_packet(const uint8_t* data, uint8_t size) { furi_hal_spi_release(&furi_hal_spi_bus_handle_subghz); } -void furi_hal_subghz_flush_rx() { +void furi_hal_subghz_flush_rx(void) { furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz); cc1101_flush_rx(&furi_hal_spi_bus_handle_subghz); furi_hal_spi_release(&furi_hal_spi_bus_handle_subghz); } -void furi_hal_subghz_flush_tx() { +void furi_hal_subghz_flush_tx(void) { furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz); cc1101_flush_tx(&furi_hal_spi_bus_handle_subghz); furi_hal_spi_release(&furi_hal_spi_bus_handle_subghz); } -bool furi_hal_subghz_rx_pipe_not_empty() { +bool furi_hal_subghz_rx_pipe_not_empty(void) { CC1101RxBytes status[1]; furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz); cc1101_read_reg( @@ -266,7 +276,7 @@ bool furi_hal_subghz_rx_pipe_not_empty() { } } -bool furi_hal_subghz_is_rx_data_crc_valid() { +bool furi_hal_subghz_is_rx_data_crc_valid(void) { furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz); uint8_t data[1]; cc1101_read_reg(&furi_hal_spi_bus_handle_subghz, CC1101_STATUS_LQI | CC1101_BURST, data); @@ -279,19 +289,22 @@ bool furi_hal_subghz_is_rx_data_crc_valid() { } void furi_hal_subghz_read_packet(uint8_t* data, uint8_t* size) { + furi_check(data); + furi_check(size); + furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz); cc1101_read_fifo(&furi_hal_spi_bus_handle_subghz, data, size); furi_hal_spi_release(&furi_hal_spi_bus_handle_subghz); } -void furi_hal_subghz_shutdown() { +void furi_hal_subghz_shutdown(void) { furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz); // Reset and shutdown cc1101_shutdown(&furi_hal_spi_bus_handle_subghz); furi_hal_spi_release(&furi_hal_spi_bus_handle_subghz); } -void furi_hal_subghz_reset() { +void furi_hal_subghz_reset(void) { furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz); furi_hal_gpio_init(&gpio_cc1101_g0, GpioModeAnalog, GpioPullNo, GpioSpeedLow); cc1101_switch_to_idle(&furi_hal_spi_bus_handle_subghz); @@ -301,7 +314,7 @@ void furi_hal_subghz_reset() { furi_hal_spi_release(&furi_hal_spi_bus_handle_subghz); } -void furi_hal_subghz_idle() { +void furi_hal_subghz_idle(void) { furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz); cc1101_switch_to_idle(&furi_hal_spi_bus_handle_subghz); //waiting for the chip to switch to IDLE mode @@ -309,7 +322,7 @@ void furi_hal_subghz_idle() { furi_hal_spi_release(&furi_hal_spi_bus_handle_subghz); } -void furi_hal_subghz_rx() { +void furi_hal_subghz_rx(void) { furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz); cc1101_switch_to_rx(&furi_hal_spi_bus_handle_subghz); //waiting for the chip to switch to Rx mode @@ -317,7 +330,7 @@ void furi_hal_subghz_rx() { furi_hal_spi_release(&furi_hal_spi_bus_handle_subghz); } -bool furi_hal_subghz_tx() { +bool furi_hal_subghz_tx(void) { if(furi_hal_subghz.regulation != SubGhzRegulationTxRx) return false; furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz); cc1101_switch_to_tx(&furi_hal_spi_bus_handle_subghz); @@ -327,7 +340,7 @@ bool furi_hal_subghz_tx() { return true; } -float furi_hal_subghz_get_rssi() { +float furi_hal_subghz_get_rssi(void) { furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz); int32_t rssi_dec = cc1101_get_rssi(&furi_hal_spi_bus_handle_subghz); furi_hal_spi_release(&furi_hal_spi_bus_handle_subghz); @@ -342,7 +355,7 @@ float furi_hal_subghz_get_rssi() { return rssi; } -uint8_t furi_hal_subghz_get_lqi() { +uint8_t furi_hal_subghz_get_lqi(void) { furi_hal_spi_acquire(&furi_hal_spi_bus_handle_subghz); uint8_t data[1]; cc1101_read_reg(&furi_hal_spi_bus_handle_subghz, CC1101_STATUS_LQI | CC1101_BURST, data); @@ -438,7 +451,7 @@ void furi_hal_subghz_set_path(FuriHalSubGhzPath path) { furi_hal_spi_release(&furi_hal_spi_bus_handle_subghz); } -static bool furi_hal_subghz_start_debug() { +static bool furi_hal_subghz_start_debug(void) { bool ret = false; if(furi_hal_subghz.async_mirror_pin != NULL) { furi_hal_gpio_write(furi_hal_subghz.async_mirror_pin, false); @@ -452,7 +465,7 @@ static bool furi_hal_subghz_start_debug() { return ret; } -static bool furi_hal_subghz_stop_debug() { +static bool furi_hal_subghz_stop_debug(void) { bool ret = false; if(furi_hal_subghz.async_mirror_pin != NULL) { furi_hal_gpio_init( @@ -498,7 +511,9 @@ static void furi_hal_subghz_capture_ISR(void* context) { } void furi_hal_subghz_start_async_rx(FuriHalSubGhzCaptureCallback callback, void* context) { - furi_assert(furi_hal_subghz.state == SubGhzStateIdle); + furi_check(furi_hal_subghz.state == SubGhzStateIdle); + furi_check(callback); + furi_hal_subghz.state = SubGhzStateAsyncRx; furi_hal_subghz_capture_callback = callback; @@ -565,8 +580,8 @@ void furi_hal_subghz_start_async_rx(FuriHalSubGhzCaptureCallback callback, void* furi_hal_subghz_capture_delta_duration = 0; } -void furi_hal_subghz_stop_async_rx() { - furi_assert(furi_hal_subghz.state == SubGhzStateAsyncRx); +void furi_hal_subghz_stop_async_rx(void) { + furi_check(furi_hal_subghz.state == SubGhzStateAsyncRx); furi_hal_subghz.state = SubGhzStateIdle; // Shutdown radio @@ -664,7 +679,7 @@ static inline uint32_t furi_hal_subghz_async_tx_middleware_get_duration( } static void furi_hal_subghz_async_tx_refill(uint32_t* buffer, size_t samples) { - furi_assert(furi_hal_subghz.state == SubGhzStateAsyncTx); + furi_check(furi_hal_subghz.state == SubGhzStateAsyncTx); while(samples > 0) { volatile uint32_t duration = furi_hal_subghz_async_tx_middleware_get_duration( @@ -704,7 +719,7 @@ static void furi_hal_subghz_async_tx_refill(uint32_t* buffer, size_t samples) { static void furi_hal_subghz_async_tx_dma_isr(void* context) { UNUSED(context); - furi_assert(furi_hal_subghz.state == SubGhzStateAsyncTx); + furi_check(furi_hal_subghz.state == SubGhzStateAsyncTx); #if SUBGHZ_DMA_CH1_CHANNEL == LL_DMA_CHANNEL_1 if(LL_DMA_IsActiveFlag_HT1(SUBGHZ_DMA)) { @@ -724,8 +739,8 @@ static void furi_hal_subghz_async_tx_dma_isr(void* context) { } bool furi_hal_subghz_start_async_tx(FuriHalSubGhzAsyncTxCallback callback, void* context) { - furi_assert(furi_hal_subghz.state == SubGhzStateIdle); - furi_assert(callback); + furi_check(furi_hal_subghz.state == SubGhzStateIdle); + furi_check(callback); //If transmission is prohibited by regional settings if(furi_hal_subghz.regulation != SubGhzRegulationTxRx) return false; @@ -832,12 +847,12 @@ bool furi_hal_subghz_start_async_tx(FuriHalSubGhzAsyncTxCallback callback, void* return true; } -bool furi_hal_subghz_is_async_tx_complete() { +bool furi_hal_subghz_is_async_tx_complete(void) { return (furi_hal_subghz.state == SubGhzStateAsyncTx) && (LL_TIM_GetAutoReload(TIM2) == 0); } -void furi_hal_subghz_stop_async_tx() { - furi_assert(furi_hal_subghz.state == SubGhzStateAsyncTx); +void furi_hal_subghz_stop_async_tx(void) { + furi_check(furi_hal_subghz.state == SubGhzStateAsyncTx); // Shutdown radio furi_hal_subghz_idle(); diff --git a/targets/f7/furi_hal/furi_hal_subghz.h b/targets/f7/furi_hal/furi_hal_subghz.h index b901e85ea..864368120 100644 --- a/targets/f7/furi_hal/furi_hal_subghz.h +++ b/targets/f7/furi_hal/furi_hal_subghz.h @@ -44,21 +44,21 @@ void furi_hal_subghz_set_async_mirror_pin(const GpioPin* pin); * * @return pointer to the gpio pin structure */ -const GpioPin* furi_hal_subghz_get_data_gpio(); +const GpioPin* furi_hal_subghz_get_data_gpio(void); /** Initialize and switch to power save mode Used by internal API-HAL * initialization routine Can be used to reinitialize device to safe state and * send it to sleep */ -void furi_hal_subghz_init(); +void furi_hal_subghz_init(void); /** Send device to sleep mode */ -void furi_hal_subghz_sleep(); +void furi_hal_subghz_sleep(void); /** Dump info to stdout */ -void furi_hal_subghz_dump_state(); +void furi_hal_subghz_dump_state(void); /** Load custom registers from preset * @@ -89,13 +89,13 @@ void furi_hal_subghz_write_packet(const uint8_t* data, uint8_t size); * * @return true if not empty */ -bool furi_hal_subghz_rx_pipe_not_empty(); +bool furi_hal_subghz_rx_pipe_not_empty(void); /** Check if received data crc is valid * * @return true if valid */ -bool furi_hal_subghz_is_rx_data_crc_valid(); +bool furi_hal_subghz_is_rx_data_crc_valid(void); /** Read packet from FIFO * @@ -106,47 +106,47 @@ void furi_hal_subghz_read_packet(uint8_t* data, uint8_t* size); /** Flush rx FIFO buffer */ -void furi_hal_subghz_flush_rx(); +void furi_hal_subghz_flush_rx(void); /** Flush tx FIFO buffer */ -void furi_hal_subghz_flush_tx(); +void furi_hal_subghz_flush_tx(void); /** Shutdown Issue SPWD command * @warning registers content will be lost */ -void furi_hal_subghz_shutdown(); +void furi_hal_subghz_shutdown(void); /** Reset Issue reset command * @warning registers content will be lost */ -void furi_hal_subghz_reset(); +void furi_hal_subghz_reset(void); /** Switch to Idle */ -void furi_hal_subghz_idle(); +void furi_hal_subghz_idle(void); /** Switch to Receive */ -void furi_hal_subghz_rx(); +void furi_hal_subghz_rx(void); /** Switch to Transmit * * @return true if the transfer is allowed by belonging to the region */ -bool furi_hal_subghz_tx(); +bool furi_hal_subghz_tx(void); /** Get RSSI value in dBm * * @return RSSI value */ -float furi_hal_subghz_get_rssi(); +float furi_hal_subghz_get_rssi(void); /** Get LQI * * @return LQI value */ -uint8_t furi_hal_subghz_get_lqi(); +uint8_t furi_hal_subghz_get_lqi(void); /** Check if frequency is in valid range * @@ -211,7 +211,7 @@ void furi_hal_subghz_start_async_rx(FuriHalSubGhzCaptureCallback callback, void* /** Disable signal timings capture Resets GPIO and TIM2 */ -void furi_hal_subghz_stop_async_rx(); +void furi_hal_subghz_stop_async_rx(void); /** Async TX callback type * @param context callback context @@ -232,11 +232,11 @@ bool furi_hal_subghz_start_async_tx(FuriHalSubGhzAsyncTxCallback callback, void* * * @return true if TX complete */ -bool furi_hal_subghz_is_async_tx_complete(); +bool furi_hal_subghz_is_async_tx_complete(void); /** Stop async transmission and cleanup resources Resets GPIO, TIM2, and DMA1 */ -void furi_hal_subghz_stop_async_tx(); +void furi_hal_subghz_stop_async_tx(void); // /** Initialize and switch to power save mode Used by internal API-HAL // * initialization routine Can be used to reinitialize device to safe state and diff --git a/targets/f7/furi_hal/furi_hal_usb.c b/targets/f7/furi_hal/furi_hal_usb.c index b88168d5d..a482940e2 100644 --- a/targets/f7/furi_hal/furi_hal_usb.c +++ b/targets/f7/furi_hal/furi_hal_usb.c @@ -153,7 +153,7 @@ bool furi_hal_usb_set_config(FuriHalUsbInterface* new_if, void* ctx) { return return_data.bool_value; } -FuriHalUsbInterface* furi_hal_usb_get_config() { +FuriHalUsbInterface* furi_hal_usb_get_config(void) { UsbApiEventReturnData return_data = { .void_value = NULL, }; @@ -168,7 +168,7 @@ FuriHalUsbInterface* furi_hal_usb_get_config() { return return_data.void_value; } -void furi_hal_usb_lock() { +void furi_hal_usb_lock(void) { UsbApiEventMessage msg = { .lock = api_lock_alloc_locked(), .type = UsbApiEventTypeLock, @@ -177,7 +177,7 @@ void furi_hal_usb_lock() { furi_hal_usb_send_message(&msg); } -void furi_hal_usb_unlock() { +void furi_hal_usb_unlock(void) { UsbApiEventMessage msg = { .lock = api_lock_alloc_locked(), .type = UsbApiEventTypeUnlock, @@ -186,7 +186,7 @@ void furi_hal_usb_unlock() { furi_hal_usb_send_message(&msg); } -bool furi_hal_usb_is_locked() { +bool furi_hal_usb_is_locked(void) { UsbApiEventReturnData return_data = { .bool_value = false, }; @@ -201,7 +201,7 @@ bool furi_hal_usb_is_locked() { return return_data.bool_value; } -void furi_hal_usb_disable() { +void furi_hal_usb_disable(void) { UsbApiEventMessage msg = { .lock = api_lock_alloc_locked(), .type = UsbApiEventTypeDisable, @@ -210,7 +210,7 @@ void furi_hal_usb_disable() { furi_hal_usb_send_message(&msg); } -void furi_hal_usb_enable() { +void furi_hal_usb_enable(void) { UsbApiEventMessage msg = { .lock = api_lock_alloc_locked(), .type = UsbApiEventTypeEnable, @@ -219,7 +219,7 @@ void furi_hal_usb_enable() { furi_hal_usb_send_message(&msg); } -void furi_hal_usb_reinit() { +void furi_hal_usb_reinit(void) { UsbApiEventMessage msg = { .lock = api_lock_alloc_locked(), .type = UsbApiEventTypeReinit, @@ -358,7 +358,7 @@ static void usb_process_mode_change(FuriHalUsbInterface* interface, void* contex } } -static void usb_process_mode_reinit() { +static void usb_process_mode_reinit(void) { // Temporary disable callback to avoid getting false reset events usbd_reg_event(&udev, usbd_evt_reset, NULL); FURI_LOG_I(TAG, "USB Reinit"); diff --git a/targets/f7/furi_hal/furi_hal_usb_ccid.c b/targets/f7/furi_hal/furi_hal_usb_ccid.c index e24713ced..d8b43fc6c 100644 --- a/targets/f7/furi_hal/furi_hal_usb_ccid.c +++ b/targets/f7/furi_hal/furi_hal_usb_ccid.c @@ -186,7 +186,7 @@ static bool smartcard_inserted = true; static CcidCallbacks* callbacks[CCID_TOTAL_SLOTS] = {NULL}; static void* ccid_set_string_descr(char* str) { - furi_assert(str); + furi_check(str); size_t len = strlen(str); struct usb_string_descriptor* dev_str_desc = malloc(len * 2 + 2); @@ -292,7 +292,7 @@ void CALLBACK_CCID_GetSlotStatus( void CALLBACK_CCID_SetParametersT0( struct pc_to_rdr_set_parameters_t0* requestSetParametersT0, struct rdr_to_pc_parameters_t0* responseSetParametersT0) { - furi_assert(requestSetParametersT0->bProtocolNum == 0x00); //T0 + furi_check(requestSetParametersT0->bProtocolNum == 0x00); //T0 responseSetParametersT0->bMessageType = RDR_TO_PC_PARAMETERS; responseSetParametersT0->bSlot = requestSetParametersT0->bSlot; responseSetParametersT0->bSeq = requestSetParametersT0->bSeq; @@ -381,11 +381,11 @@ void CALLBACK_CCID_XfrBlock( } } -void furi_hal_ccid_ccid_insert_smartcard() { +void furi_hal_ccid_ccid_insert_smartcard(void) { smartcard_inserted = true; } -void furi_hal_ccid_ccid_remove_smartcard() { +void furi_hal_ccid_ccid_remove_smartcard(void) { smartcard_inserted = false; } @@ -410,7 +410,7 @@ static void ccid_tx_ep_callback(usbd_device* dev, uint8_t event, uint8_t ep) { int32_t bytes_read = usbd_ep_read( usb_dev, ep, &ReceiveBuffer, sizeof(ccid_bulk_message_header_t) + CCID_DATABLOCK_SIZE); //minimum request size is header size - furi_assert((uint16_t)bytes_read >= sizeof(ccid_bulk_message_header_t)); + furi_check((uint16_t)bytes_read >= sizeof(ccid_bulk_message_header_t)); ccid_bulk_message_header_t* message = (ccid_bulk_message_header_t*)&ReceiveBuffer; //-V641 if(message->bMessageType == PC_TO_RDR_ICCPOWERON) { @@ -455,14 +455,14 @@ static void ccid_tx_ep_callback(usbd_device* dev, uint8_t event, uint8_t ep) { struct rdr_to_pc_data_block* responseDataBlock = (struct rdr_to_pc_data_block*)&SendBuffer; - furi_assert(receivedXfrBlock->dwLength <= CCID_DATABLOCK_SIZE); - furi_assert( + furi_check(receivedXfrBlock->dwLength <= CCID_DATABLOCK_SIZE); + furi_check( (uint16_t)bytes_read >= sizeof(ccid_bulk_message_header_t) + receivedXfrBlock->dwLength); CALLBACK_CCID_XfrBlock(receivedXfrBlock, responseDataBlock); - furi_assert(responseDataBlock->dwLength <= CCID_DATABLOCK_SIZE); + furi_check(responseDataBlock->dwLength <= CCID_DATABLOCK_SIZE); usbd_ep_write( usb_dev, @@ -476,8 +476,8 @@ static void ccid_tx_ep_callback(usbd_device* dev, uint8_t event, uint8_t ep) { struct rdr_to_pc_parameters_t0* responseSetParametersT0 = (struct rdr_to_pc_parameters_t0*)&SendBuffer; //-V641 - furi_assert(requestSetParametersT0->dwLength <= CCID_DATABLOCK_SIZE); - furi_assert( + furi_check(requestSetParametersT0->dwLength <= CCID_DATABLOCK_SIZE); + furi_check( (uint16_t)bytes_read >= sizeof(ccid_bulk_message_header_t) + requestSetParametersT0->dwLength); diff --git a/targets/f7/furi_hal/furi_hal_usb_cdc.c b/targets/f7/furi_hal/furi_hal_usb_cdc.c index 0cde83f14..865c6a448 100644 --- a/targets/f7/furi_hal/furi_hal_usb_cdc.c +++ b/targets/f7/furi_hal/furi_hal_usb_cdc.c @@ -472,7 +472,7 @@ static void cdc_deinit(usbd_device* dev) { } void furi_hal_cdc_set_callbacks(uint8_t if_num, CdcCallbacks* cb, void* context) { - furi_assert(if_num < IF_NUM_MAX); + furi_check(if_num < IF_NUM_MAX); if(callbacks[if_num] != NULL) { if(callbacks[if_num]->state_callback != NULL) { @@ -494,12 +494,12 @@ void furi_hal_cdc_set_callbacks(uint8_t if_num, CdcCallbacks* cb, void* context) } struct usb_cdc_line_coding* furi_hal_cdc_get_port_settings(uint8_t if_num) { - furi_assert(if_num < IF_NUM_MAX); + furi_check(if_num < IF_NUM_MAX); return &cdc_config[if_num]; } uint8_t furi_hal_cdc_get_ctrl_line_state(uint8_t if_num) { - furi_assert(if_num < IF_NUM_MAX); + furi_check(if_num < IF_NUM_MAX); return cdc_ctrl_line_state[if_num]; } diff --git a/targets/f7/furi_hal/furi_hal_usb_hid.c b/targets/f7/furi_hal/furi_hal_usb_hid.c index b744e5ef7..f48c4a781 100644 --- a/targets/f7/furi_hal/furi_hal_usb_hid.c +++ b/targets/f7/furi_hal/furi_hal_usb_hid.c @@ -257,11 +257,11 @@ static void* cb_ctx; static uint8_t led_state; static bool boot_protocol = false; -bool furi_hal_hid_is_connected() { +bool furi_hal_hid_is_connected(void) { return hid_connected; } -uint8_t furi_hal_hid_get_led_state() { +uint8_t furi_hal_hid_get_led_state(void) { return led_state; } @@ -300,7 +300,7 @@ bool furi_hal_hid_kb_release(uint16_t button) { return hid_send_report(ReportIdKeyboard); } -bool furi_hal_hid_kb_release_all() { +bool furi_hal_hid_kb_release_all(void) { for(uint8_t key_nb = 0; key_nb < HID_KB_MAX_KEYS; key_nb++) { hid_report.keyboard.boot.btn[key_nb] = 0; } diff --git a/targets/f7/furi_hal/furi_hal_usb_u2f.c b/targets/f7/furi_hal/furi_hal_usb_u2f.c index cc7e23b77..2a014093e 100644 --- a/targets/f7/furi_hal/furi_hal_usb_u2f.c +++ b/targets/f7/furi_hal/furi_hal_usb_u2f.c @@ -153,7 +153,7 @@ static bool hid_u2f_connected = false; static HidU2fCallback callback; static void* cb_ctx; -bool furi_hal_hid_u2f_is_connected() { +bool furi_hal_hid_u2f_is_connected(void) { return hid_u2f_connected; } diff --git a/targets/f7/furi_hal/furi_hal_version.c b/targets/f7/furi_hal/furi_hal_version.c index 46a15bde8..b0da5f4b1 100644 --- a/targets/f7/furi_hal/furi_hal_version.c +++ b/targets/f7/furi_hal/furi_hal_version.c @@ -124,11 +124,11 @@ void furi_hal_version_set_name(const char* name) { furi_hal_version.ble_mac[5] = (uint8_t)((company_id & 0x0000FF00) >> 8); } -static void furi_hal_version_load_otp_default() { +static void furi_hal_version_load_otp_default(void) { furi_hal_version_set_name(NULL); } -static void furi_hal_version_load_otp_v0() { +static void furi_hal_version_load_otp_v0(void) { const FuriHalVersionOTPv0* otp = (FuriHalVersionOTPv0*)FURI_HAL_VERSION_OTP_ADDRESS; furi_hal_version.timestamp = otp->header_timestamp; @@ -144,7 +144,7 @@ static void furi_hal_version_load_otp_v0() { } } -static void furi_hal_version_load_otp_v1() { +static void furi_hal_version_load_otp_v1(void) { const FuriHalVersionOTPv1* otp = (FuriHalVersionOTPv1*)FURI_HAL_VERSION_OTP_ADDRESS; furi_hal_version.timestamp = otp->header_timestamp; @@ -162,7 +162,7 @@ static void furi_hal_version_load_otp_v1() { } } -static void furi_hal_version_load_otp_v2() { +static void furi_hal_version_load_otp_v2(void) { const FuriHalVersionOTPv2* otp = (FuriHalVersionOTPv2*)FURI_HAL_VERSION_OTP_ADDRESS; // 1st block, programmed afer baking @@ -191,7 +191,7 @@ static void furi_hal_version_load_otp_v2() { } } -void furi_hal_version_init() { +void furi_hal_version_init(void) { switch(furi_hal_version_get_otp_version()) { case FuriHalVersionOtpVersionUnknown: case FuriHalVersionOtpVersionEmpty: @@ -215,7 +215,7 @@ void furi_hal_version_init() { FURI_LOG_I(TAG, "Init OK"); } -FuriHalVersionOtpVersion furi_hal_version_get_otp_version() { +FuriHalVersionOtpVersion furi_hal_version_get_otp_version(void) { if(*(uint64_t*)FURI_HAL_VERSION_OTP_ADDRESS == 0xFFFFFFFF) { return FuriHalVersionOtpVersionEmpty; } else { @@ -238,23 +238,23 @@ FuriHalVersionOtpVersion furi_hal_version_get_otp_version() { } } -uint8_t furi_hal_version_get_hw_version() { +uint8_t furi_hal_version_get_hw_version(void) { return furi_hal_version.board_version; } -uint8_t furi_hal_version_get_hw_target() { +uint8_t furi_hal_version_get_hw_target(void) { return furi_hal_version.board_target; } -uint8_t furi_hal_version_get_hw_body() { +uint8_t furi_hal_version_get_hw_body(void) { return furi_hal_version.board_body; } -FuriHalVersionColor furi_hal_version_get_hw_color() { +FuriHalVersionColor furi_hal_version_get_hw_color(void) { return furi_hal_version.board_color; } -uint8_t furi_hal_version_get_hw_connect() { +uint8_t furi_hal_version_get_hw_connect(void) { return furi_hal_version.board_connect; } @@ -286,27 +286,27 @@ const char* furi_hal_version_get_hw_region_name_otp() { return "R??"; } -FuriHalVersionDisplay furi_hal_version_get_hw_display() { +FuriHalVersionDisplay furi_hal_version_get_hw_display(void) { return furi_hal_version.board_display; } -uint32_t furi_hal_version_get_hw_timestamp() { +uint32_t furi_hal_version_get_hw_timestamp(void) { return furi_hal_version.timestamp; } -const char* furi_hal_version_get_name_ptr() { +const char* furi_hal_version_get_name_ptr(void) { return *furi_hal_version.name == 0x00 ? NULL : furi_hal_version.name; } -const char* furi_hal_version_get_device_name_ptr() { +const char* furi_hal_version_get_device_name_ptr(void) { return furi_hal_version.device_name + 1; } -const char* furi_hal_version_get_ble_local_device_name_ptr() { +const char* furi_hal_version_get_ble_local_device_name_ptr(void) { return furi_hal_version.device_name; } -const uint8_t* furi_hal_version_get_ble_mac() { +const uint8_t* furi_hal_version_get_ble_mac(void) { return furi_hal_version.ble_mac; } @@ -314,7 +314,7 @@ const struct Version* furi_hal_version_get_firmware_version(void) { return version_get(); } -size_t furi_hal_version_uid_size() { +size_t furi_hal_version_uid_size(void) { return 64 / 8; } diff --git a/targets/f7/furi_hal/furi_hal_version_device.c b/targets/f7/furi_hal/furi_hal_version_device.c index 897289984..af88c0671 100644 --- a/targets/f7/furi_hal/furi_hal_version_device.c +++ b/targets/f7/furi_hal/furi_hal_version_device.c @@ -1,33 +1,33 @@ #include -bool furi_hal_version_do_i_belong_here() { +bool furi_hal_version_do_i_belong_here(void) { return (furi_hal_version_get_hw_target() == 7) || (furi_hal_version_get_hw_target() == 0); } -const char* furi_hal_version_get_model_name() { +const char* furi_hal_version_get_model_name(void) { return "Flipper Zero"; } -const char* furi_hal_version_get_model_code() { +const char* furi_hal_version_get_model_code(void) { return "FZ.1"; } -const char* furi_hal_version_get_fcc_id() { +const char* furi_hal_version_get_fcc_id(void) { return "2A2V6-FZ"; } -const char* furi_hal_version_get_ic_id() { +const char* furi_hal_version_get_ic_id(void) { return "27624-FZ"; } -const char* furi_hal_version_get_mic_id() { +const char* furi_hal_version_get_mic_id(void) { return "210-175991"; } -const char* furi_hal_version_get_srrc_id() { +const char* furi_hal_version_get_srrc_id(void) { return "2023DJ16420"; } -const char* furi_hal_version_get_ncc_id() { +const char* furi_hal_version_get_ncc_id(void) { return "CCAJ23LP34D0T3"; } \ No newline at end of file diff --git a/targets/f7/furi_hal/furi_hal_vibro.c b/targets/f7/furi_hal/furi_hal_vibro.c index f46784677..33ff86549 100644 --- a/targets/f7/furi_hal/furi_hal_vibro.c +++ b/targets/f7/furi_hal/furi_hal_vibro.c @@ -3,7 +3,7 @@ #define TAG "FuriHalVibro" -void furi_hal_vibro_init() { +void furi_hal_vibro_init(void) { furi_hal_gpio_init(&gpio_vibro, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow); furi_hal_gpio_write(&gpio_vibro, false); FURI_LOG_I(TAG, "Init OK"); diff --git a/targets/f7/inc/FreeRTOSConfig.h b/targets/f7/inc/FreeRTOSConfig.h index 6a68bbae7..36800565c 100644 --- a/targets/f7/inc/FreeRTOSConfig.h +++ b/targets/f7/inc/FreeRTOSConfig.h @@ -89,7 +89,7 @@ to exclude the API function. */ /* Furi-specific */ #define configTASK_NOTIFICATION_ARRAY_ENTRIES 2 -extern __attribute__((__noreturn__)) void furi_thread_catch(); +extern __attribute__((__noreturn__)) void furi_thread_catch(void); #define configTASK_RETURN_ADDRESS (furi_thread_catch + 2) /* diff --git a/targets/f7/inc/alt_boot.h b/targets/f7/inc/alt_boot.h index d8be3aa48..23d7a46a8 100644 --- a/targets/f7/inc/alt_boot.h +++ b/targets/f7/inc/alt_boot.h @@ -4,11 +4,11 @@ extern "C" { #endif -void flipper_boot_update_exec(); +void flipper_boot_update_exec(void); -void flipper_boot_dfu_exec(); +void flipper_boot_dfu_exec(void); -void flipper_boot_recovery_exec(); +void flipper_boot_recovery_exec(void); #ifdef __cplusplus } diff --git a/targets/f7/platform_specific/cxx_virtual_stub.c b/targets/f7/platform_specific/cxx_virtual_stub.c index a81e5a5e0..74bd25478 100644 --- a/targets/f7/platform_specific/cxx_virtual_stub.c +++ b/targets/f7/platform_specific/cxx_virtual_stub.c @@ -1,6 +1,6 @@ #include "cxx_virtual_stub.h" #include -void __cxa_pure_virtual() { +void __cxa_pure_virtual(void) { furi_crash("C++ pure virtual call"); } diff --git a/targets/f7/platform_specific/cxx_virtual_stub.h b/targets/f7/platform_specific/cxx_virtual_stub.h index 46211030e..43eea5966 100644 --- a/targets/f7/platform_specific/cxx_virtual_stub.h +++ b/targets/f7/platform_specific/cxx_virtual_stub.h @@ -6,7 +6,7 @@ extern "C" { #endif -void __cxa_pure_virtual(); +void __cxa_pure_virtual(void); #ifdef __cplusplus } diff --git a/targets/f7/src/dfu.c b/targets/f7/src/dfu.c index 7e094b4c4..2d5bddb17 100644 --- a/targets/f7/src/dfu.c +++ b/targets/f7/src/dfu.c @@ -7,7 +7,7 @@ #include #include -void flipper_boot_dfu_show_splash() { +void flipper_boot_dfu_show_splash(void) { // Initialize Canvas* canvas = canvas_init(); @@ -22,7 +22,7 @@ void flipper_boot_dfu_show_splash() { canvas_free(canvas); } -void flipper_boot_dfu_exec() { +void flipper_boot_dfu_exec(void) { // Show DFU splashscreen flipper_boot_dfu_show_splash(); diff --git a/targets/f7/src/main.c b/targets/f7/src/main.c index ca705fe5e..77961f0ef 100644 --- a/targets/f7/src/main.c +++ b/targets/f7/src/main.c @@ -18,7 +18,7 @@ int32_t init_task(void* context) { return 0; } -int main() { +int main(void) { // Initialize FURI layer furi_init(); @@ -71,6 +71,6 @@ void Error_Handler(void) { furi_crash("ErrorHandler"); } -void abort() { +void abort(void) { furi_crash("AbortHandler"); } diff --git a/targets/f7/src/recovery.c b/targets/f7/src/recovery.c index 848236815..0a2532bf7 100644 --- a/targets/f7/src/recovery.c +++ b/targets/f7/src/recovery.c @@ -34,7 +34,7 @@ void flipper_boot_recovery_draw_splash(Canvas* canvas) { canvas_commit(canvas); } -void flipper_boot_recovery_exec() { +void flipper_boot_recovery_exec(void) { Canvas* canvas = canvas_init(); // Show recovery splashscreen diff --git a/targets/f7/src/update.c b/targets/f7/src/update.c index 42ac90e7b..e6cb4aabe 100644 --- a/targets/f7/src/update.c +++ b/targets/f7/src/update.c @@ -22,7 +22,7 @@ static FATFS* pfs = NULL; } \ } -static bool flipper_update_mount_sd() { +static bool flipper_update_mount_sd(void) { for(int i = 0; i < furi_hal_sd_max_mount_retry_count(); ++i) { if(furi_hal_sd_init((i % 2) == 0) != FuriStatusOk) { /* Next attempt will be without card reset, let it settle */ @@ -37,7 +37,7 @@ static bool flipper_update_mount_sd() { return false; } -static bool flipper_update_init() { +static bool flipper_update_init(void) { // TODO FL-3504: Configure missing peripherals properly furi_hal_bus_enable(FuriHalBusHSEM); furi_hal_bus_enable(FuriHalBusIPCC); @@ -180,7 +180,7 @@ static UpdateManifest* flipper_update_process_manifest(const FuriString* manifes return manifest; } -void flipper_boot_update_exec() { +void flipper_boot_update_exec(void) { if(!flipper_update_init()) { return; } diff --git a/targets/furi_hal_include/furi_hal.h b/targets/furi_hal_include/furi_hal.h index 4f8aad6bd..3eaf06da6 100644 --- a/targets/furi_hal_include/furi_hal.h +++ b/targets/furi_hal_include/furi_hal.h @@ -46,13 +46,13 @@ extern "C" { #endif /** Early FuriHal init, only essential subsystems */ -void furi_hal_init_early(); +void furi_hal_init_early(void); /** Early FuriHal deinit */ -void furi_hal_deinit_early(); +void furi_hal_deinit_early(void); /** Init FuriHal */ -void furi_hal_init(); +void furi_hal_init(void); /** Transfer execution to address * diff --git a/targets/furi_hal_include/furi_hal_bt.h b/targets/furi_hal_include/furi_hal_bt.h index cc81e0954..25ba33c28 100644 --- a/targets/furi_hal_include/furi_hal_bt.h +++ b/targets/furi_hal_include/furi_hal_bt.h @@ -30,37 +30,37 @@ typedef enum { /** Initialize */ -void furi_hal_bt_init(); +void furi_hal_bt_init(void); /** Lock core2 state transition */ -void furi_hal_bt_lock_core2(); +void furi_hal_bt_lock_core2(void); /** Lock core2 state transition */ -void furi_hal_bt_unlock_core2(); +void furi_hal_bt_unlock_core2(void); /** Start radio stack * * @return true on successfull radio stack start */ -bool furi_hal_bt_start_radio_stack(); +bool furi_hal_bt_start_radio_stack(void); /** Get radio stack type * * @return FuriHalBtStack instance */ -FuriHalBtStack furi_hal_bt_get_radio_stack(); +FuriHalBtStack furi_hal_bt_get_radio_stack(void); /** Check if radio stack supports BLE GAT/GAP * * @return true if supported */ -bool furi_hal_bt_is_gatt_gap_supported(); +bool furi_hal_bt_is_gatt_gap_supported(void); /** Check if radio stack supports testing * * @return true if supported */ -bool furi_hal_bt_is_testing_supported(); +bool furi_hal_bt_is_testing_supported(void); /** Check if particular instance of profile belongs to given type * @@ -92,7 +92,7 @@ FURI_WARN_UNUSED FuriHalBleProfileBase* furi_hal_bt_start_app( * * Also can be used to prepare core2 for stop modes */ -void furi_hal_bt_reinit(); +void furi_hal_bt_reinit(void); /** Change BLE app * Restarts 2nd core @@ -123,15 +123,15 @@ void furi_hal_bt_update_power_state(bool charging); * * @return true if device is connected or advertising, false otherwise */ -bool furi_hal_bt_is_active(); +bool furi_hal_bt_is_active(void); /** Start advertising */ -void furi_hal_bt_start_advertising(); +void furi_hal_bt_start_advertising(void); /** Stop advertising */ -void furi_hal_bt_stop_advertising(); +void furi_hal_bt_stop_advertising(void); /** Get BT/BLE system component state * @@ -143,7 +143,7 @@ void furi_hal_bt_dump_state(FuriString* buffer); * * @return true if core2 is alive */ -bool furi_hal_bt_is_alive(); +bool furi_hal_bt_is_alive(void); /** Get key storage buffer address and size * @@ -155,18 +155,18 @@ void furi_hal_bt_get_key_storage_buff(uint8_t** key_buff_addr, uint16_t* key_buf /** Get SRAM2 hardware semaphore * @note Must be called before SRAM2 read/write operations */ -void furi_hal_bt_nvm_sram_sem_acquire(); +void furi_hal_bt_nvm_sram_sem_acquire(void); /** Release SRAM2 hardware semaphore * @note Must be called after SRAM2 read/write operations */ -void furi_hal_bt_nvm_sram_sem_release(); +void furi_hal_bt_nvm_sram_sem_release(void); /** Clear key storage * * @return true on success */ -bool furi_hal_bt_clear_white_list(); +bool furi_hal_bt_clear_white_list(void); /** Set key storage change callback * @@ -186,7 +186,7 @@ void furi_hal_bt_start_tone_tx(uint8_t channel, uint8_t power); /** Stop ble tone tx */ -void furi_hal_bt_stop_tone_tx(); +void furi_hal_bt_stop_tone_tx(void); /** Start sending ble packets at a given frequency and datarate * @@ -200,7 +200,7 @@ void furi_hal_bt_start_packet_tx(uint8_t channel, uint8_t pattern, uint8_t datar * * @return sent packet count */ -uint16_t furi_hal_bt_stop_packet_test(); +uint16_t furi_hal_bt_stop_packet_test(void); /** Start receiving packets * @@ -217,19 +217,19 @@ void furi_hal_bt_start_rx(uint8_t channel); /** Stop RF listenning */ -void furi_hal_bt_stop_rx(); +void furi_hal_bt_stop_rx(void); /** Get RSSI * * @return RSSI in dBm */ -float furi_hal_bt_get_rssi(); +float furi_hal_bt_get_rssi(void); /** Get number of transmitted packets * * @return packet count */ -uint32_t furi_hal_bt_get_transmitted_packets(); +uint32_t furi_hal_bt_get_transmitted_packets(void); /** Reverse a MAC address byte order in-place * @param[in] mac mac address to reverse @@ -281,25 +281,25 @@ bool furi_hal_bt_extra_beacon_set_config(const GapExtraBeaconConfig* config); * * @return true on success */ -bool furi_hal_bt_extra_beacon_start(); +bool furi_hal_bt_extra_beacon_start(void); /** Stop extra beacon * * @return true on success */ -bool furi_hal_bt_extra_beacon_stop(); +bool furi_hal_bt_extra_beacon_stop(void); /** Check if extra beacon is active. * * @return extra beacon state */ -bool furi_hal_bt_extra_beacon_is_active(); +bool furi_hal_bt_extra_beacon_is_active(void); /** Get last configured extra beacon config * * @return extra beacon config. NULL if beacon had never been configured. */ -const GapExtraBeaconConfig* furi_hal_bt_extra_beacon_get_config(); +const GapExtraBeaconConfig* furi_hal_bt_extra_beacon_get_config(void); #ifdef __cplusplus } diff --git a/targets/furi_hal_include/furi_hal_cortex.h b/targets/furi_hal_include/furi_hal_cortex.h index ebabbabfd..81271d315 100644 --- a/targets/furi_hal_include/furi_hal_cortex.h +++ b/targets/furi_hal_include/furi_hal_cortex.h @@ -20,7 +20,7 @@ typedef struct { /** Early init stage for cortex */ -void furi_hal_cortex_init_early(); +void furi_hal_cortex_init_early(void); /** Microseconds delay * @@ -32,7 +32,7 @@ void furi_hal_cortex_delay_us(uint32_t microseconds); * * @return instructions per microsecond count */ -uint32_t furi_hal_cortex_instructions_per_microsecond(); +uint32_t furi_hal_cortex_instructions_per_microsecond(void); /** Get Timer * diff --git a/targets/furi_hal_include/furi_hal_crypto.h b/targets/furi_hal_include/furi_hal_crypto.h index 5e3b41040..04a2c67cf 100644 --- a/targets/furi_hal_include/furi_hal_crypto.h +++ b/targets/furi_hal_include/furi_hal_crypto.h @@ -91,7 +91,7 @@ typedef enum { } FuriHalCryptoGCMState; /** Initialize cryptography layer(includes AES engines, PKA and RNG) */ -void furi_hal_crypto_init(); +void furi_hal_crypto_init(void); /** Verify factory provisioned keys * diff --git a/targets/furi_hal_include/furi_hal_debug.h b/targets/furi_hal_include/furi_hal_debug.h index befbb4f40..1ea231bd0 100644 --- a/targets/furi_hal_include/furi_hal_debug.h +++ b/targets/furi_hal_include/furi_hal_debug.h @@ -13,13 +13,13 @@ extern "C" { #endif /** Enable MCU debug */ -void furi_hal_debug_enable(); +void furi_hal_debug_enable(void); /** Disable MCU debug */ -void furi_hal_debug_disable(); +void furi_hal_debug_disable(void); /** Check if GDB debug session is active */ -bool furi_hal_debug_is_gdb_session_active(); +bool furi_hal_debug_is_gdb_session_active(void); #ifdef __cplusplus } diff --git a/targets/furi_hal_include/furi_hal_i2c.h b/targets/furi_hal_include/furi_hal_i2c.h index 44f647cef..7d69cd74d 100644 --- a/targets/furi_hal_include/furi_hal_i2c.h +++ b/targets/furi_hal_include/furi_hal_i2c.h @@ -43,13 +43,13 @@ typedef enum { } FuriHalI2cEnd; /** Early Init I2C */ -void furi_hal_i2c_init_early(); +void furi_hal_i2c_init_early(void); /** Early DeInit I2C */ -void furi_hal_i2c_deinit_early(); +void furi_hal_i2c_deinit_early(void); /** Init I2C */ -void furi_hal_i2c_init(); +void furi_hal_i2c_init(void); /** Acquire I2C bus handle * diff --git a/targets/furi_hal_include/furi_hal_light.h b/targets/furi_hal_include/furi_hal_light.h index 0e06bd423..60f16afe8 100644 --- a/targets/furi_hal_include/furi_hal_light.h +++ b/targets/furi_hal_include/furi_hal_light.h @@ -15,7 +15,7 @@ extern "C" { /** Init light driver */ -void furi_hal_light_init(); +void furi_hal_light_init(void); /** Set light value * @@ -35,7 +35,7 @@ void furi_hal_light_blink_start(Light light, uint8_t brightness, uint16_t on_tim /** Stop hardware LED blinking mode */ -void furi_hal_light_blink_stop(); +void furi_hal_light_blink_stop(void); /** Set color in hardware LED blinking mode * diff --git a/targets/furi_hal_include/furi_hal_memory.h b/targets/furi_hal_include/furi_hal_memory.h index e9efa08c1..6451d93bc 100644 --- a/targets/furi_hal_include/furi_hal_memory.h +++ b/targets/furi_hal_include/furi_hal_memory.h @@ -15,7 +15,7 @@ extern "C" { /** * @brief Init memory pool manager */ -void furi_hal_memory_init(); +void furi_hal_memory_init(void); /** * @brief Allocate memory from separate memory pool. That memory can't be freed. @@ -30,14 +30,14 @@ void* furi_hal_memory_alloc(size_t size); * * @return size_t */ -size_t furi_hal_memory_get_free(); +size_t furi_hal_memory_get_free(void); /** * @brief Get max free block size from memory pool * * @return size_t */ -size_t furi_hal_memory_max_pool_block(); +size_t furi_hal_memory_max_pool_block(void); #ifdef __cplusplus } diff --git a/targets/furi_hal_include/furi_hal_mpu.h b/targets/furi_hal_include/furi_hal_mpu.h index 5dddadeb6..7a5759c17 100644 --- a/targets/furi_hal_include/furi_hal_mpu.h +++ b/targets/furi_hal_include/furi_hal_mpu.h @@ -57,17 +57,17 @@ typedef enum { /** * @brief Initialize memory protection unit */ -void furi_hal_mpu_init(); +void furi_hal_mpu_init(void); /** * @brief Enable memory protection unit */ -void furi_hal_mpu_enable(); +void furi_hal_mpu_enable(void); /** * @brief Disable memory protection unit */ -void furi_hal_mpu_disable(); +void furi_hal_mpu_disable(void); void furi_hal_mpu_protect_no_access( FuriHalMpuRegion region, diff --git a/targets/furi_hal_include/furi_hal_nfc.h b/targets/furi_hal_include/furi_hal_nfc.h index 3d8ff394e..1c9f54d35 100644 --- a/targets/furi_hal_include/furi_hal_nfc.h +++ b/targets/furi_hal_include/furi_hal_nfc.h @@ -101,14 +101,14 @@ typedef enum { * * @returns FuriHalNfcErrorNone on success, any other error code on failure. */ -FuriHalNfcError furi_hal_nfc_init(); +FuriHalNfcError furi_hal_nfc_init(void); /** * @brief Check whether the NFC HAL was properly initialised and is ready. * * @returns FuriHalNfcErrorNone if ready, any other error code if not ready. */ -FuriHalNfcError furi_hal_nfc_is_hal_ready(); +FuriHalNfcError furi_hal_nfc_is_hal_ready(void); /** * @brief Exclusively take over the NFC HAL and associated hardware. @@ -118,7 +118,7 @@ FuriHalNfcError furi_hal_nfc_is_hal_ready(); * * @returns FuriHalNfcErrorNone on success, any other error code on failure. */ -FuriHalNfcError furi_hal_nfc_acquire(); +FuriHalNfcError furi_hal_nfc_acquire(void); /** * @brief Release the exclusive lock and make the NFC HAL available for others. @@ -129,7 +129,7 @@ FuriHalNfcError furi_hal_nfc_acquire(); * * @returns FuriHalNfcErrorNone on success, any other error code on failure. */ -FuriHalNfcError furi_hal_nfc_release(); +FuriHalNfcError furi_hal_nfc_release(void); /** * @brief Configure the NFC hardware to enter the low-power mode. @@ -139,7 +139,7 @@ FuriHalNfcError furi_hal_nfc_release(); * * @returns FuriHalNfcErrorNone on success, any other error code on failure. */ -FuriHalNfcError furi_hal_nfc_low_power_mode_start(); +FuriHalNfcError furi_hal_nfc_low_power_mode_start(void); /** * @brief Configure the NFC hardware to exit the low-power mode. @@ -149,7 +149,7 @@ FuriHalNfcError furi_hal_nfc_low_power_mode_start(); * * @returns FuriHalNfcErrorNone on success, any other error code on failure. */ -FuriHalNfcError furi_hal_nfc_low_power_mode_stop(); +FuriHalNfcError furi_hal_nfc_low_power_mode_stop(void); /** * @brief Configure the NFC HAL to work in a particular mode. @@ -167,28 +167,28 @@ FuriHalNfcError furi_hal_nfc_set_mode(FuriHalNfcMode mode, FuriHalNfcTech tech); * * @returns FuriHalNfcErrorNone on success, any other error code on failure. */ -FuriHalNfcError furi_hal_nfc_reset_mode(); +FuriHalNfcError furi_hal_nfc_reset_mode(void); /** * @brief Enable field (carrier) detection by the NFC hardware. * * @returns FuriHalNfcErrorNone on success, any other error code on failure. */ -FuriHalNfcError furi_hal_nfc_field_detect_start(); +FuriHalNfcError furi_hal_nfc_field_detect_start(void); /** * @brief Disable field (carrier) detection by the NFC hardware. * * @returns FuriHalNfcErrorNone on success, any other error code on failure. */ -FuriHalNfcError furi_hal_nfc_field_detect_stop(); +FuriHalNfcError furi_hal_nfc_field_detect_stop(void); /** * @brief Check if the reader field (carrier) was detected by the NFC hardware. * * @returns true if the field was detected, false otherwise. */ -bool furi_hal_nfc_field_is_present(); +bool furi_hal_nfc_field_is_present(void); /** * @brief Enable field (carrier) generation by the NFC hardware. @@ -197,7 +197,7 @@ bool furi_hal_nfc_field_is_present(); * * @returns FuriHalNfcErrorNone on success, any other error code on failure. */ -FuriHalNfcError furi_hal_nfc_poller_field_on(); +FuriHalNfcError furi_hal_nfc_poller_field_on(void); /** * @brief Wait for an NFC HAL event in poller mode. @@ -263,7 +263,7 @@ FuriHalNfcError furi_hal_nfc_listener_rx(uint8_t* rx_data, size_t rx_data_size, * * @returns FuriHalNfcErrorNone on success, any other error code on failure. */ -FuriHalNfcError furi_hal_nfc_listener_sleep(); +FuriHalNfcError furi_hal_nfc_listener_sleep(void); /** * @brief Go to idle in listener mode. @@ -272,7 +272,7 @@ FuriHalNfcError furi_hal_nfc_listener_sleep(); * * @returns FuriHalNfcErrorNone on success, any other error code on failure. */ -FuriHalNfcError furi_hal_nfc_listener_idle(); +FuriHalNfcError furi_hal_nfc_listener_idle(void); /** * @brief Enable reception in listener mode. @@ -281,7 +281,7 @@ FuriHalNfcError furi_hal_nfc_listener_idle(); * * @returns FuriHalNfcErrorNone on success, any other error code on failure. */ -FuriHalNfcError furi_hal_nfc_listener_enable_rx(); +FuriHalNfcError furi_hal_nfc_listener_enable_rx(void); /** * @brief Reset communication. @@ -290,7 +290,7 @@ FuriHalNfcError furi_hal_nfc_listener_enable_rx(); * * @returns FuriHalNfcErrorNone on success, any other error code on failure. */ -FuriHalNfcError furi_hal_nfc_trx_reset(); +FuriHalNfcError furi_hal_nfc_trx_reset(void); /** * @brief Enable generation of NFC HAL events. @@ -300,7 +300,7 @@ FuriHalNfcError furi_hal_nfc_trx_reset(); * * @returns FuriHalNfcErrorNone on success, any other error code on failure. */ -FuriHalNfcError furi_hal_nfc_event_start(); +FuriHalNfcError furi_hal_nfc_event_start(void); /** * @brief Disable generation of NFC HAL events. @@ -309,14 +309,14 @@ FuriHalNfcError furi_hal_nfc_event_start(); * * @returns FuriHalNfcErrorNone on success, any other error code on failure. */ -FuriHalNfcError furi_hal_nfc_event_stop(); +FuriHalNfcError furi_hal_nfc_event_stop(void); /** * @brief Manually emit the FuriHalNfcEventAbortRequest event. * * @returns FuriHalNfcErrorNone on success, any other error code on failure. */ -FuriHalNfcError furi_hal_nfc_abort(); +FuriHalNfcError furi_hal_nfc_abort(void); /** * @brief Start frame wait timeout timer. @@ -328,7 +328,7 @@ void furi_hal_nfc_timer_fwt_start(uint32_t time_fc); /** * @brief Stop frame wait timeout timer. */ -void furi_hal_nfc_timer_fwt_stop(); +void furi_hal_nfc_timer_fwt_stop(void); /** * @brief Start block transmit (frame delay) timer. @@ -347,14 +347,14 @@ void furi_hal_nfc_timer_block_tx_start_us(uint32_t time_us); /** * @brief Stop block transmit (frame delay) timer. */ -void furi_hal_nfc_timer_block_tx_stop(); +void furi_hal_nfc_timer_block_tx_stop(void); /** * @brief Check whether block transmit (frame delay) timer is running. * * @returns true if timer is running, false otherwise. */ -bool furi_hal_nfc_timer_block_tx_is_running(); +bool furi_hal_nfc_timer_block_tx_is_running(void); /* * Technology-specific functions. @@ -450,7 +450,7 @@ FuriHalNfcError furi_hal_nfc_iso14443a_listener_tx_custom_parity( * * @return FuriHalNfcError */ -FuriHalNfcError furi_hal_nfc_iso15693_listener_tx_sof(); +FuriHalNfcError furi_hal_nfc_iso15693_listener_tx_sof(void); /** * @brief Set FeliCa collision resolution parameters in listener mode. diff --git a/targets/furi_hal_include/furi_hal_power.h b/targets/furi_hal_include/furi_hal_power.h index fa5e179c0..06598df86 100644 --- a/targets/furi_hal_include/furi_hal_power.h +++ b/targets/furi_hal_include/furi_hal_power.h @@ -8,6 +8,7 @@ #include #include #include +#include #include #ifdef __cplusplus @@ -21,7 +22,7 @@ typedef enum { } FuriHalPowerIC; /** Initialize drivers */ -void furi_hal_power_init(); +void furi_hal_power_init(void); /** Check if gauge is ok * @@ -32,104 +33,104 @@ void furi_hal_power_init(); * * @return true if gauge is ok */ -bool furi_hal_power_gauge_is_ok(); +bool furi_hal_power_gauge_is_ok(void); /** Check if gauge requests system shutdown * * @return true if system shutdown requested */ -bool furi_hal_power_is_shutdown_requested(); +bool furi_hal_power_is_shutdown_requested(void); /** Get current insomnia level * * @return insomnia level: 0 - no insomnia, >0 - insomnia, bearer count. */ -uint16_t furi_hal_power_insomnia_level(); +uint16_t furi_hal_power_insomnia_level(void); /** Enter insomnia mode Prevents device from going to sleep * @warning Internally increases insomnia level Must be paired with * furi_hal_power_insomnia_exit */ -void furi_hal_power_insomnia_enter(); +void furi_hal_power_insomnia_enter(void); /** Exit insomnia mode Allow device to go to sleep * @warning Internally decreases insomnia level. Must be paired with * furi_hal_power_insomnia_enter */ -void furi_hal_power_insomnia_exit(); +void furi_hal_power_insomnia_exit(void); /** Check if sleep available * * @return true if available */ -bool furi_hal_power_sleep_available(); +bool furi_hal_power_sleep_available(void); /** Go to sleep */ -void furi_hal_power_sleep(); +void furi_hal_power_sleep(void); /** Get predicted remaining battery capacity in percents * * @return remaining battery capacity in percents */ -uint8_t furi_hal_power_get_pct(); +uint8_t furi_hal_power_get_pct(void); /** Get battery health state in percents * * @return health in percents */ -uint8_t furi_hal_power_get_bat_health_pct(); +uint8_t furi_hal_power_get_bat_health_pct(void); /** Get charging status * * @return true if charging */ -bool furi_hal_power_is_charging(); +bool furi_hal_power_is_charging(void); /** Get charge complete status * * @return true if done charging and connected to charger */ -bool furi_hal_power_is_charging_done(); +bool furi_hal_power_is_charging_done(void); /** Switch MCU to SHUTDOWN */ -void furi_hal_power_shutdown(); +void furi_hal_power_shutdown(void); /** Poweroff device */ -void furi_hal_power_off(); +void furi_hal_power_off(void); /** Reset device */ -void furi_hal_power_reset(); +FURI_NORETURN void furi_hal_power_reset(void); /** OTG enable */ -bool furi_hal_power_enable_otg(); +bool furi_hal_power_enable_otg(void); /** OTG disable */ -void furi_hal_power_disable_otg(); +void furi_hal_power_disable_otg(void); /** Check OTG status fault */ -bool furi_hal_power_check_otg_fault(); +bool furi_hal_power_check_otg_fault(void); /** Check OTG status and disable it if falt happened */ -void furi_hal_power_check_otg_status(); +void furi_hal_power_check_otg_status(void); /** Get OTG status * * @return true if enabled */ -bool furi_hal_power_is_otg_enabled(); +bool furi_hal_power_is_otg_enabled(void); /** Get battery charge voltage limit in V * * @return voltage in V */ -float furi_hal_power_get_battery_charge_voltage_limit(); +float furi_hal_power_get_battery_charge_voltage_limit(void); /** Set battery charge voltage limit in V * @@ -143,19 +144,19 @@ void furi_hal_power_set_battery_charge_voltage_limit(float voltage); * * @return capacity in mAh */ -uint32_t furi_hal_power_get_battery_remaining_capacity(); +uint32_t furi_hal_power_get_battery_remaining_capacity(void); /** Get full charge battery capacity in mAh * * @return capacity in mAh */ -uint32_t furi_hal_power_get_battery_full_capacity(); +uint32_t furi_hal_power_get_battery_full_capacity(void); /** Get battery capacity in mAh from battery profile * * @return capacity in mAh */ -uint32_t furi_hal_power_get_battery_design_capacity(); +uint32_t furi_hal_power_get_battery_design_capacity(void); /** Get battery voltage in V * @@ -185,25 +186,25 @@ float furi_hal_power_get_battery_temperature(FuriHalPowerIC ic); * * @return voltage in V */ -float furi_hal_power_get_usb_voltage(); +float furi_hal_power_get_usb_voltage(void); /** Enable 3.3v on external gpio and sd card */ -void furi_hal_power_enable_external_3_3v(); +void furi_hal_power_enable_external_3_3v(void); /** Disable 3.3v on external gpio and sd card */ -void furi_hal_power_disable_external_3_3v(); +void furi_hal_power_disable_external_3_3v(void); /** Enter supress charge mode. * * Use this function when your application need clean power supply. */ -void furi_hal_power_suppress_charge_enter(); +void furi_hal_power_suppress_charge_enter(void); /** Exit supress charge mode */ -void furi_hal_power_suppress_charge_exit(); +void furi_hal_power_suppress_charge_exit(void); /** Get power information * diff --git a/targets/furi_hal_include/furi_hal_random.h b/targets/furi_hal_include/furi_hal_random.h index 5ca9cb723..051b6f928 100644 --- a/targets/furi_hal_include/furi_hal_random.h +++ b/targets/furi_hal_include/furi_hal_random.h @@ -7,13 +7,13 @@ extern "C" { #endif /** Initialize random subsystem */ -void furi_hal_random_init(); +void furi_hal_random_init(void); /** Get random value * * @return random value */ -uint32_t furi_hal_random_get(); +uint32_t furi_hal_random_get(void); /** Fill buffer with random data * diff --git a/targets/furi_hal_include/furi_hal_region.h b/targets/furi_hal_include/furi_hal_region.h index 9586d51ed..a1605c93a 100644 --- a/targets/furi_hal_include/furi_hal_region.h +++ b/targets/furi_hal_include/furi_hal_region.h @@ -28,7 +28,7 @@ typedef struct { * * @return pointer to FuriHalRegion instance (in RAM or Flash, check before freeing on region update) */ -const FuriHalRegion* furi_hal_region_get(); +const FuriHalRegion* furi_hal_region_get(void); /** Set device region data * @@ -40,7 +40,7 @@ void furi_hal_region_set(FuriHalRegion* region); * * @return true if provisioned, false otherwise */ -bool furi_hal_region_is_provisioned(); +bool furi_hal_region_is_provisioned(void); /** Get region name * @@ -52,7 +52,7 @@ bool furi_hal_region_is_provisioned(); * * @return Pointer to string */ -const char* furi_hal_region_get_name(); +const char* furi_hal_region_get_name(void); /** Сheck if transmission is allowed on this frequency for your flipper region * diff --git a/targets/furi_hal_include/furi_hal_sd.h b/targets/furi_hal_include/furi_hal_sd.h index 645403b7f..28534846c 100644 --- a/targets/furi_hal_include/furi_hal_sd.h +++ b/targets/furi_hal_include/furi_hal_sd.h @@ -29,19 +29,19 @@ typedef struct { /** * @brief Init SD card presence detection */ -void furi_hal_sd_presence_init(); +void furi_hal_sd_presence_init(void); /** * @brief Get SD card status * @return true if SD card is present */ -bool furi_hal_sd_is_present(); +bool furi_hal_sd_is_present(void); /** * @brief SD card max mount retry count * @return uint8_t */ -uint8_t furi_hal_sd_max_mount_retry_count(); +uint8_t furi_hal_sd_max_mount_retry_count(void); /** * @brief Init SD card @@ -79,7 +79,7 @@ FuriStatus furi_hal_sd_info(FuriHalSdInfo* info); * @brief Get SD card state * @return FuriStatus */ -FuriStatus furi_hal_sd_get_card_state(); +FuriStatus furi_hal_sd_get_card_state(void); #ifdef __cplusplus } diff --git a/targets/furi_hal_include/furi_hal_speaker.h b/targets/furi_hal_include/furi_hal_speaker.h index 0b33d9232..825a44e04 100644 --- a/targets/furi_hal_include/furi_hal_speaker.h +++ b/targets/furi_hal_include/furi_hal_speaker.h @@ -11,10 +11,10 @@ extern "C" { #endif /** Init speaker */ -void furi_hal_speaker_init(); +void furi_hal_speaker_init(void); /** Deinit speaker */ -void furi_hal_speaker_deinit(); +void furi_hal_speaker_deinit(void); /** Acquire speaker ownership * @@ -30,7 +30,7 @@ FURI_WARN_UNUSED bool furi_hal_speaker_acquire(uint32_t timeout); * * @warning You must release speaker ownership after use */ -void furi_hal_speaker_release(); +void furi_hal_speaker_release(void); /** Check current process speaker ownership * @@ -38,7 +38,7 @@ void furi_hal_speaker_release(); * * @return bool returns true if process owns speaker */ -bool furi_hal_speaker_is_mine(); +bool furi_hal_speaker_is_mine(void); /** Play a note * @@ -61,7 +61,7 @@ void furi_hal_speaker_set_volume(float volume); * * @warning no ownership check if called from ISR */ -void furi_hal_speaker_stop(); +void furi_hal_speaker_stop(void); #ifdef __cplusplus } diff --git a/targets/furi_hal_include/furi_hal_spi.h b/targets/furi_hal_include/furi_hal_spi.h index af15a8838..d497dff5c 100644 --- a/targets/furi_hal_include/furi_hal_spi.h +++ b/targets/furi_hal_include/furi_hal_spi.h @@ -8,16 +8,16 @@ extern "C" { #endif /** Early initialize SPI HAL */ -void furi_hal_spi_config_init_early(); +void furi_hal_spi_config_init_early(void); /** Early deinitialize SPI HAL */ -void furi_hal_spi_config_deinit_early(); +void furi_hal_spi_config_deinit_early(void); /** Initialize SPI HAL */ -void furi_hal_spi_config_init(); +void furi_hal_spi_config_init(void); /** Initialize SPI DMA HAL */ -void furi_hal_spi_dma_init(); +void furi_hal_spi_dma_init(void); /** Initialize SPI Bus * diff --git a/targets/furi_hal_include/furi_hal_usb.h b/targets/furi_hal_include/furi_hal_usb.h index a98797955..213e8d56f 100644 --- a/targets/furi_hal_include/furi_hal_usb.h +++ b/targets/furi_hal_include/furi_hal_usb.h @@ -41,7 +41,7 @@ typedef void (*FuriHalUsbStateCallback)(FuriHalUsbStateEvent state, void* contex /** USB device low-level initialization */ -void furi_hal_usb_init(); +void furi_hal_usb_init(void); /** Set USB device configuration * @@ -55,29 +55,29 @@ bool furi_hal_usb_set_config(FuriHalUsbInterface* new_if, void* ctx); * * @return current USB device mode */ -FuriHalUsbInterface* furi_hal_usb_get_config(); +FuriHalUsbInterface* furi_hal_usb_get_config(void); /** Lock USB device mode switch */ -void furi_hal_usb_lock(); +void furi_hal_usb_lock(void); /** Unlock USB device mode switch */ -void furi_hal_usb_unlock(); +void furi_hal_usb_unlock(void); /** Check if USB device mode switch locked * * @return lock state */ -bool furi_hal_usb_is_locked(); +bool furi_hal_usb_is_locked(void); /** Disable USB device */ -void furi_hal_usb_disable(); +void furi_hal_usb_disable(void); /** Enable USB device */ -void furi_hal_usb_enable(); +void furi_hal_usb_enable(void); /** Set USB state callback */ @@ -85,7 +85,7 @@ void furi_hal_usb_set_state_callback(FuriHalUsbStateCallback cb, void* ctx); /** Restart USB device */ -void furi_hal_usb_reinit(); +void furi_hal_usb_reinit(void); #ifdef __cplusplus } diff --git a/targets/furi_hal_include/furi_hal_usb_ccid.h b/targets/furi_hal_include/furi_hal_usb_ccid.h index a4880e4b6..500bafa3d 100644 --- a/targets/furi_hal_include/furi_hal_usb_ccid.h +++ b/targets/furi_hal_include/furi_hal_usb_ccid.h @@ -28,8 +28,8 @@ typedef struct { void furi_hal_ccid_set_callbacks(CcidCallbacks* cb); -void furi_hal_ccid_ccid_insert_smartcard(); -void furi_hal_ccid_ccid_remove_smartcard(); +void furi_hal_ccid_ccid_insert_smartcard(void); +void furi_hal_ccid_ccid_remove_smartcard(void); #ifdef __cplusplus } diff --git a/targets/furi_hal_include/furi_hal_usb_hid.h b/targets/furi_hal_include/furi_hal_usb_hid.h index 13e83ef67..da851cabb 100644 --- a/targets/furi_hal_include/furi_hal_usb_hid.h +++ b/targets/furi_hal_include/furi_hal_usb_hid.h @@ -190,13 +190,13 @@ enum HidMouseButtons { * * @return true / false */ -bool furi_hal_hid_is_connected(); +bool furi_hal_hid_is_connected(void); /** Get USB HID keyboard leds state * * @return leds state */ -uint8_t furi_hal_hid_get_led_state(); +uint8_t furi_hal_hid_get_led_state(void); /** Set USB HID connect/disconnect callback * @@ -220,7 +220,7 @@ bool furi_hal_hid_kb_release(uint16_t button); /** Clear all pressed keys and send HID report * */ -bool furi_hal_hid_kb_release_all(); +bool furi_hal_hid_kb_release_all(void); /** Set mouse movement and send HID report * diff --git a/targets/furi_hal_include/furi_hal_usb_hid_u2f.h b/targets/furi_hal_include/furi_hal_usb_hid_u2f.h index 1b20a33c4..444ef552f 100644 --- a/targets/furi_hal_include/furi_hal_usb_hid_u2f.h +++ b/targets/furi_hal_include/furi_hal_usb_hid_u2f.h @@ -18,7 +18,7 @@ typedef void (*HidU2fCallback)(HidU2fEvent ev, void* context); * * @return true / false */ -bool furi_hal_hid_u2f_is_connected(); +bool furi_hal_hid_u2f_is_connected(void); /** Set HID U2F event callback * diff --git a/targets/furi_hal_include/furi_hal_version.h b/targets/furi_hal_include/furi_hal_version.h index 49f4f82cb..e506741ba 100644 --- a/targets/furi_hal_include/furi_hal_version.h +++ b/targets/furi_hal_include/furi_hal_version.h @@ -55,103 +55,103 @@ typedef enum { /** Init flipper version */ -void furi_hal_version_init(); +void furi_hal_version_init(void); /** Check target firmware version * * @return true if target and real matches */ -bool furi_hal_version_do_i_belong_here(); +bool furi_hal_version_do_i_belong_here(void); /** Get model name * * @return model name C-string */ -const char* furi_hal_version_get_model_name(); +const char* furi_hal_version_get_model_name(void); /** Get model name * * @return model code C-string */ -const char* furi_hal_version_get_model_code(); +const char* furi_hal_version_get_model_code(void); /** Get FCC ID * * @return FCC id as C-string */ -const char* furi_hal_version_get_fcc_id(); +const char* furi_hal_version_get_fcc_id(void); /** Get IC id * * @return IC id as C-string */ -const char* furi_hal_version_get_ic_id(); +const char* furi_hal_version_get_ic_id(void); /** Get MIC id * * @return MIC id as C-string */ -const char* furi_hal_version_get_mic_id(); +const char* furi_hal_version_get_mic_id(void); /** Get SRRC id * * @return SRRC id as C-string */ -const char* furi_hal_version_get_srrc_id(); +const char* furi_hal_version_get_srrc_id(void); /** Get NCC id * * @return NCC id as C-string */ -const char* furi_hal_version_get_ncc_id(); +const char* furi_hal_version_get_ncc_id(void); /** Get OTP version * * @return OTP Version */ -FuriHalVersionOtpVersion furi_hal_version_get_otp_version(); +FuriHalVersionOtpVersion furi_hal_version_get_otp_version(void); /** Get hardware version * * @return Hardware Version */ -uint8_t furi_hal_version_get_hw_version(); +uint8_t furi_hal_version_get_hw_version(void); /** Get hardware target * * @return Hardware Target */ -uint8_t furi_hal_version_get_hw_target(); +uint8_t furi_hal_version_get_hw_target(void); /** Get hardware body * * @return Hardware Body */ -uint8_t furi_hal_version_get_hw_body(); +uint8_t furi_hal_version_get_hw_body(void); /** Get hardware body color * * @return Hardware Color */ -FuriHalVersionColor furi_hal_version_get_hw_color(); +FuriHalVersionColor furi_hal_version_get_hw_color(void); /** Get hardware connect * * @return Hardware Interconnect */ -uint8_t furi_hal_version_get_hw_connect(); +uint8_t furi_hal_version_get_hw_connect(void); /** Get hardware region (fake) = 0 * * @return Hardware Region (fake) */ -FuriHalVersionRegion furi_hal_version_get_hw_region(); +FuriHalVersionRegion furi_hal_version_get_hw_region(void); /** Get hardware region name (fake) = R00 * * @return Hardware Region name (fake) */ -const char* furi_hal_version_get_hw_region_name(); +const char* furi_hal_version_get_hw_region_name(void); /** Get hardware region (OTP) * @@ -169,31 +169,31 @@ const char* furi_hal_version_get_hw_region_name_otp(); * * @return Display id */ -FuriHalVersionDisplay furi_hal_version_get_hw_display(); +FuriHalVersionDisplay furi_hal_version_get_hw_display(void); /** Get hardware timestamp * * @return Hardware Manufacture timestamp */ -uint32_t furi_hal_version_get_hw_timestamp(); +uint32_t furi_hal_version_get_hw_timestamp(void); /** Get pointer to target name * * @return Hardware Name C-string */ -const char* furi_hal_version_get_name_ptr(); +const char* furi_hal_version_get_name_ptr(void); /** Get pointer to target device name * * @return Hardware Device Name C-string */ -const char* furi_hal_version_get_device_name_ptr(); +const char* furi_hal_version_get_device_name_ptr(void); /** Get pointer to target ble local device name * * @return Ble Device Name C-string */ -const char* furi_hal_version_get_ble_local_device_name_ptr(); +const char* furi_hal_version_get_ble_local_device_name_ptr(void); /** Set flipper name */ @@ -203,25 +203,25 @@ void furi_hal_version_set_name(const char* name); * * @return pointer to BLE MAC address */ -const uint8_t* furi_hal_version_get_ble_mac(); +const uint8_t* furi_hal_version_get_ble_mac(void); /** Get address of version structure of firmware. * * @return Address of firmware version structure. */ -const struct Version* furi_hal_version_get_firmware_version(); +const struct Version* furi_hal_version_get_firmware_version(void); /** Get platform UID size in bytes * * @return UID size in bytes */ -size_t furi_hal_version_uid_size(); +size_t furi_hal_version_uid_size(void); /** Get const pointer to UID * * @return pointer to UID */ -const uint8_t* furi_hal_version_uid(); +const uint8_t* furi_hal_version_uid(void); const uint8_t* furi_hal_version_uid_default(); diff --git a/targets/furi_hal_include/furi_hal_vibro.h b/targets/furi_hal_include/furi_hal_vibro.h index fa5a54c68..0254f42e0 100644 --- a/targets/furi_hal_include/furi_hal_vibro.h +++ b/targets/furi_hal_include/furi_hal_vibro.h @@ -15,7 +15,7 @@ extern "C" { /** Initialize vibro */ -void furi_hal_vibro_init(); +void furi_hal_vibro_init(void); /** Turn on/off vibro *