[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:
@@ -2,6 +2,7 @@
|
||||
#include <lib/drivers/cc1101.h>
|
||||
|
||||
#include <furi.h>
|
||||
#include <float_tools.h>
|
||||
|
||||
#define TAG "SubghzFrequencyAnalyzerWorker"
|
||||
|
||||
@@ -197,7 +198,7 @@ static int32_t subghz_frequency_analyzer_worker_thread(void* context) {
|
||||
rssi_temp = (rssi_temp + frequency_rssi.rssi_fine) / 2;
|
||||
frequency_temp = frequency_rssi.frequency_fine;
|
||||
|
||||
if(instance->filVal) {
|
||||
if(!float_is_equal(instance->filVal, 0.f)) {
|
||||
frequency_rssi.frequency_fine =
|
||||
subghz_frequency_analyzer_worker_expRunningAverageAdaptive(
|
||||
instance, frequency_rssi.frequency_fine);
|
||||
@@ -219,7 +220,7 @@ static int32_t subghz_frequency_analyzer_worker_thread(void* context) {
|
||||
instance->sample_hold_counter = 20;
|
||||
rssi_temp = (rssi_temp + frequency_rssi.rssi_coarse) / 2;
|
||||
frequency_temp = frequency_rssi.frequency_coarse;
|
||||
if(instance->filVal) {
|
||||
if(!float_is_equal(instance->filVal, 0.f)) {
|
||||
frequency_rssi.frequency_coarse =
|
||||
subghz_frequency_analyzer_worker_expRunningAverageAdaptive(
|
||||
instance, frequency_rssi.frequency_coarse);
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <dolphin/dolphin.h>
|
||||
#include <lib/subghz/protocols/raw.h>
|
||||
#include <lib/toolbox/path.h>
|
||||
#include <float_tools.h>
|
||||
|
||||
#define RAW_FILE_NAME "Raw_signal_"
|
||||
#define TAG "SubGhzSceneReadRAW"
|
||||
@@ -358,7 +359,7 @@ bool subghz_scene_read_raw_on_event(void* context, SceneManagerEvent event) {
|
||||
|
||||
float rssi = furi_hal_subghz_get_rssi();
|
||||
|
||||
if(subghz->txrx->raw_threshold_rssi == SUBGHZ_RAW_TRESHOLD_MIN) {
|
||||
if(float_is_equal(subghz->txrx->raw_threshold_rssi, SUBGHZ_RAW_TRESHOLD_MIN)) {
|
||||
subghz_read_raw_add_data_rssi(subghz->subghz_read_raw, rssi, true);
|
||||
subghz_protocol_raw_save_to_file_pause(
|
||||
(SubGhzProtocolDecoderRAW*)subghz->txrx->decoder_result, false);
|
||||
|
||||
@@ -94,7 +94,7 @@ bool subghz_scene_save_name_on_event(void* context, SceneManagerEvent event) {
|
||||
return true;
|
||||
} else if(event.type == SceneManagerEventTypeCustom) {
|
||||
if(event.event == SubGhzCustomEventSceneSaveName) {
|
||||
if(strcmp(subghz->file_name_tmp, "")) {
|
||||
if(strcmp(subghz->file_name_tmp, "") != 0) {
|
||||
furi_string_cat_printf(
|
||||
subghz->file_path, "/%s%s", subghz->file_name_tmp, SUBGHZ_APP_EXTENSION);
|
||||
if(subghz_path_is_file(subghz->file_path_tmp)) {
|
||||
|
||||
@@ -46,7 +46,7 @@ bool subghz_scene_set_type_submenu_gen_data_protocol(
|
||||
|
||||
uint8_t key_data[sizeof(uint64_t)] = {0};
|
||||
for(size_t i = 0; i < sizeof(uint64_t); i++) {
|
||||
key_data[sizeof(uint64_t) - i - 1] = (key >> i * 8) & 0xFF;
|
||||
key_data[sizeof(uint64_t) - i - 1] = (key >> (i * 8)) & 0xFF;
|
||||
}
|
||||
if(!flipper_format_update_hex(subghz->txrx->fff_data, "Key", key_data, sizeof(uint64_t))) {
|
||||
FURI_LOG_E(TAG, "Unable to update Key");
|
||||
|
||||
@@ -152,11 +152,11 @@ void subghz_cli_command_tx(Cli* cli, FuriString* args, void* context) {
|
||||
"Protocol: Princeton\n"
|
||||
"Bit: 24\n"
|
||||
"Key: 00 00 00 00 00 %02X %02X %02X\n"
|
||||
"TE: %ld\n"
|
||||
"Repeat: %ld\n",
|
||||
(uint8_t)((key >> 16) & 0xFF),
|
||||
(uint8_t)((key >> 8) & 0xFF),
|
||||
(uint8_t)(key & 0xFF),
|
||||
"TE: %lu\n"
|
||||
"Repeat: %lu\n",
|
||||
(uint8_t)((key >> 16) & 0xFFU),
|
||||
(uint8_t)((key >> 8) & 0xFFU),
|
||||
(uint8_t)(key & 0xFFU),
|
||||
te,
|
||||
repeat);
|
||||
FlipperFormat* flipper_format = flipper_format_string_alloc();
|
||||
@@ -300,7 +300,7 @@ void subghz_cli_command_rx(Cli* cli, FuriString* args, void* context) {
|
||||
|
||||
furi_hal_power_suppress_charge_exit();
|
||||
|
||||
printf("\r\nPackets received %u\r\n", instance->packet_count);
|
||||
printf("\r\nPackets received %zu\r\n", instance->packet_count);
|
||||
|
||||
// Cleanup
|
||||
subghz_receiver_free(receiver);
|
||||
@@ -787,8 +787,9 @@ static bool subghz_on_system_start_istream_decode_band(
|
||||
}
|
||||
|
||||
region->bands_count += 1;
|
||||
region =
|
||||
realloc(region, sizeof(FuriHalRegion) + sizeof(FuriHalRegionBand) * region->bands_count);
|
||||
region = realloc( //-V701
|
||||
region,
|
||||
sizeof(FuriHalRegion) + sizeof(FuriHalRegionBand) * region->bands_count);
|
||||
size_t pos = region->bands_count - 1;
|
||||
region->bands[pos].start = band.start;
|
||||
region->bands[pos].end = band.end;
|
||||
@@ -798,7 +799,7 @@ static bool subghz_on_system_start_istream_decode_band(
|
||||
|
||||
FURI_LOG_I(
|
||||
"SubGhzOnStart",
|
||||
"Add allowed band: start %ldHz, stop %ldHz, power_limit %ddBm, duty_cycle %d%%",
|
||||
"Add allowed band: start %luHz, stop %luHz, power_limit %ddBm, duty_cycle %u%%",
|
||||
band.start,
|
||||
band.end,
|
||||
band.power_limit,
|
||||
|
||||
@@ -164,7 +164,7 @@ bool subghz_tx_start(SubGhz* subghz, FlipperFormat* flipper_format) {
|
||||
|
||||
if(subghz->txrx->transmitter) {
|
||||
if(subghz_transmitter_deserialize(subghz->txrx->transmitter, flipper_format)) {
|
||||
if(strcmp(furi_string_get_cstr(subghz->txrx->preset->name), "")) {
|
||||
if(strcmp(furi_string_get_cstr(subghz->txrx->preset->name), "") != 0) {
|
||||
subghz_begin(
|
||||
subghz,
|
||||
subghz_setting_get_preset_data_by_name(
|
||||
@@ -544,11 +544,8 @@ void subghz_hopper_update(SubGhz* subghz) {
|
||||
|
||||
switch(subghz->txrx->hopper_state) {
|
||||
case SubGhzHopperStateOFF:
|
||||
return;
|
||||
break;
|
||||
case SubGhzHopperStatePause:
|
||||
return;
|
||||
break;
|
||||
case SubGhzHopperStateRSSITimeOut:
|
||||
if(subghz->txrx->hopper_timeout != 0) {
|
||||
subghz->txrx->hopper_timeout--;
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "../helpers/subghz_frequency_analyzer_log_item_array.h"
|
||||
|
||||
#include <assets_icons.h>
|
||||
#include <float_tools.h>
|
||||
|
||||
#define LOG_FREQUENCY_MAX_ITEMS 60 // uint8_t (limited by 'seq' of SubGhzFrequencyAnalyzerLogItem)
|
||||
|
||||
@@ -47,7 +48,8 @@ typedef struct {
|
||||
} SubGhzFrequencyAnalyzerModel;
|
||||
|
||||
static inline uint8_t rssi_sanitize(float rssi) {
|
||||
return (rssi ? (uint8_t)(rssi - SUBGHZ_FREQUENCY_ANALYZER_THRESHOLD) : 0);
|
||||
return (
|
||||
!float_is_equal(rssi, 0.f) ? (uint8_t)(rssi - SUBGHZ_FREQUENCY_ANALYZER_THRESHOLD) : 0);
|
||||
}
|
||||
|
||||
void subghz_frequency_analyzer_set_callback(
|
||||
@@ -294,9 +296,6 @@ static bool subghz_frequency_analyzer_log_frequency_insert(SubGhzFrequencyAnalyz
|
||||
if(items_count < LOG_FREQUENCY_MAX_ITEMS) {
|
||||
SubGhzFrequencyAnalyzerLogItem_t* item =
|
||||
SubGhzFrequencyAnalyzerLogItemArray_push_new(model->log_frequency);
|
||||
if(item == NULL) {
|
||||
return false;
|
||||
}
|
||||
(*item)->frequency = model->frequency;
|
||||
(*item)->count = 1;
|
||||
(*item)->rssi_max = model->rssi;
|
||||
@@ -340,7 +339,7 @@ void subghz_frequency_analyzer_pair_callback(
|
||||
float rssi,
|
||||
bool signal) {
|
||||
SubGhzFrequencyAnalyzer* instance = context;
|
||||
if((rssi == 0.f) && (instance->locked)) {
|
||||
if(float_is_equal(rssi, 0.f) && instance->locked) {
|
||||
if(instance->callback) {
|
||||
instance->callback(SubGhzCustomEventSceneAnalyzerUnlock, instance->context);
|
||||
}
|
||||
@@ -355,13 +354,13 @@ void subghz_frequency_analyzer_pair_callback(
|
||||
model->history_frequency[0] = model->frequency;
|
||||
},
|
||||
false);
|
||||
} else if((rssi != 0.f) && (!instance->locked)) {
|
||||
} else if(!float_is_equal(rssi, 0.f) && !instance->locked) {
|
||||
if(instance->callback) {
|
||||
instance->callback(SubGhzCustomEventSceneAnalyzerLock, instance->context);
|
||||
}
|
||||
}
|
||||
|
||||
instance->locked = (rssi != 0.f);
|
||||
instance->locked = !float_is_equal(rssi, 0.f);
|
||||
with_view_model(
|
||||
instance->view,
|
||||
SubGhzFrequencyAnalyzerModel * model,
|
||||
|
||||
@@ -91,7 +91,7 @@ void subghz_read_raw_update_sample_write(SubGhzReadRAW* instance, size_t sample)
|
||||
with_view_model(
|
||||
instance->view,
|
||||
SubGhzReadRAWModel * model,
|
||||
{ furi_string_printf(model->sample_write, "%d spl.", sample); },
|
||||
{ furi_string_printf(model->sample_write, "%zu spl.", sample); },
|
||||
false);
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ void subghz_read_raw_draw_sin(Canvas* canvas, SubGhzReadRAWModel* model) {
|
||||
canvas_draw_line(
|
||||
canvas,
|
||||
i + 1,
|
||||
32 - subghz_read_raw_tab_sin((i + model->ind_sin * 16)) / SUBGHZ_RAW_SIN_AMPLITUDE,
|
||||
32 - subghz_read_raw_tab_sin(i + model->ind_sin * 16) / SUBGHZ_RAW_SIN_AMPLITUDE,
|
||||
i + 2,
|
||||
32 + subghz_read_raw_tab_sin((i + model->ind_sin * 16 + 1) * 2) /
|
||||
SUBGHZ_RAW_SIN_AMPLITUDE);
|
||||
|
||||
@@ -114,7 +114,7 @@ static void subghz_test_packet_draw(Canvas* canvas, SubGhzTestPacketModel* model
|
||||
snprintf(buffer, sizeof(buffer), "Path: %d - %s", model->path, path_name);
|
||||
canvas_draw_str(canvas, 0, 31, buffer);
|
||||
|
||||
snprintf(buffer, sizeof(buffer), "Packets: %d", model->packets);
|
||||
snprintf(buffer, sizeof(buffer), "Packets: %zu", model->packets);
|
||||
canvas_draw_str(canvas, 0, 42, buffer);
|
||||
|
||||
if(model->status == SubGhzTestPacketModelStatusRx) {
|
||||
|
||||
Reference in New Issue
Block a user