[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:
@@ -114,7 +114,6 @@ void lfrfid_raw_worker_stop(LFRFIDRawWorker* worker) {
|
||||
worker->emulate_callback = NULL;
|
||||
worker->context = NULL;
|
||||
worker->read_callback = NULL;
|
||||
worker->context = NULL;
|
||||
furi_event_flag_set(worker->events, 1 << LFRFIDRawWorkerEventStop);
|
||||
furi_thread_join(worker->thread);
|
||||
}
|
||||
@@ -335,7 +334,7 @@ static int32_t lfrfid_raw_emulate_worker_thread(void* thread_context) {
|
||||
}
|
||||
|
||||
if(data->ctx.overrun_count) {
|
||||
FURI_LOG_E(TAG_EMULATE, "overruns: %u", data->ctx.overrun_count);
|
||||
FURI_LOG_E(TAG_EMULATE, "overruns: %zu", data->ctx.overrun_count);
|
||||
}
|
||||
|
||||
furi_stream_buffer_free(data->ctx.stream);
|
||||
@@ -344,4 +343,4 @@ static int32_t lfrfid_raw_emulate_worker_thread(void* thread_context) {
|
||||
free(data);
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@@ -139,7 +139,7 @@ static int32_t lfrfid_worker_thread(void* thread_context) {
|
||||
|
||||
while(true) {
|
||||
uint32_t flags = furi_thread_flags_wait(LFRFIDEventAll, FuriFlagWaitAny, FuriWaitForever);
|
||||
if(flags != FuriFlagErrorTimeout) {
|
||||
if(flags != (unsigned)FuriFlagErrorTimeout) {
|
||||
// stop thread
|
||||
if(flags & LFRFIDEventStopThread) break;
|
||||
|
||||
@@ -161,4 +161,4 @@ static int32_t lfrfid_worker_thread(void* thread_context) {
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@@ -276,7 +276,7 @@ static LFRFIDWorkerReadState lfrfid_worker_read_internal(
|
||||
|
||||
FURI_LOG_D(
|
||||
TAG,
|
||||
"%s, %d, [%s]",
|
||||
"%s, %zu, [%s]",
|
||||
protocol_dict_get_name(worker->protocols, protocol),
|
||||
last_read_count,
|
||||
furi_string_get_cstr(string_info));
|
||||
@@ -335,9 +335,9 @@ static LFRFIDWorkerReadState lfrfid_worker_read_internal(
|
||||
}
|
||||
|
||||
static void lfrfid_worker_mode_read_process(LFRFIDWorker* worker) {
|
||||
LFRFIDFeature feature = LFRFIDFeatureASK;
|
||||
ProtocolId read_result = PROTOCOL_NO;
|
||||
LFRFIDWorkerReadState state;
|
||||
LFRFIDFeature feature;
|
||||
|
||||
if(worker->read_type == LFRFIDWorkerReadTypePSKOnly) {
|
||||
feature = LFRFIDFeaturePSK;
|
||||
@@ -635,4 +635,4 @@ const LFRFIDWorkerModeType lfrfid_worker_modes[] = {
|
||||
[LFRFIDWorkerEmulate] = {.process = lfrfid_worker_mode_emulate_process},
|
||||
[LFRFIDWorkerReadRaw] = {.process = lfrfid_worker_mode_read_raw_process},
|
||||
[LFRFIDWorkerEmulateRaw] = {.process = lfrfid_worker_mode_emulate_raw_process},
|
||||
};
|
||||
};
|
||||
|
@@ -353,4 +353,4 @@ const ProtocolBase protocol_indala26 = {
|
||||
.render_data = (ProtocolRenderData)protocol_indala26_render_data,
|
||||
.render_brief_data = (ProtocolRenderData)protocol_indala26_render_brief_data,
|
||||
.write_data = (ProtocolWriteData)protocol_indala26_write_data,
|
||||
};
|
||||
};
|
||||
|
@@ -12,7 +12,7 @@
|
||||
#define PAC_STANLEY_ENCODED_BYTE_FULL_SIZE \
|
||||
(PAC_STANLEY_ENCODED_BYTE_SIZE + PAC_STANLEY_PREAMBLE_BYTE_SIZE)
|
||||
#define PAC_STANLEY_BYTE_LENGTH (10) // start bit, 7 data bits, parity bit, stop bit
|
||||
#define PAC_STANLEY_DATA_START_INDEX 8 + (3 * PAC_STANLEY_BYTE_LENGTH) + 1
|
||||
#define PAC_STANLEY_DATA_START_INDEX (8 + (3 * PAC_STANLEY_BYTE_LENGTH) + 1)
|
||||
|
||||
#define PAC_STANLEY_DECODED_DATA_SIZE (4)
|
||||
#define PAC_STANLEY_ENCODED_DATA_SIZE (sizeof(ProtocolPACStanley))
|
||||
@@ -128,7 +128,7 @@ bool protocol_pac_stanley_decoder_feed(ProtocolPACStanley* protocol, bool level,
|
||||
}
|
||||
|
||||
bool protocol_pac_stanley_encoder_start(ProtocolPACStanley* protocol) {
|
||||
memset(protocol->encoded_data, 0, PAC_STANLEY_ENCODED_BYTE_SIZE);
|
||||
memset(protocol->encoded_data, 0, sizeof(protocol->encoded_data));
|
||||
|
||||
uint8_t idbytes[10];
|
||||
idbytes[0] = '2';
|
||||
@@ -137,7 +137,7 @@ bool protocol_pac_stanley_encoder_start(ProtocolPACStanley* protocol) {
|
||||
uint8_to_hex_chars(protocol->data, &idbytes[2], 8);
|
||||
|
||||
// insert start and stop bits
|
||||
for(size_t i = 0; i < 16; i++) protocol->encoded_data[i] = 0x40 >> (i + 3) % 5 * 2;
|
||||
for(size_t i = 0; i < 16; i++) protocol->encoded_data[i] = 0x40 >> ((i + 3) % 5 * 2);
|
||||
|
||||
protocol->encoded_data[0] = 0xFF; // mark + stop
|
||||
protocol->encoded_data[1] = 0x20; // start + reflect8(STX)
|
||||
@@ -228,4 +228,4 @@ const ProtocolBase protocol_pac_stanley = {
|
||||
.render_data = (ProtocolRenderData)protocol_pac_stanley_render_data,
|
||||
.render_brief_data = (ProtocolRenderData)protocol_pac_stanley_render_data,
|
||||
.write_data = (ProtocolWriteData)protocol_pac_stanley_write_data,
|
||||
};
|
||||
};
|
||||
|
@@ -25,7 +25,7 @@ void bit_lib_set_bits(uint8_t* data, size_t position, uint8_t byte, uint8_t leng
|
||||
|
||||
for(uint8_t i = 0; i < length; ++i) {
|
||||
uint8_t shift = (length - 1) - i;
|
||||
bit_lib_set_bit(data, position + i, (byte >> shift) & 1);
|
||||
bit_lib_set_bit(data, position + i, (byte >> shift) & 1); //-V610
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,9 +69,9 @@ uint32_t bit_lib_get_bits_32(const uint8_t* data, size_t position, uint8_t lengt
|
||||
value |= bit_lib_get_bits(data, position + 8, 8) << (length - 16);
|
||||
value |= bit_lib_get_bits(data, position + 16, length - 16);
|
||||
} else {
|
||||
value = bit_lib_get_bits(data, position, 8) << (length - 8);
|
||||
value |= bit_lib_get_bits(data, position + 8, 8) << (length - 16);
|
||||
value |= bit_lib_get_bits(data, position + 16, 8) << (length - 24);
|
||||
value = (uint32_t)bit_lib_get_bits(data, position, 8) << (length - 8);
|
||||
value |= (uint32_t)bit_lib_get_bits(data, position + 8, 8) << (length - 16);
|
||||
value |= (uint32_t)bit_lib_get_bits(data, position + 16, 8) << (length - 24);
|
||||
value |= bit_lib_get_bits(data, position + 24, length - 24);
|
||||
}
|
||||
|
||||
@@ -364,4 +364,4 @@ uint16_t bit_lib_crc16(
|
||||
crc ^= xor_out;
|
||||
|
||||
return crc;
|
||||
}
|
||||
}
|
||||
|
@@ -7,7 +7,7 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define TOPBIT(X) (1 << (X - 1))
|
||||
#define TOPBIT(X) (1 << ((X)-1))
|
||||
|
||||
typedef enum {
|
||||
BitLibParityEven,
|
||||
@@ -26,13 +26,13 @@ typedef enum {
|
||||
* @param data value to test
|
||||
* @param index bit index to test
|
||||
*/
|
||||
#define bit_lib_bit_is_set(data, index) ((data & (1 << (index))) != 0)
|
||||
#define bit_lib_bit_is_set(data, index) (((data) & (1 << (index))) != 0)
|
||||
|
||||
/** @brief Test if a bit is not set.
|
||||
* @param data value to test
|
||||
* @param index bit index to test
|
||||
*/
|
||||
#define bit_lib_bit_is_not_set(data, index) ((data & (1 << (index))) == 0)
|
||||
#define bit_lib_bit_is_not_set(data, index) (((data) & (1 << (index))) == 0)
|
||||
|
||||
/** @brief Push a bit into a byte array.
|
||||
* @param data array to push bit into
|
||||
@@ -269,4 +269,4 @@ uint16_t bit_lib_crc16(
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
@@ -28,11 +28,9 @@ bool varint_pair_pack(VarintPair* pair, bool first, uint32_t value) {
|
||||
pair->data_length = 0;
|
||||
}
|
||||
} else {
|
||||
if(pair->data_length > 0) {
|
||||
if(pair->data_length != 0) {
|
||||
pair->data_length += varint_uint32_pack(value, pair->data + pair->data_length);
|
||||
result = true;
|
||||
} else {
|
||||
pair->data_length = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user