[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:
Georgii Surkov
2022-12-26 15:13:30 +03:00
committed by GitHub
parent ad3bff0b67
commit 8582670a34
201 changed files with 719 additions and 743 deletions

View File

@@ -244,10 +244,8 @@ static bool animation_manager_check_blocking(AnimationManager* animation_manager
furi_record_close(RECORD_DOLPHIN);
if(!blocking_animation && stats.level_up_is_pending) {
blocking_animation = animation_storage_find_animation(NEW_MAIL_ANIMATION_NAME);
furi_assert(blocking_animation);
if(blocking_animation) {
animation_manager->levelup_pending = true;
}
furi_check(blocking_animation);
animation_manager->levelup_pending = true;
}
if(blocking_animation) {
@@ -448,7 +446,7 @@ void animation_manager_unload_and_stall_animation(AnimationManager* animation_ma
if(animation_manager->state == AnimationManagerStateBlocked) {
animation_manager->state = AnimationManagerStateFreezedBlocked;
} else if(animation_manager->state == AnimationManagerStateIdle) {
} else if(animation_manager->state == AnimationManagerStateIdle) { //-V547
animation_manager->state = AnimationManagerStateFreezedIdle;
animation_manager->freezed_animation_time_left =
@@ -491,7 +489,7 @@ void animation_manager_load_and_continue_animation(AnimationManager* animation_m
furi_assert(restore_animation);
animation_manager_replace_current_animation(animation_manager, restore_animation);
animation_manager->state = AnimationManagerStateBlocked;
} else if(animation_manager->state == AnimationManagerStateFreezedIdle) {
} else if(animation_manager->state == AnimationManagerStateFreezedIdle) { //-V547
/* check if we missed some system notifications, and set current_animation */
bool blocked = animation_manager_check_blocking(animation_manager);
if(!blocked) {

View File

@@ -360,7 +360,6 @@ static bool animation_storage_load_bubbles(BubbleAnimation* animation, FlipperFo
if(u32value > 20) break;
animation->frame_bubble_sequences_count = u32value;
if(animation->frame_bubble_sequences_count == 0) {
animation->frame_bubble_sequences = NULL;
success = true;
break;
}
@@ -481,7 +480,7 @@ static BubbleAnimation* animation_storage_load_animation(const char* name) {
if(!animation_storage_load_frames(storage, name, animation, u32array, width, height))
break;
if(!flipper_format_read_uint32(ff, "Active cycles", &u32value, 1)) break;
if(!flipper_format_read_uint32(ff, "Active cycles", &u32value, 1)) break; //-V779
animation->active_cycles = u32value;
if(!flipper_format_read_uint32(ff, "Frame rate", &u32value, 1)) break;
FURI_CONST_ASSIGN(animation->icon_animation.frame_rate, u32value);
@@ -500,7 +499,7 @@ static BubbleAnimation* animation_storage_load_animation(const char* name) {
free(u32array);
}
if(!success) {
if(!success) { //-V547
if(animation->frame_order) {
free((void*)animation->frame_order);
}

View File

@@ -41,7 +41,7 @@ Slideshow* slideshow_alloc() {
void slideshow_free(Slideshow* slideshow) {
Icon* icon = &slideshow->icon;
if(icon) {
if(icon) { //-V547
for(int frame_idx = 0; frame_idx < icon->frame_count; ++frame_idx) {
uint8_t* frame_data = (uint8_t*)icon->frames[frame_idx];
free(frame_data);

View File

@@ -52,7 +52,7 @@ void desktop_debug_render(Canvas* canvas, void* model) {
#ifdef SRV_BT
c2_ver = ble_glue_get_c2_info();
#endif
if(!ver) {
if(!ver) { //-V1051
canvas_draw_str(canvas, 0, 30 + STATUS_BAR_Y_SHIFT, "No info");
return;
}
@@ -88,19 +88,19 @@ void desktop_debug_render(Canvas* canvas, void* model) {
uint32_t remaining = dolphin_state_xp_to_levelup(m->icounter);
canvas_set_font(canvas, FontSecondary);
snprintf(buffer, sizeof(buffer), "Icounter: %ld Butthurt %ld", m->icounter, m->butthurt);
snprintf(buffer, sizeof(buffer), "Icounter: %lu Butthurt %lu", m->icounter, m->butthurt);
canvas_draw_str(canvas, 5, 19 + STATUS_BAR_Y_SHIFT, buffer);
snprintf(
buffer,
sizeof(buffer),
"Level: %ld To level up: %ld",
"Level: %lu To level up: %lu",
current_lvl,
(remaining == (uint32_t)(-1) ? remaining : 0));
canvas_draw_str(canvas, 5, 29 + STATUS_BAR_Y_SHIFT, buffer);
// even if timestamp is uint64_t, it's safe to cast it to uint32_t, because furi_hal_rtc_datetime_to_timestamp only returns uint32_t
snprintf(buffer, sizeof(buffer), "%ld", (uint32_t)m->timestamp);
snprintf(buffer, sizeof(buffer), "%lu", (uint32_t)m->timestamp);
canvas_draw_str(canvas, 5, 39 + STATUS_BAR_Y_SHIFT, buffer);
canvas_draw_str(canvas, 0, 49 + STATUS_BAR_Y_SHIFT, "[< >] icounter value [ok] save");

View File

@@ -53,7 +53,7 @@ void desktop_lock_menu_draw_callback(Canvas* canvas, void* model) {
canvas_draw_icon(canvas, 116, 0 + STATUS_BAR_Y_SHIFT, &I_DoorRight_70x55);
canvas_set_font(canvas, FontSecondary);
for(uint8_t i = 0; i < DesktopLockMenuIndexTotalCount; ++i) {
for(size_t i = 0; i < DesktopLockMenuIndexTotalCount; ++i) {
const char* str = NULL;
if(i == DesktopLockMenuIndexLock) {
@@ -64,7 +64,7 @@ void desktop_lock_menu_draw_callback(Canvas* canvas, void* model) {
} else {
str = "Set PIN";
}
} else if(i == DesktopLockMenuIndexDummy) {
} else if(i == DesktopLockMenuIndexDummy) { //-V547
if(m->dummy_mode) {
str = "Brainiac Mode";
} else {
@@ -72,7 +72,7 @@ void desktop_lock_menu_draw_callback(Canvas* canvas, void* model) {
}
}
if(str)
if(str) //-V547
canvas_draw_str_aligned(
canvas, 64, 9 + (i * 17) + STATUS_BAR_Y_SHIFT, AlignCenter, AlignCenter, str);

View File

@@ -67,7 +67,7 @@ static void desktop_view_pin_timeout_draw(Canvas* canvas, void* _model) {
canvas_set_font(canvas, FontSecondary);
char str[30] = {0};
snprintf(str, sizeof(str), "Timeout: %lds", model->time_left);
snprintf(str, sizeof(str), "Timeout: %lus", model->time_left);
canvas_draw_str_aligned(canvas, 64, 38, AlignCenter, AlignCenter, str);
}