X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Foutput%2Fcsv.c;h=59dcf08cd8b3357ec8e7a6b2703272365e6c3f46;hb=58ffcf97121453fb53e885338e23e54c7ed78659;hp=c39c29a7378fe9cd935fbaff0f35f2255f548f2a;hpb=2ea1fdf12113311cbe1a4316e9e2efe4d8ac40f0;p=libsigrok.git diff --git a/src/output/csv.c b/src/output/csv.c index c39c29a7..59dcf08c 100644 --- a/src/output/csv.c +++ b/src/output/csv.c @@ -260,7 +260,7 @@ static GString *gen_header(const struct sr_output *o, g_string_append_printf(header, "%s Channels (%d/%d):", ctx->comment, ctx->num_analog_channels + ctx->num_logic_channels, num_channels); - for (i = 0, l = o->sdi->channels; l; l = l->next, i++) { + for (l = o->sdi->channels; l; l = l->next) { ch = l->data; if (ch->enabled) g_string_append_printf(header, " %s,", ch->name); @@ -378,11 +378,11 @@ static void process_logic(struct context *ctx, for (j = ch = 0; ch < ctx->num_logic_channels; j++) { if (ctx->channels[j].ch->type == SR_CHANNEL_LOGIC) { - for (i = 0; i <= logic->length - logic->unitsize; i += logic->unitsize) { - sample = logic->data + i; - idx = ctx->channels[ch].ch->index; + for (i = 0; i < num_samples; i++) { + sample = logic->data + i * logic->unitsize; + idx = ctx->channels[j].ch->index; if (ctx->label_do && !ctx->label_names) - ctx->channels[i].label = "logic"; + ctx->channels[j].label = "logic"; ctx->logic_samples[i * ctx->num_logic_channels + ch] = sample[idx / 8] & (1 << (idx % 8)); } ch++; @@ -457,7 +457,7 @@ static void dump_saved_values(struct context *ctx, GString **out) } if (ctx->time) - g_string_append_printf(*out, "%lu%s", + g_string_append_printf(*out, "%" PRIu64 "%s", ctx->sample_time, ctx->value); for (j = 0; j < num_channels; j++) { @@ -578,7 +578,7 @@ static int receive(const struct sr_output *o, break; case SR_DF_FRAME_BEGIN: *out = g_string_new(ctx->frame); - /* And then fall through to... */ + /* Fallthrough */ case SR_DF_END: /* Got to end of frame/session with part of the data. */ if (ctx->channels_seen) @@ -608,6 +608,7 @@ static int cleanup(struct sr_output *o) g_free((gpointer)ctx->frame); g_free((gpointer)ctx->comment); g_free((gpointer)ctx->gnuplot); + g_free((gpointer)ctx->value); g_free(ctx->previous_sample); g_free(ctx->channels); g_free(o->priv);