]> sigrok.org Git - libsigrok.git/commitdiff
Consistency and whitespace fixes for switch statements.
authorUwe Hermann <redacted>
Fri, 20 Mar 2015 19:14:39 +0000 (20:14 +0100)
committerUwe Hermann <redacted>
Sun, 22 Mar 2015 01:15:30 +0000 (02:15 +0100)
src/hardware/colead-slm/protocol.c
src/hardware/demo/demo.c
src/hardware/fx2lafw/api.c
src/hardware/gmc-mh-1x-2x/protocol.c
src/hardware/hantek-dso/api.c
src/hardware/motech-lps-30x/protocol.c
src/hardware/sysclk-lwla/protocol.c

index 182c77bb4b4e7a98a20fe5fcee6a56e2226c2a4a..d68e8f50b1c6dd061a1d1cd714039a4ffbe9b38d 100644 (file)
@@ -92,80 +92,79 @@ static void process_packet(const struct sr_dev_inst *sdi)
         * weighting. */
        mode = devc->buf[2] & 0x0f;
        switch (mode) {
-               case 0x0:
-                       analog.mqflags |= SR_MQFLAG_SPL_FREQ_WEIGHT_A \
-                                       | SR_MQFLAG_SPL_TIME_WEIGHT_F;
-                       break;
-               case 0x1:
-                       analog.mqflags |= SR_MQFLAG_SPL_FREQ_WEIGHT_A \
-                                       | SR_MQFLAG_SPL_TIME_WEIGHT_S;
-                       break;
-               case 0x2:
-                       analog.mqflags |= SR_MQFLAG_SPL_FREQ_WEIGHT_C \
-                                       | SR_MQFLAG_SPL_TIME_WEIGHT_F;
-                       break;
-               case 0x3:
-                       analog.mqflags |= SR_MQFLAG_SPL_FREQ_WEIGHT_C \
-                                       | SR_MQFLAG_SPL_TIME_WEIGHT_S;
-                       break;
-               case 0x4:
-                       analog.mqflags |= SR_MQFLAG_SPL_FREQ_WEIGHT_FLAT \
-                                       | SR_MQFLAG_SPL_TIME_WEIGHT_F;
-                       break;
-               case 0x5:
-                       analog.mqflags |= SR_MQFLAG_SPL_FREQ_WEIGHT_FLAT \
-                                       | SR_MQFLAG_SPL_TIME_WEIGHT_S;
-                       break;
-               case 0x6:
-                       analog.mqflags |= SR_MQFLAG_SPL_PCT_OVER_ALARM \
-                                       | SR_MQFLAG_SPL_FREQ_WEIGHT_A \
-                                       | SR_MQFLAG_SPL_TIME_WEIGHT_F;
-                       break;
-               case 0x7:
-                       analog.mqflags |= SR_MQFLAG_SPL_PCT_OVER_ALARM \
-                                       | SR_MQFLAG_SPL_FREQ_WEIGHT_A \
-                                       | SR_MQFLAG_SPL_TIME_WEIGHT_S;
-                       break;
-               case 0x8:
-                       /* 10-second mean, but we don't have MQ flags to express it. */
-                       analog.mqflags |= SR_MQFLAG_SPL_LAT \
-                                       | SR_MQFLAG_SPL_FREQ_WEIGHT_A \
-                                       | SR_MQFLAG_SPL_TIME_WEIGHT_F;
-                       break;
-               case 0x9:
-                       /* Mean over a time period between 11 seconds and 24 hours.
-                        * Which is so silly that there's no point in expressing
-                        * either this or the previous case.  */
-                       analog.mqflags |= SR_MQFLAG_SPL_LAT \
-                                       | SR_MQFLAG_SPL_FREQ_WEIGHT_A \
-                                       | SR_MQFLAG_SPL_TIME_WEIGHT_F;
-                       break;
-               case 0xa:
-                       /* 10-second mean. */
-                       analog.mqflags |= SR_MQFLAG_SPL_LAT \
-                                       | SR_MQFLAG_SPL_FREQ_WEIGHT_A \
-                                       | SR_MQFLAG_SPL_TIME_WEIGHT_S;
-                       break;
-               case 0xb:
-                       /* Mean over a time period between 11 seconds and 24 hours. */
-                       analog.mqflags |= SR_MQFLAG_SPL_LAT \
-                                       | SR_MQFLAG_SPL_FREQ_WEIGHT_A \
-                                       | SR_MQFLAG_SPL_TIME_WEIGHT_S;
-                       break;
-               case 0xc:
-                       /* Internal calibration on 1kHz sine at 94dB, not useful
-                        * to anything but the device. */
-                       analog.mqflags |= SR_MQFLAG_SPL_FREQ_WEIGHT_FLAT;
-                       break;
-               case 0xd:
-                       /* Internal calibration on 1kHz sine at 94dB, not useful
-                        * to anything but the device. */
-                       analog.mqflags |= SR_MQFLAG_SPL_FREQ_WEIGHT_FLAT;
-                       break;
-               default:
-                       sr_dbg("unknown configuration 0x%.2x", mode);
-                       return;
-                       break;
+       case 0x0:
+               analog.mqflags |= SR_MQFLAG_SPL_FREQ_WEIGHT_A \
+                               | SR_MQFLAG_SPL_TIME_WEIGHT_F;
+               break;
+       case 0x1:
+               analog.mqflags |= SR_MQFLAG_SPL_FREQ_WEIGHT_A \
+                               | SR_MQFLAG_SPL_TIME_WEIGHT_S;
+               break;
+       case 0x2:
+               analog.mqflags |= SR_MQFLAG_SPL_FREQ_WEIGHT_C \
+                               | SR_MQFLAG_SPL_TIME_WEIGHT_F;
+               break;
+       case 0x3:
+               analog.mqflags |= SR_MQFLAG_SPL_FREQ_WEIGHT_C \
+                               | SR_MQFLAG_SPL_TIME_WEIGHT_S;
+               break;
+       case 0x4:
+               analog.mqflags |= SR_MQFLAG_SPL_FREQ_WEIGHT_FLAT \
+                               | SR_MQFLAG_SPL_TIME_WEIGHT_F;
+               break;
+       case 0x5:
+               analog.mqflags |= SR_MQFLAG_SPL_FREQ_WEIGHT_FLAT \
+                               | SR_MQFLAG_SPL_TIME_WEIGHT_S;
+               break;
+       case 0x6:
+               analog.mqflags |= SR_MQFLAG_SPL_PCT_OVER_ALARM \
+                               | SR_MQFLAG_SPL_FREQ_WEIGHT_A \
+                               | SR_MQFLAG_SPL_TIME_WEIGHT_F;
+               break;
+       case 0x7:
+               analog.mqflags |= SR_MQFLAG_SPL_PCT_OVER_ALARM \
+                               | SR_MQFLAG_SPL_FREQ_WEIGHT_A \
+                               | SR_MQFLAG_SPL_TIME_WEIGHT_S;
+               break;
+       case 0x8:
+               /* 10-second mean, but we don't have MQ flags to express it. */
+               analog.mqflags |= SR_MQFLAG_SPL_LAT \
+                               | SR_MQFLAG_SPL_FREQ_WEIGHT_A \
+                               | SR_MQFLAG_SPL_TIME_WEIGHT_F;
+               break;
+       case 0x9:
+               /* Mean over a time period between 11 seconds and 24 hours.
+                * Which is so silly that there's no point in expressing
+                * either this or the previous case.  */
+               analog.mqflags |= SR_MQFLAG_SPL_LAT \
+                               | SR_MQFLAG_SPL_FREQ_WEIGHT_A \
+                               | SR_MQFLAG_SPL_TIME_WEIGHT_F;
+               break;
+       case 0xa:
+               /* 10-second mean. */
+               analog.mqflags |= SR_MQFLAG_SPL_LAT \
+                               | SR_MQFLAG_SPL_FREQ_WEIGHT_A \
+                               | SR_MQFLAG_SPL_TIME_WEIGHT_S;
+               break;
+       case 0xb:
+               /* Mean over a time period between 11 seconds and 24 hours. */
+               analog.mqflags |= SR_MQFLAG_SPL_LAT \
+                               | SR_MQFLAG_SPL_FREQ_WEIGHT_A \
+                               | SR_MQFLAG_SPL_TIME_WEIGHT_S;
+               break;
+       case 0xc:
+               /* Internal calibration on 1kHz sine at 94dB, not useful
+                * to anything but the device. */
+               analog.mqflags |= SR_MQFLAG_SPL_FREQ_WEIGHT_FLAT;
+               break;
+       case 0xd:
+               /* Internal calibration on 1kHz sine at 94dB, not useful
+                * to anything but the device. */
+               analog.mqflags |= SR_MQFLAG_SPL_FREQ_WEIGHT_FLAT;
+               break;
+       default:
+               sr_dbg("unknown configuration 0x%.2x", mode);
+               return;
        }
 
        packet.type = SR_DF_ANALOG;
index a3deecc3b68029d81cb0577d80e2cadc4cd57d21..b26b26050f5a368d1ee3801f5f95f7cf530a2d8c 100644 (file)
@@ -212,7 +212,6 @@ static void generate_analog_pattern(struct analog_gen *ag, uint64_t sample_rate)
                }
                ag->num_samples = last_end;
                break;
-
        case PATTERN_SINE:
                frequency = (double) sample_rate / ANALOG_SAMPLES_PER_PERIOD;
 
@@ -231,7 +230,6 @@ static void generate_analog_pattern(struct analog_gen *ag, uint64_t sample_rate)
 
                ag->num_samples = num_samples;
                break;
-
        case PATTERN_TRIANGLE:
                frequency = (double) sample_rate / ANALOG_SAMPLES_PER_PERIOD;
 
@@ -246,7 +244,6 @@ static void generate_analog_pattern(struct analog_gen *ag, uint64_t sample_rate)
 
                ag->num_samples = num_samples;
                break;
-
        case PATTERN_SAWTOOTH:
                frequency = (double) sample_rate / ANALOG_SAMPLES_PER_PERIOD;
 
index 5e1f66432298363178399e9031a940beb3ed4a83..6fd89795624f3a79a1f1e95e74c810cdebf2cb8a 100644 (file)
@@ -518,30 +518,30 @@ static int config_set(uint32_t key, GVariant *data, const struct sr_dev_inst *sd
        ret = SR_OK;
 
        switch (key) {
-               case SR_CONF_SAMPLERATE:
-                       arg = g_variant_get_uint64(data);
-                       for (i = 0; i < ARRAY_SIZE(samplerates); i++) {
-                               if (samplerates[i] == arg) {
-                                       devc->cur_samplerate = arg;
-                                       break;
-                               }
+       case SR_CONF_SAMPLERATE:
+               arg = g_variant_get_uint64(data);
+               for (i = 0; i < ARRAY_SIZE(samplerates); i++) {
+                       if (samplerates[i] == arg) {
+                               devc->cur_samplerate = arg;
+                               break;
                        }
-                       if (i == ARRAY_SIZE(samplerates))
-                               ret = SR_ERR_ARG;
-                       break;
-               case SR_CONF_LIMIT_SAMPLES:
-                       devc->limit_samples = g_variant_get_uint64(data);
-                       break;
-               case SR_CONF_CAPTURE_RATIO:
-                       devc->capture_ratio = g_variant_get_uint64(data);
-                       if (devc->capture_ratio > 100) {
-                               devc->capture_ratio = 0;
-                               ret = SR_ERR;
-                       } else
-                               ret = SR_OK;
-                       break;
-               default:
-                       ret = SR_ERR_NA;
+               }
+               if (i == ARRAY_SIZE(samplerates))
+                       ret = SR_ERR_ARG;
+               break;
+       case SR_CONF_LIMIT_SAMPLES:
+               devc->limit_samples = g_variant_get_uint64(data);
+               break;
+       case SR_CONF_CAPTURE_RATIO:
+               devc->capture_ratio = g_variant_get_uint64(data);
+               if (devc->capture_ratio > 100) {
+                       devc->capture_ratio = 0;
+                       ret = SR_ERR;
+               } else
+                       ret = SR_OK;
+               break;
+       default:
+               ret = SR_ERR_NA;
        }
 
        return ret;
index e7d7fc8852c559afb00712ce16b5cc137bcbc34f..6f96d504601c1a65f227b7d63853997dbba40b46 100644 (file)
@@ -568,22 +568,27 @@ static void decode_rs_2x_TR2(uint8_t rs, struct dev_context *devc)
        case SR_MQ_CURRENT:
                if (devc->scale1000 == -1) /* mA */
                        switch (range) {
-                       case 0: case 1: /* 100, 300 µA */
+                       case 0:
+                       case 1: /* 100, 300 µA */
                                devc->scale *= pow(10.0, -6);
                                break;
-                       case 2: case 3: /* 1, 3 mA */
+                       case 2:
+                       case 3: /* 1, 3 mA */
                                devc->scale *= pow(10.0, -5);
                                break;
-                       case 4: case 5: /* 10, 30 mA */
+                       case 4:
+                       case 5: /* 10, 30 mA */
                                devc->scale *= pow(10.0, -4);
                                break;
-                       case 6: case 7: /* 100, 300 mA */
+                       case 6:
+                       case 7: /* 100, 300 mA */
                                devc->scale *= pow(10.0, -3);
                                break;
                        }
                else /* A */
                        switch (range) {
-                       case 0: case 1: /* 1, 3 A */
+                       case 0:
+                       case 1: /* 1, 3 A */
                                devc->scale *= pow(10.0, -5);
                                break;
                        case 2: /* 10 A */
index 7f90b834e2eeca3115646eafad33618572b14982..4e3c6886ad9e8216d998f4d8c7e1b10e8e99739f 100644 (file)
@@ -649,7 +649,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
                return SR_ERR_ARG;
 
        if (!cg) {
-       switch (key) {
+               switch (key) {
                case SR_CONF_DEVICE_OPTIONS:
                        *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
                                        devopts, ARRAY_SIZE(devopts), sizeof(uint32_t));
@@ -683,7 +683,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst *
                        return SR_ERR_NA;
                }
        } else {
-       switch (key) {
+               switch (key) {
                case SR_CONF_DEVICE_OPTIONS:
                        *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
                                        devopts_cg, ARRAY_SIZE(devopts_cg), sizeof(uint32_t));
index 86959ba5c3a71c1ac08241665130d7d080423bd4..c8ac58ac82d1885228e6cf6f90f1c32298059912 100644 (file)
@@ -77,7 +77,10 @@ static void process_line(struct sr_dev_inst *sdi)
        case 1: /* Waiting for data reply to request */
                /* Convert numbers */
                switch (devc->acq_req) {
-               case AQ_U1:  case AQ_U2:  case AQ_I1:  case AQ_I2:
+               case AQ_U1:
+               case AQ_U2:
+               case AQ_I1:
+               case AQ_I2:
                        if (sr_atod(devc->buf, &dbl) != SR_OK) {
                                sr_err("Failed to convert '%s' to double, errno=%d %s",
                                        devc->buf, errno, strerror(errno));
index ce922374e845b6f5d419c7c1b4cd1f37f77c3d84..91cb32313a1bacfadb393eddefe8f42a5e4132aa 100644 (file)
@@ -107,8 +107,12 @@ static int capture_setup(const struct sr_dev_inst *sdi)
        /* Set bits to select external TRG input edge. */
        if (devc->cfg_trigger_source == TRIGGER_EXT_TRG)
                switch (devc->cfg_trigger_slope) {
-               case EDGE_POSITIVE: trigger_mask |= (uint64_t)1 << 35; break; 
-               case EDGE_NEGATIVE: trigger_mask |= (uint64_t)1 << 34; break; 
+               case EDGE_POSITIVE:
+                       trigger_mask |= (uint64_t)1 << 35;
+                       break; 
+               case EDGE_NEGATIVE:
+                       trigger_mask |= (uint64_t)1 << 34;
+                       break; 
                }
 
        command[19] = LWLA_WORD_0(trigger_mask);