]> sigrok.org Git - libsigrok.git/commitdiff
output/csv: reduce indentation in process_analog()
authorGerhard Sittig <redacted>
Sun, 4 Mar 2018 16:51:29 +0000 (17:51 +0100)
committerUwe Hermann <redacted>
Mon, 12 Mar 2018 14:55:22 +0000 (15:55 +0100)
Instead of nesting indentation levels upon equality of a value, skip
iterations upon inequality. This reduces indentation, and might improve
readability.

[ Indentation changes, see 'diff -w -b' for the essence. ]

src/output/csv.c

index a5770c6552db964714650a383354ebbeecd6019b..f6502fb8a9b6e6588f669e893e7f686307641e43 100644 (file)
@@ -314,6 +314,7 @@ static void process_analog(struct context *ctx,
        struct sr_analog_meaning *meaning;
        GSList *l;
        float *fdata = NULL;
+       struct sr_channel *ch;
 
        if (!ctx->analog_samples) {
                ctx->analog_samples = g_malloc(analog->num_samples
@@ -334,22 +335,22 @@ static void process_analog(struct context *ctx,
                sr_warn("Problems converting data to floating point values.");
 
        for (i = 0; i < ctx->num_analog_channels + ctx->num_logic_channels; i++) {
-               if (ctx->channels[i].ch->type == SR_CHANNEL_ANALOG) {
-                       sr_dbg("Looking for channel %s",
-                              ctx->channels[i].ch->name);
-                       for (l = meaning->channels, c = 0; l; l = l->next, c++) {
-                               struct sr_channel *ch = l->data;
-                               sr_dbg("Checking %s", ch->name);
-                               if (ctx->channels[i].ch == l->data) {
-                                       if (ctx->label_do && !ctx->label_names) {
-                                               sr_analog_unit_to_string(analog,
-                                                       &ctx->channels[i].label);
-                                       }
-                                       for (j = 0; j < analog->num_samples; j++)
-                                               ctx->analog_samples[j * ctx->num_analog_channels + i] = fdata[j * num_channels + c];
-                                       break;
-                               }
+               if (ctx->channels[i].ch->type != SR_CHANNEL_ANALOG)
+                       continue;
+               sr_dbg("Looking for channel %s",
+                      ctx->channels[i].ch->name);
+               for (l = meaning->channels, c = 0; l; l = l->next, c++) {
+                       ch = l->data;
+                       sr_dbg("Checking %s", ch->name);
+                       if (ctx->channels[i].ch != l->data)
+                               continue;
+                       if (ctx->label_do && !ctx->label_names) {
+                               sr_analog_unit_to_string(analog,
+                                       &ctx->channels[i].label);
                        }
+                       for (j = 0; j < analog->num_samples; j++)
+                               ctx->analog_samples[j * ctx->num_analog_channels + i] = fdata[j * num_channels + c];
+                       break;
                }
        }
        g_free(fdata);