[FL-2811] Fix PVS-Studio warnings (#2142)
Co-authored-by: あく <alleteam@gmail.com> Co-authored-by: gornekich <n.gorbadey@gmail.com>
This commit is contained in:
@@ -172,7 +172,7 @@ void button_panel_add_item(
|
||||
void* callback_context) {
|
||||
furi_assert(button_panel);
|
||||
|
||||
with_view_model(
|
||||
with_view_model( //-V773
|
||||
button_panel->view,
|
||||
ButtonPanelModel * model,
|
||||
{
|
||||
|
@@ -71,11 +71,13 @@ static uint8_t byte_input_get_row_size(uint8_t row_index) {
|
||||
|
||||
switch(row_index + 1) {
|
||||
case 1:
|
||||
row_size = sizeof(keyboard_keys_row_1) / sizeof(ByteInputKey);
|
||||
row_size = COUNT_OF(keyboard_keys_row_1);
|
||||
break;
|
||||
case 2:
|
||||
row_size = sizeof(keyboard_keys_row_2) / sizeof(ByteInputKey);
|
||||
row_size = COUNT_OF(keyboard_keys_row_2);
|
||||
break;
|
||||
default:
|
||||
furi_crash(NULL);
|
||||
}
|
||||
|
||||
return row_size;
|
||||
@@ -97,6 +99,8 @@ static const ByteInputKey* byte_input_get_row(uint8_t row_index) {
|
||||
case 2:
|
||||
row = keyboard_keys_row_2;
|
||||
break;
|
||||
default:
|
||||
furi_crash(NULL);
|
||||
}
|
||||
|
||||
return row;
|
||||
@@ -383,6 +387,7 @@ static void byte_input_dec_selected_byte(ByteInputModel* model) {
|
||||
if(model->selected_byte > 0) {
|
||||
model->selected_byte -= 1;
|
||||
|
||||
furi_assert(model->selected_byte >= model->first_visible_byte);
|
||||
if(model->selected_byte - model->first_visible_byte < 1) {
|
||||
if(model->first_visible_byte > 0) {
|
||||
model->first_visible_byte--;
|
||||
|
@@ -514,7 +514,7 @@ static void browser_draw_list(Canvas* canvas, FileBrowserModel* model) {
|
||||
scroll_counter = 0;
|
||||
}
|
||||
|
||||
if(custom_icon_data) {
|
||||
if(custom_icon_data) { //-V547
|
||||
// Currently only 10*10 icons are supported
|
||||
canvas_draw_bitmap(
|
||||
canvas, 2, Y_OFFSET + 1 + i * FRAME_HEIGHT, 10, 10, custom_icon_data);
|
||||
@@ -657,9 +657,7 @@ static bool file_browser_view_input_callback(InputEvent* event, void* context) {
|
||||
|
||||
if(!is_root && !file_browser_worker_is_in_start_folder(browser->worker)) {
|
||||
consumed = true;
|
||||
if(!is_root) {
|
||||
file_browser_worker_folder_exit(browser->worker);
|
||||
}
|
||||
file_browser_worker_folder_exit(browser->worker);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -375,7 +375,7 @@ BrowserWorker* file_browser_worker_alloc(
|
||||
const char* filter_ext,
|
||||
bool skip_assets,
|
||||
bool hide_dot_files) {
|
||||
BrowserWorker* browser = malloc(sizeof(BrowserWorker)); //-V773
|
||||
BrowserWorker* browser = malloc(sizeof(BrowserWorker));
|
||||
|
||||
idx_last_array_init(browser->idx_last);
|
||||
|
||||
@@ -395,7 +395,7 @@ BrowserWorker* file_browser_worker_alloc(
|
||||
furi_thread_start(browser->thread);
|
||||
|
||||
return browser;
|
||||
}
|
||||
} //-V773
|
||||
|
||||
void file_browser_worker_free(BrowserWorker* browser) {
|
||||
furi_assert(browser);
|
||||
|
@@ -225,8 +225,11 @@ void submenu_set_selected_item(Submenu* submenu, uint32_t index) {
|
||||
|
||||
if(items_size <= items_on_screen) {
|
||||
model->window_position = 0;
|
||||
} else if(model->window_position >= items_size - items_on_screen) {
|
||||
model->window_position = items_size - items_on_screen;
|
||||
} else {
|
||||
const size_t pos = items_size - items_on_screen;
|
||||
if(model->window_position > pos) {
|
||||
model->window_position = pos;
|
||||
}
|
||||
}
|
||||
},
|
||||
true);
|
||||
@@ -242,8 +245,7 @@ void submenu_process_up(Submenu* submenu) {
|
||||
|
||||
if(model->position > 0) {
|
||||
model->position--;
|
||||
if((model->position - model->window_position < 1) &&
|
||||
(model->window_position > 0)) {
|
||||
if((model->position == model->window_position) && (model->window_position > 0)) {
|
||||
model->window_position--;
|
||||
}
|
||||
} else {
|
||||
|
@@ -92,14 +92,16 @@ static uint8_t get_row_size(uint8_t row_index) {
|
||||
|
||||
switch(row_index + 1) {
|
||||
case 1:
|
||||
row_size = sizeof(keyboard_keys_row_1) / sizeof(TextInputKey);
|
||||
row_size = COUNT_OF(keyboard_keys_row_1);
|
||||
break;
|
||||
case 2:
|
||||
row_size = sizeof(keyboard_keys_row_2) / sizeof(TextInputKey);
|
||||
row_size = COUNT_OF(keyboard_keys_row_2);
|
||||
break;
|
||||
case 3:
|
||||
row_size = sizeof(keyboard_keys_row_3) / sizeof(TextInputKey);
|
||||
row_size = COUNT_OF(keyboard_keys_row_3);
|
||||
break;
|
||||
default:
|
||||
furi_crash(NULL);
|
||||
}
|
||||
|
||||
return row_size;
|
||||
@@ -118,6 +120,8 @@ static const TextInputKey* get_row(uint8_t row_index) {
|
||||
case 3:
|
||||
row = keyboard_keys_row_3;
|
||||
break;
|
||||
default:
|
||||
furi_crash(NULL);
|
||||
}
|
||||
|
||||
return row;
|
||||
@@ -184,7 +188,7 @@ static void text_input_view_draw_callback(Canvas* canvas, void* _model) {
|
||||
|
||||
canvas_set_font(canvas, FontKeyboard);
|
||||
|
||||
for(uint8_t row = 0; row <= keyboard_row_count; row++) {
|
||||
for(uint8_t row = 0; row < keyboard_row_count; row++) {
|
||||
const uint8_t column_count = get_row_size(row);
|
||||
const TextInputKey* keys = get_row(row);
|
||||
|
||||
@@ -303,7 +307,7 @@ static void text_input_handle_right(TextInput* text_input, TextInputModel* model
|
||||
|
||||
static void text_input_handle_ok(TextInput* text_input, TextInputModel* model, bool shift) {
|
||||
char selected = get_selected_char(model);
|
||||
uint8_t text_length = strlen(model->text_buffer);
|
||||
size_t text_length = strlen(model->text_buffer);
|
||||
|
||||
if(shift) {
|
||||
selected = char_to_uppercase(selected);
|
||||
@@ -481,7 +485,6 @@ void text_input_reset(TextInput* text_input) {
|
||||
text_input->view,
|
||||
TextInputModel * model,
|
||||
{
|
||||
model->text_buffer_size = 0;
|
||||
model->header = "";
|
||||
model->selected_row = 0;
|
||||
model->selected_column = 0;
|
||||
|
@@ -18,15 +18,12 @@ bool validator_is_file_callback(const char* text, FuriString* error, void* conte
|
||||
}
|
||||
}
|
||||
|
||||
bool ret = true;
|
||||
FuriString* path = furi_string_alloc_printf(
|
||||
"%s/%s%s", instance->app_path_folder, text, instance->app_extension);
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
if(storage_common_stat(storage, furi_string_get_cstr(path), NULL) == FSE_OK) {
|
||||
ret = false;
|
||||
const bool ret = storage_common_stat(storage, furi_string_get_cstr(path), NULL) != FSE_OK;
|
||||
if(!ret) {
|
||||
furi_string_printf(error, "This name\nexists!\nChoose\nanother one.");
|
||||
} else {
|
||||
ret = true;
|
||||
}
|
||||
furi_string_free(path);
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
|
@@ -188,8 +188,8 @@ void variable_item_list_process_up(VariableItemList* variable_item_list) {
|
||||
uint8_t items_on_screen = 4;
|
||||
if(model->position > 0) {
|
||||
model->position--;
|
||||
if(((model->position - model->window_position) < 1) &&
|
||||
model->window_position > 0) {
|
||||
|
||||
if((model->position == model->window_position) && (model->window_position > 0)) {
|
||||
model->window_position--;
|
||||
}
|
||||
} else {
|
||||
|
@@ -60,7 +60,7 @@ WidgetElement* widget_element_button_create(
|
||||
ButtonCallback callback,
|
||||
void* context) {
|
||||
// Allocate and init model
|
||||
GuiButtonModel* model = malloc(sizeof(GuiButtonModel)); //-V773
|
||||
GuiButtonModel* model = malloc(sizeof(GuiButtonModel));
|
||||
model->button_type = button_type;
|
||||
model->callback = callback;
|
||||
model->context = context;
|
||||
@@ -75,4 +75,4 @@ WidgetElement* widget_element_button_create(
|
||||
gui_button->model = model;
|
||||
|
||||
return gui_button;
|
||||
}
|
||||
} //-V773
|
||||
|
@@ -62,4 +62,4 @@ WidgetElement* widget_element_string_create(
|
||||
gui_string->model = model;
|
||||
|
||||
return gui_string;
|
||||
}
|
||||
} //-V773
|
||||
|
@@ -63,4 +63,4 @@ WidgetElement* widget_element_string_multiline_create(
|
||||
gui_string->model = model;
|
||||
|
||||
return gui_string;
|
||||
}
|
||||
} //-V773
|
||||
|
@@ -71,4 +71,4 @@ WidgetElement* widget_element_text_box_create(
|
||||
gui_string->model = model;
|
||||
|
||||
return gui_string;
|
||||
}
|
||||
} //-V773
|
||||
|
@@ -241,4 +241,4 @@ WidgetElement* widget_element_text_scroll_create(
|
||||
text_scroll->model_mutex = furi_mutex_alloc(FuriMutexTypeNormal);
|
||||
|
||||
return text_scroll;
|
||||
}
|
||||
} //-V773
|
||||
|
Reference in New Issue
Block a user