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 <w...@the-dreams.de>
---
 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 0dd52b1..9f206d4 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;
 }
 
-- 
2.1.4


------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance
APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month
Monitor end-to-end web transactions and take corrective actions now
Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=267308311&iu=/4140
_______________________________________________
sigrok-devel mailing list
sigrok-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sigrok-devel

Reply via email to