From: Bartosz Golaszewski Date: Thu, 4 Dec 2014 16:27:08 +0000 (+0100) Subject: opt_to_gvar: notify the user in case of invalid values for --config X-Git-Tag: sigrok-cli-0.6.0~46 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=27d310f019395f2e4d5615b3f88b7255655a8039;p=sigrok-cli.git opt_to_gvar: notify the user in case of invalid values for --config sigrok-cli exits silently in many cases where values passed to --config are empty strings or haven't been converted by GLib functions properly. Check for errors and notify the user. Signed-off-by: Bartosz Golaszewski --- diff --git a/session.c b/session.c index b024196..2c2f478 100644 --- a/session.c +++ b/session.c @@ -337,7 +337,7 @@ int opt_to_gvar(char *key, char *value, struct sr_config *src) } src->key = srci->key; - if ((value == NULL) && + if ((value == NULL || strlen(value) == 0) && (srci->datatype != SR_T_BOOL)) { g_critical("Option '%s' needs a value.", (char *)key); return -1; @@ -426,6 +426,9 @@ int opt_to_gvar(char *key, char *value, struct sr_config *src) ret = -1; } + if (ret < 0) + g_critical("Invalid value: '%s' for option '%s'", value, key); + return ret; }