Skip to content

Commit

Permalink
Api Symbols: replace asserts with checks (#3507)
Browse files Browse the repository at this point in the history
* Api Symbols: replace asserts with checks
* Api Symbols: replace asserts with checks part 2
* Update no args function signatures with void, to help compiler to track incorrect usage
* More unavoidable void
* Update PVS config and code to make it happy
* Format sources
* nfc: fix checks
* dead code cleanup & include fixes

Co-authored-by: gornekich <[email protected]>
Co-authored-by: hedger <[email protected]>
Co-authored-by: hedger <[email protected]>
  • Loading branch information
4 people authored Mar 19, 2024
1 parent a09ec4d commit acc39a4
Show file tree
Hide file tree
Showing 571 changed files with 3,565 additions and 2,704 deletions.
9 changes: 3 additions & 6 deletions .pvsconfig
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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/
20 changes: 10 additions & 10 deletions applications/debug/accessor/accessor_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<Scene> 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<Scene> previous_scenes_list = {Scene::Exit};
Expand Down
8 changes: 4 additions & 4 deletions applications/debug/accessor/accessor_view_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ class AccessorAppViewManager {

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;
Expand Down
20 changes: 10 additions & 10 deletions applications/debug/accessor/helpers/wiegand.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion applications/debug/battery_test_app/battery_test_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion applications/debug/battery_test_app/views/battery_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion applications/debug/battery_test_app/views/battery_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion applications/debug/bt_debug_app/bt_debug_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion applications/debug/bt_debug_app/views/bt_carrier_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion applications/debug/bt_debug_app/views/bt_carrier_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion applications/debug/bt_debug_app/views/bt_packet_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion applications/debug/bt_debug_app/views/bt_packet_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion applications/debug/bt_debug_app/views/bt_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion applications/debug/bt_debug_app/views/bt_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion applications/debug/ccid_test/ccid_test_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions applications/debug/crash_test/crash_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion applications/debug/direct_draw/direct_draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion applications/debug/display_test/display_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion applications/debug/display_test/view_display_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion applications/debug/display_test/view_display_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion applications/debug/expansion_test/expansion_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion applications/debug/lfrfid_debug/lfrfid_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion applications/debug/locale_test/locale_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion applications/debug/rpc_debug_app/rpc_debug_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion applications/debug/speaker_debug/speaker_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion applications/debug/subghz_test/subghz_test_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion applications/debug/subghz_test/views/subghz_test_carrier.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,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
Expand Down
2 changes: 1 addition & 1 deletion applications/debug/subghz_test/views/subghz_test_carrier.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,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);

Expand Down
2 changes: 1 addition & 1 deletion applications/debug/subghz_test/views/subghz_test_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit acc39a4

Please sign in to comment.