]> sigrok.org Git - sigrok-cli.git/blobdiff - parsers.c
Show only one output type at the same time.
[sigrok-cli.git] / parsers.c
index 59b1f6823aaa1f52b9243642f2e49c550329de06..e94041764c36bc5ccf7034a7afe6f16b611aefd7 100644 (file)
--- a/parsers.c
+++ b/parsers.c
@@ -1,5 +1,5 @@
 /*
- * This file is part of the sigrok project.
+ * This file is part of the sigrok-cli project.
  *
  * Copyright (C) 2011 Bert Vermeulen <bert@biot.com>
  *
@@ -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);