]> sigrok.org Git - sigrok-cli.git/blobdiff - parsers.c
Don't use SR_CONF_MAX_UNCOMPRESSED_SAMPLES.
[sigrok-cli.git] / parsers.c
index 206e1d639940f6a042ed87b55704f958ab614456..f587f8d0e9da6701083a16283de0992e64b51c8f 100644 (file)
--- a/parsers.c
+++ b/parsers.c
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include "sigrok-cli.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdint.h>
 #include <string.h>
 #include <glib.h>
-#include <libsigrok/libsigrok.h>
-#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 +72,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 +109,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 +136,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 +182,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;