X-Git-Url: http://sigrok.org/gitweb/?a=blobdiff_plain;f=parsers.c;h=059d33930d6ce373147dce663e8df91171cdb850;hb=2be182e6437fb082aedca653fdc106d702518db0;hp=206e1d639940f6a042ed87b55704f958ab614456;hpb=630293b49d7645f2525ac5addad37c1f9315d2ce;p=sigrok-cli.git diff --git a/parsers.c b/parsers.c index 206e1d6..059d339 100644 --- a/parsers.c +++ b/parsers.c @@ -25,7 +25,7 @@ #include #include "sigrok-cli.h" -struct sr_probe *find_probe(GSList *probelist, const char *probename) +static struct sr_probe *find_probe(GSList *probelist, const char *probename) { struct sr_probe *probe; GSList *l; @@ -73,25 +73,25 @@ GSList *parse_probestring(struct sr_dev_inst *sdi, const char *probestring) /* Need exactly two arguments. */ g_critical("Invalid probe syntax '%s'.", tokens[i]); ret = SR_ERR; - break; + goto range_fail; } b = strtol(range[0], &eptr, 10); if (eptr == range[0] || *eptr != '\0') { g_critical("Invalid probe '%s'.", range[0]); ret = SR_ERR; - break; + goto range_fail; } e = strtol(range[1], NULL, 10); if (eptr == range[1] || *eptr != '\0') { g_critical("Invalid probe '%s'.", range[1]); ret = SR_ERR; - break; + goto range_fail; } if (b < 0 || b >= e) { g_critical("Invalid probe range '%s'.", tokens[i]); ret = SR_ERR; - break; + goto range_fail; } while (b <= e) { @@ -110,6 +110,10 @@ GSList *parse_probestring(struct sr_dev_inst *sdi, const char *probestring) probelist = g_slist_append(probelist, probe); b++; } +range_fail: + if (range) + g_strfreev(range); + if (ret != SR_OK) break; } else { @@ -133,13 +137,11 @@ GSList *parse_probestring(struct sr_dev_inst *sdi, const char *probestring) probe->name = g_strdup(names[1]); } probelist = g_slist_append(probelist, probe); + + if (names) + g_strfreev(names); } } - if (range) - g_strfreev(range); - - if (names) - g_strfreev(names); if (ret != SR_OK) { g_slist_free(probelist); @@ -181,7 +183,7 @@ GHashTable *parse_generic_arg(const char *arg, gboolean sep_first) return hash; } -char *strcanon(const char *str) +static char *strcanon(const char *str) { int p0, p1; char *s;