Api Symbols: replace asserts with checks (#3507)

* 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 <n.gorbadey@gmail.com>
Co-authored-by: hedger <hedger@users.noreply.github.com>
Co-authored-by: hedger <hedger@nanode.su>
This commit is contained in:
あく
2024-03-19 23:43:52 +09:00
committed by GitHub
parent a09ec4d976
commit acc39a4bc0
571 changed files with 3565 additions and 2704 deletions
@@ -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;
}
+5 -5
View File
@@ -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;
}
@@ -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);
@@ -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;
@@ -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;
}
@@ -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;
}
@@ -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;
}
@@ -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;
}
@@ -4,7 +4,7 @@
#include <stdbool.h>
#include <stdint.h>
void test_furi_memmgr() {
void test_furi_memmgr(void) {
void* ptr;
// allocate memory case
@@ -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;
@@ -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);
@@ -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;
@@ -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;
@@ -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;
@@ -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;
@@ -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);
@@ -543,7 +543,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;
}
@@ -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;
}
@@ -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;
}
+7 -7
View File
@@ -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;
}
@@ -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;
@@ -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;
}
@@ -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;
}
+1 -1
View File
@@ -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");
@@ -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;
}
@@ -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);
@@ -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;
}
@@ -314,7 +314,7 @@ static LevelDuration subghz_hal_async_tx_test_yield(void* context) {
furi_crash("Yield after reset");
}
} else {
furi_crash("Programming error");
furi_crash();
}
}
@@ -904,7 +904,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;
}
+2 -2
View File
@@ -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);
@@ -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;
}