mirror of
https://github.com/merbanan/rtl_433.git
synced 2026-05-24 17:55:13 -04:00
minor: fix some cppcheck warnings
This commit is contained in:
@@ -58,8 +58,8 @@ void am_analyze(am_analyze_t *a, int16_t *am_buf, unsigned n_samples, int debug_
|
||||
a->signal_pulse_data[a->signal_pulse_counter][1] = -1;
|
||||
a->signal_pulse_data[a->signal_pulse_counter][2] = -1;
|
||||
if (debug_output) {
|
||||
fprintf(stderr, "pulse_distance %d\n", a->counter - a->pulse_end);
|
||||
fprintf(stderr, "pulse_start distance %d\n", a->pulse_start - a->prev_pulse_start);
|
||||
fprintf(stderr, "pulse_distance %u\n", a->counter - a->pulse_end);
|
||||
fprintf(stderr, "pulse_start distance %u\n", a->pulse_start - a->prev_pulse_start);
|
||||
fprintf(stderr, "pulse_start[%u] found at sample %u, value = %d\n", a->pulses_found, a->counter, am_buf[i]);
|
||||
}
|
||||
a->prev_pulse_start = a->pulse_start;
|
||||
@@ -178,7 +178,7 @@ void am_analyze_classify(am_analyze_t *aa)
|
||||
fprintf(stderr, "Pulse coding: Short pulse length %u - Long pulse length %u\n", min, max);
|
||||
signal_type = 2;
|
||||
} else {
|
||||
fprintf(stderr, "Distance coding: Pulse length %d\n", (min + max) / 2);
|
||||
fprintf(stderr, "Distance coding: Pulse length %u\n", (min + max) / 2);
|
||||
signal_type = 1;
|
||||
}
|
||||
p_limit = (max + min) / 2;
|
||||
|
||||
@@ -92,7 +92,7 @@ static int archos_tbh_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
||||
return DECODE_ABORT_LENGTH;
|
||||
}
|
||||
|
||||
uint8_t frame[62] = {0}; //TODO check max size, I have no idea, arbitrary limit of 60 bytes + 2 bytes crc
|
||||
uint8_t frame[63] = {0}; //TODO check max size, I have no idea, arbitrary limit of 60 bytes + 2 bytes crc
|
||||
frame[0] = len;
|
||||
// Get frame (len don't include the length byte and the crc16 bytes)
|
||||
bitbuffer_extract_bytes(bitbuffer, row,
|
||||
@@ -149,9 +149,9 @@ static int archos_tbh_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
||||
return DECODE_FAIL_MIC;
|
||||
}
|
||||
|
||||
uint32_t idx = payload[6] << 16 | payload[7] << 8 | payload[8];
|
||||
uint32_t ts = payload[9] << 16 | payload[10] << 8 | payload[11];
|
||||
uint32_t maxPower = payload[12] << 8 | payload[13];
|
||||
int idx = payload[6] << 16 | payload[7] << 8 | payload[8];
|
||||
int ts = payload[9] << 16 | payload[10] << 8 | payload[11];
|
||||
int maxPower = payload[12] << 8 | payload[13];
|
||||
|
||||
if (decoder->verbose > 1)
|
||||
fprintf(stderr, "%s: index: %d, timestamp: %d, maxPower: %d\n", __func__,
|
||||
|
||||
@@ -90,7 +90,7 @@ static int gt_wt_03_decode(r_device *decoder, bitbuffer_t *bitbuffer)
|
||||
{
|
||||
data_t *data;
|
||||
int row = 0;
|
||||
uint8_t *b = bitbuffer->bb[row];
|
||||
uint8_t *b;
|
||||
|
||||
// nominal 1 row or 23 rows, require more than half to match
|
||||
if (bitbuffer->num_rows > 1)
|
||||
|
||||
@@ -128,7 +128,7 @@ static int idm_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
||||
|
||||
// to be removed later
|
||||
if (decoder->verbose && bitbuffer->bits_per_row[0] > 600) {
|
||||
fprintf(stderr, "%s: %s, row len=%hu < %u\n", __func__, "DECODE_ABORT_LENGTH",
|
||||
fprintf(stderr, "%s: DECODE_ABORT_LENGTH, row len=%hu < %d\n", __func__,
|
||||
bitbuffer->bits_per_row[0], IDM_PACKET_BITLEN);
|
||||
fprintf(stderr, "%s: DECODE_ABORT_LENGTH 1 %hu < %d\n", __func__, bitbuffer->bits_per_row[0], IDM_PACKET_BITLEN);
|
||||
bitbuffer_print(bitbuffer);
|
||||
@@ -139,7 +139,7 @@ static int idm_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
||||
sync_index = bitbuffer_search(bitbuffer, 0, 0, idm_frame_sync, 24);
|
||||
|
||||
if (decoder->verbose) {
|
||||
fprintf(stderr, "%s: sync_index=%d\n", __func__, sync_index);
|
||||
fprintf(stderr, "%s: sync_index=%u\n", __func__, sync_index);
|
||||
}
|
||||
|
||||
if (sync_index >= bitbuffer->bits_per_row[0]) {
|
||||
@@ -156,7 +156,7 @@ static int idm_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
||||
|
||||
// to be removed later
|
||||
if (decoder->verbose) {
|
||||
fprintf(stderr, "%s: DECODE_ABORT_LENGTH 2 %d < %d\n", __func__, (bitbuffer->bits_per_row[0] - sync_index), IDM_PACKET_BITLEN);
|
||||
fprintf(stderr, "%s: DECODE_ABORT_LENGTH 2 %u < %d\n", __func__, (bitbuffer->bits_per_row[0] - sync_index), IDM_PACKET_BITLEN);
|
||||
// bitrow_printf(b, bitbuffer->bits_per_row[0], "%s bitrow_printf", __func__);
|
||||
bitbuffer_print(bitbuffer);
|
||||
}
|
||||
@@ -405,7 +405,7 @@ static int netidm_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
||||
|
||||
// to be removed later
|
||||
if (decoder->verbose && bitbuffer->bits_per_row[0] > 600) {
|
||||
fprintf(stderr, "%s: %s, row len=%hu < %u\n", __func__, "DECODE_ABORT_LENGTH",
|
||||
fprintf(stderr, "%s: DECODE_ABORT_LENGTH, row len=%hu < %d\n", __func__,
|
||||
bitbuffer->bits_per_row[0], IDM_PACKET_BITLEN);
|
||||
fprintf(stderr, "%s: DECODE_ABORT_LENGTH 1 %d < %d\n", __func__, bitbuffer->bits_per_row[0], IDM_PACKET_BITLEN);
|
||||
}
|
||||
@@ -416,7 +416,7 @@ static int netidm_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
||||
sync_index = bitbuffer_search(bitbuffer, 0, 0, idm_frame_sync, 24);
|
||||
|
||||
if (decoder->verbose) {
|
||||
fprintf(stderr, "%s: sync_index=%d\n", __func__, sync_index);
|
||||
fprintf(stderr, "%s: sync_index=%u\n", __func__, sync_index);
|
||||
}
|
||||
|
||||
if (sync_index >= bitbuffer->bits_per_row[0]) {
|
||||
@@ -431,7 +431,7 @@ static int netidm_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
||||
|
||||
if ((bitbuffer->bits_per_row[0] - sync_index) < IDM_PACKET_BITLEN) {
|
||||
if (decoder->verbose) {
|
||||
fprintf(stderr, "%s: DECODE_ABORT_LENGTH 2 %d < %d\n", __func__, (bitbuffer->bits_per_row[0] - sync_index), IDM_PACKET_BITLEN);
|
||||
fprintf(stderr, "%s: DECODE_ABORT_LENGTH 2 %u < %d\n", __func__, (bitbuffer->bits_per_row[0] - sync_index), IDM_PACKET_BITLEN);
|
||||
// bitrow_printf(b, bitbuffer->bits_per_row[0], "%s bitrow_printf", __func__);
|
||||
bitbuffer_print(bitbuffer);
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ static int ikea_sparsnas_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
||||
ikea_sparsnas_sensor_id = ikea_sparsnas_brute_force_encryption(buffer);
|
||||
if (decoder->verbose > 1) {
|
||||
if (ikea_sparsnas_sensor_id) {
|
||||
fprintf(stderr, "IKEA Sparsnäs: Found valid sensor ID %06d. If reported values does not make sense, this might be incorrect.\n", ikea_sparsnas_sensor_id);
|
||||
fprintf(stderr, "IKEA Sparsnäs: Found valid sensor ID %06u. If reported values does not make sense, this might be incorrect.\n", ikea_sparsnas_sensor_id);
|
||||
} else {
|
||||
fprintf(stderr, "IKEA Sparsnäs: No valid sensor ID found.\n");
|
||||
}
|
||||
@@ -213,12 +213,12 @@ static int ikea_sparsnas_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
||||
fprintf(stderr, "IKEA Sparsnäs: CRC OK (%X == %X)\n", crc_calculated, crc_received);
|
||||
fprintf(stderr, "IKEA Sparsnäs: Encryption key: 0x%X%X%X%X%X\n", key[0], key[1], key[2], key[3], key[4]);
|
||||
decoder_output_bitrowf(decoder, decrypted, 18 * 8, "Decrypted");
|
||||
fprintf(stderr, "IKEA Sparsnäs: Received sensor id: %d\n", rcv_sensor_id);
|
||||
fprintf(stderr, "IKEA Sparsnäs: Received sensor id: %06u\n", rcv_sensor_id);
|
||||
}
|
||||
|
||||
if (rcv_sensor_id != ikea_sparsnas_sensor_id) {
|
||||
if (decoder->verbose > 1) {
|
||||
fprintf(stderr, "IKEA Sparsnäs: Malformed package, or wrong sensor id. Received sensor id (%d) not the same as sender (%d)\n", rcv_sensor_id, ikea_sparsnas_sensor_id);
|
||||
fprintf(stderr, "IKEA Sparsnäs: Malformed package, or wrong sensor id. Received sensor id (%06u) not the same as sender (%d)\n", rcv_sensor_id, ikea_sparsnas_sensor_id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -184,7 +184,7 @@ static int parse_insteon_pkt(r_device *decoder, bitbuffer_t *bits, unsigned int
|
||||
|
||||
if (decoder->verbose) {
|
||||
uint8_t buffy[4];
|
||||
fprintf(stderr, "%s\tstart_pos %u row_length %hu = %d\n",
|
||||
fprintf(stderr, "%s\tstart_pos %u row_length %hu = %u\n",
|
||||
__func__, start_pos, bits->bits_per_row[row], (bits->bits_per_row[row] - start_pos));
|
||||
fprintf(stderr, "%s\t%s\t%-5s\t%s\t%s\t%s\n",
|
||||
__func__, "pkt_i", "pkt_d", "next", "length", "count");
|
||||
@@ -227,7 +227,7 @@ static int parse_insteon_pkt(r_device *decoder, bitbuffer_t *bits, unsigned int
|
||||
y = (next_pos - start_pos);
|
||||
if (y != 26) {
|
||||
if (decoder->verbose)
|
||||
fprintf(stderr, "%s: stop %d != 26\n", __func__, y);
|
||||
fprintf(stderr, "%s: stop %u != 26\n", __func__, y);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -397,7 +397,6 @@ static int insteon_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
||||
{
|
||||
// unsigned int pkt_start_pos;
|
||||
uint16_t row;
|
||||
unsigned int bit_index;
|
||||
unsigned int ret_value = 0;
|
||||
int fail_value = 0;
|
||||
// unsigned int pkt_cnt = 0;
|
||||
@@ -416,7 +415,7 @@ static int insteon_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
||||
* loop over all rows and look for preamble
|
||||
*/
|
||||
for (row = 0; row < bitbuffer->num_rows; ++row) {
|
||||
bit_index = 0;
|
||||
unsigned bit_index = 0;
|
||||
// Validate message and reject it as fast as possible : check for preamble
|
||||
|
||||
if (bitbuffer->bits_per_row[row] < INSTEON_BITLEN_MIN) {
|
||||
|
||||
@@ -125,7 +125,7 @@ static int interlogix_callback(r_device *decoder, bitbuffer_t *bitbuffer)
|
||||
unsigned int bit_offset = bitbuffer_search(bitbuffer, row, 0, &preamble, (sizeof preamble) * 8);
|
||||
if (bit_offset == bitbuffer->bits_per_row[row]) {
|
||||
if (decoder->verbose > 1)
|
||||
fprintf(stderr, "Interlogix: Preamble not found, bit_offset: %d\n", bit_offset);
|
||||
fprintf(stderr, "Interlogix: Preamble not found, bit_offset: %u\n", bit_offset);
|
||||
return DECODE_FAIL_SANITY;
|
||||
}
|
||||
|
||||
|
||||
@@ -216,8 +216,8 @@ static int m_bus_decode_records(data_t *data, const uint8_t *b, uint8_t dif_codi
|
||||
case 0x19:
|
||||
temp = (int16_t)((b[1]<<8)|b[0])*record_factor[vif_uam&0x3];
|
||||
data = data_append(data,
|
||||
oms_temp[dif_ff&0x3][dif_sn&0x3], oms_temp_el[dif_ff&0x3][dif_sn&0x3], DATA_FORMAT, "%.02f C", DATA_DOUBLE, temp,
|
||||
NULL);
|
||||
oms_temp[dif_ff&0x3][dif_sn&0x3], oms_temp_el[dif_ff&0x3][dif_sn&0x3], DATA_FORMAT, "%.02f C", DATA_DOUBLE, temp,
|
||||
NULL);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -226,7 +226,9 @@ static int m_bus_decode_records(data_t *data, const uint8_t *b, uint8_t dif_codi
|
||||
case 0x7B:
|
||||
switch(vif_uam>>1) {
|
||||
case 0xD:
|
||||
data = data_append(data, oms_hum[dif_ff&0x3][dif_sn&0x3], oms_hum_el[dif_ff&0x3][dif_sn&0x3], DATA_FORMAT, "%.1f %%", DATA_DOUBLE, b[0]*humidity_factor[vif_uam&0x1], NULL);
|
||||
data = data_append(data,
|
||||
oms_hum[dif_ff&0x3][dif_sn&0x3], oms_hum_el[dif_ff&0x3][dif_sn&0x3], DATA_FORMAT, "%.1f %%", DATA_DOUBLE, b[0]*humidity_factor[vif_uam&0x1],
|
||||
NULL);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -239,11 +241,15 @@ static int m_bus_decode_records(data_t *data, const uint8_t *b, uint8_t dif_codi
|
||||
// Open sets bits 2 and 6 to 1
|
||||
// Close sets bits 2 and 6 to 0
|
||||
state = b[0]&0x44;
|
||||
data = data_append(data, "switch", "Switch", DATA_FORMAT, "%s", DATA_STRING, (state==0x44) ? "open":"closed", NULL);
|
||||
data = data_append(data,
|
||||
"switch", "Switch", DATA_FORMAT, "%s", DATA_STRING, (state==0x44) ? "open":"closed",
|
||||
NULL);
|
||||
break;
|
||||
case 0x3a:
|
||||
/* Only use 32 bits of 48 available */
|
||||
data = data_append(data, ((dif_su==0)?"counter_0":"counter_1"), ((dif_su==0)?"Counter 0":"Counter 1"), DATA_FORMAT, "%d", DATA_INT, (b[3]<<24|b[2]<<16|b[1]<<8|b[0]), NULL);
|
||||
data = data_append(data,
|
||||
((dif_su==0)?"counter_0":"counter_1"), ((dif_su==0)?"Counter 0":"Counter 1"), DATA_FORMAT, "%d", DATA_INT, (b[3]<<24|b[2]<<16|b[1]<<8|b[0]),
|
||||
NULL);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -465,7 +471,7 @@ static void m_bus_output_data(r_device *decoder, const m_bus_data_t *out, const
|
||||
for (unsigned n=0; n<6; n++) { sprintf(sn_str+n*2, "%02x", block1->knx_sn[n]); }
|
||||
|
||||
data = data_make(
|
||||
"model", "", DATA_STRING, _X("KNX-RF","KNX-RF"),
|
||||
"model", "", DATA_STRING, "KNX-RF",
|
||||
"sn", "SN", DATA_STRING, sn_str,
|
||||
"knx_ctrl", "KNX-Ctrl", DATA_FORMAT, "0x%02X", DATA_INT, block1->block2.knx_ctrl,
|
||||
"src", "Src", DATA_FORMAT, "0x%04X", DATA_INT, block1->block2.src,
|
||||
@@ -506,8 +512,8 @@ static void m_bus_output_data(r_device *decoder, const m_bus_data_t *out, const
|
||||
parse_payload(data, block1, out);
|
||||
} else {
|
||||
data = data_append(data,
|
||||
"payload_encrypted", "Payload Encrypted", DATA_FORMAT, "1", DATA_INT, NULL,
|
||||
NULL);
|
||||
"payload_encrypted", "Payload Encrypted", DATA_FORMAT, "1", DATA_INT, NULL,
|
||||
NULL);
|
||||
}
|
||||
decoder_output_data(decoder, data);
|
||||
}
|
||||
@@ -533,7 +539,7 @@ static int m_bus_mode_c_t_callback(r_device *decoder, bitbuffer_t *bitbuffer) {
|
||||
if (bit_offset + 13*8 >= bitbuffer->bits_per_row[0]) { // Did not find a big enough package
|
||||
return DECODE_ABORT_EARLY;
|
||||
}
|
||||
if (decoder->verbose) { fprintf(stderr, "PREAMBLE_T: found at: %d\n", bit_offset);
|
||||
if (decoder->verbose) { fprintf(stderr, "PREAMBLE_T: found at: %u\n", bit_offset);
|
||||
bitbuffer_print(bitbuffer);
|
||||
}
|
||||
bit_offset += sizeof(PREAMBLE_T)*8; // skip preamble
|
||||
@@ -580,7 +586,7 @@ static int m_bus_mode_c_t_callback(r_device *decoder, bitbuffer_t *bitbuffer) {
|
||||
if (decoder->verbose) { fprintf(stderr, "Experimental - Not tested\n"); }
|
||||
// Extract data
|
||||
data_in.length = (bitbuffer->bits_per_row[0]-bit_offset)/12; // Each byte is encoded into 12 bits
|
||||
if (decoder->verbose) { fprintf(stderr, "MBus telegram length: %d\n", data_in.length); }
|
||||
if (decoder->verbose) { fprintf(stderr, "MBus telegram length: %u\n", data_in.length); }
|
||||
if (m_bus_decode_3of6_buffer(bitbuffer->bb[0], bit_offset, data_in.data, data_in.length) < 0) {
|
||||
if (decoder->verbose) fprintf(stderr, "M-Bus: Decoding error\n");
|
||||
return 0;
|
||||
|
||||
@@ -117,7 +117,7 @@ ttx201_decode(r_device *decoder, bitbuffer_t *bitbuffer, unsigned row, unsigned
|
||||
bits, MSG_PREAMBLE_BITS);
|
||||
}
|
||||
} else if (row != (unsigned)bitbuffer->num_rows - 1 && bits == 1) {
|
||||
fprintf(stderr, "Wrong packet #%d length: %d bits (expected %d)\n",
|
||||
fprintf(stderr, "Wrong packet #%u length: %d bits (expected %d)\n",
|
||||
row, bits, MSG_PACKET_BITS);
|
||||
}
|
||||
}
|
||||
@@ -136,7 +136,7 @@ ttx201_decode(r_device *decoder, bitbuffer_t *bitbuffer, unsigned row, unsigned
|
||||
bitbuffer_print(bitbuffer);
|
||||
fprintf(stderr, "Data decoded:\n" \
|
||||
" r cs K ID S B C X T M J\n");
|
||||
fprintf(stderr, "%2d %2d %2d %3d 0x%01x %1d %1d %1d %4d 0x%02x",
|
||||
fprintf(stderr, "%2u %2d %2d %3d 0x%01x %1d %1d %1d %4d 0x%02x",
|
||||
row,
|
||||
checksum_calculated,
|
||||
checksum,
|
||||
@@ -155,14 +155,14 @@ ttx201_decode(r_device *decoder, bitbuffer_t *bitbuffer, unsigned row, unsigned
|
||||
|
||||
if (postmark != MSG_PACKET_POSTMARK) {
|
||||
if (decoder->verbose > 1)
|
||||
fprintf(stderr, "Packet #%d wrong postmark 0x%02x (expected 0x%02x).\n",
|
||||
fprintf(stderr, "Packet #%u wrong postmark 0x%02x (expected 0x%02x).\n",
|
||||
row, postmark, MSG_PACKET_POSTMARK);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (checksum != checksum_calculated) {
|
||||
if (decoder->verbose > 1)
|
||||
fprintf(stderr, "Packet #%d checksum error.\n", row);
|
||||
fprintf(stderr, "Packet #%u checksum error.\n", row);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -506,13 +506,11 @@ int pulse_demod_nrzs(const pulse_data_t *pulses, r_device *device)
|
||||
{
|
||||
int events = 0;
|
||||
bitbuffer_t bits = {0};
|
||||
int i, n, limit;
|
||||
|
||||
limit = device->s_short_width;
|
||||
int limit = device->s_short_width;
|
||||
|
||||
for (unsigned n = 0; n < pulses->num_pulses; ++n) {
|
||||
if (pulses->pulse[n] > limit) {
|
||||
for(i = 0 ; i < (pulses->pulse[n]/limit) ; i++) {
|
||||
for(int i = 0 ; i < (pulses->pulse[n]/limit) ; i++) {
|
||||
bitbuffer_add_bit(&bits, 1);
|
||||
}
|
||||
bitbuffer_add_bit(&bits, 0);
|
||||
|
||||
@@ -101,7 +101,7 @@ void samp_grab_write(samp_grab_t *g, unsigned grab_len, unsigned grab_end)
|
||||
double freq_mhz = *g->frequency / 1000000.0;
|
||||
double rate_khz = *g->samp_rate / 1000.0;
|
||||
while (1) {
|
||||
sprintf(f_name, "g%03d_%gM_%gk.%s", g->sg_counter, freq_mhz, rate_khz, format);
|
||||
sprintf(f_name, "g%03u_%gM_%gk.%s", g->sg_counter, freq_mhz, rate_khz, format);
|
||||
g->sg_counter++;
|
||||
if (access(f_name, F_OK) == -1) {
|
||||
break;
|
||||
@@ -132,10 +132,11 @@ void samp_grab_write(samp_grab_t *g, unsigned grab_len, unsigned grab_end)
|
||||
//fprintf(stderr, "signal_bsize = %d - sg_index = %d\n", signal_bsize, g->sg_index);
|
||||
//fprintf(stderr, "start_pos = %d - buffer_size = %d\n", start_pos, g->sg_size);
|
||||
|
||||
fprintf(stderr, "*** Saving signal to file %s (%d samples, %d bytes)\n", f_name, grab_len, signal_bsize);
|
||||
fprintf(stderr, "*** Saving signal to file %s (%u samples, %u bytes)\n", f_name, grab_len, signal_bsize);
|
||||
fp = fopen(f_name, "wb");
|
||||
if (!fp) {
|
||||
fprintf(stderr, "Failed to open %s\n", f_name);
|
||||
return;
|
||||
}
|
||||
|
||||
wlen = signal_bsize;
|
||||
|
||||
Reference in New Issue
Block a user