From e786e625d3e3b63ea5e85b98c9e1f0281abdc2d5 Mon Sep 17 00:00:00 2001 From: Bert Vermeulen Date: Sun, 3 Aug 2014 01:19:55 +0200 Subject: [PATCH] Better output module checking. --- session.c | 3 ++- show.c | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/session.c b/session.c index 46bb4d9..39eb164 100644 --- a/session.c +++ b/session.c @@ -174,7 +174,8 @@ void datafeed_in(const struct sr_dev_inst *sdi, switch (packet->type) { case SR_DF_HEADER: g_debug("cli: Received SR_DF_HEADER."); - o = setup_output_format(sdi); + if (!(o = setup_output_format(sdi))) + g_critical("Failed to initialize output module."); /* Set up backup analog output module. */ oa = sr_output_new(sr_output_find("analog"), NULL, sdi); diff --git a/show.c b/show.c index 817a65f..4c0cd8f 100644 --- a/show.c +++ b/show.c @@ -649,9 +649,10 @@ void show_output(void) const struct sr_output_module *omod; const struct sr_option *opt; GSList *l; - char *s; + char *s, **tok; - if (!(omod = sr_output_find(opt_output_format))) + tok = g_strsplit(opt_output_format, ":", 0); + if (!tok[0] || !(omod = sr_output_find(tok[0]))) g_critical("Output module '%s' not found.", opt_output_format); printf("ID: %s\nName: %s\n", sr_output_id_get(omod), @@ -680,5 +681,6 @@ void show_output(void) } sr_output_options_free(omod); } + g_strfreev(tok); } -- 2.30.2