[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:
@@ -242,7 +242,6 @@ void subghz_protocol_decoder_bett_feed(void* context, bool level, uint32_t durat
|
||||
if(!level) {
|
||||
if(DURATION_DIFF(duration, subghz_protocol_bett_const.te_short * 44) <
|
||||
(subghz_protocol_bett_const.te_delta * 15)) {
|
||||
instance->decoder.parser_step = BETTDecoderStepSaveDuration;
|
||||
if(instance->decoder.decode_count_bit ==
|
||||
subghz_protocol_bett_const.min_count_bit_for_found) {
|
||||
instance->generic.data = instance->decoder.decode_data;
|
||||
|
||||
@@ -240,7 +240,6 @@ void subghz_protocol_decoder_holtek_feed(void* context, bool level, uint32_t dur
|
||||
if(!level) {
|
||||
if(duration >= ((uint32_t)subghz_protocol_holtek_const.te_short * 10 +
|
||||
subghz_protocol_holtek_const.te_delta)) {
|
||||
instance->decoder.parser_step = HoltekDecoderStepSaveDuration;
|
||||
if(instance->decoder.decode_count_bit ==
|
||||
subghz_protocol_holtek_const.min_count_bit_for_found) {
|
||||
if((instance->decoder.decode_data & HOLTEK_HEADER_MASK) == HOLTEK_HEADER) {
|
||||
|
||||
@@ -119,8 +119,8 @@ void subghz_protocol_encoder_keeloq_free(void* context) {
|
||||
*/
|
||||
static bool subghz_protocol_keeloq_gen_data(SubGhzProtocolEncoderKeeloq* instance, uint8_t btn) {
|
||||
instance->generic.cnt++;
|
||||
uint32_t fix = btn << 28 | instance->generic.serial;
|
||||
uint32_t decrypt = btn << 28 |
|
||||
uint32_t fix = (uint32_t)btn << 28 | instance->generic.serial;
|
||||
uint32_t decrypt = (uint32_t)btn << 28 |
|
||||
(instance->generic.serial & 0x3FF)
|
||||
<< 16 | //ToDo in some protocols the discriminator is 0
|
||||
instance->generic.cnt;
|
||||
@@ -271,7 +271,8 @@ bool subghz_protocol_encoder_keeloq_deserialize(void* context, FlipperFormat* fl
|
||||
subghz_protocol_keeloq_check_remote_controller(
|
||||
&instance->generic, instance->keystore, &instance->manufacture_name);
|
||||
|
||||
if(strcmp(instance->manufacture_name, "DoorHan")) {
|
||||
if(strcmp(instance->manufacture_name, "DoorHan") != 0) {
|
||||
FURI_LOG_E(TAG, "Wrong manufacturer name");
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -287,7 +288,7 @@ bool subghz_protocol_encoder_keeloq_deserialize(void* context, FlipperFormat* fl
|
||||
}
|
||||
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] = (instance->generic.data >> i * 8) & 0xFF;
|
||||
key_data[sizeof(uint64_t) - i - 1] = (instance->generic.data >> (i * 8)) & 0xFF;
|
||||
}
|
||||
if(!flipper_format_update_hex(flipper_format, "Key", key_data, sizeof(uint64_t))) {
|
||||
FURI_LOG_E(TAG, "Unable to add Key");
|
||||
|
||||
@@ -142,7 +142,7 @@ void subghz_protocol_decoder_kia_feed(void* context, bool level, uint32_t durati
|
||||
case KIADecoderStepSaveDuration:
|
||||
if(level) {
|
||||
if(duration >=
|
||||
(uint32_t)(subghz_protocol_kia_const.te_long + subghz_protocol_kia_const.te_delta * 2)) {
|
||||
(subghz_protocol_kia_const.te_long + subghz_protocol_kia_const.te_delta * 2UL)) {
|
||||
//Found stop bit
|
||||
instance->decoder.parser_step = KIADecoderStepReset;
|
||||
if(instance->decoder.decode_count_bit ==
|
||||
|
||||
@@ -417,7 +417,7 @@ void subghz_protocol_decoder_megacode_get_string(void* context, FuriString* outp
|
||||
output,
|
||||
"%s %dbit\r\n"
|
||||
"Key:0x%06lX\r\n"
|
||||
"Sn:0x%04lX - %ld\r\n"
|
||||
"Sn:0x%04lX - %lu\r\n"
|
||||
"Facility:%lX Btn:%X\r\n",
|
||||
instance->generic.protocol_name,
|
||||
instance->generic.data_count_bit,
|
||||
|
||||
@@ -308,7 +308,7 @@ void subghz_protocol_decoder_nero_radio_feed(void* context, bool level, uint32_t
|
||||
}
|
||||
instance->decoder.decode_data = 0;
|
||||
instance->decoder.decode_count_bit = 0;
|
||||
instance->decoder.parser_step = NeroRadioDecoderStepReset;
|
||||
instance->decoder.parser_step = NeroRadioDecoderStepReset; //-V1048
|
||||
break;
|
||||
} else if(
|
||||
(DURATION_DIFF(
|
||||
|
||||
@@ -363,7 +363,7 @@ void subghz_protocol_decoder_princeton_get_string(void* context, FuriString* out
|
||||
"Key:0x%08lX\r\n"
|
||||
"Yek:0x%08lX\r\n"
|
||||
"Sn:0x%05lX Btn:%01X\r\n"
|
||||
"Te:%ldus\r\n",
|
||||
"Te:%luus\r\n",
|
||||
instance->generic.protocol_name,
|
||||
instance->generic.data_count_bit,
|
||||
(uint32_t)(instance->generic.data & 0xFFFFFF),
|
||||
|
||||
@@ -94,12 +94,12 @@ void subghz_encoder_princeton_for_testing_print_log(void* context) {
|
||||
((float)instance->time_high / (instance->time_high + instance->time_low)) * 100;
|
||||
FURI_LOG_I(
|
||||
TAG "Encoder",
|
||||
"Radio tx_time=%ldus ON=%ldus, OFF=%ldus, DutyCycle=%ld,%ld%%",
|
||||
"Radio tx_time=%luus ON=%luus, OFF=%luus, DutyCycle=%lu,%lu%%",
|
||||
instance->time_high + instance->time_low,
|
||||
instance->time_high,
|
||||
instance->time_low,
|
||||
(uint32_t)duty_cycle,
|
||||
(uint32_t)((duty_cycle - (uint32_t)duty_cycle) * 100));
|
||||
(uint32_t)((duty_cycle - (uint32_t)duty_cycle) * 100UL));
|
||||
}
|
||||
|
||||
LevelDuration subghz_encoder_princeton_for_testing_yield(void* context) {
|
||||
|
||||
@@ -151,8 +151,8 @@ void subghz_protocol_decoder_scher_khan_feed(void* context, bool level, uint32_t
|
||||
break;
|
||||
case ScherKhanDecoderStepSaveDuration:
|
||||
if(level) {
|
||||
if(duration >= (uint32_t)(subghz_protocol_scher_khan_const.te_long +
|
||||
subghz_protocol_scher_khan_const.te_delta * 2)) {
|
||||
if(duration >= (subghz_protocol_scher_khan_const.te_delta * 2UL +
|
||||
subghz_protocol_scher_khan_const.te_long)) {
|
||||
//Found stop bit
|
||||
instance->decoder.parser_step = ScherKhanDecoderStepReset;
|
||||
if(instance->decoder.decode_count_bit >=
|
||||
|
||||
@@ -291,7 +291,7 @@ bool subghz_protocol_encoder_secplus_v1_deserialize(void* context, FlipperFormat
|
||||
|
||||
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] = (instance->generic.data >> i * 8) & 0xFF;
|
||||
key_data[sizeof(uint64_t) - i - 1] = (instance->generic.data >> (i * 8)) & 0xFF;
|
||||
}
|
||||
if(!flipper_format_update_hex(flipper_format, "Key", key_data, sizeof(uint64_t))) {
|
||||
FURI_LOG_E(TAG, "Unable to add Key");
|
||||
@@ -550,7 +550,7 @@ bool subghz_protocol_secplus_v1_check_fixed(uint32_t fixed) {
|
||||
|
||||
do {
|
||||
if(id1 == 0) return false;
|
||||
if(!(btn == 0 || btn == 1 || btn == 2)) return false;
|
||||
if(!(btn == 0 || btn == 1 || btn == 2)) return false; //-V560
|
||||
} while(false);
|
||||
return true;
|
||||
}
|
||||
@@ -588,7 +588,7 @@ void subghz_protocol_decoder_secplus_v1_get_string(void* context, FuriString* ou
|
||||
|
||||
if(pin <= 9999) {
|
||||
furi_string_cat_printf(output, " pin:%d", pin);
|
||||
} else if(10000 <= pin && pin <= 11029) {
|
||||
} else if(pin <= 11029) {
|
||||
furi_string_cat_printf(output, " pin:enter");
|
||||
}
|
||||
|
||||
@@ -618,7 +618,7 @@ void subghz_protocol_decoder_secplus_v1_get_string(void* context, FuriString* ou
|
||||
furi_string_cat_printf(output, " Btn:left\r\n");
|
||||
} else if(instance->generic.btn == 0) {
|
||||
furi_string_cat_printf(output, " Btn:middle\r\n");
|
||||
} else if(instance->generic.btn == 2) {
|
||||
} else if(instance->generic.btn == 2) { //-V547
|
||||
furi_string_cat_printf(output, " Btn:right\r\n");
|
||||
}
|
||||
|
||||
|
||||
@@ -151,7 +151,7 @@ static bool subghz_protocol_secplus_v2_mix_order_decode(uint8_t order, uint16_t
|
||||
case 0x06: // 0b0110 2, 1, 0],
|
||||
case 0x09: // 0b1001 2, 1, 0],
|
||||
p[2] = a;
|
||||
p[1] = b;
|
||||
// p[1]: no change
|
||||
p[0] = c;
|
||||
break;
|
||||
case 0x08: // 0b1000 1, 2, 0],
|
||||
@@ -166,20 +166,18 @@ static bool subghz_protocol_secplus_v2_mix_order_decode(uint8_t order, uint16_t
|
||||
p[1] = c;
|
||||
break;
|
||||
case 0x00: // 0b0000 0, 2, 1],
|
||||
p[0] = a;
|
||||
// p[0]: no change
|
||||
p[2] = b;
|
||||
p[1] = c;
|
||||
break;
|
||||
case 0x05: // 0b0101 1, 0, 2],
|
||||
p[1] = a;
|
||||
p[0] = b;
|
||||
p[2] = c;
|
||||
// p[2]: no change
|
||||
break;
|
||||
case 0x02: // 0b0010 0, 1, 2],
|
||||
case 0x0A: // 0b1010 0, 1, 2],
|
||||
p[0] = a;
|
||||
p[1] = b;
|
||||
p[2] = c;
|
||||
// no reordering
|
||||
break;
|
||||
default:
|
||||
FURI_LOG_E(TAG, "Order FAIL");
|
||||
@@ -539,7 +537,7 @@ bool subghz_protocol_encoder_secplus_v2_deserialize(void* context, FlipperFormat
|
||||
|
||||
//update data
|
||||
for(size_t i = 0; i < sizeof(uint64_t); i++) {
|
||||
key_data[sizeof(uint64_t) - i - 1] = (instance->generic.data >> i * 8) & 0xFF;
|
||||
key_data[sizeof(uint64_t) - i - 1] = (instance->generic.data >> (i * 8)) & 0xFF;
|
||||
}
|
||||
if(!flipper_format_update_hex(flipper_format, "Key", key_data, sizeof(uint64_t))) {
|
||||
FURI_LOG_E(TAG, "Unable to add Key");
|
||||
@@ -547,7 +545,7 @@ bool subghz_protocol_encoder_secplus_v2_deserialize(void* context, FlipperFormat
|
||||
}
|
||||
|
||||
for(size_t i = 0; i < sizeof(uint64_t); i++) {
|
||||
key_data[sizeof(uint64_t) - i - 1] = (instance->secplus_packet_1 >> i * 8) & 0xFF;
|
||||
key_data[sizeof(uint64_t) - i - 1] = (instance->secplus_packet_1 >> (i * 8)) & 0xFF;
|
||||
}
|
||||
if(!flipper_format_update_hex(
|
||||
flipper_format, "Secplus_packet_1", key_data, sizeof(uint64_t))) {
|
||||
@@ -605,7 +603,7 @@ bool subghz_protocol_secplus_v2_create_data(
|
||||
|
||||
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] = (instance->secplus_packet_1 >> i * 8) & 0xFF;
|
||||
key_data[sizeof(uint64_t) - i - 1] = (instance->secplus_packet_1 >> (i * 8)) & 0xFF;
|
||||
}
|
||||
|
||||
if(res &&
|
||||
@@ -691,7 +689,7 @@ void subghz_protocol_decoder_secplus_v2_feed(void* context, bool level, uint32_t
|
||||
subghz_protocol_secplus_v2_const.te_delta) {
|
||||
event = ManchesterEventLongLow;
|
||||
} else if(
|
||||
duration >= (uint32_t)(subghz_protocol_secplus_v2_const.te_long * 2 +
|
||||
duration >= (subghz_protocol_secplus_v2_const.te_long * 2UL +
|
||||
subghz_protocol_secplus_v2_const.te_delta)) {
|
||||
if(instance->decoder.decode_count_bit ==
|
||||
subghz_protocol_secplus_v2_const.min_count_bit_for_found) {
|
||||
@@ -766,7 +764,7 @@ bool subghz_protocol_decoder_secplus_v2_serialize(
|
||||
|
||||
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] = (instance->secplus_packet_1 >> i * 8) & 0xFF;
|
||||
key_data[sizeof(uint64_t) - i - 1] = (instance->secplus_packet_1 >> (i * 8)) & 0xFF;
|
||||
}
|
||||
|
||||
if(res &&
|
||||
|
||||
@@ -372,8 +372,8 @@ void subghz_protocol_decoder_smc5326_get_string(void* context, FuriString* outpu
|
||||
|
||||
furi_string_cat_printf(
|
||||
output,
|
||||
"%s %dbit\r\n"
|
||||
"Key:%07lX Te:%ldus\r\n"
|
||||
"%s %ubit\r\n"
|
||||
"Key:%07lX Te:%luus\r\n"
|
||||
" +: " DIP_PATTERN "\r\n"
|
||||
" o: " DIP_PATTERN " ",
|
||||
instance->generic.protocol_name,
|
||||
|
||||
Reference in New Issue
Block a user