aboutsummaryrefslogtreecommitdiff
path: root/degesch.c
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2015-05-14 06:45:24 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2015-05-14 06:45:24 +0200
commitd41e3499c9d77aacc54f0fd3cc42ed85ec008f8a (patch)
treeaedf95a2690b8dc17afb43af629104d95045af0a /degesch.c
parenta77ab689eb1d6ba15f3f2195d70bcdc464b0c74c (diff)
downloadxK-d41e3499c9d77aacc54f0fd3cc42ed85ec008f8a.tar.gz
xK-d41e3499c9d77aacc54f0fd3cc42ed85ec008f8a.tar.xz
xK-d41e3499c9d77aacc54f0fd3cc42ed85ec008f8a.zip
degesch: prevent playing with unknown options
Diffstat (limited to 'degesch.c')
-rw-r--r--degesch.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/degesch.c b/degesch.c
index 5b54e0d..fe9469b 100644
--- a/degesch.c
+++ b/degesch.c
@@ -4591,7 +4591,9 @@ config_dump_item (struct config_item_ *item, struct config_dump_data *data)
config_item_write (item, false, &value);
str_append_str (&line, &value);
- if (has_default && strcmp (schema->default_, value.str))
+ if (!schema)
+ str_append (&line, " (unrecognized)");
+ else if (has_default && strcmp (schema->default_, value.str))
str_append_printf (&line, " (default: %s)", schema->default_);
else if (!has_default && item->type != CONFIG_ITEM_NULL)
str_append_printf (&line, " (default: %s)", "null");
@@ -4837,7 +4839,9 @@ handle_command_set_assign_item (struct app_context *ctx,
hard_assert (item);
struct error *e = NULL;
- if ((add | remove) && item->type != CONFIG_ITEM_STRING_ARRAY)
+ if (!item->schema)
+ error_set (&e, "option not recognized");
+ else if ((add | remove) && item->type != CONFIG_ITEM_STRING_ARRAY)
// FIXME: it can also be null, which makes this message confusing
error_set (&e, "not a string array");
else if (add)
@@ -5301,7 +5305,7 @@ try_handle_command_help_option (struct app_context *ctx, const char *name)
if (!schema)
{
buffer_send_error (ctx, ctx->global_buffer,
- "%s: %s", "This option has no schema", name);
+ "%s: %s", "Option not recognized", name);
return true;
}