Commit d232b261 authored by Christian Kellner's avatar Christian Kellner

boltclt: config: re-factor 'action' dispatching

The current code makes sure that 'action' is either _GET or _SET,
and thus _UNKNOWN was redundant and the dispatching code for it
was logically dead (CID 341492). Remove the _UNKNOWN enum value
completely and don't initialize 'action' and thus rely in the
compiler to check 'action' is properly initialized.
parent 7a73b440
......@@ -247,7 +247,6 @@ parse_option (const char *opt_str,
/* */
typedef enum {
ACTION_UNKNOWN = 0,
ACTION_GET = 1,
ACTION_SET = 2,
} Action;
......@@ -276,7 +275,7 @@ config (BoltClient *client, int argc, char **argv)
gboolean describe = FALSE;
gboolean ok = FALSE;
GParamSpec *prop;
Action action = ACTION_UNKNOWN;
Action action;
GType type = 0;
int res = EXIT_FAILURE;
GOptionEntry options[] = {
......@@ -340,20 +339,11 @@ config (BoltClient *client, int argc, char **argv)
if (target == NULL)
return usage_error (err); /* must be set if target == NULL */
switch (action)
{
case ACTION_GET:
res = property_get (target, prop, &err);
break;
case ACTION_SET:
res = property_set (target, prop, value, &err);
break;
case ACTION_UNKNOWN:
res = usage_error_need_arg ("KEY");
break;
}
/* action must either be GET or SET */
if (action == ACTION_GET)
res = property_get (target, prop, &err);
else if (action == ACTION_SET)
res = property_set (target, prop, value, &err);
if (res == EXIT_FAILURE)
g_printerr ("%s\n", err->message);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment