mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-26 14:30:25 +00:00
Code cleanup: srand, PVS warnings (#1974)
* Remove srand invocation * PVS High priority fixes * PVS High errors part 2 * Furi: heap tracing inheritance * Furi add __builtin_unreachable to furi_thread_catch
This commit is contained in:
parent
04e50c9f89
commit
e8913f2e33
37 changed files with 76 additions and 85 deletions
|
@ -338,10 +338,6 @@ static int32_t
|
|||
furi_hal_hid_kb_release(key);
|
||||
return (0);
|
||||
}
|
||||
if(error != NULL) {
|
||||
strncpy(error, "Unknown error", error_len);
|
||||
}
|
||||
return SCRIPT_STATE_ERROR;
|
||||
}
|
||||
|
||||
static bool ducky_set_usb_id(BadUsbScript* bad_usb, const char* line) {
|
||||
|
@ -656,7 +652,7 @@ static int32_t bad_usb_worker(void* context) {
|
|||
BadUsbScript* bad_usb_script_open(FuriString* file_path) {
|
||||
furi_assert(file_path);
|
||||
|
||||
BadUsbScript* bad_usb = malloc(sizeof(BadUsbScript));
|
||||
BadUsbScript* bad_usb = malloc(sizeof(BadUsbScript)); //-V773
|
||||
bad_usb->file_path = furi_string_alloc();
|
||||
furi_string_set(bad_usb->file_path, file_path);
|
||||
|
||||
|
|
|
@ -155,7 +155,7 @@ static bool fap_loader_select_app(FapLoader* loader) {
|
|||
}
|
||||
|
||||
static FapLoader* fap_loader_alloc(const char* path) {
|
||||
FapLoader* loader = malloc(sizeof(FapLoader));
|
||||
FapLoader* loader = malloc(sizeof(FapLoader)); //-V773
|
||||
loader->fap_path = furi_string_alloc_set(path);
|
||||
loader->storage = furi_record_open(RECORD_STORAGE);
|
||||
loader->dialogs = furi_record_open(RECORD_DIALOGS);
|
||||
|
|
|
@ -184,7 +184,7 @@ static int32_t usb_uart_worker(void* context) {
|
|||
while(1) {
|
||||
uint32_t events =
|
||||
furi_thread_flags_wait(WORKER_ALL_RX_EVENTS, FuriFlagWaitAny, FuriWaitForever);
|
||||
furi_check((events & FuriFlagError) == 0);
|
||||
furi_check(!(events & FuriFlagError));
|
||||
if(events & WorkerEvtStop) break;
|
||||
if(events & WorkerEvtRxDone) {
|
||||
size_t len = furi_stream_buffer_receive(
|
||||
|
@ -288,7 +288,7 @@ static int32_t usb_uart_tx_thread(void* context) {
|
|||
while(1) {
|
||||
uint32_t events =
|
||||
furi_thread_flags_wait(WORKER_ALL_TX_EVENTS, FuriFlagWaitAny, FuriWaitForever);
|
||||
furi_check((events & FuriFlagError) == 0);
|
||||
furi_check(!(events & FuriFlagError));
|
||||
if(events & WorkerEvtTxStop) break;
|
||||
if(events & WorkerEvtCdcRx) {
|
||||
furi_check(furi_mutex_acquire(usb_uart->usb_mutex, FuriWaitForever) == FuriStatusOk);
|
||||
|
|
|
@ -32,7 +32,7 @@ static void rpc_command_callback(RpcAppSystemEvent rpc_event, void* context) {
|
|||
}
|
||||
|
||||
static LfRfid* lfrfid_alloc() {
|
||||
LfRfid* lfrfid = malloc(sizeof(LfRfid));
|
||||
LfRfid* lfrfid = malloc(sizeof(LfRfid)); //-V773
|
||||
|
||||
lfrfid->storage = furi_record_open(RECORD_STORAGE);
|
||||
lfrfid->dialogs = furi_record_open(RECORD_DIALOGS);
|
||||
|
|
|
@ -24,7 +24,7 @@ void nfc_scene_mf_classic_read_success_on_enter(void* context) {
|
|||
widget_add_button_element(
|
||||
widget, GuiButtonTypeRight, "More", nfc_scene_mf_classic_read_success_widget_callback, nfc);
|
||||
|
||||
FuriString* temp_str;
|
||||
FuriString* temp_str = NULL;
|
||||
if(furi_string_size(nfc->dev->dev_data.parsed_data)) {
|
||||
temp_str = furi_string_alloc_set(nfc->dev->dev_data.parsed_data);
|
||||
} else {
|
||||
|
|
|
@ -31,7 +31,7 @@ void nfc_scene_mf_ultralight_read_success_on_enter(void* context) {
|
|||
nfc_scene_mf_ultralight_read_success_widget_callback,
|
||||
nfc);
|
||||
|
||||
FuriString* temp_str;
|
||||
FuriString* temp_str = NULL;
|
||||
if(furi_string_size(nfc->dev->dev_data.parsed_data)) {
|
||||
temp_str = furi_string_alloc_set(nfc->dev->dev_data.parsed_data);
|
||||
} else {
|
||||
|
|
|
@ -513,12 +513,6 @@ bool subghz_path_is_file(FuriString* path) {
|
|||
}
|
||||
|
||||
uint32_t subghz_random_serial(void) {
|
||||
static bool rand_generator_inited = false;
|
||||
|
||||
if(!rand_generator_inited) {
|
||||
srand(DWT->CYCCNT);
|
||||
rand_generator_inited = true;
|
||||
}
|
||||
return (uint32_t)rand();
|
||||
}
|
||||
|
||||
|
|
|
@ -203,7 +203,7 @@ static int32_t u2f_hid_worker(void* context) {
|
|||
WorkerEvtStop | WorkerEvtConnect | WorkerEvtDisconnect | WorkerEvtRequest,
|
||||
FuriFlagWaitAny,
|
||||
FuriWaitForever);
|
||||
furi_check((flags & FuriFlagError) == 0);
|
||||
furi_check(!(flags & FuriFlagError));
|
||||
if(flags & WorkerEvtStop) break;
|
||||
if(flags & WorkerEvtConnect) {
|
||||
u2f_set_state(u2f_hid->u2f_instance, 1);
|
||||
|
|
|
@ -318,7 +318,6 @@ static void
|
|||
|
||||
int32_t snake_game_app(void* p) {
|
||||
UNUSED(p);
|
||||
srand(DWT->CYCCNT);
|
||||
|
||||
FuriMessageQueue* event_queue = furi_message_queue_alloc(8, sizeof(SnakeEvent));
|
||||
|
||||
|
|
|
@ -200,7 +200,6 @@ void ws_protocol_decoder_ambient_weather_feed(void* context, bool level, uint32_
|
|||
((instance->decoder.decode_data & AMBIENT_WEATHER_PACKET_HEADER_MASK) ==
|
||||
AMBIENT_WEATHER_PACKET_HEADER_2)) {
|
||||
if(ws_protocol_ambient_weather_check_crc(instance)) {
|
||||
instance->decoder.decode_data = instance->decoder.decode_data;
|
||||
instance->generic.data = instance->decoder.decode_data;
|
||||
instance->generic.data_count_bit =
|
||||
ws_protocol_ambient_weather_const.min_count_bit_for_found;
|
||||
|
|
|
@ -61,15 +61,20 @@ static void gpio_print_pins(void) {
|
|||
}
|
||||
}
|
||||
|
||||
typedef enum { OK, ERR_CMD_SYNTAX, ERR_PIN, ERR_VALUE } GpioParseError;
|
||||
typedef enum {
|
||||
GpioParseReturnOk,
|
||||
GpioParseReturnCmdSyntaxError,
|
||||
GpioParseReturnPinError,
|
||||
GpioParseReturnValueError
|
||||
} GpioParseReturn;
|
||||
|
||||
static GpioParseError gpio_command_parse(FuriString* args, size_t* pin_num, uint8_t* value) {
|
||||
static GpioParseReturn gpio_command_parse(FuriString* args, size_t* pin_num, uint8_t* value) {
|
||||
FuriString* pin_name;
|
||||
pin_name = furi_string_alloc();
|
||||
|
||||
size_t ws = furi_string_search_char(args, ' ');
|
||||
if(ws == FURI_STRING_FAILURE) {
|
||||
return ERR_CMD_SYNTAX;
|
||||
return GpioParseReturnCmdSyntaxError;
|
||||
}
|
||||
|
||||
furi_string_set_n(pin_name, args, 0, ws);
|
||||
|
@ -78,7 +83,7 @@ static GpioParseError gpio_command_parse(FuriString* args, size_t* pin_num, uint
|
|||
|
||||
if(!pin_name_to_int(pin_name, pin_num)) {
|
||||
furi_string_free(pin_name);
|
||||
return ERR_PIN;
|
||||
return GpioParseReturnPinError;
|
||||
}
|
||||
|
||||
furi_string_free(pin_name);
|
||||
|
@ -88,10 +93,10 @@ static GpioParseError gpio_command_parse(FuriString* args, size_t* pin_num, uint
|
|||
} else if(!furi_string_cmp(args, "1")) {
|
||||
*value = 1;
|
||||
} else {
|
||||
return ERR_VALUE;
|
||||
return GpioParseReturnValueError;
|
||||
}
|
||||
|
||||
return OK;
|
||||
return GpioParseReturnOk;
|
||||
}
|
||||
|
||||
void cli_command_gpio_mode(Cli* cli, FuriString* args, void* context) {
|
||||
|
@ -101,15 +106,15 @@ void cli_command_gpio_mode(Cli* cli, FuriString* args, void* context) {
|
|||
size_t num = 0;
|
||||
uint8_t value = 255;
|
||||
|
||||
GpioParseError err = gpio_command_parse(args, &num, &value);
|
||||
GpioParseReturn err = gpio_command_parse(args, &num, &value);
|
||||
|
||||
if(ERR_CMD_SYNTAX == err) {
|
||||
if(err == GpioParseReturnCmdSyntaxError) {
|
||||
cli_print_usage("gpio mode", "<pin_name> <0|1>", furi_string_get_cstr(args));
|
||||
return;
|
||||
} else if(ERR_PIN == err) {
|
||||
} else if(err == GpioParseReturnPinError) {
|
||||
gpio_print_pins();
|
||||
return;
|
||||
} else if(ERR_VALUE == err) {
|
||||
} else if(err == GpioParseReturnValueError) {
|
||||
printf("Value is invalid. Enter 1 for input or 0 for output");
|
||||
return;
|
||||
}
|
||||
|
@ -161,15 +166,15 @@ void cli_command_gpio_set(Cli* cli, FuriString* args, void* context) {
|
|||
|
||||
size_t num = 0;
|
||||
uint8_t value = 0;
|
||||
GpioParseError err = gpio_command_parse(args, &num, &value);
|
||||
GpioParseReturn err = gpio_command_parse(args, &num, &value);
|
||||
|
||||
if(ERR_CMD_SYNTAX == err) {
|
||||
if(err == GpioParseReturnCmdSyntaxError) {
|
||||
cli_print_usage("gpio set", "<pin_name> <0|1>", furi_string_get_cstr(args));
|
||||
return;
|
||||
} else if(ERR_PIN == err) {
|
||||
} else if(err == GpioParseReturnPinError) {
|
||||
gpio_print_pins();
|
||||
return;
|
||||
} else if(ERR_VALUE == err) {
|
||||
} else if(err == GpioParseReturnValueError) {
|
||||
printf("Value is invalid. Enter 1 for high or 0 for low");
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ static int32_t vcp_worker(void* context) {
|
|||
while(1) {
|
||||
uint32_t flags =
|
||||
furi_thread_flags_wait(VCP_THREAD_FLAG_ALL, FuriFlagWaitAny, FuriWaitForever);
|
||||
furi_assert((flags & FuriFlagError) == 0);
|
||||
furi_assert(!(flags & FuriFlagError));
|
||||
|
||||
// VCP session opened
|
||||
if(flags & VcpEvtConnect) {
|
||||
|
@ -303,7 +303,7 @@ static void vcp_on_cdc_control_line(void* context, uint8_t state) {
|
|||
static void vcp_on_cdc_rx(void* context) {
|
||||
UNUSED(context);
|
||||
uint32_t ret = furi_thread_flags_set(furi_thread_get_id(vcp->thread), VcpEvtRx);
|
||||
furi_check((ret & FuriFlagError) == 0);
|
||||
furi_check(!(ret & FuriFlagError));
|
||||
}
|
||||
|
||||
static void vcp_on_cdc_tx_complete(void* context) {
|
||||
|
|
|
@ -167,7 +167,7 @@ void crypto_cli_decrypt(Cli* cli, FuriString* args) {
|
|||
void crypto_cli_has_key(Cli* cli, FuriString* args) {
|
||||
UNUSED(cli);
|
||||
int key_slot = 0;
|
||||
uint8_t iv[16];
|
||||
uint8_t iv[16] = {0};
|
||||
|
||||
do {
|
||||
if(!args_read_int_and_trim(args, &key_slot) || !(key_slot > 0 && key_slot <= 100)) {
|
||||
|
@ -249,7 +249,7 @@ void crypto_cli_store_key(Cli* cli, FuriString* args) {
|
|||
}
|
||||
|
||||
if(key_slot > 0) {
|
||||
uint8_t iv[16];
|
||||
uint8_t iv[16] = {0};
|
||||
if(key_slot > 1) {
|
||||
if(!furi_hal_crypto_store_load_key(key_slot - 1, iv)) {
|
||||
printf(
|
||||
|
|
|
@ -436,7 +436,7 @@ void gui_add_framebuffer_callback(Gui* gui, GuiCanvasCommitCallback callback, vo
|
|||
const CanvasCallbackPair p = {callback, context};
|
||||
|
||||
gui_lock(gui);
|
||||
furi_assert(CanvasCallbackPairArray_count(gui->canvas_callback_pair, p) == 0);
|
||||
furi_assert(!CanvasCallbackPairArray_count(gui->canvas_callback_pair, p));
|
||||
CanvasCallbackPairArray_push_back(gui->canvas_callback_pair, p);
|
||||
gui_unlock(gui);
|
||||
|
||||
|
|
|
@ -359,7 +359,7 @@ static int32_t browser_worker(void* context) {
|
|||
|
||||
BrowserWorker*
|
||||
file_browser_worker_alloc(FuriString* path, const char* filter_ext, bool skip_assets) {
|
||||
BrowserWorker* browser = malloc(sizeof(BrowserWorker));
|
||||
BrowserWorker* browser = malloc(sizeof(BrowserWorker)); //-V773
|
||||
|
||||
idx_last_array_init(browser->idx_last);
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ WidgetElement* widget_element_button_create(
|
|||
ButtonCallback callback,
|
||||
void* context) {
|
||||
// Allocate and init model
|
||||
GuiButtonModel* model = malloc(sizeof(GuiButtonModel));
|
||||
GuiButtonModel* model = malloc(sizeof(GuiButtonModel)); //-V773
|
||||
model->button_type = button_type;
|
||||
model->callback = callback;
|
||||
model->context = context;
|
||||
|
|
|
@ -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) == 0);
|
||||
furi_assert(!ViewDict_size(view_dispatcher->views));
|
||||
|
||||
ViewDict_clear(view_dispatcher->views);
|
||||
// Free ViewPort
|
||||
|
@ -157,7 +157,7 @@ void view_dispatcher_remove_view(ViewDispatcher* view_dispatcher, uint32_t view_
|
|||
view_dispatcher->ongoing_input_view = NULL;
|
||||
}
|
||||
// Remove view
|
||||
ViewDict_erase(view_dispatcher->views, view_id);
|
||||
furi_check(ViewDict_erase(view_dispatcher->views, view_id));
|
||||
|
||||
view_set_update_callback(view, NULL);
|
||||
view_set_update_callback_context(view, NULL);
|
||||
|
|
|
@ -269,7 +269,7 @@ static void loader_thread_state_callback(FuriThreadState thread_state, void* con
|
|||
event.type = LoaderEventTypeApplicationStarted;
|
||||
furi_pubsub_publish(loader_instance->pubsub, &event);
|
||||
|
||||
if(!loader_instance->application->flags & FlipperApplicationFlagInsomniaSafe) {
|
||||
if(!(loader_instance->application->flags & FlipperApplicationFlagInsomniaSafe)) {
|
||||
furi_hal_power_insomnia_enter();
|
||||
}
|
||||
} else if(thread_state == FuriThreadStateStopped) {
|
||||
|
@ -284,7 +284,7 @@ static void loader_thread_state_callback(FuriThreadState thread_state, void* con
|
|||
loader_instance->application_arguments = NULL;
|
||||
}
|
||||
|
||||
if(!loader_instance->application->flags & FlipperApplicationFlagInsomniaSafe) {
|
||||
if(!(loader_instance->application->flags & FlipperApplicationFlagInsomniaSafe)) {
|
||||
furi_hal_power_insomnia_exit();
|
||||
}
|
||||
loader_unlock(instance);
|
||||
|
|
|
@ -275,7 +275,7 @@ static void storage_cli_read_chunks(Cli* cli, FuriString* path, FuriString* args
|
|||
uint32_t buffer_size;
|
||||
int parsed_count = sscanf(furi_string_get_cstr(args), "%lu", &buffer_size);
|
||||
|
||||
if(parsed_count == EOF || parsed_count != 1) {
|
||||
if(parsed_count != 1) {
|
||||
storage_cli_print_usage();
|
||||
} else if(storage_file_open(file, furi_string_get_cstr(path), FSAM_READ, FSOM_OPEN_EXISTING)) {
|
||||
uint64_t file_size = storage_file_size(file);
|
||||
|
@ -315,7 +315,7 @@ static void storage_cli_write_chunk(Cli* cli, FuriString* path, FuriString* args
|
|||
uint32_t buffer_size;
|
||||
int parsed_count = sscanf(furi_string_get_cstr(args), "%lu", &buffer_size);
|
||||
|
||||
if(parsed_count == EOF || parsed_count != 1) {
|
||||
if(parsed_count != 1) {
|
||||
storage_cli_print_usage();
|
||||
} else {
|
||||
if(storage_file_open(file, furi_string_get_cstr(path), FSAM_WRITE, FSOM_OPEN_APPEND)) {
|
||||
|
|
|
@ -545,8 +545,8 @@ static FS_Error
|
|||
|
||||
FS_Error storage_common_merge(Storage* storage, const char* old_path, const char* new_path) {
|
||||
FS_Error error;
|
||||
const char* new_path_tmp;
|
||||
FuriString* new_path_next;
|
||||
const char* new_path_tmp = NULL;
|
||||
FuriString* new_path_next = NULL;
|
||||
new_path_next = furi_string_alloc();
|
||||
|
||||
FileInfo fileinfo;
|
||||
|
|
|
@ -179,7 +179,7 @@ SVCCTL_UserEvtFlowStatus_t SVCCTL_App_Notification(void* pckt) {
|
|||
|
||||
case EVT_BLUE_GAP_PASS_KEY_REQUEST: {
|
||||
// Generate random PIN code
|
||||
uint32_t pin = rand() % 999999;
|
||||
uint32_t pin = rand() % 999999; //-V1064
|
||||
aci_gap_pass_key_resp(gap->service.connection_handle, pin);
|
||||
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagLock)) {
|
||||
FURI_LOG_I(TAG, "Pass key request event. Pin: ******");
|
||||
|
@ -478,7 +478,6 @@ bool gap_init(GapConfig* config, GapEventCallback on_event_cb, void* context) {
|
|||
|
||||
gap = malloc(sizeof(Gap));
|
||||
gap->config = config;
|
||||
srand(DWT->CYCCNT);
|
||||
// Create advertising timer
|
||||
gap->advertise_timer = furi_timer_alloc(gap_advetise_timer_callback, FuriTimerTypeOnce, NULL);
|
||||
// Initialization of GATT & GAP layer
|
||||
|
|
|
@ -91,7 +91,7 @@ bool furi_hal_crypto_verify_key(uint8_t key_slot) {
|
|||
uint8_t keys_nb = 0;
|
||||
uint8_t valid_keys_nb = 0;
|
||||
uint8_t last_valid_slot = ENCLAVE_FACTORY_KEY_SLOTS;
|
||||
uint8_t empty_iv[16];
|
||||
uint8_t empty_iv[16] = {0};
|
||||
furi_hal_crypto_verify_enclave(&keys_nb, &valid_keys_nb);
|
||||
if(key_slot <= ENCLAVE_FACTORY_KEY_SLOTS) { // It's a factory key
|
||||
if(key_slot > keys_nb) return false;
|
||||
|
|
|
@ -46,7 +46,7 @@ FURI_NORETURN void __furi_halt();
|
|||
/** Check condition and crash if check failed */
|
||||
#define furi_check(__e) \
|
||||
do { \
|
||||
if((__e) == 0) { \
|
||||
if(!(__e)) { \
|
||||
furi_crash("furi_check failed\r\n"); \
|
||||
} \
|
||||
} while(0)
|
||||
|
@ -55,7 +55,7 @@ FURI_NORETURN void __furi_halt();
|
|||
#ifdef FURI_DEBUG
|
||||
#define furi_assert(__e) \
|
||||
do { \
|
||||
if((__e) == 0) { \
|
||||
if(!(__e)) { \
|
||||
furi_crash("furi_assert failed\r\n"); \
|
||||
} \
|
||||
} while(0)
|
||||
|
|
|
@ -25,7 +25,7 @@ uint32_t furi_event_flag_set(FuriEventFlag* instance, uint32_t flags) {
|
|||
uint32_t rflags;
|
||||
BaseType_t yield;
|
||||
|
||||
if(FURI_IS_IRQ_MODE() != 0U) {
|
||||
if(FURI_IS_IRQ_MODE()) {
|
||||
yield = pdFALSE;
|
||||
if(xEventGroupSetBitsFromISR(hEventGroup, (EventBits_t)flags, &yield) == pdFAIL) {
|
||||
rflags = (uint32_t)FuriStatusErrorResource;
|
||||
|
@ -48,7 +48,7 @@ uint32_t furi_event_flag_clear(FuriEventFlag* instance, uint32_t flags) {
|
|||
EventGroupHandle_t hEventGroup = (EventGroupHandle_t)instance;
|
||||
uint32_t rflags;
|
||||
|
||||
if(FURI_IS_IRQ_MODE() != 0U) {
|
||||
if(FURI_IS_IRQ_MODE()) {
|
||||
rflags = xEventGroupGetBitsFromISR(hEventGroup);
|
||||
|
||||
if(xEventGroupClearBitsFromISR(hEventGroup, (EventBits_t)flags) == pdFAIL) {
|
||||
|
@ -73,7 +73,7 @@ uint32_t furi_event_flag_get(FuriEventFlag* instance) {
|
|||
EventGroupHandle_t hEventGroup = (EventGroupHandle_t)instance;
|
||||
uint32_t rflags;
|
||||
|
||||
if(FURI_IS_IRQ_MODE() != 0U) {
|
||||
if(FURI_IS_IRQ_MODE()) {
|
||||
rflags = xEventGroupGetBitsFromISR(hEventGroup);
|
||||
} else {
|
||||
rflags = xEventGroupGetBits(hEventGroup);
|
||||
|
|
|
@ -150,8 +150,7 @@ void memmgr_heap_disable_thread_trace(FuriThreadId thread_id) {
|
|||
vTaskSuspendAll();
|
||||
{
|
||||
memmgr_heap_thread_trace_depth++;
|
||||
furi_check(MemmgrHeapThreadDict_get(memmgr_heap_thread_dict, (uint32_t)thread_id) != NULL);
|
||||
MemmgrHeapThreadDict_erase(memmgr_heap_thread_dict, (uint32_t)thread_id);
|
||||
furi_check(MemmgrHeapThreadDict_erase(memmgr_heap_thread_dict, (uint32_t)thread_id));
|
||||
memmgr_heap_thread_trace_depth--;
|
||||
}
|
||||
(void)xTaskResumeAll();
|
||||
|
@ -212,7 +211,8 @@ static inline void traceFREE(void* pointer, size_t size) {
|
|||
MemmgrHeapAllocDict_t* alloc_dict =
|
||||
MemmgrHeapThreadDict_get(memmgr_heap_thread_dict, (uint32_t)thread_id);
|
||||
if(alloc_dict) {
|
||||
MemmgrHeapAllocDict_erase(*alloc_dict, (uint32_t)pointer);
|
||||
// In some cases thread may want to release memory that was not allocated by it
|
||||
(void)MemmgrHeapAllocDict_erase(*alloc_dict, (uint32_t)pointer);
|
||||
}
|
||||
memmgr_heap_thread_trace_depth--;
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ FuriStatus furi_mutex_acquire(FuriMutex* instance, uint32_t timeout) {
|
|||
|
||||
stat = FuriStatusOk;
|
||||
|
||||
if(FURI_IS_IRQ_MODE() != 0U) {
|
||||
if(FURI_IS_IRQ_MODE()) {
|
||||
stat = FuriStatusErrorISR;
|
||||
} else if(hMutex == NULL) {
|
||||
stat = FuriStatusErrorParameter;
|
||||
|
@ -85,7 +85,7 @@ FuriStatus furi_mutex_release(FuriMutex* instance) {
|
|||
|
||||
stat = FuriStatusOk;
|
||||
|
||||
if(FURI_IS_IRQ_MODE() != 0U) {
|
||||
if(FURI_IS_IRQ_MODE()) {
|
||||
stat = FuriStatusErrorISR;
|
||||
} else if(hMutex == NULL) {
|
||||
stat = FuriStatusErrorParameter;
|
||||
|
@ -111,7 +111,7 @@ FuriThreadId furi_mutex_get_owner(FuriMutex* instance) {
|
|||
|
||||
hMutex = (SemaphoreHandle_t)((uint32_t)instance & ~1U);
|
||||
|
||||
if((FURI_IS_IRQ_MODE() != 0U) || (hMutex == NULL)) {
|
||||
if((FURI_IS_IRQ_MODE()) || (hMutex == NULL)) {
|
||||
owner = 0;
|
||||
} else {
|
||||
owner = (FuriThreadId)xSemaphoreGetMutexHolder(hMutex);
|
||||
|
|
|
@ -45,7 +45,7 @@ FuriStatus furi_semaphore_acquire(FuriSemaphore* instance, uint32_t timeout) {
|
|||
|
||||
stat = FuriStatusOk;
|
||||
|
||||
if(FURI_IS_IRQ_MODE() != 0U) {
|
||||
if(FURI_IS_IRQ_MODE()) {
|
||||
if(timeout != 0U) {
|
||||
stat = FuriStatusErrorParameter;
|
||||
} else {
|
||||
|
@ -80,7 +80,7 @@ FuriStatus furi_semaphore_release(FuriSemaphore* instance) {
|
|||
|
||||
stat = FuriStatusOk;
|
||||
|
||||
if(FURI_IS_IRQ_MODE() != 0U) {
|
||||
if(FURI_IS_IRQ_MODE()) {
|
||||
yield = pdFALSE;
|
||||
|
||||
if(xSemaphoreGiveFromISR(hSemaphore, &yield) != pdTRUE) {
|
||||
|
@ -104,7 +104,7 @@ uint32_t furi_semaphore_get_count(FuriSemaphore* instance) {
|
|||
SemaphoreHandle_t hSemaphore = (SemaphoreHandle_t)instance;
|
||||
uint32_t count;
|
||||
|
||||
if(FURI_IS_IRQ_MODE() != 0U) {
|
||||
if(FURI_IS_IRQ_MODE()) {
|
||||
count = (uint32_t)uxSemaphoreGetCountFromISR(hSemaphore);
|
||||
} else {
|
||||
count = (uint32_t)uxSemaphoreGetCount(hSemaphore);
|
||||
|
|
|
@ -23,7 +23,7 @@ size_t furi_stream_buffer_send(
|
|||
uint32_t timeout) {
|
||||
size_t ret;
|
||||
|
||||
if(FURI_IS_IRQ_MODE() != 0U) {
|
||||
if(FURI_IS_IRQ_MODE()) {
|
||||
BaseType_t yield;
|
||||
ret = xStreamBufferSendFromISR(stream_buffer, data, length, &yield);
|
||||
portYIELD_FROM_ISR(yield);
|
||||
|
@ -41,7 +41,7 @@ size_t furi_stream_buffer_receive(
|
|||
uint32_t timeout) {
|
||||
size_t ret;
|
||||
|
||||
if(FURI_IS_IRQ_MODE() != 0U) {
|
||||
if(FURI_IS_IRQ_MODE()) {
|
||||
BaseType_t yield;
|
||||
ret = xStreamBufferReceiveFromISR(stream_buffer, data, length, &yield);
|
||||
portYIELD_FROM_ISR(yield);
|
||||
|
|
|
@ -29,13 +29,13 @@ FuriString* furi_string_alloc() {
|
|||
}
|
||||
|
||||
FuriString* furi_string_alloc_set(const FuriString* s) {
|
||||
FuriString* string = malloc(sizeof(FuriString));
|
||||
FuriString* string = malloc(sizeof(FuriString)); //-V773
|
||||
string_init_set(string->string, s->string);
|
||||
return string;
|
||||
}
|
||||
|
||||
FuriString* furi_string_alloc_set_str(const char cstr[]) {
|
||||
FuriString* string = malloc(sizeof(FuriString));
|
||||
FuriString* string = malloc(sizeof(FuriString)); //-V773
|
||||
string_init_set(string->string, cstr);
|
||||
return string;
|
||||
}
|
||||
|
|
|
@ -50,6 +50,7 @@ static int32_t __furi_thread_stdout_flush(FuriThread* thread);
|
|||
__attribute__((__noreturn__)) void furi_thread_catch() {
|
||||
asm volatile("nop"); // extra magic
|
||||
furi_crash("You are doing it wrong");
|
||||
__builtin_unreachable();
|
||||
}
|
||||
|
||||
static void furi_thread_set_state(FuriThread* thread, FuriThreadState state) {
|
||||
|
@ -112,6 +113,12 @@ FuriThread* furi_thread_alloc() {
|
|||
FuriThread* thread = malloc(sizeof(FuriThread));
|
||||
thread->output.buffer = furi_string_alloc();
|
||||
thread->is_service = false;
|
||||
|
||||
if(furi_thread_get_current_id()) {
|
||||
FuriThread* parent = pvTaskGetThreadLocalStoragePointer(NULL, 0);
|
||||
if(parent) thread->heap_trace_enabled = parent->heap_trace_enabled;
|
||||
}
|
||||
|
||||
return thread;
|
||||
}
|
||||
|
||||
|
|
|
@ -313,7 +313,7 @@ bool flipper_format_stream_write_value_line(Stream* stream, FlipperStreamWriteDa
|
|||
furi_crash("Unknown FF type");
|
||||
}
|
||||
|
||||
if((size_t)(i + 1) < write_data->data_size) {
|
||||
if(((size_t)i + 1) < write_data->data_size) {
|
||||
furi_string_cat(value, " ");
|
||||
}
|
||||
|
||||
|
|
|
@ -85,8 +85,8 @@ static InfraredStatus infrared_common_decode_bits(InfraredCommonDecoder* decoder
|
|||
if(timings->min_split_time && !level) {
|
||||
if(timing > timings->min_split_time) {
|
||||
/* long low timing - check if we're ready for any of protocol modification */
|
||||
for(size_t i = 0; decoder->protocol->databit_len[i] &&
|
||||
(i < COUNT_OF(decoder->protocol->databit_len));
|
||||
for(size_t i = 0; i < COUNT_OF(decoder->protocol->databit_len) &&
|
||||
decoder->protocol->databit_len[i];
|
||||
++i) {
|
||||
if(decoder->protocol->databit_len[i] == decoder->databit_cnt) {
|
||||
return InfraredStatusReady;
|
||||
|
@ -199,7 +199,7 @@ InfraredMessage* infrared_common_decoder_check_ready(InfraredCommonDecoder* deco
|
|||
bool found_length = false;
|
||||
|
||||
for(size_t i = 0;
|
||||
decoder->protocol->databit_len[i] && (i < COUNT_OF(decoder->protocol->databit_len));
|
||||
i < COUNT_OF(decoder->protocol->databit_len) && decoder->protocol->databit_len[i];
|
||||
++i) {
|
||||
if(decoder->protocol->databit_len[i] == decoder->databit_cnt) {
|
||||
found_length = true;
|
||||
|
|
|
@ -140,9 +140,8 @@ size_t lfrfid_worker_dict_get_data_size(LFRFIDWorker* worker, LFRFIDProtocol pro
|
|||
|
||||
static int32_t lfrfid_worker_thread(void* thread_context) {
|
||||
LFRFIDWorker* worker = thread_context;
|
||||
bool running = true;
|
||||
|
||||
while(running) {
|
||||
while(true) {
|
||||
uint32_t flags = furi_thread_flags_wait(LFRFIDEventAll, FuriFlagWaitAny, FuriWaitForever);
|
||||
if(flags != FuriFlagErrorTimeout) {
|
||||
// stop thread
|
||||
|
|
|
@ -541,7 +541,7 @@ static size_t _etoa(
|
|||
exp2 = (int)(expval * 3.321928094887362 + 0.5);
|
||||
const double z = expval * 2.302585092994046 - exp2 * 0.6931471805599453;
|
||||
const double z2 = z * z;
|
||||
conv.U = (uint64_t)(exp2 + 1023) << 52U;
|
||||
conv.U = ((uint64_t)exp2 + 1023) << 52U;
|
||||
// compute exp(z) using continued fractions, see https://en.wikipedia.org/wiki/Exponential_function#Continued_fractions_for_ex
|
||||
conv.F *= 1 + 2 * z / (2 - z + (z2 / (6 + (z2 / (10 + z2 / 14)))));
|
||||
// correct for rounding errors
|
||||
|
|
|
@ -312,7 +312,6 @@ void subghz_protocol_decoder_power_smart_feed(
|
|||
if((instance->decoder.decode_data & POWER_SMART_PACKET_HEADER_MASK) ==
|
||||
POWER_SMART_PACKET_HEADER) {
|
||||
if(subghz_protocol_power_smart_chek_valid(instance->decoder.decode_data)) {
|
||||
instance->decoder.decode_data = instance->decoder.decode_data;
|
||||
instance->generic.data = instance->decoder.decode_data;
|
||||
instance->generic.data_count_bit =
|
||||
subghz_protocol_power_smart_const.min_count_bit_for_found;
|
||||
|
|
|
@ -464,7 +464,7 @@ bool subghz_keystore_raw_encrypted_save(
|
|||
}
|
||||
stream_write_cstring(output_stream, encrypted_line);
|
||||
|
||||
} while(ret > 0 && result);
|
||||
} while(result);
|
||||
|
||||
flipper_format_free(output_flipper_format);
|
||||
|
||||
|
|
|
@ -5,12 +5,6 @@
|
|||
#include <furi.h>
|
||||
|
||||
void set_random_name(char* name, uint8_t max_name_size) {
|
||||
static bool rand_generator_inited = false;
|
||||
|
||||
if(!rand_generator_inited) {
|
||||
srand(DWT->CYCCNT);
|
||||
rand_generator_inited = true;
|
||||
}
|
||||
const char* prefix[] = {
|
||||
"ancient", "hollow", "strange", "disappeared", "unknown",
|
||||
"unthinkable", "unnamable", "nameless", "my", "concealed",
|
||||
|
|
Loading…
Reference in a new issue