[FL-2520] FW build with -Wextra (#1185)
* Fixing compiler warnings with -Wextra * More warnings suppression, WIP * Even more warning fixes * Added new lines at end of text files. * Padding fix * Additional fixes to warnings on different build configurations; added -Wextra to default build pipeline * Fixes for Secplus v1 * -additional warnings * +-Wredundant-decls fixes * FuriHal: print stack overflow task name in console * FuriHal: add missing include Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
@@ -66,6 +66,7 @@ void archive_free(ArchiveApp* archive) {
|
||||
}
|
||||
|
||||
int32_t archive_app(void* p) {
|
||||
UNUSED(p);
|
||||
ArchiveApp* archive = archive_alloc();
|
||||
scene_manager_next_scene(archive->scene_manager, ArchiveAppSceneBrowser);
|
||||
view_dispatcher_run(archive->view_dispatcher);
|
||||
|
@@ -7,8 +7,8 @@ static const char* known_apps[] = {
|
||||
};
|
||||
|
||||
ArchiveAppTypeEnum archive_get_app_type(const char* path) {
|
||||
for(size_t i = 0; i < SIZEOF_ARRAY(known_apps); i++) {
|
||||
if(strncmp(path, known_apps[i], strlen(known_apps[i])) != STRING_FAILURE) {
|
||||
for(size_t i = 0; i < COUNT_OF(known_apps); i++) {
|
||||
if(strncmp(path, known_apps[i], strlen(known_apps[i])) == 0) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,7 @@ ArchiveAppTypeEnum archive_get_app_type(const char* path) {
|
||||
}
|
||||
|
||||
bool archive_app_is_available(void* context, const char* path) {
|
||||
UNUSED(context);
|
||||
furi_assert(path);
|
||||
|
||||
ArchiveAppTypeEnum app = archive_get_app_type(path);
|
||||
|
@@ -11,7 +11,7 @@ static const ArchiveFileTypeEnum app_file_types[] = {
|
||||
[ArchiveAppTypeUnknown] = ArchiveFileTypeUnknown,
|
||||
};
|
||||
|
||||
static inline const ArchiveFileTypeEnum archive_get_app_filetype(ArchiveAppTypeEnum app) {
|
||||
static inline ArchiveFileTypeEnum archive_get_app_filetype(ArchiveAppTypeEnum app) {
|
||||
return app_file_types[app];
|
||||
}
|
||||
|
||||
|
@@ -6,7 +6,8 @@
|
||||
bool archive_is_item_in_array(ArchiveBrowserViewModel* model, uint32_t idx) {
|
||||
size_t array_size = files_array_size(model->files);
|
||||
|
||||
if((idx >= model->array_offset + array_size) || (idx < model->array_offset)) {
|
||||
if((idx >= (uint32_t)model->array_offset + array_size) ||
|
||||
(idx < (uint32_t)model->array_offset)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -20,12 +21,14 @@ void archive_update_offset(ArchiveBrowserView* browser) {
|
||||
browser->view, (ArchiveBrowserViewModel * model) {
|
||||
uint16_t bounds = model->item_cnt > 3 ? 2 : model->item_cnt;
|
||||
|
||||
if(model->item_cnt > 3 && model->item_idx >= model->item_cnt - 1) {
|
||||
if((model->item_cnt > 3u) && ((uint32_t)model->item_idx >= (model->item_cnt - 1))) {
|
||||
model->list_offset = model->item_idx - 3;
|
||||
} else if(model->list_offset < model->item_idx - bounds) {
|
||||
model->list_offset = CLAMP(model->item_idx - 2, model->item_cnt - bounds, 0);
|
||||
model->list_offset =
|
||||
CLAMP((uint32_t)model->item_idx - 2, model->item_cnt - bounds, 0u);
|
||||
} else if(model->list_offset > model->item_idx - bounds) {
|
||||
model->list_offset = CLAMP(model->item_idx - 1, model->item_cnt - bounds, 0);
|
||||
model->list_offset =
|
||||
CLAMP((uint32_t)model->item_idx - 1, model->item_cnt - bounds, 0u);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -77,7 +80,7 @@ void archive_set_item_count(ArchiveBrowserView* browser, uint32_t count) {
|
||||
with_view_model(
|
||||
browser->view, (ArchiveBrowserViewModel * model) {
|
||||
model->item_cnt = count;
|
||||
model->item_idx = CLAMP(model->item_idx, model->item_cnt - 1, 0);
|
||||
model->item_idx = CLAMP((uint32_t)model->item_idx, model->item_cnt - 1, 0u);
|
||||
return false;
|
||||
});
|
||||
archive_update_offset(browser);
|
||||
@@ -94,7 +97,7 @@ void archive_file_array_rm_selected(ArchiveBrowserView* browser) {
|
||||
model->item_idx - model->array_offset,
|
||||
model->item_idx - model->array_offset + 1);
|
||||
model->item_cnt--;
|
||||
model->item_idx = CLAMP(model->item_idx, model->item_cnt - 1, 0);
|
||||
model->item_idx = CLAMP((uint32_t)model->item_idx, model->item_cnt - 1, 0u);
|
||||
items_cnt = model->item_cnt;
|
||||
return false;
|
||||
});
|
||||
@@ -113,14 +116,14 @@ void archive_file_array_swap(ArchiveBrowserView* browser, int8_t dir) {
|
||||
browser->view, (ArchiveBrowserViewModel * model) {
|
||||
ArchiveFile_t temp;
|
||||
size_t array_size = files_array_size(model->files) - 1;
|
||||
uint8_t swap_idx = CLAMP(model->item_idx + dir, array_size, 0);
|
||||
uint8_t swap_idx = CLAMP((size_t)(model->item_idx + dir), array_size, 0u);
|
||||
|
||||
if(model->item_idx == 0 && dir < 0) {
|
||||
ArchiveFile_t_init(&temp);
|
||||
files_array_pop_at(&temp, model->files, array_size);
|
||||
files_array_push_at(model->files, model->item_idx, temp);
|
||||
ArchiveFile_t_clear(&temp);
|
||||
} else if(model->item_idx == array_size && dir > 0) {
|
||||
} else if(((uint32_t)model->item_idx == array_size) && (dir > 0)) {
|
||||
ArchiveFile_t_init(&temp);
|
||||
files_array_pop_at(&temp, model->files, 0);
|
||||
files_array_push_at(model->files, array_size, temp);
|
||||
@@ -157,7 +160,7 @@ bool archive_file_array_load(ArchiveBrowserView* browser, int8_t dir) {
|
||||
} else {
|
||||
offset_new = model->item_idx - FILE_LIST_BUF_LEN / 4 * 1;
|
||||
}
|
||||
offset_new = CLAMP(offset_new, model->item_cnt - FILE_LIST_BUF_LEN, 0);
|
||||
offset_new = CLAMP((uint32_t)offset_new, model->item_cnt - FILE_LIST_BUF_LEN, 0u);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
@@ -196,7 +199,7 @@ ArchiveFile_t* archive_get_file_at(ArchiveBrowserView* browser, size_t idx) {
|
||||
|
||||
with_view_model(
|
||||
browser->view, (ArchiveBrowserViewModel * model) {
|
||||
idx = CLAMP(idx - model->array_offset, files_array_size(model->files), 0);
|
||||
idx = CLAMP(idx - model->array_offset, files_array_size(model->files), 0u);
|
||||
selected = files_array_size(model->files) ? files_array_get(model->files, idx) : NULL;
|
||||
return false;
|
||||
});
|
||||
@@ -247,6 +250,7 @@ void archive_set_tab(ArchiveBrowserView* browser, ArchiveTabEnum tab) {
|
||||
});
|
||||
}
|
||||
void archive_set_last_tab(ArchiveBrowserView* browser, ArchiveTabEnum tab) {
|
||||
UNUSED(tab); // FIXME?
|
||||
furi_assert(browser);
|
||||
|
||||
with_view_model(
|
||||
|
@@ -42,7 +42,7 @@ static const ArchiveFileTypeEnum known_type[] = {
|
||||
[ArchiveTabBrowser] = ArchiveFileTypeUnknown,
|
||||
};
|
||||
|
||||
static inline const ArchiveFileTypeEnum archive_get_tab_filetype(ArchiveTabEnum tab) {
|
||||
static inline ArchiveFileTypeEnum archive_get_tab_filetype(ArchiveTabEnum tab) {
|
||||
return known_type[tab];
|
||||
}
|
||||
|
||||
|
@@ -54,7 +54,7 @@ void archive_set_file_type(ArchiveFile_t* file, FileInfo* file_info, const char*
|
||||
} else {
|
||||
furi_assert(file_info);
|
||||
|
||||
for(size_t i = 0; i < SIZEOF_ARRAY(known_ext); i++) {
|
||||
for(size_t i = 0; i < COUNT_OF(known_ext); i++) {
|
||||
if((known_ext[i][0] == '?') || (known_ext[i][0] == '*')) continue;
|
||||
if(string_search_str(file->name, known_ext[i], 0) != STRING_FAILURE) {
|
||||
if(i == ArchiveFileTypeBadUsb) {
|
||||
|
@@ -31,6 +31,7 @@ static void archive_loader_callback(const void* message, void* context) {
|
||||
}
|
||||
|
||||
static void archive_run_in_app(ArchiveBrowserView* browser, ArchiveFile_t* selected) {
|
||||
UNUSED(browser);
|
||||
Loader* loader = furi_record_open("loader");
|
||||
|
||||
LoaderStatus status;
|
||||
|
@@ -106,17 +106,17 @@ static void draw_list(Canvas* canvas, ArchiveBrowserViewModel* model) {
|
||||
size_t array_size = files_array_size(model->files);
|
||||
bool scrollbar = model->item_cnt > 4;
|
||||
|
||||
for(size_t i = 0; i < MIN(model->item_cnt, MENU_ITEMS); ++i) {
|
||||
for(uint32_t i = 0; i < MIN(model->item_cnt, MENU_ITEMS); ++i) {
|
||||
string_t str_buff;
|
||||
char cstr_buff[MAX_NAME_LEN];
|
||||
size_t idx = CLAMP(i + model->list_offset, model->item_cnt, 0);
|
||||
int32_t idx = CLAMP((uint32_t)(i + model->list_offset), model->item_cnt, 0u);
|
||||
uint8_t x_offset = (model->move_fav && model->item_idx == idx) ? MOVE_OFFSET : 0;
|
||||
|
||||
ArchiveFileTypeEnum file_type = ArchiveFileTypeLoading;
|
||||
|
||||
if(archive_is_item_in_array(model, idx)) {
|
||||
ArchiveFile_t* file =
|
||||
files_array_get(model->files, CLAMP(idx - model->array_offset, array_size - 1, 0));
|
||||
ArchiveFile_t* file = files_array_get(
|
||||
model->files, CLAMP(idx - model->array_offset, (int32_t)(array_size - 1), 0));
|
||||
strlcpy(cstr_buff, string_get_cstr(file->name), string_size(file->name) + 1);
|
||||
archive_trim_file_path(cstr_buff, archive_is_known_app(file->type));
|
||||
string_init_set_str(str_buff, cstr_buff);
|
||||
@@ -216,7 +216,7 @@ static bool is_file_list_load_required(ArchiveBrowserViewModel* model) {
|
||||
}
|
||||
|
||||
if(((model->array_offset + array_size) < model->item_cnt) &&
|
||||
(model->item_idx > (model->array_offset + array_size - FILE_LIST_BUF_LEN / 4))) {
|
||||
(model->item_idx > (int32_t)(model->array_offset + array_size - FILE_LIST_BUF_LEN / 4))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -376,4 +376,4 @@ void browser_free(ArchiveBrowserView* browser) {
|
||||
|
||||
view_free(browser->view);
|
||||
free(browser);
|
||||
}
|
||||
}
|
||||
|
@@ -13,8 +13,8 @@
|
||||
#define MAX_NAME_LEN 255
|
||||
#define MAX_EXT_LEN 6
|
||||
#define FRAME_HEIGHT 12
|
||||
#define MENU_ITEMS 4
|
||||
#define MOVE_OFFSET 5
|
||||
#define MENU_ITEMS 4u
|
||||
#define MOVE_OFFSET 5u
|
||||
|
||||
typedef enum {
|
||||
ArchiveTabFavorites,
|
||||
|
Reference in New Issue
Block a user