]> sigrok.org Git - libsigrok.git/commitdiff
input: vcd: register channels when parsing header not when initializing
authorWolfram Sang <redacted>
Sun, 10 Jan 2016 11:08:54 +0000 (12:08 +0100)
committerUwe Hermann <redacted>
Thu, 28 Jan 2016 18:03:53 +0000 (19:03 +0100)
Benefits:

* only channels really used in vcd will be added
* we can give them the proper name found in the vcd file
* less code :)

Signed-off-by: Wolfram Sang <redacted>
src/input/vcd.c

index a9d3c45c1b91c2ba907336f7dea8452290dbe731..214eb83235a43d38e150829f37073dc0c110a1f1 100644 (file)
@@ -233,8 +233,8 @@ static gboolean parse_header(const struct sr_input *in, GString *buf)
                                sr_info("Channel %d is '%s' identified by '%s'.",
                                                inc->channelcount, vcd_ch->name, vcd_ch->identifier);
 
+                               sr_channel_new(in->sdi, inc->channelcount++, SR_CHANNEL_LOGIC, TRUE, vcd_ch->name);
                                inc->channels = g_slist_append(inc->channels, vcd_ch);
-                               inc->channelcount++;
                        }
 
                        g_strfreev(parts);
@@ -479,9 +479,8 @@ static void parse_contents(const struct sr_input *in, char *data)
 
 static int init(struct sr_input *in, GHashTable *options)
 {
-       int num_channels, i;
-       char name[16];
        struct context *inc;
+       int num_channels;
 
        num_channels = g_variant_get_int32(g_hash_table_lookup(options, "numchannels"));
        if (num_channels < 1) {
@@ -504,11 +503,6 @@ static int init(struct sr_input *in, GHashTable *options)
 
        inc->buffer = g_malloc(CHUNKSIZE);
 
-       for (i = 0; i < num_channels; i++) {
-               snprintf(name, 16, "%d", i);
-               sr_channel_new(in->sdi, i, SR_CHANNEL_LOGIC, TRUE, name);
-       }
-
        return SR_OK;
 }