X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=src%2Foutput%2Fcsv.c;h=426cb6ed344ed3040bb7adb9a84f6c3844695ab1;hb=aa0979482f6e7c269609bb2c22d7d75a2845ac75;hp=2be4db372f67101ae3241ede4d7d4c2e9ba3b27c;hpb=d05b1a860606e078eed77722d8a0c62850ee39af;p=libsigrok.git diff --git a/src/output/csv.c b/src/output/csv.c index 2be4db37..426cb6ed 100644 --- a/src/output/csv.c +++ b/src/output/csv.c @@ -216,7 +216,7 @@ static GString *gen_header(const struct sr_output *o, struct sr_channel *ch; GVariant *gvar; GString *header; - GSList *l; + GSList *channels, *l; unsigned int num_channels, i; uint64_t samplerate = 0, sr; char *samplerate_s; @@ -256,18 +256,20 @@ static GString *gen_header(const struct sr_output *o, ctx->title, ctime(&hdr->starttime.tv_sec)); /* Columns / channels */ - num_channels = g_slist_length(o->sdi->channels); + channels = o->sdi ? o->sdi->channels : NULL; + num_channels = g_slist_length(channels); g_string_append_printf(header, "%s Channels (%d/%d):", ctx->comment, ctx->num_analog_channels + ctx->num_logic_channels, num_channels); - for (l = o->sdi->channels; l; l = l->next) { + for (l = channels; l; l = l->next) { ch = l->data; if (ch->enabled) g_string_append_printf(header, " %s,", ch->name); } - if (o->sdi->channels) + if (channels) { /* Drop last separator. */ g_string_truncate(header, header->len - 1); + } g_string_append_printf(header, "\n"); if (samplerate != 0) { samplerate_s = sr_samplerate_string(samplerate); @@ -578,7 +580,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) @@ -623,7 +625,7 @@ static struct sr_option options[] = { {"scale", "scale", "Scale gnuplot graphs", NULL, NULL}, {"value", "Value separator", "Character to print between values", NULL, NULL}, {"record", "Record separator", "String to print between records", NULL, NULL}, - {"frame", "Frame seperator", "String to print between frames", NULL, NULL}, + {"frame", "Frame separator", "String to print between frames", NULL, NULL}, {"comment", "Comment start string", "String used at start of comment lines", NULL, NULL}, {"header", "Output header", "Output header comment with capture metdata", NULL, NULL}, {"label", "Label values", "Type of column labels", NULL, NULL},