From: Bert Vermeulen Date: Mon, 23 Jul 2012 00:58:56 +0000 (+0200) Subject: sr: fix sr_parse_triggerstring() to use probe numbers starting from 0 X-Git-Tag: dsupstream~765 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=31fc1fbce399ac89d07093886301b9b4971f56f9;p=libsigrok.git sr: fix sr_parse_triggerstring() to use probe numbers starting from 0 --- diff --git a/strutil.c b/strutil.c index 0a03ca75..9ad83d7f 100644 --- a/strutil.c +++ b/strutil.c @@ -188,14 +188,13 @@ SR_API char **sr_parse_triggerstring(const struct sr_dev_inst *sdi, return NULL; } - tokens = g_strsplit(triggerstring, ",", max_probes); - if (sdi->driver->info_get(SR_DI_TRIGGER_TYPES, (const void **)&trigger_types, sdi) != SR_OK) { sr_err("strutil: %s: Device doesn't support any triggers.", __func__); return NULL; } + tokens = g_strsplit(triggerstring, ",", max_probes); for (i = 0; tokens[i]; i++) { if (tokens[i][0] < '0' || tokens[i][0] > '9') { /* Named probe */ @@ -213,7 +212,7 @@ SR_API char **sr_parse_triggerstring(const struct sr_dev_inst *sdi, probenum = strtol(tokens[i], NULL, 10); } - if (probenum < 1 || probenum > max_probes) { + if (probenum < 0 || probenum >= max_probes) { sr_err("strutil: Invalid probe (%d).", probenum); error = TRUE; break; @@ -229,7 +228,7 @@ SR_API char **sr_parse_triggerstring(const struct sr_dev_inst *sdi, } } if (!error) - triggerlist[probenum - 1] = g_strdup(trigger); + triggerlist[probenum] = g_strdup(trigger); } } g_strfreev(tokens);