From ab464eb3dc7fc9646592d882ca79aa0a8fa5101b Mon Sep 17 00:00:00 2001 From: Wolfram Sang Date: Sun, 10 Jan 2016 12:08:54 +0100 Subject: [PATCH] input: vcd: register channels when parsing header not when initializing 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 --- src/input/vcd.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/input/vcd.c b/src/input/vcd.c index a9d3c45c..214eb832 100644 --- a/src/input/vcd.c +++ b/src/input/vcd.c @@ -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; }