1
mirror of https://github.com/flipperdevices/flipperzero-firmware.git synced 2025-12-12 04:41:26 +04:00

Fix PVS warnings (#4277)

* Fixing PVS warns

* pvs: additional fixes

---------

Co-authored-by: hedger <hedger@nanode.su>
This commit is contained in:
MMX
2025-09-24 20:00:39 +03:00
committed by GitHub
parent 5c54be4d9c
commit 30077dd512
34 changed files with 54 additions and 39 deletions

View File

@@ -18,7 +18,7 @@ struct BtTestParam {
void* context;
};
ARRAY_DEF(BtTestParamArray, BtTestParam, M_POD_OPLIST);
ARRAY_DEF(BtTestParamArray, BtTestParam, M_POD_OPLIST); //-V658
struct BtTest {
View* view;

View File

@@ -7,7 +7,7 @@
#include "infrared_signal.h"
ARRAY_DEF(SignalPositionArray, size_t, M_DEFAULT_OPLIST);
ARRAY_DEF(SignalPositionArray, size_t, M_DEFAULT_OPLIST); //-V658
typedef struct {
size_t index;

View File

@@ -21,7 +21,7 @@ typedef struct {
uint32_t ar1;
} Mfkey32LoggerParams;
ARRAY_DEF(Mfkey32LoggerParams, Mfkey32LoggerParams, M_POD_OPLIST);
ARRAY_DEF(Mfkey32LoggerParams, Mfkey32LoggerParams, M_POD_OPLIST); //-V658
struct Mfkey32Logger {
uint32_t cuid;

View File

@@ -29,7 +29,7 @@ typedef struct {
NfcSupportedCardsPluginFeature feature;
} NfcSupportedCardsPluginCache;
ARRAY_DEF(NfcSupportedCardsPluginCache, NfcSupportedCardsPluginCache, M_POD_OPLIST);
ARRAY_DEF(NfcSupportedCardsPluginCache, NfcSupportedCardsPluginCache, M_POD_OPLIST); //-V658
typedef enum {
NfcSupportedCardsLoadStateIdle,

View File

@@ -25,7 +25,7 @@ static void onewire_cli_search(PipeSide* pipe) {
onewire_host_start(onewire);
power_enable_otg(power, true);
while(!done) {
while(!done) { //-V1044
if(onewire_host_search(onewire, address, OneWireHostSearchModeNormal) != 1) {
printf("Search finished\r\n");
onewire_host_reset_search(onewire);

View File

@@ -35,7 +35,7 @@ TUPLE_DEF2( //-V1048
M_DEFAULT_OPLIST)
/* Define the array, register the oplist and define further algorithms on it */
ARRAY_DEF(SubGhzFrequencyAnalyzerLogItemArray, SubGhzFrequencyAnalyzerLogItem_t) //-V779
ARRAY_DEF(SubGhzFrequencyAnalyzerLogItemArray, SubGhzFrequencyAnalyzerLogItem_t) //-V779 //-V658
#define M_OPL_SubGhzFrequencyAnalyzerLogItemArray_t() \
ARRAY_OPLIST(SubGhzFrequencyAnalyzerLogItemArray, M_OPL_SubGhzFrequencyAnalyzerLogItem_t())
ALGO_DEF(SubGhzFrequencyAnalyzerLogItemArray, SubGhzFrequencyAnalyzerLogItemArray_t)

View File

@@ -16,7 +16,7 @@ typedef struct {
SubGhzRadioPreset* preset;
} SubGhzHistoryItem;
ARRAY_DEF(SubGhzHistoryItemArray, SubGhzHistoryItem, M_POD_OPLIST)
ARRAY_DEF(SubGhzHistoryItemArray, SubGhzHistoryItem, M_POD_OPLIST) //-V658
#define M_OPL_SubGhzHistoryItemArray_t() ARRAY_OPLIST(SubGhzHistoryItemArray, M_POD_OPLIST)

View File

@@ -18,7 +18,7 @@ typedef struct {
uint8_t type;
} SubGhzReceiverMenuItem;
ARRAY_DEF(SubGhzReceiverMenuItemArray, SubGhzReceiverMenuItem, M_POD_OPLIST)
ARRAY_DEF(SubGhzReceiverMenuItemArray, SubGhzReceiverMenuItem, M_POD_OPLIST) //-V658
#define M_OPL_SubGhzReceiverMenuItemArray_t() \
ARRAY_OPLIST(SubGhzReceiverMenuItemArray, M_POD_OPLIST)

View File

@@ -93,12 +93,17 @@ static const FrameBubble*
bubble_animation_pick_bubble(BubbleAnimationViewModel* model, bool active) {
const FrameBubble* bubble = NULL;
if((model->active_bubbles == 0) && (model->passive_bubbles == 0)) {
// Check for division by zero based on the active parameter
if((active && model->active_bubbles == 0) || (!active && model->passive_bubbles == 0)) {
return NULL;
}
uint8_t index =
furi_hal_random_get() % (active ? model->active_bubbles : model->passive_bubbles);
uint8_t random_value = furi_hal_random_get();
// In case random generator return zero lets set it to 3
if(random_value == 0) {
random_value = 3;
}
uint8_t index = random_value % (active ? model->active_bubbles : model->passive_bubbles);
const BubbleAnimation* animation = model->current;
for(int i = 0; i < animation->frame_bubble_sequences_count; ++i) {

View File

@@ -29,7 +29,7 @@ typedef struct {
void* context;
} CanvasCallbackPair;
ARRAY_DEF(CanvasCallbackPairArray, CanvasCallbackPair, M_POD_OPLIST);
ARRAY_DEF(CanvasCallbackPairArray, CanvasCallbackPair, M_POD_OPLIST); //-V658
#define M_OPL_CanvasCallbackPairArray_t() ARRAY_OPLIST(CanvasCallbackPairArray, M_POD_OPLIST)

View File

@@ -854,7 +854,7 @@ void elements_text_box(
for(size_t i = 0; i < line_num; i++) {
for(size_t j = 0; j < line[i].len; j++) {
// Process format symbols
if(line[i].text[j] == '\e' && j < line[i].len - 1) {
if(line[i].text[j] == '\e' && j < line[i].len - 1) { //-V781
++j;
if(line[i].text[j] == ELEMENTS_BOLD_MARKER) {
if(bold) {

View File

@@ -25,7 +25,7 @@ struct ButtonMenuItem {
void* callback_context;
};
ARRAY_DEF(ButtonMenuItemArray, ButtonMenuItem, M_POD_OPLIST);
ARRAY_DEF(ButtonMenuItemArray, ButtonMenuItem, M_POD_OPLIST); //-V658
struct ButtonMenu {
View* view;

View File

@@ -98,7 +98,7 @@ void button_panel_reserve(ButtonPanel* button_panel, size_t reserve_x, size_t re
furi_check(reserve_x > 0);
furi_check(reserve_y > 0);
with_view_model(
with_view_model( //-V621
button_panel->view,
ButtonPanelModel * model,
{

View File

@@ -32,8 +32,8 @@ typedef enum {
(WorkerEvtStop | WorkerEvtLoad | WorkerEvtFolderEnter | WorkerEvtFolderExit | \
WorkerEvtFolderRefresh | WorkerEvtConfigChange)
ARRAY_DEF(IdxLastArray, int32_t)
ARRAY_DEF(ExtFilterArray, FuriString*, FURI_STRING_OPLIST)
ARRAY_DEF(IdxLastArray, int32_t) //-V658
ARRAY_DEF(ExtFilterArray, FuriString*, FURI_STRING_OPLIST) //-V658
struct BrowserWorker {
FuriThread* thread;

View File

@@ -17,7 +17,7 @@ typedef struct {
void* callback_context;
} MenuItem;
ARRAY_DEF(MenuItemArray, MenuItem, M_POD_OPLIST);
ARRAY_DEF(MenuItemArray, MenuItem, M_POD_OPLIST); //-V658
#define M_OPL_MenuItemArray_t() ARRAY_OPLIST(MenuItemArray, M_POD_OPLIST)

View File

@@ -14,7 +14,7 @@ struct VariableItem {
void* context;
};
ARRAY_DEF(VariableItemArray, VariableItem, M_POD_OPLIST);
ARRAY_DEF(VariableItemArray, VariableItem, M_POD_OPLIST); //-V658
struct VariableItemList {
View* view;

View File

@@ -10,7 +10,7 @@ typedef struct {
FuriString* text;
} TextScrollLineArray;
ARRAY_DEF(TextScrollLineArray, TextScrollLineArray, M_POD_OPLIST)
ARRAY_DEF(TextScrollLineArray, TextScrollLineArray, M_POD_OPLIST) //-V658
typedef struct {
TextScrollLineArray_t line_array;

View File

@@ -8,7 +8,7 @@
#include "scene_manager.h"
#include <m-array.h>
ARRAY_DEF(SceneManagerIdStack, uint32_t, M_DEFAULT_OPLIST);
ARRAY_DEF(SceneManagerIdStack, uint32_t, M_DEFAULT_OPLIST); //-V658
typedef struct {
uint32_t state;

View File

@@ -88,6 +88,7 @@ static void loader_show_gui_error(
LoaderMessageLoaderStatusResult status,
const char* name,
FuriString* error_message) {
furi_check(name);
DialogsApp* dialogs = furi_record_open(RECORD_DIALOGS);
DialogMessage* message = dialog_message_alloc();
@@ -609,6 +610,8 @@ static LoaderMessageLoaderStatusResult loader_do_start_by_name(
status.value = loader_make_success_status(error_message);
status.error = LoaderStatusErrorUnknown;
if(name == NULL) return status;
LoaderEvent event;
event.type = LoaderEventTypeApplicationBeforeLoad;
furi_pubsub_publish(loader->pubsub, &event);
@@ -835,7 +838,10 @@ int32_t loader_srv(void* p) {
switch(message.type) {
case LoaderMessageTypeStartByName: {
LoaderMessageLoaderStatusResult status = loader_do_start_by_name(
loader, message.start.name, message.start.args, message.start.error_message);
loader,
message.start.name,
message.start.args,
message.start.error_message); //-V595
*(message.status_value) = status;
if(status.value != LoaderStatusOk) loader_do_emit_queue_empty_event(loader);
api_lock_unlock(message.api_lock);
@@ -844,7 +850,7 @@ int32_t loader_srv(void* p) {
case LoaderMessageTypeStartByNameDetachedWithGuiError: {
FuriString* error_message = furi_string_alloc();
LoaderMessageLoaderStatusResult status = loader_do_start_by_name(
loader, message.start.name, message.start.args, error_message);
loader, message.start.name, message.start.args, error_message); //-V595
loader_show_gui_error(status, message.start.name, error_message);
if(status.value != LoaderStatusOk) loader_do_emit_queue_empty_event(loader);
if(message.start.name) free((void*)message.start.name);

View File

@@ -293,7 +293,7 @@ static void rpc_system_storage_list_process(const PB_Main* request, void* contex
finish = true;
}
while(!finish) {
while(!finish) { //-V1044
FileInfo fileinfo;
char* name = malloc(MAX_NAME_LENGTH + 1);
if(storage_dir_read(dir, &fileinfo, name, MAX_NAME_LENGTH)) {

View File

@@ -30,7 +30,8 @@ static void rpc_system_system_ping_process(const PB_Main* request, void* context
}
PB_Main response = PB_Main_init_default;
response.command_status = PB_CommandStatus_OK;
// PB_CommandStatus_OK is 0 in current case, and var by default is 0 too, commenting PVS warn
response.command_status = PB_CommandStatus_OK; //-V1048
response.command_id = request->command_id;
response.which_content = PB_Main_system_ping_response_tag;

View File

@@ -76,7 +76,7 @@ void desktop_settings_scene_favorite_on_enter(void* context) {
default_passport = true;
}
} else {
favorite_id &= ~(SCENE_STATE_SET_DUMMY_APP);
favorite_id &= ~(SCENE_STATE_SET_DUMMY_APP); //-V784
furi_assert(favorite_id < DummyAppNumber);
curr_favorite_app = &app->settings.dummy_apps[favorite_id];
default_passport = true;
@@ -182,7 +182,7 @@ bool desktop_settings_scene_favorite_on_event(void* context, SceneManagerEvent e
furi_assert(favorite_id < FavoriteAppNumber);
curr_favorite_app = &app->settings.favorite_apps[favorite_id];
} else {
favorite_id &= ~(SCENE_STATE_SET_DUMMY_APP);
favorite_id &= ~(SCENE_STATE_SET_DUMMY_APP); //-V784
furi_assert(favorite_id < DummyAppNumber);
curr_favorite_app = &app->settings.dummy_apps[favorite_id];
}

View File

@@ -27,7 +27,7 @@ typedef struct {
// - an rbtree because i deemed it more tedious to implement, and with the
// amount of modules in use (under 10 in the overwhelming majority of cases)
// i bet it's going to be slower than a plain array
ARRAY_DEF(JsModuleArray, JsModuleData, M_POD_OPLIST);
ARRAY_DEF(JsModuleArray, JsModuleData, M_POD_OPLIST); //-V658
#define M_OPL_JsModuleArray_t() ARRAY_OPLIST(JsModuleArray)
static const JsModuleDescriptor modules_builtin[] = {

View File

@@ -20,7 +20,7 @@ typedef struct {
char* data;
} PatternArrayItem;
ARRAY_DEF(PatternArray, PatternArrayItem, M_POD_OPLIST);
ARRAY_DEF(PatternArray, PatternArrayItem, M_POD_OPLIST); //-V658
static void
js_serial_on_async_rx(FuriHalSerialHandle* handle, FuriHalSerialRxEvent event, void* context) {

View File

@@ -192,6 +192,9 @@ void lp5562_execute_ramp(
// Prepare command sequence
uint16_t program[16];
uint8_t diff = (val_end > val_start) ? (val_end - val_start) : (val_start - val_end);
if(diff == 0) { // Making division below safer
diff = 1;
}
uint16_t time_step = time * 2 / diff;
uint8_t prescaller = 0;
if(time_step > 0x3F) {

View File

@@ -26,7 +26,7 @@ typedef struct {
uint8_t dots;
} NoteBlock;
ARRAY_DEF(NoteBlockArray, NoteBlock, M_POD_OPLIST);
ARRAY_DEF(NoteBlockArray, NoteBlock, M_POD_OPLIST); //-V658
struct MusicWorker {
FuriThread* thread;

View File

@@ -650,7 +650,7 @@ static int
// evaluate flags
flags = 0U;
do {
do { //-V1044
switch(*format) {
case '0':
flags |= FLAGS_ZEROPAD;

View File

@@ -455,7 +455,7 @@ static bool
//sort by number of occurrences
bool swap = true;
while(swap) {
while(swap) { //-V1044
swap = false;
for(size_t i = 1; i < BIN_RAW_SEARCH_CLASSES; i++) {
if(classes[i].count > classes[i - 1].count) {
@@ -571,7 +571,7 @@ static bool
bit_count = 0;
if(data_markup_ind == BIN_RAW_MAX_MARKUP_COUNT) break;
ind &= 0xFFFFFFF8; //jump to the pre whole byte
ind &= 0xFFFFFFF8; //jump to the pre whole byte //-V784
}
} while(gap_ind != 0);
if((data_markup_ind != BIN_RAW_MAX_MARKUP_COUNT) && (ind != 0)) {

View File

@@ -8,7 +8,7 @@ typedef struct {
SubGhzProtocolEncoderBase* base;
} SubGhzReceiverSlot;
ARRAY_DEF(SubGhzReceiverSlotArray, SubGhzReceiverSlot, M_POD_OPLIST);
ARRAY_DEF(SubGhzReceiverSlotArray, SubGhzReceiverSlot, M_POD_OPLIST); //-V658
#define M_OPL_SubGhzReceiverSlotArray_t() ARRAY_OPLIST(SubGhzReceiverSlotArray, M_POD_OPLIST)
struct SubGhzReceiver {

View File

@@ -14,7 +14,7 @@ typedef struct {
uint16_t type;
} SubGhzKey;
ARRAY_DEF(SubGhzKeyArray, SubGhzKey, M_POD_OPLIST)
ARRAY_DEF(SubGhzKeyArray, SubGhzKey, M_POD_OPLIST) //-V658
#define M_OPL_SubGhzKeyArray_t() ARRAY_OPLIST(SubGhzKeyArray, M_POD_OPLIST)

View File

@@ -163,7 +163,7 @@ typedef struct {
size_t custom_preset_data_size;
} SubGhzSettingCustomPresetItem;
ARRAY_DEF(SubGhzSettingCustomPresetItemArray, SubGhzSettingCustomPresetItem, M_POD_OPLIST)
ARRAY_DEF(SubGhzSettingCustomPresetItemArray, SubGhzSettingCustomPresetItem, M_POD_OPLIST) //-V658
#define M_OPL_SubGhzSettingCustomPresetItemArray_t() \
ARRAY_OPLIST(SubGhzSettingCustomPresetItemArray, M_POD_OPLIST)

View File

@@ -1,6 +1,6 @@
#include "cli_shell_completions.h"
ARRAY_DEF(CommandCompletions, FuriString*, FURI_STRING_OPLIST); // -V524
ARRAY_DEF(CommandCompletions, FuriString*, FURI_STRING_OPLIST); // -V524 //-V658
#define M_OPL_CommandCompletions_t() ARRAY_OPLIST(CommandCompletions)
struct CliShellCompletions {

View File

@@ -80,7 +80,7 @@ StrintParseError strint_to_uint64_internal(
if(result > mul_limit) return StrintParseOverflowError;
result *= base;
if(result > limit - digit_value) return StrintParseOverflowError;
if(result > limit - digit_value) return StrintParseOverflowError; //-V658
result += digit_value;
read_total++;

View File

@@ -68,7 +68,7 @@ void SystemInit(void) {
RCC->PLLSAI1CFGR = 0x22041000U;
#endif
// Reset HSEBYP bit
RCC->CR &= 0xFFFBFFFFU;
RCC->CR &= 0xFFFBFFFFU; //-V784
// Disable all RCC related interrupts
RCC->CIER = 0x00000000;
}