[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

@@ -13,7 +13,7 @@ ArchiveAppTypeEnum archive_get_app_type(const char* path) {
}
app_name++;
for(size_t i = 0; i < COUNT_OF(known_apps); i++) {
for(size_t i = 0; i < COUNT_OF(known_apps); i++) { //-V1008
if(strncmp(app_name, known_apps[i], strlen(known_apps[i])) == 0) {
return i;
}

View File

@@ -177,7 +177,7 @@ bool archive_favorites_read(void* context) {
archive_set_item_count(browser, file_count);
if(need_refresh) {
if(need_refresh) { //-V547
archive_favourites_rescan();
}

View File

@@ -116,7 +116,7 @@ bool archive_scene_browser_on_event(void* context, SceneManagerEvent event) {
case ArchiveBrowserEventFileMenuPin: {
const char* name = archive_get_name(browser);
if(favorites) {
archive_favorites_delete(name);
archive_favorites_delete("%s", name);
archive_file_array_rm_selected(browser);
archive_show_file_menu(browser, false);
} else if(archive_is_known_app(selected->type)) {

View File

@@ -218,8 +218,8 @@ static bool ducky_string(const char* param) {
}
static uint16_t ducky_get_keycode(const char* param, bool accept_chars) {
for(uint8_t i = 0; i < (sizeof(ducky_keys) / sizeof(ducky_keys[0])); i++) {
uint8_t key_cmd_len = strlen(ducky_keys[i].name);
for(size_t i = 0; i < (sizeof(ducky_keys) / sizeof(ducky_keys[0])); i++) {
size_t key_cmd_len = strlen(ducky_keys[i].name);
if((strncmp(param, ducky_keys[i].name, key_cmd_len) == 0) &&
(ducky_is_line_end(param[key_cmd_len]))) {
return ducky_keys[i].keycode;
@@ -417,7 +417,7 @@ static int32_t ducky_script_execute_next(BadUsbScript* bad_usb, File* script_fil
return 0;
} else if(delay_val < 0) { // Script error
bad_usb->st.error_line = bad_usb->st.line_cur - 1;
FURI_LOG_E(WORKER_TAG, "Unknown command at line %u", bad_usb->st.line_cur - 1);
FURI_LOG_E(WORKER_TAG, "Unknown command at line %u", bad_usb->st.line_cur - 1U);
return SCRIPT_STATE_ERROR;
} else {
return (delay_val + bad_usb->defdelay);
@@ -596,7 +596,9 @@ static int32_t bad_usb_worker(void* context) {
}
bad_usb->st.state = worker_state;
continue;
} else if((flags == FuriFlagErrorTimeout) || (flags == FuriFlagErrorResource)) {
} else if(
(flags == (unsigned)FuriFlagErrorTimeout) ||
(flags == (unsigned)FuriFlagErrorResource)) {
if(delay_val > 0) {
bad_usb->st.delay_remain--;
continue;
@@ -650,7 +652,7 @@ static int32_t bad_usb_worker(void* context) {
BadUsbScript* bad_usb_script_open(FuriString* file_path) {
furi_assert(file_path);
BadUsbScript* bad_usb = malloc(sizeof(BadUsbScript)); //-V773
BadUsbScript* bad_usb = malloc(sizeof(BadUsbScript));
bad_usb->file_path = furi_string_alloc();
furi_string_set(bad_usb->file_path, file_path);
@@ -660,7 +662,7 @@ BadUsbScript* bad_usb_script_open(FuriString* file_path) {
bad_usb->thread = furi_thread_alloc_ex("BadUsbWorker", 2048, bad_usb_worker, bad_usb);
furi_thread_start(bad_usb->thread);
return bad_usb;
}
} //-V773
void bad_usb_script_close(BadUsbScript* bad_usb) {
furi_assert(bad_usb);

View File

@@ -156,7 +156,7 @@ static bool fap_loader_select_app(FapLoader* loader) {
}
static FapLoader* fap_loader_alloc(const char* path) {
FapLoader* loader = malloc(sizeof(FapLoader)); //-V773
FapLoader* loader = malloc(sizeof(FapLoader)); //-V799
loader->fap_path = furi_string_alloc_set(path);
loader->storage = furi_record_open(RECORD_STORAGE);
loader->dialogs = furi_record_open(RECORD_DIALOGS);
@@ -167,7 +167,7 @@ static FapLoader* fap_loader_alloc(const char* path) {
loader->view_dispatcher, loader->gui, ViewDispatcherTypeFullscreen);
view_dispatcher_add_view(loader->view_dispatcher, 0, loading_get_view(loader->loading));
return loader;
}
} //-V773
static void fap_loader_free(FapLoader* loader) {
view_dispatcher_remove_view(loader->view_dispatcher, 0);

View File

@@ -278,7 +278,7 @@ bool ibutton_save_key(iButton* ibutton, const char* key_name) {
flipper_format_free(file);
if(!result) {
if(!result) { //-V547
dialog_message_show_storage_error(ibutton->dialogs, "Cannot save\nkey file");
}
@@ -302,7 +302,7 @@ void ibutton_text_store_set(iButton* ibutton, const char* text, ...) {
}
void ibutton_text_store_clear(iButton* ibutton) {
memset(ibutton->text_store, 0, IBUTTON_TEXT_STORE_SIZE);
memset(ibutton->text_store, 0, IBUTTON_TEXT_STORE_SIZE + 1);
}
void ibutton_notification_message(iButton* ibutton, uint32_t message) {
@@ -343,7 +343,7 @@ int32_t ibutton_app(void* p) {
} else {
view_dispatcher_attach_to_gui(
ibutton->view_dispatcher, ibutton->gui, ViewDispatcherTypeFullscreen);
if(key_loaded) {
if(key_loaded) { //-V547
scene_manager_next_scene(ibutton->scene_manager, iButtonSceneEmulate);
DOLPHIN_DEED(DolphinDeedIbuttonEmulate);
} else {

View File

@@ -360,7 +360,7 @@ void infrared_text_store_set(Infrared* infrared, uint32_t bank, const char* text
}
void infrared_text_store_clear(Infrared* infrared, uint32_t bank) {
memset(infrared->text_store[bank], 0, INFRARED_TEXT_STORE_SIZE);
memset(infrared->text_store[bank], 0, INFRARED_TEXT_STORE_SIZE + 1);
}
void infrared_play_notification_message(Infrared* infrared, uint32_t message) {
@@ -455,7 +455,7 @@ int32_t infrared_app(void* p) {
} else {
view_dispatcher_attach_to_gui(
infrared->view_dispatcher, infrared->gui, ViewDispatcherTypeFullscreen);
if(is_remote_loaded) {
if(is_remote_loaded) { //-V547
scene_manager_next_scene(infrared->scene_manager, InfraredSceneRemote);
} else {
scene_manager_next_scene(infrared->scene_manager, InfraredSceneStart);

View File

@@ -65,7 +65,7 @@ bool infrared_brute_force_calculate_messages(InfraredBruteForce* brute_force) {
while(flipper_format_read_string(ff, "name", signal_name)) {
InfraredBruteForceRecord* record =
InfraredBruteForceRecordDict_get(brute_force->records, signal_name);
if(record) {
if(record) { //-V547
++(record->count);
}
}

View File

@@ -55,7 +55,7 @@ static void signal_received_callback(void* context, InfraredWorkerSignal* receiv
size_t timings_cnt;
infrared_worker_get_raw_signal(received_signal, &timings, &timings_cnt);
buf_cnt = snprintf(buf, sizeof(buf), "RAW, %d samples:\r\n", timings_cnt);
buf_cnt = snprintf(buf, sizeof(buf), "RAW, %zu samples:\r\n", timings_cnt);
cli_write(cli, (uint8_t*)buf, buf_cnt);
for(size_t i = 0; i < timings_cnt; ++i) {
buf_cnt = snprintf(buf, sizeof(buf), "%lu ", timings[i]);
@@ -276,7 +276,9 @@ static bool infrared_cli_decode_file(FlipperFormat* input_file, FlipperFormat* o
}
InfraredRawSignal* raw_signal = infrared_signal_get_raw_signal(signal);
printf(
"Raw signal: %s, %u samples\r\n", furi_string_get_cstr(tmp), raw_signal->timings_size);
"Raw signal: %s, %zu samples\r\n",
furi_string_get_cstr(tmp),
raw_signal->timings_size);
if(!infrared_cli_decode_raw_signal(
raw_signal, decoder, output_file, furi_string_get_cstr(tmp)))
break;
@@ -382,7 +384,7 @@ static void infrared_cli_list_remote_signals(FuriString* remote_name) {
while(flipper_format_read_string(ff, "name", signal_name)) {
furi_string_set_str(key, furi_string_get_cstr(signal_name));
int* v = dict_signals_get(signals_dict, key);
if(v != NULL) {
if(v != NULL) { //-V547
(*v)++;
max = M_MAX(*v, max);
} else {
@@ -436,7 +438,7 @@ static void
break;
}
printf("Sending %ld signal(s)...\r\n", record_count);
printf("Sending %lu signal(s)...\r\n", record_count);
printf("Press Ctrl-C to stop.\r\n");
int records_sent = 0;

View File

@@ -145,15 +145,14 @@ bool infrared_remote_load(InfraredRemote* remote, FuriString* path) {
buf = furi_string_alloc();
FURI_LOG_I(TAG, "load file: \'%s\'", furi_string_get_cstr(path));
bool success = flipper_format_buffered_file_open_existing(ff, furi_string_get_cstr(path));
bool success = false;
if(success) {
do {
if(!flipper_format_buffered_file_open_existing(ff, furi_string_get_cstr(path))) break;
uint32_t version;
success = flipper_format_read_header(ff, buf, &version) &&
!furi_string_cmp(buf, "IR signals file") && (version == 1);
}
if(!flipper_format_read_header(ff, buf, &version)) break;
if(!furi_string_equal(buf, "IR signals file") || (version != 1)) break;
if(success) {
path_extract_filename(path, buf, true);
infrared_remote_clear_buttons(remote);
infrared_remote_set_name(remote, furi_string_get_cstr(buf));
@@ -169,7 +168,8 @@ bool infrared_remote_load(InfraredRemote* remote, FuriString* path) {
infrared_remote_button_free(button);
}
}
}
success = true;
} while(false);
furi_string_free(buf);
flipper_format_free(ff);

View File

@@ -74,7 +74,7 @@ static bool infrared_signal_is_raw_valid(InfraredRawSignal* raw) {
} else if((raw->timings_size <= 0) || (raw->timings_size > MAX_TIMINGS_AMOUNT)) {
FURI_LOG_E(
TAG,
"Timings amount is out of range (0 - %X): %X",
"Timings amount is out of range (0 - %X): %zX",
MAX_TIMINGS_AMOUNT,
raw->timings_size);
return false;
@@ -275,8 +275,8 @@ bool infrared_signal_search_and_read(
is_name_found = furi_string_equal(name, tmp);
if(is_name_found) break;
}
if(!is_name_found) break;
if(!infrared_signal_read_body(signal, ff)) break;
if(!is_name_found) break; //-V547
if(!infrared_signal_read_body(signal, ff)) break; //-V779
success = true;
} while(false);

View File

@@ -26,7 +26,7 @@ bool infrared_scene_debug_on_event(void* context, SceneManagerEvent event) {
InfraredRawSignal* raw = infrared_signal_get_raw_signal(signal);
infrared_debug_view_set_text(debug_view, "RAW\n%d samples\n", raw->timings_size);
printf("RAW, %d samples:\r\n", raw->timings_size);
printf("RAW, %zu samples:\r\n", raw->timings_size);
for(size_t i = 0; i < raw->timings_size; ++i) {
printf("%lu ", raw->timings[i]);
}

View File

@@ -32,7 +32,7 @@ static void rpc_command_callback(RpcAppSystemEvent rpc_event, void* context) {
}
static LfRfid* lfrfid_alloc() {
LfRfid* lfrfid = malloc(sizeof(LfRfid)); //-V773
LfRfid* lfrfid = malloc(sizeof(LfRfid));
lfrfid->storage = furi_record_open(RECORD_STORAGE);
lfrfid->dialogs = furi_record_open(RECORD_DIALOGS);
@@ -100,7 +100,7 @@ static LfRfid* lfrfid_alloc() {
lfrfid->view_dispatcher, LfRfidViewRead, lfrfid_view_read_get_view(lfrfid->read_view));
return lfrfid;
}
} //-V773
static void lfrfid_free(LfRfid* lfrfid) {
furi_assert(lfrfid);

View File

@@ -87,7 +87,7 @@ static void lfrfid_cli_read(Cli* cli, FuriString* args) {
uint32_t flags =
furi_event_flag_wait(context.event, available_flags, FuriFlagWaitAny, 100);
if(flags != FuriFlagErrorTimeout) {
if(flags != (unsigned)FuriFlagErrorTimeout) {
if(FURI_BIT(flags, LFRFIDWorkerReadDone)) {
break;
}
@@ -153,7 +153,7 @@ static bool lfrfid_cli_parse_args(FuriString* args, ProtocolDict* dict, Protocol
for(ProtocolId i = 0; i < LFRFIDProtocolMax; i++) {
printf(
"\t%s, %d bytes long\r\n",
"\t%s, %zu bytes long\r\n",
protocol_dict_get_name(dict, i),
protocol_dict_get_data_size(dict, i));
}
@@ -165,7 +165,7 @@ static bool lfrfid_cli_parse_args(FuriString* args, ProtocolDict* dict, Protocol
// check data arg
if(!args_read_hex_bytes(data_text, data, data_size)) {
printf(
"%s data needs to be %d bytes long\r\n",
"%s data needs to be %zu bytes long\r\n",
protocol_dict_get_name(dict, *protocol),
data_size);
break;
@@ -211,7 +211,7 @@ static void lfrfid_cli_write(Cli* cli, FuriString* args) {
while(!cli_cmd_interrupt_received(cli)) {
uint32_t flags = furi_event_flag_wait(event, available_flags, FuriFlagWaitAny, 100);
if(flags != FuriFlagErrorTimeout) {
if(flags != (unsigned)FuriFlagErrorTimeout) {
if(FURI_BIT(flags, LFRFIDWorkerWriteOK)) {
printf("Written!\r\n");
break;
@@ -309,9 +309,9 @@ static void lfrfid_cli_raw_analyze(Cli* cli, FuriString* args) {
warn = true;
}
furi_string_printf(info_string, "[%ld %ld]", pulse, duration);
furi_string_printf(info_string, "[%lu %lu]", pulse, duration);
printf("%-16s", furi_string_get_cstr(info_string));
furi_string_printf(info_string, "[%ld %ld]", pulse, duration - pulse);
furi_string_printf(info_string, "[%lu %lu]", pulse, duration - pulse);
printf("%-16s", furi_string_get_cstr(info_string));
if(warn) {
@@ -335,7 +335,7 @@ static void lfrfid_cli_raw_analyze(Cli* cli, FuriString* args) {
total_pulse += pulse;
total_duration += duration;
if(total_protocol != PROTOCOL_NO) {
if(total_protocol != PROTOCOL_NO) { //-V1051
break;
}
} else {
@@ -346,9 +346,9 @@ static void lfrfid_cli_raw_analyze(Cli* cli, FuriString* args) {
printf(" Frequency: %f\r\n", (double)frequency);
printf(" Duty Cycle: %f\r\n", (double)duty_cycle);
printf(" Warns: %ld\r\n", total_warns);
printf(" Pulse sum: %ld\r\n", total_pulse);
printf("Duration sum: %ld\r\n", total_duration);
printf(" Warns: %lu\r\n", total_warns);
printf(" Pulse sum: %lu\r\n", total_pulse);
printf("Duration sum: %lu\r\n", total_duration);
printf(" Average: %f\r\n", (double)((float)total_pulse / (float)total_duration));
printf(" Protocol: ");
@@ -435,7 +435,7 @@ static void lfrfid_cli_raw_read(Cli* cli, FuriString* args) {
while(true) {
uint32_t flags = furi_event_flag_wait(event, available_flags, FuriFlagWaitAny, 100);
if(flags != FuriFlagErrorTimeout) {
if(flags != (unsigned)FuriFlagErrorTimeout) {
if(FURI_BIT(flags, LFRFIDWorkerReadRawFileError)) {
printf("File is not RFID raw file\r\n");
break;
@@ -510,7 +510,7 @@ static void lfrfid_cli_raw_emulate(Cli* cli, FuriString* args) {
while(true) {
uint32_t flags = furi_event_flag_wait(event, available_flags, FuriFlagWaitAny, 100);
if(flags != FuriFlagErrorTimeout) {
if(flags != (unsigned)FuriFlagErrorTimeout) {
if(FURI_BIT(flags, LFRFIDWorkerEmulateRawFileError)) {
printf("File is not RFID raw file\r\n");
break;
@@ -573,4 +573,4 @@ static void lfrfid_cli(Cli* cli, FuriString* args, void* context) {
}
furi_string_free(cmd);
}
}

View File

@@ -39,7 +39,7 @@ static void nfc_scene_emulate_uid_widget_config(Nfc* nfc, bool data_received) {
widget_add_icon_element(widget, 0, 3, &I_NFC_dolphin_emulation_47x61);
widget_add_string_element(widget, 57, 13, AlignLeft, AlignTop, FontPrimary, "Emulating UID");
if(strcmp(nfc->dev->dev_name, "")) {
if(strcmp(nfc->dev->dev_name, "") != 0) {
furi_string_printf(info_str, "%s", nfc->dev->dev_name);
} else {
for(uint8_t i = 0; i < data->uid_len; i++) {

View File

@@ -18,7 +18,7 @@ void nfc_scene_mf_classic_emulate_on_enter(void* context) {
// Setup view
Popup* popup = nfc->popup;
popup_set_header(popup, "Emulating", 67, 13, AlignLeft, AlignTop);
if(strcmp(nfc->dev->dev_name, "")) {
if(strcmp(nfc->dev->dev_name, "") != 0) {
nfc_text_store_set(nfc, "%s", nfc->dev->dev_name);
} else {
nfc_text_store_set(nfc, "MIFARE\nClassic");

View File

@@ -28,9 +28,9 @@ void nfc_scene_mf_classic_keys_on_enter(void* context) {
widget_add_string_element(
nfc->widget, 0, 0, AlignLeft, AlignTop, FontPrimary, "Mifare Classic Keys");
char temp_str[32];
snprintf(temp_str, sizeof(temp_str), "Flipper list: %ld", flipper_dict_keys_total);
snprintf(temp_str, sizeof(temp_str), "Flipper list: %lu", flipper_dict_keys_total);
widget_add_string_element(nfc->widget, 0, 20, AlignLeft, AlignTop, FontSecondary, temp_str);
snprintf(temp_str, sizeof(temp_str), "User list: %ld", user_dict_keys_total);
snprintf(temp_str, sizeof(temp_str), "User list: %lu", user_dict_keys_total);
widget_add_string_element(nfc->widget, 0, 32, AlignLeft, AlignTop, FontSecondary, temp_str);
widget_add_button_element(
nfc->widget, GuiButtonTypeCenter, "Add", nfc_scene_mf_classic_keys_widget_callback, nfc);

View File

@@ -27,7 +27,7 @@ void nfc_scene_mf_classic_keys_list_prepare(Nfc* nfc, MfClassicDict* dict) {
char* current_key = (char*)malloc(sizeof(char) * 13);
strncpy(current_key, furi_string_get_cstr(temp_key), 12);
MfClassicUserKeys_push_back(nfc->mfc_key_strs, current_key);
FURI_LOG_D("ListKeys", "Key %ld: %s", index, current_key);
FURI_LOG_D("ListKeys", "Key %lu: %s", index, current_key);
submenu_add_item(
submenu, current_key, index++, nfc_scene_mf_classic_keys_list_submenu_callback, nfc);
}

View File

@@ -26,13 +26,13 @@ void nfc_scene_mf_desfire_read_success_on_enter(void* context) {
furi_string_cat_printf(temp_str, " %02X", nfc_data->uid[i]);
}
uint32_t bytes_total = 1 << (data->version.sw_storage >> 1);
uint32_t bytes_total = 1UL << (data->version.sw_storage >> 1);
uint32_t bytes_free = data->free_memory ? data->free_memory->bytes : 0;
furi_string_cat_printf(temp_str, "\n%ld", bytes_total);
furi_string_cat_printf(temp_str, "\n%lu", bytes_total);
if(data->version.sw_storage & 1) {
furi_string_push_back(temp_str, '+');
}
furi_string_cat_printf(temp_str, " bytes, %ld bytes free\n", bytes_free);
furi_string_cat_printf(temp_str, " bytes, %lu bytes free\n", bytes_free);
uint16_t n_apps = 0;
uint16_t n_files = 0;

View File

@@ -21,7 +21,7 @@ void nfc_scene_mf_ultralight_emulate_on_enter(void* context) {
(type == MfUltralightTypeUnknown);
Popup* popup = nfc->popup;
popup_set_header(popup, "Emulating", 67, 13, AlignLeft, AlignTop);
if(strcmp(nfc->dev->dev_name, "")) {
if(strcmp(nfc->dev->dev_name, "") != 0) {
nfc_text_store_set(nfc, "%s", nfc->dev->dev_name);
} else if(is_ultralight) {
nfc_text_store_set(nfc, "MIFARE\nUltralight");

View File

@@ -57,13 +57,13 @@ void nfc_scene_nfc_data_info_on_enter(void* context) {
// Set application specific data
if(protocol == NfcDeviceProtocolMifareDesfire) {
MifareDesfireData* data = &dev_data->mf_df_data;
uint32_t bytes_total = 1 << (data->version.sw_storage >> 1);
uint32_t bytes_total = 1UL << (data->version.sw_storage >> 1);
uint32_t bytes_free = data->free_memory ? data->free_memory->bytes : 0;
furi_string_cat_printf(temp_str, "\n%ld", bytes_total);
furi_string_cat_printf(temp_str, "\n%lu", bytes_total);
if(data->version.sw_storage & 1) {
furi_string_push_back(temp_str, '+');
}
furi_string_cat_printf(temp_str, " bytes, %ld bytes free\n", bytes_free);
furi_string_cat_printf(temp_str, " bytes, %lu bytes free\n", bytes_free);
uint16_t n_apps = 0;
uint16_t n_files = 0;
@@ -147,4 +147,4 @@ void nfc_scene_nfc_data_info_on_exit(void* context) {
Nfc* nfc = context;
widget_reset(nfc->widget);
}
}

View File

@@ -71,7 +71,7 @@ bool nfc_scene_read_on_event(void* context, SceneManagerEvent event) {
} else if(event.event == NfcWorkerEventReadMfUltralight) {
notification_message(nfc->notifications, &sequence_success);
// Set unlock password input to 0xFFFFFFFF only on fresh read
memset(nfc->byte_input_store, 0xFF, 4);
memset(nfc->byte_input_store, 0xFF, sizeof(nfc->byte_input_store));
scene_manager_next_scene(nfc->scene_manager, NfcSceneMfUltralightReadSuccess);
DOLPHIN_DEED(DolphinDeedNfcReadSuccess);
consumed = true;

View File

@@ -55,7 +55,7 @@ bool nfc_scene_save_name_on_event(void* context, SceneManagerEvent event) {
if(event.type == SceneManagerEventTypeCustom) {
if(event.event == NfcCustomEventTextInputDone) {
if(strcmp(nfc->dev->dev_name, "")) {
if(strcmp(nfc->dev->dev_name, "") != 0) {
nfc_device_delete(nfc->dev, true);
}
if(scene_manager_has_previous_scene(nfc->scene_manager, NfcSceneSetUid)) {

View File

@@ -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);

View File

@@ -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);

View File

@@ -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)) {

View File

@@ -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");

View File

@@ -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,

View File

@@ -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--;

View File

@@ -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,

View File

@@ -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);

View File

@@ -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) {

View File

@@ -58,7 +58,7 @@ bool u2f_scene_main_on_event(void* context, SceneManagerEvent event) {
app->event_cur = event.event;
if(event.event == U2fCustomEventRegister)
u2f_view_set_state(app->u2f_view, U2fMsgRegister);
else if(event.event == U2fCustomEventAuth)
else if(event.event == U2fCustomEventAuth) //-V547
u2f_view_set_state(app->u2f_view, U2fMsgAuth);
notification_message(app->notifications, &sequence_display_backlight_on);
notification_message(app->notifications, &sequence_single_vibro);

View File

@@ -402,9 +402,9 @@ bool u2f_data_cnt_read(uint32_t* cnt_val) {
FURI_LOG_E(TAG, "Unable to load encryption key");
break;
}
memset(&cnt, 0, 32);
if(!furi_hal_crypto_decrypt(cnt_encr, (uint8_t*)&cnt, 32)) {
memset(&cnt, 0, 32);
memset(&cnt, 0, sizeof(U2fCounterData));
if(!furi_hal_crypto_decrypt(cnt_encr, (uint8_t*)&cnt, sizeof(U2fCounterData))) {
memset(&cnt, 0, sizeof(U2fCounterData));
FURI_LOG_E(TAG, "Decryption failed");
break;
}

View File

@@ -94,7 +94,7 @@ static void u2f_hid_send_response(U2fHid* u2f_hid) {
uint16_t data_ptr = 0;
memset(packet_buf, 0, HID_U2F_PACKET_LEN);
memcpy(packet_buf, &(u2f_hid->packet.cid), 4);
memcpy(packet_buf, &(u2f_hid->packet.cid), sizeof(uint32_t)); //-V1086
// Init packet
packet_buf[4] = u2f_hid->packet.cmd;
@@ -166,7 +166,7 @@ static bool u2f_hid_parse_request(U2fHid* u2f_hid) {
return false;
u2f_hid->packet.len = 17;
uint32_t random_cid = furi_hal_random_get();
memcpy(&(u2f_hid->packet.payload[8]), &random_cid, 4);
memcpy(&(u2f_hid->packet.payload[8]), &random_cid, sizeof(uint32_t)); //-V1086
u2f_hid->packet.payload[12] = 2; // Protocol version
u2f_hid->packet.payload[13] = 1; // Device version major
u2f_hid->packet.payload[14] = 0; // Device version minor
@@ -177,7 +177,7 @@ static bool u2f_hid_parse_request(U2fHid* u2f_hid) {
} else if(u2f_hid->packet.cmd == U2F_HID_WINK) { // WINK - notify user
if(u2f_hid->packet.len != 0) return false;
u2f_wink(u2f_hid->u2f_instance);
u2f_hid->packet.len = 0;
u2f_hid->packet.len = 0; //-V1048
u2f_hid_send_response(u2f_hid);
} else
return false;