Browse Source

Cleanup style minor

Christian W. Zuckschwerdt 3 months ago
parent
commit
739e856a92

+ 2 - 2
src/devices/alecto.c

@@ -88,12 +88,12 @@ int alecto_checksum(r_device *decoder, bitrow_t *bb)
     /* Quit if checksum does not work out */
     if (csum != (bb[1][4] >> 4) || csum2 != (bb[5][4] >> 4)) {
         //fprintf(stderr, "\nAlectoV1 CRC error");
-        if(decoder->verbose) {
+        if (decoder->verbose) {
             fprintf(stderr, "AlectoV1 Checksum/Parity error\n");
         }
         return 0;
     } //Invalid checksum
-    if (decoder->verbose){
+    if (decoder->verbose) {
         fprintf(stderr, "Checksum      = %01x (calculated %01x)\n", bb[1][4] >> 4, csum);
     }
 

+ 37 - 37
src/devices/cardin.c

@@ -26,7 +26,7 @@ static int cardin_callback(r_device *decoder, bitbuffer_t *bitbuffer) {
     data_t *data;
 
     // validate message as we can
-    if((bb[0][2] & 48) == 0 && bitbuffer->bits_per_row[0] == 24 && (
+    if ((bb[0][2] & 48) == 0 && bitbuffer->bits_per_row[0] == 24 && (
                 (bb[0][2] & 0x0f) == 3 ||
                 (bb[0][2] & 0x0f) == 9 ||
                 (bb[0][2] & 0x0f) == 12 ||
@@ -49,58 +49,58 @@ static int cardin_callback(r_device *decoder, bitbuffer_t *bitbuffer) {
 */
 
         // Dip 1
-        if(bb[0][0] & 8) {
-            dip[0]='o';
-            if(bb[0][1] & 8)
-                dip[0]='+';
+        if (bb[0][0] & 8) {
+            dip[0] = 'o';
+            if (bb[0][1] & 8)
+                dip[0] = '+';
         }
         // Dip 2
-        if(bb[0][0] & 16) {
-            dip[1]='o';
-            if(bb[0][1] & 16)
-                dip[1]='+';
+        if (bb[0][0] & 16) {
+            dip[1] = 'o';
+            if (bb[0][1] & 16)
+                dip[1] = '+';
         }
         // Dip 3
-        if(bb[0][0] & 32) {
-            dip[2]='o';
-            if(bb[0][1] & 32)
-                dip[2]='+';
+        if (bb[0][0] & 32) {
+            dip[2] = 'o';
+            if (bb[0][1] & 32)
+                dip[2] = '+';
         }
         // Dip 4
-        if(bb[0][0] & 64) {
-            dip[3]='o';
-            if(bb[0][1] & 64)
-                dip[3]='+';
+        if (bb[0][0] & 64) {
+            dip[3] = 'o';
+            if (bb[0][1] & 64)
+                dip[3] = '+';
         }
         // Dip 5
-        if(bb[0][0] & 128) {
-            dip[4]='o';
-            if(bb[0][1] & 128)
-                dip[4]='+';
+        if (bb[0][0] & 128) {
+            dip[4] = 'o';
+            if (bb[0][1] & 128)
+                dip[4] = '+';
         }
         // Dip 6
-        if(bb[0][2] & 128) {
-            dip[5]='o';
-            if(bb[0][2] & 64)
-                dip[5]='+';
+        if (bb[0][2] & 128) {
+            dip[5] = 'o';
+            if (bb[0][2] & 64)
+                dip[5] = '+';
         }
         // Dip 7
-        if(bb[0][0] & 1) {
-            dip[6]='o';
-            if(bb[0][1] & 1)
-                dip[6]='+';
+        if (bb[0][0] & 1) {
+            dip[6] = 'o';
+            if (bb[0][1] & 1)
+                dip[6] = '+';
         }
         // Dip 8
-        if(bb[0][0] & 2) {
-            dip[7]='o';
-            if(bb[0][1] & 2)
-                dip[7]='+';
+        if (bb[0][0] & 2) {
+            dip[7] = 'o';
+            if (bb[0][1] & 2)
+                dip[7] = '+';
         }
         // Dip 9
-        if(bb[0][0] & 4) {
-            dip[8]='o';
-            if(bb[0][1] & 4)
-                dip[8]='+';
+        if (bb[0][0] & 4) {
+            dip[8] = 'o';
+            if (bb[0][1] & 4)
+                dip[8] = '+';
         }
 
         data = data_make(

+ 1 - 1
src/devices/ht680.c

@@ -37,7 +37,7 @@ static int ht680_callback(r_device *decoder, bitbuffer_t *bitbuffer)
         char *p = tristate;
         for (int byte = 0; byte < 5; byte++) {
             for (int bit = 7; bit > 0; bit -= 2) {
-                switch ((b[byte] >> (bit-1)) & 0x03){
+                switch ((b[byte] >> (bit-1)) & 0x03) {
                     case 0x00: *p++ = '0'; break;
                     case 0x01: *p++ = 'X'; break; // Invalid code 01
                     case 0x02: *p++ = 'Z'; break; // Floating state Z is 10

+ 1 - 1
src/devices/ibis_beacon.c

@@ -28,7 +28,7 @@ static int ibis_beacon_callback(r_device *decoder, bitbuffer_t *bitbuffer) {
     char code_str[63];
 
     // 224 bits data + 12 bits preamble
-    if(bitbuffer->num_rows != 1 || bitbuffer->bits_per_row[0] < 232 || bitbuffer->bits_per_row[0] > 250) {
+    if (bitbuffer->num_rows != 1 || bitbuffer->bits_per_row[0] < 232 || bitbuffer->bits_per_row[0] > 250) {
         return 0; // Unrecognized data
     }
 

+ 2 - 2
src/devices/ikea_sparsnas.c

@@ -195,7 +195,7 @@ static int ikea_sparsnas_callback(r_device *decoder, bitbuffer_t *bitbuffer)
     for (size_t i = 0; i < 5; i++)
         decrypted[i] = buffer[i];
 
-    for(size_t i = 0; i < 13; i++)
+    for (size_t i = 0; i < 13; i++)
         decrypted[5 + i] = buffer[5 + i] ^ key[i % 5];
 
     // Additional integrity checks
@@ -250,7 +250,7 @@ static int ikea_sparsnas_callback(r_device *decoder, bitbuffer_t *bitbuffer)
     float watt = effect * 24.;
     uint8_t mode = decrypted[4]^0x0f;
 
-    if(mode == 1) {     //Note that mode cycles between 0-3 when you first put in the batteries in
+    if (mode == 1) {     //Note that mode cycles between 0-3 when you first put in the batteries in
       watt = ((3600000.0 / ikea_sparsnas_pulses_per_kwh) * 1024.0) / effect;
     } else if (mode == 0 ) { // special mode for low power usage
       watt = effect * 0.24 / ikea_sparsnas_pulses_per_kwh;

+ 3 - 3
src/devices/lightwave_rf.c

@@ -82,12 +82,12 @@ static int lightwave_rf_callback(r_device *decoder, bitbuffer_t *bitbuffer)
     // Strip delimiter bits
     // row_in = 1, row_out = 2
     bitbuffer_add_row(bitbuffer);
-    for(unsigned n=0; n<10; ++n) { // We have 10 bytes
+    for (unsigned n = 0; n < 10; ++n) { // We have 10 bytes
         delimiter_bit = bitrow_get_bit(bb[1], bit_idx++);
         if (delimiter_bit == 0)
             return 0; // Decode error
 
-        for(unsigned m=0; m<8; ++m) {
+        for (unsigned m = 0; m < 8; ++m) {
             bitbuffer_add_bit(bitbuffer, bitrow_get_bit(bb[1], bit_idx++));
         }
     }
@@ -96,7 +96,7 @@ static int lightwave_rf_callback(r_device *decoder, bitbuffer_t *bitbuffer)
     // Decode bytes to nibbles
     // row_in = 2, row_out = 3
     bitbuffer_add_row(bitbuffer);
-    for(unsigned n=0; n<10; ++n) { // We have 10 bytes/nibbles
+    for (unsigned n = 0; n < 10; ++n) { // We have 10 bytes/nibbles
         int nibble = lightwave_rf_nibble_from_byte(bb[2][n]);
         if (nibble < 0) {
             if (decoder->verbose) {

+ 5 - 5
src/devices/m_bus.c

@@ -289,7 +289,7 @@ static int m_bus_mode_c_t_callback(r_device *decoder, bitbuffer_t *bitbuffer) {
             data_in.length = (bitbuffer->bits_per_row[0]-bit_offset)/8;
             bitbuffer_extract_bytes(bitbuffer, 0, bit_offset, data_in.data, data_in.length*8);
             // Decode
-            if(!m_bus_decode_format_a(decoder, &data_in, &data_out, &block1))    return 0;
+            if (!m_bus_decode_format_a(decoder, &data_in, &data_out, &block1))    return 0;
         } // Format A
         // Format B
         else if (next_byte == 0x3D) {
@@ -298,7 +298,7 @@ static int m_bus_mode_c_t_callback(r_device *decoder, bitbuffer_t *bitbuffer) {
             data_in.length = (bitbuffer->bits_per_row[0]-bit_offset)/8;
             bitbuffer_extract_bytes(bitbuffer, 0, bit_offset, data_in.data, data_in.length*8);
             // Decode
-            if(!m_bus_decode_format_b(decoder, &data_in, &data_out, &block1))    return 0;
+            if (!m_bus_decode_format_b(decoder, &data_in, &data_out, &block1))    return 0;
         }   // Format B
         // Unknown Format
         else {
@@ -318,12 +318,12 @@ static int m_bus_mode_c_t_callback(r_device *decoder, bitbuffer_t *bitbuffer) {
         // 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(m_bus_decode_3of6_buffer(bitbuffer->bb[0], bit_offset, data_in.data, data_in.length) < 0) {
+        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;
         }
         // Decode
-        if(!m_bus_decode_format_a(decoder, &data_in, &data_out, &block1))    return 0;
+        if (!m_bus_decode_format_a(decoder, &data_in, &data_out, &block1))    return 0;
     }   // Mode T
 
     m_bus_output_data(decoder, &data_out, &block1, mode);
@@ -356,7 +356,7 @@ static int m_bus_mode_r_callback(r_device *decoder, bitbuffer_t *bitbuffer) {
     data_in.length = (bitbuffer->bits_per_row[0]-bit_offset)/8;
     bitbuffer_extract_bytes(bitbuffer, 0, bit_offset, data_in.data, data_in.length*8);
     // Decode
-    if(!m_bus_decode_format_a(decoder, &data_in, &data_out, &block1))    return 0;
+    if (!m_bus_decode_format_a(decoder, &data_in, &data_out, &block1))    return 0;
 
     m_bus_output_data(decoder, &data_out, &block1, "R");
     return 1;

+ 3 - 3
src/devices/maverick_et73x.c

@@ -38,15 +38,15 @@ static int maverick_et73x_callback(r_device *decoder, bitbuffer_t *bitbuffer)
     data_t *data;
     bitbuffer_t mc = {0};
 
-    if(bitbuffer->num_rows != 1)
+    if (bitbuffer->num_rows != 1)
         return 0;
 
     //check correct data length
-    if(bitbuffer->bits_per_row[0] != 104) // 104 raw half-bits, 52 bits payload
+    if (bitbuffer->bits_per_row[0] != 104) // 104 raw half-bits, 52 bits payload
         return 0;
 
     //check for correct preamble (0x55666a)
-    if((bitbuffer->bb[0][0] != 0x55 ) || bitbuffer->bb[0][1] != 0x66 || bitbuffer->bb[0][2] != 0x6a)
+    if ((bitbuffer->bb[0][0] != 0x55 ) || bitbuffer->bb[0][1] != 0x66 || bitbuffer->bb[0][2] != 0x6a)
         return 0; // preamble missing
 
     // decode the inner manchester encoding

+ 1 - 1
src/devices/mebus.c

@@ -11,7 +11,7 @@ static int mebus433_callback(r_device *decoder, bitbuffer_t *bitbuffer) {
     uint8_t unknown2;
     data_t *data;
 
-    if (bb[0][0] == 0 && bb[1][4] !=0 && (bb[1][0] & 0x60) && bb[1][3]==bb[5][3] && bb[1][4] == bb[12][4]){
+    if (bb[0][0] == 0 && bb[1][4] !=0 && (bb[1][0] & 0x60) && bb[1][3]==bb[5][3] && bb[1][4] == bb[12][4]) {
 
         address = bb[1][0] & 0x1f;
 

+ 1 - 1
src/devices/oregon_scientific_sl109h.c

@@ -34,7 +34,7 @@ static int oregon_scientific_sl109h_callback(r_device *decoder, bitbuffer_t *bit
     int status;
     uint8_t id;
 
-    for(int row_index = 0; row_index < bitbuffer->num_rows; row_index++) {
+    for (int row_index = 0; row_index < bitbuffer->num_rows; row_index++) {
         if (bitbuffer->bits_per_row[row_index] != 38) // expected length is 38 bit
             continue;
 

+ 3 - 2
src/devices/rftech.c

@@ -23,7 +23,7 @@ static int rftech_callback(r_device *decoder, bitbuffer_t *bitbuffer) {
 
     r = bitbuffer_find_repeated_row(bitbuffer, 3, 24);
 
-    if(r < 0 || bitbuffer->bits_per_row[r] != 24)
+    if (r < 0 || bitbuffer->bits_per_row[r] != 24)
         return 0;
 
     /* Example of message:
@@ -47,7 +47,8 @@ static int rftech_callback(r_device *decoder, bitbuffer_t *bitbuffer) {
      */
     sensor_id = bb[r][0];
     value = (bb[r][1] & 0x7f) + (bb[r][2] & 0x0f) / 10.0;
-    if(bb[r][1] & 0x80) value = -value;
+    if (bb[r][1] & 0x80)
+        value = -value;
 
     battery = (bb[r][2] & 0x80) == 0x80;
     button = (bb[r][2] & 0x60) != 0;

+ 2 - 2
src/devices/tfa_pool_thermometer.c

@@ -29,8 +29,8 @@ static int tfa_pool_thermometer_callback(r_device *decoder, bitbuffer_t *bitbuff
     int temp_raw;
     float temp_f;
 
-    for(i=1;i<8;i++){
-        if(bitbuffer->bits_per_row[i]!=28){
+    for (i = 1; i < 8; i++) {
+        if (bitbuffer->bits_per_row[i] != 28) {
             /*10 24 bits frame*/
             return 0;
         }

+ 1 - 1
src/devices/thermopro_tp11.c

@@ -30,7 +30,7 @@ static int valid(unsigned data, unsigned check) {
         0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x51, 0xa2,
         0x15, 0x2a, 0x54, 0xa8, 0x00, 0x00, 0xed, 0x00,
         0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00, 0x00};
-    for(int i=0;i<24;i++) {
+    for (int i = 0; i < 24; i++) {
         if (data & (1 << i)) check ^= table[i];
     }
     return check == 0;

+ 1 - 1
src/devices/vaillant_vrt340f.c

@@ -134,7 +134,7 @@ vaillant_vrt340_callback(r_device *decoder, bitbuffer_t *bitbuffer)
     //bitrow_print(bb[0], bitcount);
 
     // A correct message has 128 bits plus potentially two extra bits for clock sync at the end
-    if(!(128 <= bitcount && bitcount <= 131) && !(168 <= bitcount && bitcount <= 171))
+    if (!(128 <= bitcount && bitcount <= 131) && !(168 <= bitcount && bitcount <= 171))
         return 0;
 
     // "Normal package":

+ 2 - 2
src/pulse_detect_fsk.c

@@ -172,8 +172,8 @@ void pulse_FSK_wrap_up(pulse_data_t *fsk_pulses, pulse_FSK_state_t *s)
 /// @param fm_n: One single sample of FM data
 /// @param *fsk_pulses: Will return a pulse_data_t structure for FSK demodulated data
 /// @param *s: Internal state
-void pulse_FSK_detect_mm(int16_t fm_n, pulse_data_t *fsk_pulses, pulse_FSK_state_t *s){
-
+void pulse_FSK_detect_mm(int16_t fm_n, pulse_data_t *fsk_pulses, pulse_FSK_state_t *s)
+{
     int16_t mid = 0;
 
     /* Skip a few samples in the beginning, need for framing

+ 1 - 1
src/rtl_433.c

@@ -1399,7 +1399,7 @@ int main(int argc, char **argv) {
                 if (demod->load_info.format == CF32_IQ) {
                     n_read = fread(test_mode_float_buf, sizeof(float), DEFAULT_BUF_LENGTH / 2, in_file);
                     // clamp float to [-1,1] and scale to Q0.15
-                    for(unsigned long n = 0; n < n_read; n++) {
+                    for (unsigned long n = 0; n < n_read; n++) {
                         int s_tmp = test_mode_float_buf[n] * INT16_MAX;
                         if (s_tmp < -INT16_MAX)
                             s_tmp = -INT16_MAX;

+ 2 - 2
tests/style-check.c

@@ -28,8 +28,8 @@ static int style_check(char *path)
 
     FILE *fp = fopen(path, "r");
     assert(fp);
-    if(!fp)
-      exit(EXIT_FAILURE);
+    if (!fp)
+        exit(EXIT_FAILURE);
 
     int read_errors = 0;
     int long_errors = 0;