[common] option: add debug errors for invalid options

This commit is contained in:
Geoffrey McRae 2019-05-21 14:58:11 +10:00
parent a29639fceb
commit db0d966102
2 changed files with 10 additions and 1 deletions

View file

@ -1 +1 @@
a12-198-g0605b7df8c+1 a12-199-ga29639fceb+1

View file

@ -684,7 +684,10 @@ int option_get_int(const char * module, const char * name)
{ {
struct Option * o = option_get(module, name); struct Option * o = option_get(module, name);
if (!o) if (!o)
{
DEBUG_ERROR("BUG: Failed to get the value for option %s:%s", module, name);
return -1; return -1;
}
assert(o->type == OPTION_TYPE_INT); assert(o->type == OPTION_TYPE_INT);
return o->value.x_int; return o->value.x_int;
} }
@ -693,7 +696,10 @@ const char * option_get_string(const char * module, const char * name)
{ {
struct Option * o = option_get(module, name); struct Option * o = option_get(module, name);
if (!o) if (!o)
{
DEBUG_ERROR("BUG: Failed to get the value for option %s:%s", module, name);
return NULL; return NULL;
}
assert(o->type == OPTION_TYPE_STRING); assert(o->type == OPTION_TYPE_STRING);
return o->value.x_string; return o->value.x_string;
} }
@ -702,7 +708,10 @@ bool option_get_bool(const char * module, const char * name)
{ {
struct Option * o = option_get(module, name); struct Option * o = option_get(module, name);
if (!o) if (!o)
{
DEBUG_ERROR("BUG: Failed to get the value for option %s:%s", module, name);
return false; return false;
}
assert(o->type == OPTION_TYPE_BOOL); assert(o->type == OPTION_TYPE_BOOL);
return o->value.x_bool; return o->value.x_bool;
} }