Skip to content

Commit

Permalink
[FL-2520] FW build with -Wextra (flipperdevices#1185)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
hedger and skotopes authored May 6, 2022
1 parent 1ca9817 commit 4d6b170
Show file tree
Hide file tree
Showing 461 changed files with 940 additions and 519 deletions.
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,4 @@ SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp03
TabWidth: 4
UseTab: Never
UseTab: Never
2 changes: 1 addition & 1 deletion .github/workflows/build_toolchain.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ jobs:
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
cache-from: type=registry,ref=flipperdevices/flipperzero-toolchain:buildcache
cache-to: type=registry,ref=flipperdevices/flipperzero-toolchain:buildcache,mode=max
cache-to: type=registry,ref=flipperdevices/flipperzero-toolchain:buildcache,mode=max
2 changes: 1 addition & 1 deletion .github/workflows/check_submodules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ jobs:
with:
path: assets/protobuf
branch: dev
fetch_depth: 50
fetch_depth: 50
1 change: 1 addition & 0 deletions applications/about/about.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ const AboutDialogScreen about_screens[] = {
const size_t about_screens_count = sizeof(about_screens) / sizeof(AboutDialogScreen);

int32_t about_settings_app(void* p) {
UNUSED(p);
DialogsApp* dialogs = furi_record_open("dialogs");
DialogMessage* message = dialog_message_alloc();

Expand Down
3 changes: 2 additions & 1 deletion applications/accessor/accessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

// app enter function
extern "C" int32_t accessor_app(void* p) {
UNUSED(p);
AccessorApp* app = new AccessorApp();
app->run();
delete app;

return 255;
}
}
2 changes: 1 addition & 1 deletion applications/accessor/accessor_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ class AccessorApp {
OneWireHost* onewire_host;

NotificationApp* notification;
};
};
4 changes: 2 additions & 2 deletions applications/accessor/accessor_view_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void AccessorAppViewManager::send_event(AccessorEvent* event) {
furi_check(result == osOK);
}

uint32_t AccessorAppViewManager::previous_view_callback(void* context) {
uint32_t AccessorAppViewManager::previous_view_callback(void*) {
if(event_queue != NULL) {
AccessorEvent event;
event.type = AccessorEvent::Type::Back;
Expand All @@ -76,4 +76,4 @@ uint32_t AccessorAppViewManager::previous_view_callback(void* context) {

void AccessorAppViewManager::add_view(ViewType view_type, View* view) {
view_dispatcher_add_view(view_dispatcher, static_cast<uint32_t>(view_type), view);
}
}
2 changes: 1 addition & 1 deletion applications/accessor/accessor_view_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ class AccessorAppViewManager {
// view elements
Submenu* submenu;
Popup* popup;
};
};
2 changes: 1 addition & 1 deletion applications/accessor/helpers/wiegand.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ class WIEGAND {
static int _wiegandType;
static unsigned long _code;
static unsigned long _codeHigh;
};
};
2 changes: 1 addition & 1 deletion applications/accessor/scene/accessor_scene_generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ class AccessorScene {
virtual void on_exit(AccessorApp* app) = 0;

private:
};
};
2 changes: 1 addition & 1 deletion applications/accessor/scene/accessor_scene_start.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ class AccessorSceneStart : public AccessorScene {
void on_enter(AccessorApp* app) final;
bool on_event(AccessorApp* app, AccessorEvent* event) final;
void on_exit(AccessorApp* app) final;
};
};
1 change: 1 addition & 0 deletions applications/archive/archive.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions applications/archive/helpers/archive_apps.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ 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;
}
}
return ArchiveAppTypeUnknown;
}

bool archive_app_is_available(void* context, const char* path) {
UNUSED(context);
furi_assert(path);

ArchiveAppTypeEnum app = archive_get_app_type(path);
Expand Down
2 changes: 1 addition & 1 deletion applications/archive/helpers/archive_apps.h
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}

Expand Down
24 changes: 14 additions & 10 deletions applications/archive/helpers/archive_browser.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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;
});
Expand All @@ -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);
Expand Down Expand Up @@ -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;
});
Expand Down Expand Up @@ -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;
});
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion applications/archive/helpers/archive_browser.h
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}

Expand Down
2 changes: 1 addition & 1 deletion applications/archive/helpers/archive_files.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 1 addition & 0 deletions applications/archive/scenes/archive_scene_browser.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 6 additions & 6 deletions applications/archive/views/archive_browser_view.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -376,4 +376,4 @@ void browser_free(ArchiveBrowserView* browser) {

view_free(browser->view);
free(browser);
}
}
4 changes: 2 additions & 2 deletions applications/archive/views/archive_browser_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 3 additions & 0 deletions applications/bad_usb/scenes/bad_usb_scene_file_select.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,13 @@ void bad_usb_scene_file_select_on_enter(void* context) {
}

bool bad_usb_scene_file_select_on_event(void* context, SceneManagerEvent event) {
UNUSED(context);
UNUSED(event);
// BadUsbApp* bad_usb = context;
return false;
}

void bad_usb_scene_file_select_on_exit(void* context) {
UNUSED(context);
// BadUsbApp* bad_usb = context;
}
1 change: 1 addition & 0 deletions applications/bad_usb/views/bad_usb_view.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ void bad_usb_set_ok_callback(BadUsb* bad_usb, BadUsbOkCallback callback, void* c
furi_assert(callback);
with_view_model(
bad_usb->view, (BadUsbModel * model) {
UNUSED(model);
bad_usb->callback = callback;
bad_usb->context = context;
return true;
Expand Down
10 changes: 10 additions & 0 deletions applications/bt/bt_cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ static const char* bt_cli_address_types[] = {
};

static void bt_cli_command_hci_info(Cli* cli, string_t args, void* context) {
UNUSED(cli);
UNUSED(args);
UNUSED(context);
string_t buffer;
string_init(buffer);
furi_hal_bt_dump_state(buffer);
Expand All @@ -21,6 +24,7 @@ static void bt_cli_command_hci_info(Cli* cli, string_t args, void* context) {
}

static void bt_cli_command_carrier_tx(Cli* cli, string_t args, void* context) {
UNUSED(context);
int channel = 0;
int power = 0;

Expand All @@ -47,6 +51,7 @@ static void bt_cli_command_carrier_tx(Cli* cli, string_t args, void* context) {
}

static void bt_cli_command_carrier_rx(Cli* cli, string_t args, void* context) {
UNUSED(context);
int channel = 0;

do {
Expand All @@ -72,6 +77,7 @@ static void bt_cli_command_carrier_rx(Cli* cli, string_t args, void* context) {
}

static void bt_cli_command_packet_tx(Cli* cli, string_t args, void* context) {
UNUSED(context);
int channel = 0;
int pattern = 0;
int datarate = 1;
Expand Down Expand Up @@ -115,6 +121,7 @@ static void bt_cli_command_packet_tx(Cli* cli, string_t args, void* context) {
}

static void bt_cli_command_packet_rx(Cli* cli, string_t args, void* context) {
UNUSED(context);
int channel = 0;
int datarate = 1;

Expand Down Expand Up @@ -152,6 +159,8 @@ static void bt_cli_scan_callback(GapAddress address, void* context) {
}

static void bt_cli_command_scan(Cli* cli, string_t args, void* context) {
UNUSED(context);
UNUSED(args);
osMessageQueueId_t queue = osMessageQueueNew(20, sizeof(GapAddress), NULL);
furi_hal_bt_start_scan(bt_cli_scan_callback, queue);

Expand Down Expand Up @@ -189,6 +198,7 @@ static void bt_cli_print_usage() {
}

static void bt_cli(Cli* cli, string_t args, void* context) {
UNUSED(context);
furi_record_open("bt");

string_t cmd;
Expand Down
3 changes: 3 additions & 0 deletions applications/bt/bt_debug_app/bt_debug_app.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ void bt_debug_submenu_callback(void* context, uint32_t index) {
}

uint32_t bt_debug_exit(void* context) {
UNUSED(context);
return VIEW_NONE;
}

uint32_t bt_debug_start_view(void* context) {
UNUSED(context);
return BtDebugAppViewSubmenu;
}

Expand Down Expand Up @@ -94,6 +96,7 @@ void bt_debug_app_free(BtDebugApp* app) {
}

int32_t bt_debug_app(void* p) {
UNUSED(p);
if(furi_hal_bt_get_radio_stack() != FuriHalBtStackHciLayer) {
FURI_LOG_E(TAG, "Incorrect radio stack, replace with HciLayer for tests.");
DialogsApp* dialogs = furi_record_open("dialogs");
Expand Down
Loading

0 comments on commit 4d6b170

Please sign in to comment.