]> sigrok.org Git - sigrok-cli.git/blobdiff - sigrok-cli.c
Drop unneeded comments.
[sigrok-cli.git] / sigrok-cli.c
index 2f6c59d80b26bb1eb016ea05fd27426f70943320..4af47d2da2a3fe0470fee124af052e62fbcff140 100644 (file)
@@ -821,7 +821,6 @@ static int register_pds(struct sr_dev *dev, const char *pdstring)
        int ret;
        char **pdtokens, **pdtok, *pd_name;
 
-       /* Avoid compiler warnings. */
        (void)dev;
 
        ret = 0;
@@ -1458,7 +1457,6 @@ static void run_session(void)
 static void logger(const gchar *log_domain, GLogLevelFlags log_level,
                   const gchar *message, gpointer cb_data)
 {
-       /* Avoid compiler warnings. */
        (void)log_domain;
        (void)cb_data;
 
@@ -1478,6 +1476,7 @@ int main(int argc, char **argv)
        int ret = 1;
        GOptionContext *context;
        GError *error;
+       struct sr_context *sr_ctx = NULL;
 
        g_log_set_default_handler(logger, NULL);
 
@@ -1487,19 +1486,19 @@ int main(int argc, char **argv)
 
        if (!g_option_context_parse(context, &argc, &argv, &error)) {
                g_critical("%s", error->message);
-               goto done_noexit;
+               goto done;
        }
 
        /* Set the loglevel (amount of messages to output) for libsigrok. */
        if (sr_log_loglevel_set(opt_loglevel) != SR_OK)
-               goto done_noexit;
+               goto done;
 
        /* Set the loglevel (amount of messages to output) for libsigrokdecode. */
        if (srd_log_loglevel_set(opt_loglevel) != SRD_OK)
-               goto done_noexit;
+               goto done;
 
-       if (sr_init() != SR_OK)
-               goto done_noexit;
+       if (sr_init(&sr_ctx) != SR_OK)
+               goto done;
 
        if (opt_pds) {
                if (srd_init(NULL) != SRD_OK)
@@ -1539,9 +1538,9 @@ int main(int argc, char **argv)
        ret = 0;
 
 done:
-       sr_exit();
+       if (sr_ctx)
+               sr_exit(sr_ctx);
 
-done_noexit:
        g_option_context_free(context);
 
        return ret;