]> sigrok.org Git - libsigrok.git/blobdiff - src/output/csv.c
output/wav: fixup coding style nits, adjust data types
[libsigrok.git] / src / output / csv.c
index 59dcf08cd8b3357ec8e7a6b2703272365e6c3f46..426cb6ed344ed3040bb7adb9a84f6c3844695ab1 100644 (file)
@@ -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);
@@ -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},